fix: enable password unprotected wallets

This commit is contained in:
Sérgio Salgado 2022-05-18 18:25:12 +01:00
parent f25ff92e25
commit 7e6942d0e5

View file

@ -64,6 +64,12 @@ function handleError (error, method) {
}
case -21:
throw new Error('Wallet already exists!')
case -22:
try {
return openWalletWithPassword()
} catch {
throw new Error('Invalid wallet password!')
}
case -17:
throw new E.InsufficientFundsError()
case -37:
@ -80,11 +86,16 @@ function handleError (error, method) {
}
function openWallet () {
return fetch('open_wallet', { filename: 'Wallet' })
.catch(err => handleError(err, 'openWallet'))
}
function openWalletWithPassword () {
return fetch('open_wallet', { filename: 'Wallet', password: rpcConfig().password })
}
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(() => fetch('auto_refresh'))
}