mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-08 14:57:38 +02:00
lnd+config+sample-lnd.conf: add wallet-unlock-allow-create flag
As requested by users of node bundle software. They want to use the wallet-unlock-password-file configuration option in their default/template config file. This makes the first-time lnd setup a bit more tricky since lnd will fail with an error if no wallet exists yet while that config option is used. The new wallet-unlock-allow-create option instructs lnd to not fail if no wallet exists yet but instead spin up its unlocker RPC as it would without the wallet-unlock-password-file being present. This is not recommended for auto-provisioned or high-security systems because the wallet creation RPC is unauthenticated and an attacker could inject a seed while lnd is in that state.
This commit is contained in:
13
lnd.go
13
lnd.go
@@ -481,9 +481,14 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
|
||||
interceptorChain.SetWalletLocked()
|
||||
}
|
||||
|
||||
// If we've started in auto unlock mode, then a wallet _must_ already
|
||||
// exist because we never want to enable the RPC unlocker in that case.
|
||||
if cfg.WalletUnlockPasswordFile != "" && !walletExists {
|
||||
// If we've started in auto unlock mode, then a wallet should already
|
||||
// exist because we don't want to enable the RPC unlocker in that case
|
||||
// for security reasons (an attacker could inject their seed since the
|
||||
// RPC is unauthenticated). Only if the user explicitly wants to allow
|
||||
// wallet creation we don't error out here.
|
||||
if cfg.WalletUnlockPasswordFile != "" && !walletExists &&
|
||||
!cfg.WalletUnlockAllowCreate {
|
||||
|
||||
return fmt.Errorf("wallet unlock password file was specified " +
|
||||
"but wallet does not exist; initialize the wallet " +
|
||||
"before using auto unlocking")
|
||||
@@ -498,7 +503,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
|
||||
// set above.
|
||||
|
||||
// A password for unlocking is provided in a file.
|
||||
case cfg.WalletUnlockPasswordFile != "":
|
||||
case cfg.WalletUnlockPasswordFile != "" && walletExists:
|
||||
ltndLog.Infof("Attempting automatic wallet unlock with " +
|
||||
"password provided in file")
|
||||
pwBytes, err := ioutil.ReadFile(cfg.WalletUnlockPasswordFile)
|
||||
|
Reference in New Issue
Block a user