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

Allow use with a remote wallet #40

Merged
merged 11 commits into from
Oct 15, 2019
Merged

Conversation

matheusd
Copy link
Member

@matheusd matheusd commented Sep 20, 2019

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.

This changes the defer function in the test for channel backups to
correctly close over the 'dave' variable.

Without this closure, the shutdownAndAssert call would attempt to
shutdown the original (non-restored) dave instead of the most recently
created (restored) dave, causing a leak of a node during tests.
This adds a check for the wallet funding transactions before proceeding
to improve the reliability of the tests.

It also increases the maximum time to sync the wallet due to ocasional
failing tests in -race mode.
This changes the dcrd make target to build the required dcrd version in
a temp dir instead of using go get.

During development it's common to have a situation where not all dcrd
modules have been tagged yet so go get might fail. It's easier to fetch
the repo in a temp dir and build from there, so that all module
replacements are correct.
This fixes the metadata in pseudo-version strings and tidies the module
entries so that go 1.13 doesn't complain about wrong strings.
This removes most replace directives and switches to using a correct
required version where possible.

Replaces are still used for the unmerged/untagged lightning-onion
version needed and for chaincfg v1.5.2 which is also untagged.
@matheusd matheusd changed the title Remote wallet pub Allow use with a remote wallet Sep 20, 2019
// newWalletKeyRing creates a new implementation of the keychain.SecretKeyRing
// interface backed by dcrwallet.
// creates a new implementation of the keychain.SecretKeyRing
//interface backed by dcrwallet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

This switches to using version 3 of the wallet packages.

This is currently used an as-of-yet unreleased version of the packages
since they have a few bug fixes that are useful and are likely to become
the new released version in a short amount of time.

In order to change to wallet v3 the rpcclient version for some
components also had to be bumped to version 3 due to incompatibility in
the API for dcrd's rescan rpc call.
This updates the rest of project to use the latest released major
version of all dependencies.
This changes the SendCoins implementation to try and ensure there are no
previous unmined utxos for the given node.

This is necessary because the current SendCoins implementation verifies
it's the single utxo, so before starting it we need to ensure no
previous utxos exist that could cause the test to fail.
This adds an additional check for clean slate after tests to ensure the
existing nodes do not have any lingering unmined utxos.
This is the initial version of the remote wallet driver implementation.

This implementation allows dcrlnd to connect to an existing, running and
synced dcrwallet and use a specific account to generate the on-chain
operations and off-chain keys necessary for dcrlnd to function.
This adds the ability to run integration tests against the remote wallet
implementation.

It also modifies the travis matrix to run integration tests against both
the embedded and the remote wallet drivers.
Copy link
Member

@vctt94 vctt94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I tested and found no issues.

I think it would be good if we have some kind of message letting people know that they can not use grpc wallets with an existing wallet, but as lightning still do not have many users, I think just some doc on the README should be fine.

@matheusd matheusd merged commit cbf65d2 into decred:master Oct 15, 2019
@matheusd matheusd deleted the remote-wallet-pub branch April 23, 2020 19:28
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

Successfully merging this pull request may close these issues.

3 participants