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)
{
2023-04-05 10:55:35 +09:00
<a href="@Url.EnsureLocal(backUrl, Context.Request)" id="GoBack">
2022-07-04 06:20:08 +02:00
<vc:icon symbol="back" />
</a>
}
2023-04-05 10:55:35 +09:00
<a href="@Url.EnsureLocal(cancelUrl, Context.Request)" 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>
2022-10-21 16:13:36 +09:00
<div id="walletAlert" class="alert alert-warning 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
});
2022-10-21 16:13:36 +09:00
var alertMsg = document.getElementById("alertMessage");
var walletAlert = document.getElementById("walletAlert");
var isSafari = window.safari !== undefined;
if (isSafari)
{
alertMsg.innerHTML = "Safari doesn't support BTCPay Server Vault. Please use a different browser. (<a class=\"alert-link\" href=\"https://bugs.webkit.org/show_bug.cgi?id=171934\" target=\"_blank\" rel=\"noreferrer noopener\">More information</a>)";
walletAlert.style.display = null;
}
var isBrave = navigator.brave !== undefined;
if (isBrave)
{
alertMsg.innerHTML = "Brave supports BTCPay Server Vault, but you need to disable Brave Shields. (<a class=\"alert-link\" href=\"https://www.updateland.com/how-to-turn-off-brave-shields/\" target=\"_blank\" rel=\"noreferrer noopener\">More information</a>)";
walletAlert.style.display = null;
}
2019-11-11 14:22:04 +09:00
</script>
}