decred / dcrlnd

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

Don't rely on the wallet for off-chain keys #25

Closed matheusd closed 5 years ago

matheusd commented 5 years ago

Currently, the keychain package (responsible for generating public and private keys used throughout the ln processes) is implemented by generating accounts and addresses directly in the underlying wallet.

This has the following drawbacks:

In the upstream lnd, this was solved by using a separate HD branch with a different purpose value and implementing a mechanism in the underlying btcwallet (KeyScope) to allow usage of branches with a purpose other than the default 44'.

While some feature to allow different purpose branches isn't available in dcrwallet, an alternative approach is to use a single account masterpub to derive all dcrlnd-specific keys. Done correctly, this can ease switching to a different root purpose key in the future.

This means dcrlnd will have to track the indexes of used keys itself instead of relying on the underlying wallet, but this seems reasonable given that pretty much all the functionality associated with addresses and accounts is useless for the off-chain side anyway.

matheusd commented 5 years ago

Closed by #29

The wallet will be able to handle arbitrary xpubs in the future (and possibly individually unlocked accounts) so there may be other options for this, but for now we can close this.