wallet: close db on Open() failure.
This commit makes sure the wallet db is closed if the call to open the wallet fails, as subsequent calls to OpenExistingWallet would fail to open the already open database.
This commit is contained in:
parent
d59a767ab8
commit
255f23679f
1 changed files with 7 additions and 0 deletions
|
@ -177,6 +177,13 @@ func (l *Loader) OpenExistingWallet(pubPassphrase []byte, canConsolePrompt bool)
|
|||
}
|
||||
w, err := Open(db, pubPassphrase, cbs, l.chainParams)
|
||||
if err != nil {
|
||||
// If opening the wallet fails (e.g. because of wrong
|
||||
// passphrase), we must close the backing database to
|
||||
// allow future calls to walletdb.Open().
|
||||
e := db.Close()
|
||||
if e != nil {
|
||||
log.Warnf("Error closing database: %v", e)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
w.Start()
|
||||
|
|
Loading…
Add table
Reference in a new issue