lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.67k stars 2.07k forks source link

Improve error message in lncli when "changepassword" is used after wallet is already unlocked #2529

Closed molxyz closed 2 years ago

molxyz commented 5 years ago

Background

When LND node is unlocked and running, try to change password by entering on a different terminal screen. LND seems to allow the password to be changed but actually it is not changed.

Your environment

Expected behaviour

If trying to change password when the node is already unlocked and running, LND should not allow the steps to happen and should issue an error message such as

Cannot change password while wallet is already unlocked. Please stop lnd and restart to change your password.
Roasbeef commented 5 years ago

You can only run changepassword with the wallet unlocker active. The command tries, but doesn't actually succeed. We should update the error message there to make this more explicit.

stridentbean commented 5 years ago

If I'm reading this correctly, the wallet unlocker service is deactivated after the wallet is unlocked. Is there any way to activate the service on the fly? Right now, I have to restart lnd and then change the password.

wpaulino commented 5 years ago

Is there any way to activate the service on the fly?

Not at the moment.

redek-zelton commented 2 years ago

may be can help https://github.com/lightningnetwork/lnd/blob/master/docs/wallet.md

redek-zelton commented 2 years ago

here: https://api.lightning.community/?shell#v1-changepassword

$ MACAROON_HEADER="Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 $LND_DIR/data/chain/bitcoin/simnet/admin.macaroon)"
$ curl -X POST --cacert $LND_DIR/tls.cert --header "$MACAROON_HEADER" https://localhost:8080/v1/changepassword  \
    -d '{ "current_password":<byte>,"new_password":<byte>,"stateless_init":<boolean>,"new_macaroon_root_key":<boolean>, }' 
{ 
    "admin_macaroon": <byte>, 
}
guggero commented 2 years ago

This issue is only about the error message, really.

Currently if you try to change the password after the wallet is already unlocked, lncli will return:

[lncli] Wallet is encrypted. Please unlock using 'lncli unlock', or set password using 'lncli create' if this is the first time starting lnd.

While it should probably say something more specific or more informative.

guggero commented 2 years ago

Fixed by #6349.