fix: RPC error handling
feat: create and load wallets
This commit is contained in:
parent
f9ae681453
commit
0135d50416
7 changed files with 84 additions and 33 deletions
|
|
@ -15,6 +15,16 @@ function fetch (method, params) {
|
|||
return jsonRpc.fetch(rpcConfig, method, params)
|
||||
}
|
||||
|
||||
function errorHandle (e) {
|
||||
const err = JSON.parse(e.message)
|
||||
switch (err.code) {
|
||||
case -6:
|
||||
throw new E.InsufficientFundsError()
|
||||
default:
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
function checkCryptoCode (cryptoCode) {
|
||||
if (cryptoCode !== 'DASH') return Promise.reject(new Error('Unsupported crypto: ' + cryptoCode))
|
||||
return Promise.resolve()
|
||||
|
|
@ -52,10 +62,7 @@ function sendCoins (account, tx, settings, operatorId) {
|
|||
txid: pickedObj.txid
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.code === -6) throw new E.InsufficientFundsError()
|
||||
throw err
|
||||
})
|
||||
.catch(errorHandle)
|
||||
}
|
||||
|
||||
function newAddress (account, info, tx, settings, operatorId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue