Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

myNode GUI causing me to send funds to wrong address (after change of lnd directory) #809

Open
realnessy opened this issue Sep 5, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@realnessy
Copy link

Describe the bug
After I change the lnd directory, I am shown the QR code and text representation of the old (former) last bc1 deposit address, rather than the QR code and text presentation of a BTC address of the newly created wallet. This can lead to loosing all funds that are deposited!

Expected behavior
After creating a new wallet, no matter if I had a wallet before, I want to ONLY see QR codes and text fields that contain BTC addresses of my NEW wallet. I do not want to see any address, that does NOT belong to the new wallet.

I understand that caching is convenient, but I would strongly suggest to also cache the public key of the wallet, and to display the cached deposit address only if the public key did not change.

Screenshots
I created a test wallet (I add the seed as it is a test wallet only). The seed was computed by lnd.

about depend ripple gas north hybrid material flip canoe ten age camp enrich lens short soccer legal caught future explain school cream wear retreat

After restart of lnd with the new wallet, it took a little bit (not more than a few minutes) until the first deposit address was shown in text and QR code. This is what I saw after creating a wallet with the above seed:

grafik

The problem: the FIRST of these QR codes belongs to the FORMER lnd wallet. It is NOT part of the current seed. This is not an image cache problem, also the text representation shows the wrong address.

Desktop (please complete the following information):

  • Firefox
  • 117.0

MyNode hardware (please complete the following information):

  • Device: Raspi 4
  • Version: 0.3.19

Additional context

When this first happened to me, it was a productive system, and there were real funds involved. So I invested some time, to find out, what happened, and why my funds did not appear in the LND wallet. Luckily, I found the reason (credits to Mr. Donty from Telegram, who was a big help during debugging.

During my tests I did the same as in the productive environment.

  • stop the lnd-related processes using the GUI
  • mv /mnt/hdd/mynode/lnd /mnt/hdd/mynode/lnd.old
  • mkdir /mnt/hdd/mynode/lnd
  • chown bitcoin:bitcoin /mnt/hdd/mynode/lnd
  • start the related processes again using the GUI

In my productive environment, the first deposit did not arrive. The 2nd deposit showed up in the lnd wallet (it was done on a new deposit address, I think I clicked the Generate New Address button twice, and the deposit was on /0/1). So the 3rd BTC address was correct, I assume the 2nd BTC address was correct as well, in my productive system.

When I tried to reproduce the problem, I have bee shown the last BTC address of the OLD wallet as first BTC deposit address, in mynode GUI. So this part of the bug report is very well reproducable.

When I now click on "Generate New Address", I am not sure if those addresses are part of my new wallet seed. E.g. bc1qa4yrxl3ma5ua46yaa6p6g2z0mmqn5lf7xwugfj is the 3rd address that was shown by mynode, and for some reason, I cannot find it in the test wallet that I generated from the rootkey. Maybe somebody wants to check this, either I am not experienced enough, or there can be cases where even more than the 1st address is broken. Maybe somebody can help to check. This experience differs from my productive system, where I had valid addresses on e.g. the 3rd deposit address.

Please take the first BTC address shown as real and reproducable bugreport, and maybe have a look at the following addresses as well.

Thank you very much, keep on the good work, happy hacking!

Angela

@realnessy realnessy added the bug Something isn't working label Sep 5, 2023
@tehelsper
Copy link
Collaborator

Yeah, I do see how that could happen if you manually make reset LND without a reboot. The intended way to do it is to delete the wallet data (you could make a backup first) via the web UI which does a reboot to ensure everything resets. We cache the LND address because generating a new address on each refresh will use up addresses quickly and cause a huge address lookback value to be required if a wallet needs to be recovered.

@realnessy
Copy link
Author

I forgot to mention: while I did those things, I used https://mynode/apps to stop all lnd-related apps. Even though I did that, I found lnd running when I started with the command line.

As mentioned, my test wallet had the BTC address of the previous wallet that was seen in the GUI. But inbetween I had another wallet, that I deleted right away when I saw that lnd was running (for whatever reason - I stopped it before). So that wallet was alive for only a minute or so. I then killed the lnd-related processes from command line, and I deleted mynode/lnd/*, to start with my test.

I ASSUME that the following happened:

  • I killed lnd (and I think some other lnd-related processes)
  • mynode started lnd again, I didn't notice that (even though I disabled lnd from GUI, previously)
  • I removed lnd/* (but lnd has read the config already)
  • I started over with the next test wallet.
  • mynode found an empty directory and created a wallet, I noted the seed
  • lnd was running with the wallet data of the temporary wallet
  • mynode presented the deposit address of the last good wallet (not of the temporary wallet)
  • when I generated a new deposit address, it showed the address of the temporary wallet

Even though I noted the seed carefully, my current test wallet is using a seed and generating BTC addresses that are not at all related to my seed. I put the seed into sparrow, using the rootkey. None of the addresses is in sparrow. If I deposit money, it will be lost, even though I generated new addresses.

I have NOT rebooted yet. After rebooting, I will check if unknown deposit addresses will be generated, of if now addresses from my known test seed will be generated.

Luckily I did not send funds to any such BTC addresses, but it could easily have happened. It was really just luck!

I truly think that mynode should store the pubkey when caching, and it should only display a cached address when the pubkey matches.

PLUS it should store the pubkey of the seed that it displayed to the user., and if it is running on a wrong pubkey, it should go into an warning/error state and never display a deposit address, unless the user confirms.

I think I ran into big chaos because lnd started and I didn't notice. And yes, this should be fixed. But ... better save than sorry ... you might consider adding some extra-check if mynode presented seed1, and later on it is running on seed2. Maybe "Warning, lnd is currently running on a wallet that has not been created by mynode, press "resume" if you created this wallet and if you have written down the seed. Press "Recreate wallet" otherwise."

Recreate Wallet would move away the foreign lnd directory and start with a new seed.

Maybe I should have created a new issue? Not sure... It is all related on knowing if the wallet changed for some reason.

Kind regards, Angela

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants