You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
lnd: a failed init-wallet leaves a wallet.db that blocks wallet creation on later starts #56
lnd's preStart creates the wallet only if wallet.db doesn't exist (modules/lnd.nix:239):
if [[ !-f${networkDir}/wallet.db ]];then
...
${lndinit} -v init-wallet --file.seed="$seed" --file.wallet-password=... --init-file.output-wallet-dir=...
fi
lndinit init-wallet creates wallet.db before it creates the wallet inside it. If the second step fails, a wallet.db with no wallet stays behind. The check then skips init-wallet on every later start, even after the cause is fixed.
One way to get there: an empty lnd-wallet-password. makePasswordSecret (modules/secrets/secrets.nix:91) writes with a plain redirect, so a failed pwgen leaves an empty file, and [[ -e $1 ]] never regenerates it. #44 fixes that part (temp file plus -s), but a stub wallet.db created before that fix stays.
The seed has the same shape: gen-seed > "$seed" (modules/lnd.nix:244) creates the file before lndinit runs, and [[ ! -f "$seed" ]] won't retry an empty one. That part comes from reading the code; I didn't trigger it.
Evidence
lndinit from nixpkgs, empty password file:
$ : > pw
$ lndinit gen-seed > seed
$ lndinit -v init-wallet --file.seed=seed --file.wallet-password=pw --init-file.output-wallet-dir=$PWD/lw
LNDINIT: Reading seed from file
LNDINIT: Reading wallet password from file
LNDINIT: Creating new wallet in .../lw
LNDINIT: Runtime error: error creating wallet from seed: private passphrase may not be empty
$ ls -l lw
-rw------- 1 ... 16384 ... wallet.db
Not checked: what lnd does when it starts on that stub wallet.db with wallet-unlock-password-file set.
Possible fix
Make the wallet creation atomic from the module's point of view: run init-wallet into a temp dir next to networkDir and mv the resulting wallet.db into place only on success. Or delete wallet.db when init-wallet fails, which is safe only because the module just checked that no wallet.db existed before. Write the seed through a temp file too, and check it with -s.
Activity
secrets: reject empty secret files and write generated keys atomically (