fix: revert BTC wallet automatic creation
This commit is contained in:
parent
46484957e7
commit
063b9b1dbe
2 changed files with 4 additions and 22 deletions
|
|
@ -23,6 +23,8 @@ module.exports = {
|
||||||
|
|
||||||
const BINARIES = {
|
const BINARIES = {
|
||||||
BTC: {
|
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',
|
url: 'https://bitcoincore.org/bin/bitcoin-core-23.0/bitcoin-23.0-x86_64-linux-gnu.tar.gz',
|
||||||
dir: 'bitcoin-23.0/bin'
|
dir: 'bitcoin-23.0/bin'
|
||||||
},
|
},
|
||||||
|
|
@ -54,7 +56,7 @@ const BINARIES = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const coinsUpdateDependent = []
|
const coinsUpdateDependent = ['BTC']
|
||||||
|
|
||||||
function firewall (ports) {
|
function firewall (ports) {
|
||||||
if (!ports || ports.length === 0) throw new Error('No ports supplied')
|
if (!ports || ports.length === 0) throw new Error('No ports supplied')
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,10 @@ function fetch (method, params) {
|
||||||
function errorHandle (e) {
|
function errorHandle (e) {
|
||||||
const err = JSON.parse(e.message)
|
const err = JSON.parse(e.message)
|
||||||
switch (err.code) {
|
switch (err.code) {
|
||||||
case -4:
|
|
||||||
return loadWallet()
|
|
||||||
case -5:
|
case -5:
|
||||||
return logger.error(`${err}`)
|
return logger.error(`${err}`)
|
||||||
case -6:
|
case -6:
|
||||||
throw new E.InsufficientFundsError()
|
throw new E.InsufficientFundsError()
|
||||||
case -18:
|
|
||||||
return createWallet()
|
|
||||||
case -35:
|
|
||||||
// Wallet is already loaded, just return
|
|
||||||
return
|
|
||||||
default:
|
default:
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
@ -38,20 +31,7 @@ function errorHandle (e) {
|
||||||
|
|
||||||
function checkCryptoCode (cryptoCode) {
|
function checkCryptoCode (cryptoCode) {
|
||||||
if (cryptoCode !== 'BTC') return Promise.reject(new Error('Unsupported crypto: ' + cryptoCode))
|
if (cryptoCode !== 'BTC') return Promise.reject(new Error('Unsupported crypto: ' + cryptoCode))
|
||||||
return Promise.resolve().then(loadWallet)
|
return Promise.resolve()
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function accountBalance (cryptoCode) {
|
function accountBalance (cryptoCode) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue