lnd was crashing with the following error.
goroutine 1 [running]:
github.com/lightningnetwork/lnd/vendor/github.com/roasbeef/btcwallet/snacl.(*SecretKey).Zero(...)
/home/me/go/src/github.com/lightningnetwork/lnd/vendor/github.com/roasbeef/btcwallet/snacl/snacl.go:194
github.com/lightningnetwork/lnd/macaroons.(*RootKeyStorage).Close(0xc42003a9f0, 0xc4200001a8, 0xc42006d998)
/home/me/go/src/github.com/lightningnetwork/lnd/macaroons/store.go:199 +0x26
github.com/lightningnetwork/lnd/macaroons.(*Service).Close(0xc4204eeae0, 0x1, 0x1)
/home/me/go/src/github.com/lightningnetwork/lnd/macaroons/service.go:182 +0x2f
main.lndMain(0x108b720, 0xc42003a9b0)
/home/me/go/src/github.com/lightningnetwork/lnd/lnd.go:229 +0x285a
main.main()
/home/me/go/src/github.com/lightningnetwork/lnd/lnd.go:600 +0x36
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb9a8b6]
When I tried to unlock the wallet, it wouldn't work, said wrong password.
So I wiped everything (stupidly without making a backup) and restored from the seed.
This worked, and I got my node up and running again. No further password errors.
Except it wasn't creating any channels...
I checked the walletbalance, and it was zero.
I thought perhaps I should test this from another node, to see if there's a problem here.
First, check balance:
lncli walletbalance
{
"total_balance": "929109850",
"confirmed_balance": "929109850",
"unconfirmed_balance": "0"
}
then after making a backup of wallet.db, I moved it out of the way and delete macaroon files & db, tls, and started lnd.
proceeded with lncli create, add password, and use my recovery seed from the prior wallet.
lnd proceeds and begins to sync. Once done I check the balance. Zero
{
"total_balance": "0",
"confirmed_balance": "0",
"unconfirmed_balance": "0"
}
Any ideas?
That fragment you listed above was fixed in this commit: https://github.com/lightningnetwork/lnd/commit/92eebff64e1c74501f2755ab50892bcee39dc593. It can happen if the unlocker service is unable to bind to the proper port.
When I tried to unlock the wallet, it wouldn't work, said wrong password.
The macaroon database is encrypted with the same passphrase as the wallet, so if you were unable to unlock the wallet, then it's likely that your passphrase was incorrect. If you were switching between testnet and mainnet (or something like that), then currently you need to wipe the macaroon db so a new one is generated.
Except it wasn't creating any channels...
I checked the walletbalance, and it was zero.
So I wiped everything (stupidly without making a backup) and restored from the seed.
Never delete wallet data :/
As you wiped the channel state, it didn't retain any knowledge of the channels. Full look ahead rescanning isn't yet implemented, but as you have the seed, and our key derivation is deterministic, it's possible to write a program manually to run through the keychain and re-derive relevant addresses.
this was from a fresh install with the 0.4-beta, which due to dns-seed issues, had no active channels.
I didn't get the (*SecretKey).Zero(...) error on the other node which was freshly installed at the same time.
Am I making an incorrect assumption that it's possible to get back a wallet & full balance with just the seed?
this was from a fresh install with the 0.4-beta, which due to dns-seed issues, had no active channels.
That commit I referenced was created _after_ the release, and will be included in an upcoming patch release to bundle all the bug fixes discovered since then.
Am I making an incorrect assumption that it's possible to get back a wallet & full balance with just the seed?
The on-chain balance, yes, it just yet isn't implemented in an automated fashion yet.
@Roasbeef I switched from testnet to mainnet and have been experiencing a similar issue. At first it said my wallet password is incorrect. So I created a new wallet using the same seed. Then when unlocking the wallet, terminal says "lnd successfully unlocked!". But no commands work with lncli afterwards and my LND logs show "invalid password".
I think I need to wipe macaroon db as per your recommendation. Is there a special procedure for wiping it? This is the first time I'm working with LND and bitcoin nodes.
Would I just run the following command?
$ sudo rm /home/bitcoin/.lnd/admin.macaroon
Also I'm guessing I need to remove readonly.macaroon as well?
And to generate a new macaroon db file would I just need to restart the node? Or is there anything else I need to do?
You'll need to locate the macaroon db, and delete that.
On Thu, Mar 22, 2018, 4:49 PM Manveer Jarosz notifications@github.com
wrote:
@Roasbeef https://github.com/roasbeef I switched from testnet to
mainnet and have been experiencing a similar issue. At first it said my
wallet password is incorrect. So I created a new wallet using the same
seed. Then when unlocking the wallet, terminal says "lnd successfully
unlocked!". But no commands work with lncli afterwards and my LND logs show
"invalid password".I think I need to wipe macaroon db as per your recommendation. Is there a
special procedure for wiping it? This is the first time I'm working with
LND and bitcoin nodes.Would I just run the following command?
$ sudo rm /home/bitcoin/.lnd/admin.macaroonAlso I'm guessing I need to remove readonly.macaroon as well?
And to generate a new macaroon db file would I just need to restart the
node? Or is there anything else I need to do?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/lightningnetwork/lnd/issues/900#issuecomment-375494405,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA87LjRfs8I12Pjl7UF3C4WYuBaun6NIks5thDiTgaJpZM4SyjPO
.
@Roasbeef so would that be the admin.macaroon and readonly.macaroon files, or another file(s)? Please be as specific as possible.
If you look in the data directory, there's a file called macaroon.db.
@Roasbeef I've deleted macaroon.db, restarted my node, and tried creating a new wallet. At the end of the wallet creation process, I got an error saying a wallet already exists.
[lncli] rpc error: code = Unknown desc = wallet already exists
So then I tried logging into my previous wallet. It said "lnd successfully unlocked!"
But when I try to run any lncli command, I receive this error:
[lncli] rpc error: code = Unknown desc = cannot retrieve macaroon: cannot get macaroon: root key with id 0 doesn't exist
UPDATE: looks like it's necessary to delete admin.macaroon and readonly.macaroon as well. This gets rid of the second error. But it's still remembering my old wallet, so my only option is to unlock it. I can't create a new wallet.
I was able to recreate my old wallet. I had to delete wallet.db
I created a few new addresses and finaly hit my old wallet address. Now I need a way to rescan the wallet.
Any idea how to trigger lnd to rescan the wallet? I restarted the service after creating my address but still 0 balance after switching backend from btcd to bitcoind (testnet).
I restartet my bitcoind with config file zapwallettxes=2
PR for wallet recovery in btcwallet is open here https://github.com/Roasbeef/btcwallet/pull/22
Gonna make a PR to lnd later today that has it hooked up so you can attempt to restore from seed and get on chain funds. Would appreciate some testers :)
I am a test engineer. Happy to help :)
If the build process is automated please build a test binary lnd-darwin-amd64
If that takes to much time I will have to setup everything to build from source.
PR now here: https://github.com/lightningnetwork/lnd/pull/1005
well done all :)
@bretton all 929109850 accounted for?
@cfromknecht I'll have to restore the wallet on a new host sometime, just tBTC so no rush
Hi, I've just run into the same problem after wiping the SD card and HDD on my Raspberry Pi node. I re-installed LND with:
lnd version 0.4.2-beta commit=7cf5ebe2650b6798182e10be198c7ffc1f1d6e19
Is there an additional step I need to do to activate this wallet recovery? I've created my wallet using my previous cipher seed and passphrase, but walletbalance still shows 0.
Thanks!
@Cees2daBees It should restore if you used the correct seed and passphrase. Not that funds in channels won't be restored.
@halseth Hmm, I believe I've got the correct seed and passphrase. When using 'lncli create' and indicating I have an existing cipher seed, would there be some error if I input an incorrect seed and/or passphrase? I assumed that since it created the wallet using the cipher seed and passphrase I supplied without any errors, that I must have originally recorded them and subsequently input them correctly?
Is there some log file that shows the wallet recovery process that I could go to to review whether there are any issues with wallet recovery?
P.S. I did not have any open channels. Just some mainnet BTC in my LND wallet.
@Cees2daBees during lncli create it should ask you if you already have a seed, which you should enter. It will also ask you for a "recovery window", which defaults to 250 I believe. If there's a chance that your node may have generated a bunch of addrs, it may be worthwhile to crank that up.
Also if you restart your node during a recovery, you can resume by passing --recovery_window XXX to lncli unlock.
@cfromknecht that's what i was doing originally and didn't seem to recover the wallet before. but i just deleted the entire lnd folder and re-installed and re-initialized the wallet with the cipher and passphrase and looks all ok now. walletbalance and onchaintxns all back. thanks!
Awesome, great news @Cees2daBees!
@cfromknecht that's what i was doing originally and didn't seem to recover the wallet before. but i just deleted the entire lnd folder and re-installed and re-initialized the wallet with the cipher and passphrase and looks all ok now. walletbalance and onchaintxns all back. thanks!
I had a previous mainnet LND wallet with some balance. I understand I'll lose my channel balances, but I'd like to recover on a brand new pi+hard drive. I started with testnet, moved to mainnet, recovered with seed. No balance at this point after defaulting recovery window to 250. Would you suggest I do the same and delete all of LND and reinstall it?
I started with testnet, moved to mainnet
Can you clarify what you mean by this?
recovered with seed. No balance at this point after defaulting recovery window to 250.
Can you try to increase the recovery window?
I'm pretty new to this, so this is probably a simple fix that I'm just not understanding. First, to clarify, I recreated my node with Stadicus guide, first with testnet, then I upgraded to mainnet. When I used 'lncli create' on mainnet i used my previous seed words that were used on a previous pi + hard drive.
When you say "Can you try to increase the recovery window?" you mean by unlocking with lncli unlock --recovery_window (# > 250) correct? I have tried a few larger numbers, 1000, 10000. The node was not being used for a month + so would that take an even larger number? what is the best way to monitor progress? sudo journalctl -f -u lnd ?
When I used 'lncli create' on mainnet i used my previous seed words that were used on a previous pi + hard drive
This was your _testnet_ seed?
It was my mainnet seed. I just mentioned that I was on testnet first because I wasn't sure if there would be any issues with moving from testnet to mainnet with wallet creation. Is the best way to try this again to delete my LND folder and then crank recovery_window up and try it again? Or is there a way to run recovery_window without lncli create?
To clarify, you have both testnet and mainnet coins in this seed?
When you say "Can you try to increase the recovery window?" you mean by unlocking with lncli unlock --recovery_window (# > 250) correct? I have tried a few larger numbers, 1000, 10000. The node was not being used for a month + so would that take an even larger number? what is the best way to monitor progress?
lncli create and lncli unlock both accept a --recovery_window, but you'll need to doing a fresh sync to have any effect. Just unlocking the wallet after already being synced won't fix the issue.
I'd recommend _moving your existing lnd data dir_, then try to sync a fresh node using:
lnd --nobootstrap --nolisten
lncli create
when asked if you want to set a recovery window, enter XXXX. If lnd crashes or dies during this initial sync, you can start it again and unlock using:
lncli unlock --recovery_window=XXXX
Once the node has finished syncing, you can then unlock on subsequent starts as normal,
without needing the window parameter.
If all goes smoothly and your coins are accounted for, then go ahead and delete the old state. (Just wanna make sure we don't delete preemptively)
The node was not being used for a month + so would that take an even larger number?
Probably not, but it depends. It needs to be larger than the number of consecutive unused addresses the node has ever generated. I'd guess XXXX=1000 is more than plenty.
I copied my /.lnd/ folder to another drive, deleted everything off the pi, then reinstalled LND. I followed your instructions but actually did recovery window of 5000. I have a working node, but still recovered zero funds. It wasn't anything too substantial so it isn't a big deal, but now I'm worried about the future case that this could happen again. The only thing I didn't mention is that my original wallet was LND 0.4.2 and now I'm running LND 5.0. Would that be an issue?
Most helpful comment
well done all :)