The signing context should not be passed to PSBT screen

This commit is contained in:
nicolas.dorier
2020-05-25 07:05:01 +09:00
parent 9e9b5945fe
commit cccf3ca617
6 changed files with 16 additions and 20 deletions

View File

@@ -128,10 +128,7 @@ namespace BTCPayServer.Tests
var ready = (await walletController.WalletPSBTReady(walletId, new WalletPSBTReadyViewModel()
{
SigningContext = new SigningContextModel()
{
PSBT = signedPSBT.ToBase64()
}
SigningContext = new SigningContextModel(signedPSBT)
})).AssertViewModel<WalletPSBTReadyViewModel>();
Assert.Equal(signedPSBT.ToBase64(), ready.SigningContext.PSBT);
psbt = AssertRedirectedPSBT(await walletController.WalletPSBTReady(walletId, ready, command: "analyze-psbt"), nameof(walletController.WalletPSBT));
@@ -146,7 +143,7 @@ namespace BTCPayServer.Tests
var postRedirectView = Assert.IsType<ViewResult>(view);
var postRedirectViewModel = Assert.IsType<PostRedirectViewModel>(postRedirectView.Model);
Assert.Equal(actionName, postRedirectViewModel.AspAction);
var redirectedPSBT = postRedirectViewModel.Parameters.Single(p => p.Key == "psbt").Value;
var redirectedPSBT = postRedirectViewModel.Parameters.Single(p => p.Key == "psbt" || p.Key == "SigningContext.PSBT").Value;
return redirectedPSBT;
}
}

View File

@@ -100,8 +100,7 @@ namespace BTCPayServer.Controllers
ModelState.AddModelError(nameof(vm.PSBT), "Invalid PSBT");
return View(vm);
}
var res = await TryHandleSigningCommands(walletId, psbt, command, vm.SigningContext);
var res = await TryHandleSigningCommands(walletId, psbt, command, new SigningContextModel(psbt));
if (res != null)
{
return res;
@@ -129,18 +128,14 @@ namespace BTCPayServer.Controllers
return RedirectToWalletPSBT(new WalletPSBTViewModel()
{
PSBT = psbt.ToBase64(),
FileName = vm.FileName,
SigningContext = vm.SigningContext
FileName = vm.FileName
});
case "broadcast":
{
return RedirectToWalletPSBTReady(new WalletPSBTReadyViewModel()
{
SigningContext = new SigningContextModel()
{
PSBT = psbt.ToBase64()
}
SigningContext = new SigningContextModel(psbt)
});
}
case "combine":
@@ -437,8 +432,7 @@ namespace BTCPayServer.Controllers
case "analyze-psbt":
return RedirectToWalletPSBT(new WalletPSBTViewModel()
{
PSBT = psbt.ToBase64(),
SigningContext = vm.SigningContext
PSBT = psbt.ToBase64()
});
default:
vm.GlobalError = "Unknown command";

View File

@@ -677,8 +677,7 @@ namespace BTCPayServer.Controllers
return RedirectToWalletPSBT(new WalletPSBTViewModel()
{
PSBT = psbt.PSBT.ToBase64(),
FileName = name,
SigningContext = signingContext
FileName = name
});
default:
return View(vm);
@@ -801,7 +800,6 @@ namespace BTCPayServer.Controllers
new KeyValuePair<string, string>("fileName", vm.FileName)
}
};
AddSigningContext(redirectVm, vm.SigningContext);
return View("PostRedirect", redirectVm);
}

View File

@@ -2,11 +2,20 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NBitcoin;
namespace BTCPayServer.Models.WalletViewModels
{
public class SigningContextModel
{
public SigningContextModel()
{
}
public SigningContextModel(PSBT psbt)
{
PSBT = psbt.ToBase64();
}
public string PSBT { get; set; }
public string OriginalPSBT { get; set; }
public string PayJoinEndpointUrl { get; set; }

View File

@@ -10,7 +10,6 @@ namespace BTCPayServer.Models.WalletViewModels
{
public class WalletPSBTViewModel
{
public SigningContextModel SigningContext { get; set; } = new SigningContextModel();
public string CryptoCode { get; set; }
public string Decoded { get; set; }
string _FileName;

View File

@@ -30,7 +30,6 @@
<div class="form-group">
<form method="post" asp-action="WalletPSBT" asp-route-walletId="@this.Context.GetRouteValue("walletId")">
<input type="hidden" asp-for="CryptoCode" />
<partial name="SigningContext" for="SigningContext" />
<input type="hidden" asp-for="NBXSeedAvailable" />
<input type="hidden" asp-for="PSBT" />
<input type="hidden" asp-for="FileName" />