mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 22:11:48 +01:00
Remove psbt ready view
The transaction info is now shown on the decoded PSBT page.
This commit is contained in:
parent
de3d966835
commit
b4c1f695a8
2 changed files with 8 additions and 101 deletions
|
@ -191,26 +191,6 @@ namespace BTCPayServer.Controllers
|
|||
return await _payjoinClient.RequestPayjoin(bip21, new PayjoinWallet(derivationSchemeSettings), psbt, cancellationToken);
|
||||
}
|
||||
|
||||
[HttpGet("{walletId}/psbt/ready")]
|
||||
public async Task<IActionResult> WalletPSBTReady(
|
||||
[ModelBinder(typeof(WalletIdModelBinder))]
|
||||
WalletId walletId,
|
||||
WalletPSBTReadyViewModel vm)
|
||||
{
|
||||
if (vm is null)
|
||||
return NotFound();
|
||||
var network = NetworkProvider.GetNetwork<BTCPayNetwork>(walletId.CryptoCode);
|
||||
var derivationSchemeSettings = GetDerivationSchemeSettings(walletId);
|
||||
if (derivationSchemeSettings == null)
|
||||
return NotFound();
|
||||
try
|
||||
{
|
||||
await FetchTransactionDetails(derivationSchemeSettings, vm, network);
|
||||
}
|
||||
catch { return BadRequest(); }
|
||||
return View(nameof(WalletPSBTReady), vm);
|
||||
}
|
||||
|
||||
private async Task FetchTransactionDetails(DerivationSchemeSettings derivationSchemeSettings, WalletPSBTReadyViewModel vm, BTCPayNetwork network)
|
||||
{
|
||||
var psbtObject = PSBT.Parse(vm.SigningContext.PSBT, network.NBitcoinNetwork);
|
||||
|
@ -316,11 +296,11 @@ namespace BTCPayServer.Controllers
|
|||
[HttpPost("{walletId}/psbt/ready")]
|
||||
public async Task<IActionResult> WalletPSBTReady(
|
||||
[ModelBinder(typeof(WalletIdModelBinder))]
|
||||
WalletId walletId, WalletPSBTReadyViewModel vm, string command = null, CancellationToken cancellationToken = default)
|
||||
WalletId walletId, WalletPSBTViewModel vm, string command = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (command == null)
|
||||
return await WalletPSBTReady(walletId, vm);
|
||||
PSBT psbt = null;
|
||||
return await WalletPSBT(walletId, vm);
|
||||
PSBT psbt;
|
||||
var network = NetworkProvider.GetNetwork<BTCPayNetwork>(walletId.CryptoCode);
|
||||
DerivationSchemeSettings derivationSchemeSettings = null;
|
||||
try
|
||||
|
@ -334,7 +314,7 @@ namespace BTCPayServer.Controllers
|
|||
catch
|
||||
{
|
||||
vm.GlobalError = "Invalid PSBT";
|
||||
return View(nameof(WalletPSBTReady), vm);
|
||||
return View(nameof(WalletPSBT), vm);
|
||||
}
|
||||
|
||||
switch (command)
|
||||
|
@ -410,7 +390,7 @@ namespace BTCPayServer.Controllers
|
|||
return await WalletPSBTReady(walletId, vm, "broadcast");
|
||||
case "broadcast" when !psbt.IsAllFinalized() && !psbt.TryFinalize(out var errors):
|
||||
vm.SetErrors(errors);
|
||||
return View(nameof(WalletPSBTReady), vm);
|
||||
return View(nameof(WalletPSBT), vm);
|
||||
case "broadcast":
|
||||
{
|
||||
var transaction = psbt.ExtractTransaction();
|
||||
|
@ -433,13 +413,13 @@ namespace BTCPayServer.Controllers
|
|||
}
|
||||
|
||||
vm.GlobalError = $"RPC Error while broadcasting: {broadcastResult.RPCCode} {broadcastResult.RPCCodeMessage} {broadcastResult.RPCMessage}";
|
||||
return View(nameof(WalletPSBTReady), vm);
|
||||
return View(nameof(WalletPSBT), vm);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
vm.GlobalError = "Error while broadcasting: " + ex.Message;
|
||||
return View(nameof(WalletPSBTReady), vm);
|
||||
return View(nameof(WalletPSBT), vm);
|
||||
}
|
||||
|
||||
if (!TempData.HasStatusMessage())
|
||||
|
@ -455,7 +435,7 @@ namespace BTCPayServer.Controllers
|
|||
});
|
||||
default:
|
||||
vm.GlobalError = "Unknown command";
|
||||
return View(nameof(WalletPSBTReady), vm);
|
||||
return View(nameof(WalletPSBT), vm);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
@model WalletPSBTReadyViewModel
|
||||
@{
|
||||
Layout = "_LayoutWizard";
|
||||
ViewData.SetActivePageAndTitle(WalletsNavPages.PSBT, "Review PSBT", Context.GetStoreData().StoreName);
|
||||
}
|
||||
|
||||
@section Navbar {
|
||||
<a asp-action="WalletPSBT" asp-route-walletId="@Context.GetRouteValue("walletId")" onclick="history.back();return false;">
|
||||
<vc:icon symbol="back" />
|
||||
</a>
|
||||
<a asp-action="WalletSend" asp-route-walletId="@Context.GetRouteValue("walletId")" class="cancel">
|
||||
<vc:icon symbol="close" />
|
||||
</a>
|
||||
}
|
||||
|
||||
<header class="text-center">
|
||||
<h1>@ViewData["PageTitle"]</h1>
|
||||
|
||||
@if (Model.CanCalculateBalance)
|
||||
{
|
||||
<p class="lead text-secondary mt-3">
|
||||
If you broadcast this transaction, your balance will change:
|
||||
<br>
|
||||
@if (Model.Positive)
|
||||
{
|
||||
<span class="text-success">@Model.BalanceChange</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="text-danger">@Model.BalanceChange</span>
|
||||
}
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="lead text-secondary mt-3">This PSBT is already finalized. We can't properly detect which input or output belongs to you.</p>
|
||||
}
|
||||
</header>
|
||||
|
||||
<partial name="_StatusMessage" />
|
||||
|
||||
@if (Model.GlobalError != null)
|
||||
{
|
||||
<div class="alert alert-danger alert-dismissible" role="alert">
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
|
||||
<vc:icon symbol="close" />
|
||||
</button>
|
||||
<span>@Model.GlobalError</span><br/>
|
||||
</div>
|
||||
}
|
||||
|
||||
<partial name="_PSBTInfo" model="Model" />
|
||||
|
||||
<form method="post" asp-action="WalletPSBTReady" asp-route-walletId="@Context.GetRouteValue("walletId")" class="text-center">
|
||||
<input type="hidden" asp-for="SigningKey" />
|
||||
<input type="hidden" asp-for="SigningKeyPath" />
|
||||
<partial name="SigningContext" for="SigningContext" />
|
||||
@if (!Model.HasErrors)
|
||||
{
|
||||
@if (!string.IsNullOrEmpty(Model.SigningContext?.PayJoinBIP21))
|
||||
{
|
||||
<button type="submit" class="btn btn-primary" name="command" value="payjoin">Broadcast (Payjoin)</button>
|
||||
<span class="mx-2">or</span>
|
||||
<button type="submit" class="btn btn-secondary" name="command" value="broadcast">Broadcast (Simple)</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="submit" class="btn btn-primary" name="command" value="broadcast">Broadcast it</button>
|
||||
}
|
||||
<span class="mx-2">or</span>
|
||||
}
|
||||
<button type="submit" class="btn btn-secondary" name="command" value="analyze-psbt">View PSBT</button>
|
||||
</form>
|
Loading…
Add table
Reference in a new issue