2022-07-04 06:20:08 +02:00
|
|
|
@using BTCPayServer.Controllers
|
2020-10-05 12:17:18 +09:00
|
|
|
@model WalletSendVaultModel
|
2019-11-11 14:22:04 +09:00
|
|
|
@{
|
2021-12-31 08:36:38 +01:00
|
|
|
var walletId = Context.GetRouteValue("walletId").ToString();
|
2022-07-04 06:20:08 +02:00
|
|
|
var cancelUrl = Model.ReturnUrl ?? Url.Action(nameof(UIWalletsController.WalletTransactions), new { walletId });
|
|
|
|
var backUrl = Model.BackUrl != null ? $"{Model.BackUrl}?returnUrl={Model.ReturnUrl}" : null;
|
2021-07-29 15:53:10 +02:00
|
|
|
Layout = "_LayoutWizard";
|
2021-12-31 08:36:38 +01:00
|
|
|
ViewData.SetActivePage(WalletsNavPages.Send, "Sign the transaction", walletId);
|
2019-11-11 14:22:04 +09:00
|
|
|
}
|
|
|
|
|
2021-07-29 15:53:10 +02:00
|
|
|
@section Navbar {
|
2022-07-04 06:20:08 +02:00
|
|
|
@if (backUrl != null)
|
|
|
|
{
|
|
|
|
<a href="@backUrl" id="GoBack">
|
|
|
|
<vc:icon symbol="back" />
|
|
|
|
</a>
|
|
|
|
}
|
|
|
|
<a href="@cancelUrl" id="CancelWizard" class="cancel">
|
2021-07-29 15:53:10 +02:00
|
|
|
<vc:icon symbol="close" />
|
|
|
|
</a>
|
|
|
|
}
|
2021-04-08 15:32:42 +02:00
|
|
|
|
2021-07-29 15:53:10 +02:00
|
|
|
<header class="text-center">
|
2021-12-16 11:17:02 +01:00
|
|
|
<h1>@ViewData["Title"]</h1>
|
2021-07-29 15:53:10 +02:00
|
|
|
<p class="lead text-secondary mt-3">Using BTCPay Server Vault</p>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div id="walletAlert" class="alert alert-danger alert-dismissible my-4" style="display:none;" role="alert">
|
2021-05-19 04:39:27 +02:00
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
|
|
|
|
<vc:icon symbol="close" />
|
|
|
|
</button>
|
2019-11-11 14:22:04 +09:00
|
|
|
<span id="alertMessage"></span>
|
|
|
|
</div>
|
2021-07-29 15:53:10 +02:00
|
|
|
|
|
|
|
<div id="body" class="my-4">
|
2022-07-04 06:20:08 +02:00
|
|
|
<form id="broadcastForm" asp-action="WalletSendVault" asp-route-walletId="@walletId" method="post" style="display:none;">
|
2021-07-29 15:53:10 +02:00
|
|
|
<input type="hidden" id="WalletId" asp-for="WalletId" />
|
|
|
|
<input type="hidden" asp-for="WebsocketPath" />
|
2022-07-04 06:20:08 +02:00
|
|
|
<input type="hidden" asp-for="ReturnUrl" />
|
|
|
|
<input type="hidden" asp-for="BackUrl" />
|
2021-07-29 15:53:10 +02:00
|
|
|
<partial name="SigningContext" for="SigningContext" />
|
|
|
|
</form>
|
|
|
|
<div id="vaultPlaceholder"></div>
|
|
|
|
<button id="vault-retry" class="btn btn-primary" style="display:none;" type="button">Retry</button>
|
|
|
|
<button id="vault-confirm" class="btn btn-primary" style="display:none;"></button>
|
2019-11-11 14:22:04 +09:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<partial name="VaultElements" />
|
2021-05-19 04:39:27 +02:00
|
|
|
|
|
|
|
@section PageFootContent
|
2019-11-11 14:22:04 +09:00
|
|
|
{
|
2020-04-18 17:56:05 +02:00
|
|
|
<script src="~/js/vaultbridge.js" type="text/javascript" defer="defer" asp-append-version="true"></script>
|
|
|
|
<script src="~/js/vaultbridge.ui.js" type="text/javascript" defer="defer" asp-append-version="true"></script>
|
2021-05-19 04:39:27 +02:00
|
|
|
<script>
|
2019-12-10 18:58:12 +09:00
|
|
|
async function askSign() {
|
2019-11-11 14:22:04 +09:00
|
|
|
var websocketPath = $("#WebsocketPath").val();
|
|
|
|
var loc = window.location, ws_uri;
|
|
|
|
if (loc.protocol === "https:") {
|
|
|
|
ws_uri = "wss:";
|
|
|
|
} else {
|
|
|
|
ws_uri = "ws:";
|
|
|
|
}
|
|
|
|
ws_uri += "//" + loc.host;
|
|
|
|
ws_uri += websocketPath;
|
|
|
|
var html = $("#VaultConnection").html();
|
|
|
|
$("#vaultPlaceholder").html(html);
|
|
|
|
var vaultUI = new vaultui.VaultBridgeUI(ws_uri);
|
2020-10-05 12:17:18 +09:00
|
|
|
|
|
|
|
while (!await vaultUI.askForDevice() || !await vaultUI.askSignPSBT({
|
2019-11-11 14:22:04 +09:00
|
|
|
walletId: $("#WalletId").val(),
|
2020-05-25 06:27:01 +09:00
|
|
|
psbt: $("#SigningContext_PSBT").val()
|
2019-12-10 18:58:12 +09:00
|
|
|
})) {
|
|
|
|
}
|
2020-10-05 12:17:18 +09:00
|
|
|
$("#SigningContext_PSBT").val(vaultUI.psbt);
|
|
|
|
$("#broadcastForm").submit();
|
2019-12-10 18:58:12 +09:00
|
|
|
}
|
2021-05-19 04:39:27 +02:00
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
2019-12-10 18:58:12 +09:00
|
|
|
askSign();
|
2019-11-11 14:22:04 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
}
|