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

[test] add tests to verify support for sending to bech32m address #402

Merged
merged 3 commits into from
Nov 17, 2021
Merged

[test] add tests to verify support for sending to bech32m address #402

merged 3 commits into from
Nov 17, 2021

Conversation

sandipndev
Copy link
Contributor

@sandipndev sandipndev commented Jul 20, 2021

Description

This PR is in reference to #396
It adds some tests to confirm sending transactions to Bech32m addresses, introduced in BIP350

Note: This change requires bitcoin-core v22.0 to be incorporated into bitcoind.

Checklists

  • 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 tests for Bech32m adoption by rust-bitcoin

@RCasatta
Copy link
Member

Ideally, I think it's a test to be added (also) to the bdk_blockchain_tests! macro

@notmandatory
Copy link
Member

Looks like bech32m addresses are not supported yet in rust-bitcoin 0.26.2. The PR that added support is rust-bitcoin/rust-bitcoin#601 and it has other breaking changes that will also need to be fixed in bdk. You can see the errors by updating bdk's Cargo.toml like this:

bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin.git", branch = "master", features = ["use-serde", "base64"] }

Also @RCasatta has a good idea about also updating the bdk_blockchain_tests macro, so this could could be a bit larger task but also a good opportunity to learn about macros. You'll also be able to get to know other parts of bdk by fixing the other errors to make bdk work with the master branch of rust-bitcoin (until a new released version is ready). Want to give it a go?

@sandipndev
Copy link
Contributor Author

Thank you for going through the problem.

We can develop using the master branch but should we release the Bech32m adoption before rust-bitcoin officially releases a version upgrade with the same?

In most places, there is a similar error after changing Cargo.toml to use the master branch of rust-bitcoin.

the trait `InnerXKey` is not implemented for `bitcoin::util::bip32`

I'm on fixing it!

@notmandatory
Copy link
Member

We can develop using the master branch but should we release the Bech32m adoption before rust-bitcoin officially releases a version upgrade with the same?

You will need to keep this PR in "draft" mode until an official rust-bitcoin release is ready, and then you can put that version in the Cargo.toml. In the mean time you can still work on getting ready for that release by making your fixes against the master branch.

@notmandatory
Copy link
Member

notmandatory commented Jul 26, 2021

The 0.27.0 version of rust-bitcoin is now released which includes bech32m support. I was able to get your new test to pass after these steps:

  1. In Cargo.toml update bitcoin version to "^0.27"
  2. Fork and make local clones of the rust-miniscript and rust-electrum-client projects and update both also to the rust-bitcoin version 0.27
  3. In Cargo.toml update the dependencies there for rust-miniscript and rust-electrum-client to the local path of your updated clones of these project, something like this:
    miniscript = { path = "../rust-miniscript" }
    ...
    electrum-client = { path = "../rust-electrum-client", optional = true }
    

Give it a try and then we can discuss additional tests (as @RCasatta suggested) and how to make the updates to those other projects (if no one else is already working on it).

@sandipndev
Copy link
Contributor Author

For the time being, I changed the dependencies to point to my git fork with updated rust-bitcoin v0.27 in order to check if all the test cases pass.

The added test case for bech32m is passing with cargo test.

But it looks like builds and some other test cases are still failing.

@RCasatta
Copy link
Member

RCasatta commented Jul 27, 2021

From a quick look, it seems you need to use patch in Cargo.toml for the rust-bitcoin 0.27 dep so that dependencies of dependencies are replaced as well, see https://doc.rust-lang.org/edition-guide/rust-2018/cargo-and-crates-io/replacing-dependencies-with-patch.html.

Otherwise, you may end up for something that seems the same Object but they are from different crate versions

@notmandatory
Copy link
Member

notmandatory commented Sep 14, 2021

I created a couple more PRs that also need to be merged to support this PR:

  1. Add feature "22_0" for bitcoin 22.0 rust-bitcoin/bitcoind#30
  2. Add feature "bitcoind_22_0" for bitcoin 22.0 RCasatta/electrsd#21

1. RCasatta/rust-bitcoincore-rpc#2 (optional, not really needed for this PR)

Comment on lines 888 to 930
test_client.bitcoind.client
.import_descriptors(
vec![
ImportDescriptorRequest::new(wallet_descriptor, false),
ImportDescriptorRequest::new(change_descriptor, false),
]
).unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated this section to match the newer prototype of import_descriptors in rust-bitcoincore-rpc

@notmandatory
Copy link
Member

Track via #63

@notmandatory notmandatory mentioned this pull request Nov 2, 2021
8 tasks
@notmandatory
Copy link
Member

This needs to be reworked a little to use raw rpc calls to create our test tr() descriptor wallet as @RCasatta suggested. Once rust-bitcoin/rust-bitcoincore-rpc#174 is merged we can rework the tests to use the lib instead.

Moving to '0.15.0' feature freeze so we have more time to work on it.

@notmandatory
Copy link
Member

notmandatory commented Nov 11, 2021

I got the blockchain_tests to work without the core-rpc or bitcoind patches 🎉. Once I have my code cleaned up I'll add it as a commit to this PR. Moving this back into code freeze for 0.14.0.

sandipndev and others added 3 commits November 11, 2021 08:20
Now works with latest released versions of rust-bitcoincore-rpc and
bitcoind. Once these crates are updated to support creating descriptor
wallets and add importdescriptors and bech32m support this test will
need to be updated.
@notmandatory notmandatory marked this pull request as ready for review November 11, 2021 21:59
Copy link
Member

@notmandatory notmandatory left a comment

Choose a reason for hiding this comment

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

ACK afa1ab4

@notmandatory
Copy link
Member

FYI, here is an explanation from stackexchange that we followed for creating a P2TR wallet in bitcoind and then creating a deposit address for it: https://bitcoin.stackexchange.com/questions/108006/how-to-make-a-taproot-transaction-with-bitcoin-cli

@sandipndev
Copy link
Contributor Author

Awesome, thanks for fixing this PR. Calling the RPC commands, for now, seems to work perfectly and tests run - which is fantastic and ACK afa1ab4 🎉

Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

tACK afa1ab4.

below are few minor question and suggestions.

@notmandatory notmandatory merged commit afa1ab4 into bitcoindevkit:master Nov 17, 2021
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.

4 participants