mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-28 13:52:55 +02:00
lnd: Call loader.UnloadWallet on shutdown
This is required to make restart work for LndMobile builds. Not calling UnloadWallet would make `UnlockWallet` stall forever as the file is already opened.
This commit is contained in:
11
lnd.go
11
lnd.go
@@ -387,6 +387,11 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
||||
walletInitParams = *params
|
||||
privateWalletPw = walletInitParams.Password
|
||||
publicWalletPw = walletInitParams.Password
|
||||
defer func() {
|
||||
if err := walletInitParams.UnloadWallet(); err != nil {
|
||||
ltndLog.Errorf("Could not unload wallet: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
if walletInitParams.RecoveryWindow > 0 {
|
||||
ltndLog.Infof("Wallet recovery mode enabled with "+
|
||||
@@ -944,6 +949,10 @@ type WalletUnlockParams struct {
|
||||
// ChansToRestore a set of static channel backups that should be
|
||||
// restored before the main server instance starts up.
|
||||
ChansToRestore walletunlocker.ChannelsToRecover
|
||||
|
||||
// UnloadWallet is a function for unloading the wallet, which should
|
||||
// be called on shutdown.
|
||||
UnloadWallet func() error
|
||||
}
|
||||
|
||||
// waitForWalletPassword will spin up gRPC and REST endpoints for the
|
||||
@@ -1105,6 +1114,7 @@ func waitForWalletPassword(cfg *Config, restEndpoints []net.Addr,
|
||||
RecoveryWindow: recoveryWindow,
|
||||
Wallet: newWallet,
|
||||
ChansToRestore: initMsg.ChanBackups,
|
||||
UnloadWallet: loader.UnloadWallet,
|
||||
}, nil
|
||||
|
||||
// The wallet has already been created in the past, and is simply being
|
||||
@@ -1115,6 +1125,7 @@ func waitForWalletPassword(cfg *Config, restEndpoints []net.Addr,
|
||||
RecoveryWindow: unlockMsg.RecoveryWindow,
|
||||
Wallet: unlockMsg.Wallet,
|
||||
ChansToRestore: unlockMsg.ChanBackups,
|
||||
UnloadWallet: unlockMsg.UnloadWallet,
|
||||
}, nil
|
||||
|
||||
case <-signal.ShutdownChannel():
|
||||
|
Reference in New Issue
Block a user