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

Add support for Taproot and tr() descriptors #2

Conversation

IgboPharaoh
Copy link
Owner

Description

This is a work-in-progress PR to update BDK to rust-bitcoin 0.28 which introduces taproot support and a few other improvements. While updating we also introduce taproot support in BDK.

High level list of subtasks for this PR:

  • Update rust-bitcoin and rust-miniscript
  • Stop using deprecated structs
  • Add taproot metadata to psbts
  • Produce schnorr signatures
  • Finalize taproot txs
  • Support tr() descriptors in the descriptor!() macro
  • Write a lot of tests
    • Interoperability with other wallets (Core + ?)
      • Signing/finalizing a psbt made by core
      • Producing a psbt that core can sign and finalize
    • Creating psbts
      • Verify the metadata are correct
      • Verify sighashes are applied correctly
      • Create a tx with a foreign taproot and non-taproot utxo
    • Signing psbts
      • Signing for a key spend
      • Signing for a script spend
      • Signing with a single (wif) key
      • Signing with an xprv (with and without knowing the utxo being spent in the db)
      • Signing with weird sighashes
    • Policy module
      • Simple key spend
      • More complex tap tree with a few keys
      • Verify both contribution and satisfaction of a PSBT input
    • Wallet module
      • Generate addresses

Fixes bitcoindevkit#63

Notes to the reviewers

Milestone

I'm adding this to the 0.19 milestone because now that rust-bitcoin and rust-miniscript have been released we should not waiting too long to release a version of BDK that supports the new libraries.

API Breaks

Since this is an API-break because of the new version of rust-bitcoin and rust-miniscript, I'm also taking the chance to update a few things in our lib that I had been thinking about for a while.

One example is the signer interface, which had that weird sign_whole_tx() method. This has now been removed, and the Signer trait replaced with TransactionSigner and InputSigner. I'm also starting to think that the signer should not only look at the psbt to figure out what to do, but ideally it should also receive some information about the descriptor (for example, the type) to simplify the code.

One option is to add an extra parameter, but that would probably only be used by our internal signers and not much else (for example, if you ask an hardware wallet to sign, it will probably already know what kind of wallet you have).

Another option is to wrap PrivateKey and DescriptorXKey<ExtendedPrivKey> which are the two internal signers we support with a struct that contains metadata about the descriptor, and then implement the signer traits on that struct. We could construct this in Wallet::new(), after miniscript parses the descriptor.

MSRV Bump

Due to the update of rust-electrum-client, which in turn depends on an updated webpki, we will have to bump our MSRV beacuse 1.46 is not supported by the new webpki version.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added docs for the new feature
  • I've updated CHANGELOG.md

Sorry, something went wrong.

afilini and others added 18 commits May 27, 2022 11:48
This allows the signer to know the signing context precisely without
relying on heuristics on the psbt fields.

Due to the context being static, we still have to look at the PSBT when
producing taproot signatures to determine the set of leaf hashes that
the key can sign for.
For whatever reason we were using a struct as an enum, so we might as
well fix it in this PR since we are already breaking the API quite
badly.
Also refactor our code to lookup signatures in PSBTs to use the context
We used to only look at `bip32_derivations` which is only used for ECDSA
keys.
This is to ensure a Bitcoin node accepts our transactions
Co-authored-by: Daniela Brozzoni <danielabrozzoni@protonmail.com>
@IgboPharaoh IgboPharaoh deleted the afilini-fresheyes-feature/taproot-593 branch May 20, 2024 14:19
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.

None yet

3 participants