decred / dcrlnd

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

Move keyring implementation from keychain to dcrwallet package #29

Closed matheusd closed 5 years ago

matheusd commented 5 years ago

The main goal for this changeset is to move the keyring implementation (which requires an active and unlocked backing dcrwallet) from the keychain package to the lnwallet/dcrwallet package.

This makes the keychain package cleaner, more generic and removes its dependency to dcrwallet packages in particular and allows future keyring implementations to not be based on a local backing dcrwallet.

It also binds the existing keyring implementation (WalletKeyRing) to the existing wallet driver, which makes sense since it entirely relies on the internal backing wallet.

Another change introduced is that the public keys generated for use within the LN processes are no longer generated inside the backing dcrwallet (via NextAddress() calls), but rather on the keyring itself, based on the root coin type extended private key provided by the wallet. This removes the need for the wallet to track the large(ish) amount of keys (with their associated addresses) used by LN scripts which should never appear on-chain and that the wallet doesn't even (currently) know how to deal with, given the fact that it doesn't understand how the LN scripts work. It also increases the uncoupling between dcrlnd and the backing dcrwallet, which might eventually allow dcrlnd to use remote (instead of embedded) wallets.

The individual commits should be sane enough to be reviewed individually if needed, performing the required changes in stages.

davecgh commented 5 years ago

This is an excellent change that I'm happy to see.