decred / dcrlnd

Decred Lightning Network Daemon ⚡️
MIT License
36 stars 24 forks source link

Allow use with a remote wallet #40

Closed matheusd closed 4 years ago

matheusd commented 5 years ago

Requires #39

This allows you to run dcrlnd by connecting it to an existing remote dcrwallet instead of running an embedded one.

When running dcrlnd, specify the new command line options --dcrwallet.grpchost and --dcrwallet.certpath as appropriate and (optionally) --dcrwallet.accountnumber to specify an account. Then unlock dcrlnd using your wallet password.

The first time this is done, dcrlnd will record the first external pubkey from the account and will refuse to run if you specify a different account number in the future. In other words: you can't change the account afterwards.

The decrediton LN PR has been updated to use this method instead of requiring users to manually specify credentials.

Using a remote wallet works by connecting via grpc to the wallet, exporting the specified account's xpriv and deriving all LN-related keys from there. The multisig keys (the ones used to create the funding tx) are directly derived from the account's external branch while the off-chain keys are derived from a special hardened account branch (1017). Ideally this would be a different purpose branch, but currently the wallet can't track custom xprivs so this will be improved upon in the future.

Note that when using autopilot, dcrlnd will use the funds from the given account to establish channels. In other words, dcrlnd will take control of the funds for the given account, so ideally this should be one dedicated to LN operations.