From ad0dbb1c15d7a744c7eeaa4448bd0f5364dd41ee Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 9 Dec 2022 11:09:05 +0100 Subject: [PATCH] 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. --- walletunlocker/service.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/walletunlocker/service.go b/walletunlocker/service.go index 6d58b0478..d896c2d88 100644 --- a/walletunlocker/service.go +++ b/walletunlocker/service.go @@ -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