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

Issue Summary: LND Unlock Passwort actually not "hellorockstar" due to Trailing Line Feed in docker-initunlocklnd.sh #934

Open
warioishere opened this issue Oct 3, 2024 · 1 comment
Assignees

Comments

@warioishere
Copy link

warioishere commented Oct 3, 2024

Whiling trying to work with my wallet.db I found out that using the standardpassword hellorockstar doesnt actually work. With big help of @ziggie1984, he found out, that the actually wallet.db password ist not hellorockstar

Problem:

The unlock script for LND on BTCPayServer has a issue that led to all LND wallets being initialized and setup with an incorrect default password. Instead of the expected password hellorockstar, due to a coding mistake, the password included an extra line feed (\n) at the end, leading to an actual default password of hellorockstar\n for all LND wallets currently created.

This issue arises because the script did not properly strip newline characters from the password before storing it. As a result, all attempts to manually unlock the wallet with the expected password hellorockstar fail, since the actual password stored contains this hidden newline. Because of this, it is not possible to extract the masterrootkey in case of azeed loss because chantools doesnt support \n when entering the walletpassword.

@ziggie1984 from LND hast also released a special chantools version that can extract the xpriv/masterroot with the current password hellorockstar\n

to be found here:

https://github.com/ziggie1984/chantools/tree/btcpay-pw-fix

Current Fix:

A fix has been proposed by @ziggie1984 to address this issue by ensuring the trailing newline is not anymore included in the password when it is Base64-encoded and stored in the wallet. This ensures that future wallets are setup up and initialized with the correct password.

It also contains a fallback so that also with this fixed code, older wallets will still be able to unlock.

btcpayserver/lnd#7

This change strips any extraneous newline or carriage return characters, ensuring the password is stored correctly.

Migration Plan:

For users whose wallets were initialized with the incorrect password (hellorockstar\n), a password migration process is necessary:

  1. Use the LND REST API: Call the changepassword function using the old code logic to input the current incorrect password (hellorockstar\n).

  2. Password Change: Since manual password entry won't work due to the incorrect stored password, the unlock process must first use the incorrect password to unlock the wallet because lnd asks for the old password. Then, the correct password can be set via the REST API with the new code

  3. Automate the Process: A migration script could be included in the LND Docker startup bash script to check if the wallet is still using the old, incorrect password format. If so, the script could automate the password change process via the rest API function changepassword.

This ensures that wallets using hellorockstar\n as the password can be corrected without user intervention, preventing future unlock issues.

greetings

@rockstardev rockstardev self-assigned this Oct 10, 2024
@rockstardev
Copy link
Member

Continued discussion here: btcpayserver/lnd#7 (review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants