walletunlocker: re-create loader after unloading wallet

Because the wallet loader sets its internal database reference to nil
when unloading a wallet, it cannot be loaded again in case of a remote
DB such as etcd or postgres. To avoid running into a nil pointer panic
we just re-create the loader as well before opening the wallet.
This commit is contained in:
Oliver Gugger 2022-12-09 11:09:05 +01:00
parent d04182f482
commit ad0dbb1c15
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

View File

@ -677,7 +677,13 @@ func (u *UnlockerService) LoadAndUnlock(password []byte,
return nil, nil, dropErr
}
// All looks good, let's now open the wallet again.
// All looks good, let's now open the wallet again. The loader
// was unloaded and might have removed its remote DB connection,
// so let's re-create it as well.
loader, err = u.newLoader(recoveryWindow)
if err != nil {
return nil, nil, err
}
unlockedWallet, err = loader.OpenExistingWallet(password, false)
if err != nil {
return nil, nil, err