fix: enable password unprotected wallets

This commit is contained in:
Sérgio Salgado 2022-05-18 15:47:43 +01:00
parent f8223df4c8
commit 6aafb818b7

View file

@ -63,6 +63,12 @@ function handleError (error, method) {
} }
case -21: case -21:
throw new Error('Wallet already exists!') throw new Error('Wallet already exists!')
case -22:
try {
return openWalletWithPassword()
} catch {
throw new Error('Invalid wallet password!')
}
case -17: case -17:
throw new E.InsufficientFundsError() throw new E.InsufficientFundsError()
case -37: case -37:
@ -79,11 +85,16 @@ function handleError (error, method) {
} }
function openWallet () { function openWallet () {
return fetch('open_wallet', { filename: 'Wallet' })
.catch(err => handleError(err, 'openWallet'))
}
function openWalletWithPassword () {
return fetch('open_wallet', { filename: 'Wallet', password: rpcConfig().password }) return fetch('open_wallet', { filename: 'Wallet', password: rpcConfig().password })
} }
function createWallet () { function createWallet () {
return fetch('create_wallet', { filename: 'Wallet', password: rpcConfig().password, language: 'English' }) return fetch('create_wallet', { filename: 'Wallet', language: 'English' })
.then(() => new Promise(() => setTimeout(() => openWallet(), 3000))) .then(() => new Promise(() => setTimeout(() => openWallet(), 3000)))
.then(() => fetch('auto_refresh')) .then(() => fetch('auto_refresh'))
} }