diff --git a/BTCPayServer/Controllers/WalletsController.PSBT.cs b/BTCPayServer/Controllers/WalletsController.PSBT.cs index 09d023331..d31d539a7 100644 --- a/BTCPayServer/Controllers/WalletsController.PSBT.cs +++ b/BTCPayServer/Controllers/WalletsController.PSBT.cs @@ -81,8 +81,7 @@ namespace BTCPayServer.Controllers if (derivationSchemeSettings == null) return NotFound(); - vm.NBXSeedAvailable = await CanUseHotWallet() && !string.IsNullOrEmpty(await ExplorerClientProvider.GetExplorerClient(network) - .GetMetadataAsync(derivationSchemeSettings.AccountDerivation, WellknownMetadataKeys.Mnemonic)); + vm.NBXSeedAvailable = await CanUseHotWallet() && derivationSchemeSettings.IsHotWallet; if (await vm.GetPSBT(network.NBitcoinNetwork) is PSBT psbt) { @@ -111,8 +110,7 @@ namespace BTCPayServer.Controllers if (derivationSchemeSettings == null) return NotFound(); - vm.NBXSeedAvailable = await CanUseHotWallet() && !string.IsNullOrEmpty(await ExplorerClientProvider.GetExplorerClient(network) - .GetMetadataAsync(derivationSchemeSettings.AccountDerivation, WellknownMetadataKeys.Mnemonic)); + vm.NBXSeedAvailable = await CanUseHotWallet() && derivationSchemeSettings.IsHotWallet; var psbt = await vm.GetPSBT(network.NBitcoinNetwork); if (psbt == null) { @@ -121,17 +119,14 @@ namespace BTCPayServer.Controllers } vm.PSBTHex = psbt.ToHex(); - var routeBack = new Dictionary - { - {"action", nameof(WalletPSBT)}, {"walletId", walletId.ToString()} - }; - var res = await TryHandleSigningCommands(walletId, psbt, command, vm.SigningContext, routeBack); + var res = await TryHandleSigningCommands(walletId, psbt, command, vm.SigningContext, nameof(WalletPSBT)); if (res != null) { return res; } switch (command) { + case "export": case "decode": ModelState.Remove(nameof(vm.PSBT)); ModelState.Remove(nameof(vm.FileName)); @@ -142,18 +137,14 @@ namespace BTCPayServer.Controllers await FetchTransactionDetails(derivationSchemeSettings, vm, network); return View("WalletPSBTDecoded", vm); - case "export": - vm.PSBT = vm.SigningContext.PSBT; - vm.PSBTHex = psbt.ToHex(); - vm.Decoded = psbt.ToString(); - await FetchTransactionDetails(derivationSchemeSettings, vm, network); - return View("WalletPSBTExport", vm); + case "save-psbt": + return FilePSBT(psbt, vm.FileName); case "update": psbt = await ExplorerClientProvider.UpdatePSBT(derivationSchemeSettings, psbt); if (psbt == null) { - ModelState.AddModelError(nameof(vm.PSBT), "You need to update your version of NBXplorer"); + TempData[WellKnownTempData.ErrorMessage] = "You need to update your version of NBXplorer"; return View(vm); } TempData[WellKnownTempData.SuccessMessage] = "PSBT updated!"; @@ -162,6 +153,10 @@ namespace BTCPayServer.Controllers PSBT = psbt.ToBase64(), FileName = vm.FileName }); + + case "combine": + ModelState.Remove(nameof(vm.PSBT)); + return View(nameof(WalletPSBTCombine), new WalletPSBTCombineViewModel { OtherPSBT = psbt.ToBase64() }); case "broadcast": { @@ -170,12 +165,6 @@ namespace BTCPayServer.Controllers SigningContext = new SigningContextModel(psbt) }); } - case "combine": - ModelState.Remove(nameof(vm.PSBT)); - return View(nameof(WalletPSBTCombine), new WalletPSBTCombineViewModel { OtherPSBT = psbt.ToBase64() }); - - case "save-psbt": - return FilePSBT(psbt, vm.FileName); default: var viewName = string.IsNullOrEmpty(vm.PSBT) ? "WalletPSBT" : "WalletPSBTDecoded"; @@ -470,12 +459,16 @@ namespace BTCPayServer.Controllers } private async Task TryHandleSigningCommands(WalletId walletId, PSBT psbt, string command, - SigningContextModel signingContext, Dictionary routeBack) + SigningContextModel signingContext, string actionBack) { signingContext.PSBT = psbt.ToBase64(); switch (command) { case "sign": + var routeBack = new Dictionary + { + {"action", actionBack }, {"walletId", walletId.ToString()} + }; return View("WalletSigningOptions", new WalletSigningOptionsModel(signingContext, routeBack)); case "vault": return ViewVault(walletId, signingContext); diff --git a/BTCPayServer/Controllers/WalletsController.cs b/BTCPayServer/Controllers/WalletsController.cs index d8bf3a768..57df1e612 100644 --- a/BTCPayServer/Controllers/WalletsController.cs +++ b/BTCPayServer/Controllers/WalletsController.cs @@ -721,13 +721,8 @@ namespace BTCPayServer.Controllers EnforceLowR = psbtResponse.Suggestions?.ShouldEnforceLowR, ChangeAddress = psbtResponse.ChangeAddress?.ToString() }; - - var routeBack = new Dictionary - { - {"action", nameof(WalletSend)}, {"walletId", walletId.ToString()} - }; - var res = await TryHandleSigningCommands(walletId, psbt, command, signingContext, routeBack); + var res = await TryHandleSigningCommands(walletId, psbt, command, signingContext, nameof(WalletSend)); if (res != null) { return res; diff --git a/BTCPayServer/Views/Wallets/WalletPSBTDecoded.cshtml b/BTCPayServer/Views/Wallets/WalletPSBTDecoded.cshtml index 3bedd961a..bf0a25b81 100644 --- a/BTCPayServer/Views/Wallets/WalletPSBTDecoded.cshtml +++ b/BTCPayServer/Views/Wallets/WalletPSBTDecoded.cshtml @@ -2,10 +2,33 @@ @addTagHelper *, BundlerMinifier.TagHelpers @{ var isReady = !Model.HasErrors; + var isSignable = !isReady && Model.NBXSeedAvailable; + var needsExport = !isSignable && !isReady; Layout = "_LayoutWizard"; ViewData.SetActivePageAndTitle(WalletsNavPages.PSBT, isReady ? "Transaction Broadcasting" : "Transaction Details", Context.GetStoreData().StoreName); } +@section PageHeadContent { + + +} + +@section PageFootContent { + + + +} + @section Navbar { @@ -21,30 +44,28 @@ -@if (!isReady) +@if (isSignable) { -
+ -
- - - +
+
-} -else +} +else if (isReady) { -
+ -
+
@if (!string.IsNullOrEmpty(Model.SigningContext?.PayJoinBIP21)) { - + or } @@ -55,3 +76,93 @@ else
} +else +{ +

+ Export the PSBT for your wallet. Sign it with your wallet and + import the signed PSBT version here for finalization and broadcasting. +

+} + +
+ + + diff --git a/BTCPayServer/Views/Wallets/WalletPSBTExport.cshtml b/BTCPayServer/Views/Wallets/WalletPSBTExport.cshtml deleted file mode 100644 index 33a4198ca..000000000 --- a/BTCPayServer/Views/Wallets/WalletPSBTExport.cshtml +++ /dev/null @@ -1,105 +0,0 @@ -@model WalletPSBTViewModel -@addTagHelper *, BundlerMinifier.TagHelpers -@{ - Layout = "_LayoutWizard"; - ViewData.SetActivePageAndTitle(WalletsNavPages.PSBT, "Transaction Signing", Context.GetStoreData().StoreName); -} - -@section PageHeadContent { - - -} - -@section PageFootContent { - - - -} - -@section Navbar { - - - - - - -} - -
-

@ViewData["PageTitle"]

-
- - - -

- Export the PSBT for your wallet. Sign it with your wallet and - import the signed PSBT version here for finalization and broadcasting. -

- -
-
-

- -

-
-
-
- - -
- - - Show raw versions -
-
- -
-
@Model.Decoded
-
@Model.PSBT
-
-
-
-
-
-

- -

-
-
-
-
- - -
-
- - -
-
- - -
-
-
-
-
-
- - -