fix: revert BTC wallet automatic creation

This commit is contained in:
Sérgio Salgado 2022-05-13 17:34:15 +01:00
parent 46484957e7
commit 063b9b1dbe
2 changed files with 4 additions and 22 deletions

View file

@ -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')

View file

@ -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) {