Skip to content

Conversation

darosior
Copy link
Owner

This implements BIP389 "Multipath Descriptor Key Expressions" (see bitcoin/bips#1354).

@darosior
Copy link
Owner Author

I've tested this against rust-bitcoin/rust-miniscript#470, and i need it for Minisafe's functional testing framework. I'll mention it explicitly as experimental.

@darosior darosior merged commit f25eb2a into master Oct 24, 2022
@darosior darosior deleted the multipath_descriptors branch October 24, 2022 12:56
darosior added a commit to wizardsardine/liana that referenced this pull request Oct 28, 2022
117171f commands: use a separate key chain for change addresses (Antoine Poinsot)
d9f905a db: track the next unused derivation index for change, too (Antoine Poinsot)
58a0e57 db: record whether a coin was received on a change address (Antoine Poinsot)
9b04a55 db: store derivation index also for addresses from the change desc (Antoine Poinsot)
4f3daa7 descriptors: cache the receive and change descriptors (Antoine Poinsot)
ca3d7c1 descriptors: introduce a newtype for the multipath descriptor (Antoine Poinsot)
1320ee3 daemon: use multipath descriptors (Antoine Poinsot)
d4db804 qa: add a missing 'wait_for' in spend creation test (Antoine Poinsot)
7a18c58 bitcoind: filter received coins based on parent descriptors (Antoine Poinsot)
ba4c1e0 bitcoind: include change outputs in listsinceblock (Antoine Poinsot)
caaca1f descriptors: rename derive into derive_received (Antoine Poinsot)
f985fd7 descriptors: remove as_inner method (Antoine Poinsot)
846d924 qa: upgrade python-bip380 to latest master (Antoine Poinsot)
3105b86 Use my own fork of rust-miniscript (Antoine Poinsot)

Pull request description:

  This fixes #18 by implementing the de-facto standard of using a `/0/*` keychain for receiving addresses and a `/1/*` keychain for change addresses. Note that once we'll have multisig, reusing addresses will still be possible since wallet don't share the same "next derivation index".

  In order to avoid forcing the user to configure and backup two almost identical descriptors, we make use of the recently proposed BIP389 (bitcoin/bips#1354). In order to prevent as much as possible introducing a backward incompatibility in the configuration file after the first release, we restrict the usage of multipath descriptors to `<0;1>` here.
  We now derive public keys from `xpub/0/*` and `xpub/1/*` while we were previously deriving them from `xpub/*`.

  This triggered a pretty invasive refactoring, as most parts of the codebase had to be updated to support the new change/receive separation (even the functional test miniscript dependency had to be updated, see darosior/python-bip380#21).
  Broadly, this:
  1. Update our Miniscript dependency to my upstream PR (rust-bitcoin/rust-miniscript#470) rebased on top of the 8.0.0 release.
  2. Updates the descriptors module to handle somewhat safely the multipath descriptors (to avoid mixing up the single, multi, and derived descriptors).
  3. Makes a multipath descriptor mandatory in the configuration file.
  4. Updates the Bitcoin backend poller aware of descriptors for which to track coins.
     - Necessarily this updates the bitcoind implementation to import two descriptors
  5. Record in database whether a coin was for the change or receive descriptor, in addition to its derivation index

ACKs for top commit:
  edouardparis:
    ACK 117171f

Tree-SHA512: efcb7267f1ba6a5a3072e96fd1c70272f81092e86ee1178833f83d0aa88f271f42c269b71ca9992e76bb3e103baf1a189a609cc20f14f29b7388ab133da99044
@darosior
Copy link
Owner Author

Note for posterity: the last commit making the exec_info be computed dynamically is because the cost calculation needs access to the script, which can't be created before the derivation path to be used is chosen.

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.

1 participant