From af22d6a4e3c34d92fc0b6bda54d2a38b8310f114 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Tue, 25 Dec 2018 19:32:14 +0900 Subject: [PATCH] Remove preliminary test to know if the ledger can handle the store. If it can't signing will fail anyway. --- BTCPayServer/Controllers/WalletsController.cs | 9 --- .../Views/Wallets/WalletSendLedger.cshtml | 4 -- BTCPayServer/wwwroot/js/WalletSendLedger.js | 68 +++++++------------ 3 files changed, 26 insertions(+), 55 deletions(-) diff --git a/BTCPayServer/Controllers/WalletsController.cs b/BTCPayServer/Controllers/WalletsController.cs index aa0290cd8..edfed01f7 100644 --- a/BTCPayServer/Controllers/WalletsController.cs +++ b/BTCPayServer/Controllers/WalletsController.cs @@ -476,15 +476,6 @@ namespace BTCPayServer.Controllers } catch { throw new FormatException("Invalid value for subtract fees"); } } - if (command == "getinfo") - { - var strategy = GetDirectDerivationStrategy(derivationScheme); - if (strategy == null || await hw.GetKeyPath(network, strategy, normalOperationTimeout.Token) == null) - { - throw new Exception($"This store is not configured to use this ledger"); - } - result = new GetInfoResult(); - } if (command == "test") { result = await hw.Test(normalOperationTimeout.Token); diff --git a/BTCPayServer/Views/Wallets/WalletSendLedger.cshtml b/BTCPayServer/Views/Wallets/WalletSendLedger.cshtml index 3ea9d344d..525b07d67 100644 --- a/BTCPayServer/Views/Wallets/WalletSendLedger.cshtml +++ b/BTCPayServer/Views/Wallets/WalletSendLedger.cshtml @@ -28,10 +28,6 @@

Detecting hardware wallet...

- - - - diff --git a/BTCPayServer/wwwroot/js/WalletSendLedger.js b/BTCPayServer/wwwroot/js/WalletSendLedger.js index e0c3577bd..c1813fb32 100644 --- a/BTCPayServer/wwwroot/js/WalletSendLedger.js +++ b/BTCPayServer/wwwroot/js/WalletSendLedger.js @@ -41,52 +41,36 @@ var updateInfo = function () { if (!ledgerDetected) return false; - $(".crypto-info").css("display", "none"); - bridge.sendCommand("getinfo", "cryptoCode=" + cryptoCode) - .catch(function (reason) { Write('check', 'error', reason); }) + $(".crypto-info").css("display", "block"); + var args = ""; + args += "cryptoCode=" + cryptoCode; + args += "&destination=" + destination; + args += "&amount=" + amount; + args += "&feeRate=" + fee; + args += "&substractFees=" + substractFee; + + WriteAlert("warning", 'Please validate the transaction on your ledger'); + + var confirmButton = $("#confirm-button"); + confirmButton.prop("disabled", true); + confirmButton.addClass("disabled"); + + bridge.sendCommand('sendtoaddress', args, 60 * 10 /* timeout */) + .catch(function (reason) { + WriteAlert("danger", reason); + confirmButton.prop("disabled", false); + confirmButton.removeClass("disabled"); + }) .then(function (result) { if (!result) return; + confirmButton.prop("disabled", false); + confirmButton.removeClass("disabled"); if (result.error) { - Write('check', 'error', result.error); - return; - } - else { - Write('check', 'success', 'This store is configured to use your ledger'); - $(".crypto-info").css("display", "block"); - - - var args = ""; - args += "cryptoCode=" + cryptoCode; - args += "&destination=" + destination; - args += "&amount=" + amount; - args += "&feeRate=" + fee; - args += "&substractFees=" + substractFee; - - WriteAlert("warning", 'Please validate the transaction on your ledger'); - - var confirmButton = $("#confirm-button"); - confirmButton.prop("disabled", true); - confirmButton.addClass("disabled"); - - bridge.sendCommand('sendtoaddress', args, 60 * 10 /* timeout */) - .catch(function (reason) { - WriteAlert("danger", reason); - confirmButton.prop("disabled", false); - confirmButton.removeClass("disabled"); - }) - .then(function (result) { - if (!result) - return; - confirmButton.prop("disabled", false); - confirmButton.removeClass("disabled"); - if (result.error) { - WriteAlert("danger", result.error); - } else { - WriteAlert("success", 'Transaction broadcasted (' + result.transactionId + ')'); - window.location.replace(successCallback + "?txid=" + result.transactionId); - } - }); + WriteAlert("danger", result.error); + } else { + WriteAlert("success", 'Transaction broadcasted (' + result.transactionId + ')'); + window.location.replace(successCallback + "?txid=" + result.transactionId); } }); };