btcpayserver/BTCPayServer/wwwroot/js/trezor/trezor-add-derivation-scheme.js
Andrew Camilleri 5571413a78 Put Ledger Wallet pairing in a popup, prepare code for Trezor pairing (#836)
* Allowing for POS to be displayed at website root

* Switching to asp attributes for form post action

* Applying default formatting rules on HTML

* The destination pays mining fees => Subtract fees from amount

* small cleanup (#851)

* Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies (#567)

* Part 1: OpenIddict - Minor Changes & Config prep

* Part 1: OpenIddict - Minor Changes & Config prep

* Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies

* pr changes

* pr changes

* fix merge

* pr fixes

* remove config for openid -- no need for it for now

* fix compile

* fix compile #2

* remove extra ns using

* Update Startup.cs

* compile

* adjust settings a bit

* remove duplicate

* remove external login provider placeholder html

* remove unused directives

* regenerate db snapshot model

* Remove dynamic policy

* Provide Pretty descriptions for payment methods from their handlers (#852)

* small cleanup

* Provide Pretty descriptions for payment methods from their handlers

* remove PrettyMethod()

* integration with trezor

* rough load xpub from trezor

* update deriv scheme trezor

* move ledger import to dialog

* add import from hw wallet dropdown

* Support temporary links for local file system provider (#848)

* wip

* Support temporary links for local file system provider

* pass base url to file services

* fix test

* do not crash on errors with local filesystem

* remove console

* fix paranthesis

* work on trezor.net integration

* pushed non compiling sign wallet code

* comment out wallet code

* abstract ledger ws in add deriv

* Auto stash before merge of "trezor" and "btcpayserver/master"

* final add changes

* cleanup

* improve connectivity and fix e2e tests

* fix selenium

* add experimental warning for trezor

* move import button to right and convert to text link

* switch to defer and async scripts in add deriv scheme

* make defer not async

* more elaborate import trezor dialog

* Fix small issues

* hide trezor for now
2019-05-25 11:45:36 +09:00

81 lines
2.8 KiB
JavaScript

$(document).ready(function() {
var trezorInit = false;
$(".check-for-trezor").on("click",
function() {
if (!trezorInit || !window.trezorDevice) {
trezorClient.init();
trezorInit = true;
}
});
$("[data-trezorkeypath]").on("click",
function() {
$("#trezor-error").hide();
var keypath = $(this).data("trezorkeypath");
var suffix = $(this).data("derivation-suffix");
var keys = keypath.split("/");
if (trezorDevice != null) {
var hardeningConstant = 0x80000000;
trezorDevice.waitForSessionAndRun(function(session) {
var path = [];
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (keys[i].endsWith("'")) {
key = key.substring(0, key.length - 1);
path.push((parseInt(key) | hardeningConstant) >>> 0);
continue;
}
path.push(parseInt(key));
}
return session.getHDNode(path, window.coinName);
})
.then(function(hdNode) {
$("#RootFingerprint").val(hdNode.parentFingerprint);
$("#KeyPath").val(keys[keys.length - 1]);
$("#DerivationScheme").val(hdNode.toBase58()+ suffix);
$("#trezorsubmitbutton").show();
}).catch(function(e){
alert(e.message);
$("#trezor-error").text("An error occurred when communicating with the trezor device. try with a different USB port?").show();
})
}
});
$("[data-hide]").on("click", function(){
$($(this).data("hide")).hide();
});
$("[data-show]").on("click", function(){
$($(this).data("show")).show();
});
$(".trezor-account-dropdown select").on("input", function(){
$(this).find(":selected").click();
});
$("#trezor-address-type-select").on("input", function(){
$(this).find(":selected").click();
$("#RootFingerprint").val("");
$("#KeyPath").val("");
$("#DerivationScheme").val("");
$("#trezorsubmitbutton").hide();
});
});
function onTrezorDeviceFound(device) {
$(".display-when-trezor-connected").show();
}
function onTrezorDeviceLost(){
$(".display-when-trezor-connected").hide();
$("#RootFingerprint").val("");
$(".trezor-account-dropdown").hide();
$("#KeyPath").val("");
$("#DerivationScheme").val("");
$("#trezorsubmitbutton").hide();
}