From 063b9b1dbed880a9f90f008c83856bdb0be456f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Fri, 13 May 2022 17:34:15 +0100 Subject: [PATCH] fix: revert BTC wallet automatic creation --- lib/blockchain/common.js | 4 +++- lib/plugins/wallet/bitcoind/bitcoind.js | 22 +--------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/lib/blockchain/common.js b/lib/blockchain/common.js index da059ba0..c4cff1a9 100644 --- a/lib/blockchain/common.js +++ b/lib/blockchain/common.js @@ -23,6 +23,8 @@ module.exports = { const BINARIES = { BTC: { + defaultUrl: 'https://bitcoincore.org/bin/bitcoin-core-0.20.1/bitcoin-0.20.1-x86_64-linux-gnu.tar.gz', + defaultDir: 'bitcoin-0.20.1/bin', url: 'https://bitcoincore.org/bin/bitcoin-core-23.0/bitcoin-23.0-x86_64-linux-gnu.tar.gz', dir: 'bitcoin-23.0/bin' }, @@ -54,7 +56,7 @@ const BINARIES = { } } -const coinsUpdateDependent = [] +const coinsUpdateDependent = ['BTC'] function firewall (ports) { if (!ports || ports.length === 0) throw new Error('No ports supplied') diff --git a/lib/plugins/wallet/bitcoind/bitcoind.js b/lib/plugins/wallet/bitcoind/bitcoind.js index 66fb6ed6..3b227d37 100644 --- a/lib/plugins/wallet/bitcoind/bitcoind.js +++ b/lib/plugins/wallet/bitcoind/bitcoind.js @@ -20,17 +20,10 @@ function fetch (method, params) { function errorHandle (e) { const err = JSON.parse(e.message) switch (err.code) { - case -4: - return loadWallet() case -5: return logger.error(`${err}`) case -6: throw new E.InsufficientFundsError() - case -18: - return createWallet() - case -35: - // Wallet is already loaded, just return - return default: throw e } @@ -38,20 +31,7 @@ function errorHandle (e) { function checkCryptoCode (cryptoCode) { if (cryptoCode !== 'BTC') return Promise.reject(new Error('Unsupported crypto: ' + cryptoCode)) - return Promise.resolve().then(loadWallet) -} - -function createWallet () { - return fetch('createwallet', ['wallet']) - .then(loadWallet) -} - -function loadWallet () { - return fetch('loadwallet', ['wallet', true]) - // Catching the error here to suppress error code -35 - // This improves UX on the initial wallet load and serves as error sink - // for wallet creation/loading related issues before actual business logic runs - .catch(errorHandle) + return Promise.resolve() } function accountBalance (cryptoCode) {