2020-10-05 12:17:18 +09:00
|
|
|
function getVaultUI() {
|
2019-12-10 21:22:46 +09:00
|
|
|
var websocketPath = $("#WebsocketPath").text();
|
|
|
|
var loc = window.location, ws_uri;
|
|
|
|
if (loc.protocol === "https:") {
|
|
|
|
ws_uri = "wss:";
|
|
|
|
} else {
|
|
|
|
ws_uri = "ws:";
|
|
|
|
}
|
|
|
|
ws_uri += "//" + loc.host;
|
|
|
|
ws_uri += websocketPath;
|
|
|
|
return new vaultui.VaultBridgeUI(ws_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
function showModal() {
|
|
|
|
var html = $("#btcpayservervault_template").html();
|
|
|
|
$("#btcpayservervault").html(html);
|
|
|
|
html = $("#VaultConnection").html();
|
|
|
|
$("#vaultPlaceholder").html(html);
|
|
|
|
$('#btcpayservervault').modal();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function showAddress(rootedKeyPath, address) {
|
|
|
|
$(".showaddress").addClass("disabled");
|
|
|
|
showModal();
|
|
|
|
$("#btcpayservervault #displayedAddress").text(address);
|
|
|
|
var vaultUI = getVaultUI();
|
|
|
|
$('#btcpayservervault').on('hidden.bs.modal', function () {
|
|
|
|
vaultUI.closeBridge();
|
|
|
|
$(".showaddress").removeClass("disabled");
|
|
|
|
});
|
|
|
|
if (await vaultUI.askForDevice())
|
|
|
|
await vaultUI.askForDisplayAddress(rootedKeyPath);
|
|
|
|
$('#btcpayservervault').modal("hide");
|
|
|
|
}
|
|
|
|
|
2019-05-25 02:45:36 +00:00
|
|
|
$(document).ready(function () {
|
2019-12-04 15:54:08 +09:00
|
|
|
function displayXPubs(xpub) {
|
|
|
|
$("#DerivationScheme").val(xpub.strategy);
|
|
|
|
$("#RootFingerprint").val(xpub.fingerprint);
|
|
|
|
$("#AccountKey").val(xpub.accountKey);
|
|
|
|
$("#Source").val("Vault");
|
|
|
|
$("#DerivationSchemeFormat").val("BTCPay");
|
|
|
|
$("#KeyPath").val(xpub.keyPath);
|
|
|
|
$(".modal").modal('hide');
|
|
|
|
$(".hw-fields").show();
|
2019-11-11 14:22:04 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
$(".check-for-vault").on("click", async function () {
|
2019-12-10 21:22:46 +09:00
|
|
|
var vaultUI = getVaultUI();
|
|
|
|
showModal();
|
2019-12-04 16:16:41 +09:00
|
|
|
$('#btcpayservervault').on('hidden.bs.modal', function () {
|
|
|
|
vaultUI.closeBridge();
|
|
|
|
});
|
2020-10-05 12:17:18 +09:00
|
|
|
while (! await vaultUI.askForDevice() || ! await vaultUI.askForXPubs()) {
|
2019-11-11 14:22:04 +09:00
|
|
|
}
|
2020-10-05 12:17:18 +09:00
|
|
|
displayXPubs(vaultUI.xpub);
|
2019-11-11 14:22:04 +09:00
|
|
|
});
|
2018-02-13 03:27:36 +09:00
|
|
|
});
|