Show the inputs of the PSBT in the review screen

This commit is contained in:
nicolas.dorier
2019-05-31 00:23:23 +09:00
parent 8379b07de0
commit c877937fdf
3 changed files with 73 additions and 46 deletions

View File

@@ -8,16 +8,10 @@ namespace BTCPayServer.Models.WalletViewModels
{
public class WalletPSBTReadyViewModel
{
public class FinalizeError
{
public int Index { get; set; }
public string Error { get; set; }
}
public string PSBT { get; set; }
public string SigningKey { get; set; }
public string SigningKeyPath { get; set; }
public string GlobalError { get; set; }
public List<FinalizeError> Errors { get; set; }
public class DestinationViewModel
{
@@ -26,18 +20,26 @@ namespace BTCPayServer.Models.WalletViewModels
public string Balance { get; set; }
}
public class InputViewModel
{
public int Index { get; set; }
public string Error { get; set; }
public bool Positive { get; set; }
public string BalanceChange { get; set; }
}
public bool HasErrors => Inputs.Count == 0 || Inputs.Any(i => !string.IsNullOrEmpty(i.Error));
public string BalanceChange { get; set; }
public bool CanCalculateBalance { get; set; }
public bool Positive { get; set; }
public List<DestinationViewModel> Destinations { get; set; } = new List<DestinationViewModel>();
public List<InputViewModel> Inputs { get; set; } = new List<InputViewModel>();
public string FeeRate { get; set; }
internal void SetErrors(IList<PSBTError> errors)
{
Errors = new List<FinalizeError>();
foreach (var err in errors)
{
Errors.Add(new FinalizeError() { Index = (int)err.InputIndex, Error = err.Message });
Inputs[(int)err.InputIndex].Error = err.Message;
}
}
}