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

Adding importdescriptors for Descriptor-Based Wallets #199

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sandipndev
Copy link

This PR adds the following features:

  1. importdescriptors RPC command
  2. Bech32m address support
  3. Updated createwallet to add in descriptors parameter
  4. Updates version of rust-bitcoin to 0.27
  5. The integration_test/run.sh script was updated to support the latest versioning of Bitcoin Core.

I figure this would be very useful for anyone creating descriptor based wallets, especially with Taproot coming in!

@xraid
Copy link

xraid commented Mar 15, 2022

Running bitcoind (master) and a BDK descriptor-based wallet

wallet.sync gives me Rpc(JsonRpc(Rpc(RpcError { code: -4, message: "This type of wallet does not support this command", data: None })))'

that seems come from /bitcoin/src/wallet/rpc/util.cpp line 109

and have mention in bitcoin 23946
"This occurs when your wallet is a descriptor wallet. It is expected behavior.
For builds of the master branch (and the future 23.0 release), newly created wallets will default to being descriptor wallets."

Running bitcoind v22.0 and a BDK descriptor-based wallet works but will break at v23.0 onward it seems

so maybe this PR after review can make us progress forward ...

@RCasatta
Copy link
Collaborator

so maybe this PR after review can make us progress forward ...

importdescriptor was avoided in BDK RPCBlockchain because at that time the descriptor supported by core was a subset of the descriptors supported by BDK.

We should verify if it's not the case anymore with 23.0 and use importdescriptor or otherwise BDK should specify the non-default option during wallet creation (non-descriptor wallet)

Sorry for the BDK off-topic, this PR should be worked on anyway

@danielabrozzoni
Copy link

Concept ACK - the code looks good, but there are conflicts with master. I'll review once is rebased :)

@@ -5,6 +5,6 @@ authors = ["Steven Roose <steven@stevenroose.org>"]

[dependencies]
bitcoincore-rpc = { path = "../client" }
bitcoin = { version = "0.26", features = [ "use-serde", "rand" ] }
bitcoin = { version = "0.27", features = [ "use-serde", "rand" ] }
Copy link

Choose a reason for hiding this comment

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

Currently master is at 0.28.0, but I believe we should drop the patch specification as before so users of the library can resolve the latest patch.

So just a rebase is in order and then we can drop the patch version :)

Suggested change
bitcoin = { version = "0.27", features = [ "use-serde", "rand" ] }
bitcoin = { version = "0.28", features = [ "use-serde", "rand" ] }

@@ -21,4 +21,4 @@ path = "src/lib.rs"
serde = { version = "1", features = [ "derive" ] }
serde_json = "1"

bitcoin = { version = "0.26", features = [ "use-serde" ] }
bitcoin = { version = "0.27", features = [ "use-serde" ] }
Copy link

Choose a reason for hiding this comment

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

Suggested change
bitcoin = { version = "0.27", features = [ "use-serde" ] }
bitcoin = { version = "0.28", features = [ "use-serde" ] }

@dunxen
Copy link

dunxen commented Jun 5, 2022

We'll also need to make the following an Option<usize> for descriptor wallet compatibility:

pub keypool_oldest: usize,

@@ -914,20 +919,23 @@ fn test_create_wallet(cl: &Client) {
blank: None,
passphrase: None,
avoid_reuse: None,
descriptors: None,

Choose a reason for hiding this comment

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

Bitcoin Core 23 now creates descriptor wallets by default. So in order for these tests to pass, this needs to be descriptors: Some(false) for each of these WalletParams.

@andrewtoth
Copy link

This should be an Option<usize> as well if we're updating getwalletinfo:

pub keypool_size_hd_internal: usize,


test_get_network_info(&cl);
unsafe { VERSION = cl.version().unwrap() };
println!("Version: {}", version());

cl.create_wallet("testwallet", None, None, None, None).unwrap();
cl.create_wallet("testwallet", None, None, None, None, None).unwrap();

Choose a reason for hiding this comment

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

Needs to be Some(false) for Bitcoin Core 23 compatibility.

handle_defaults(&mut args, &[false.into(), false.into(), into_json("")?, false.into()]),
handle_defaults(
&mut args,
&[false.into(), false.into(), into_json("")?, false.into(), false.into()],

Choose a reason for hiding this comment

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

Last default option should be true.into() to be compatible with Bitcoin Core 23.

@craigraw
Copy link

craigraw commented Nov 8, 2022

I don't mean to seem impatient, but is there any hope of this getting merged? I find it amazing that the Rust Bitcoin community has no need to use descriptor wallets in Bitcoin Core, which have now been available for over 2 years and are required for Taproot.

@dunxen
Copy link

dunxen commented Nov 8, 2022

I don't mean to seem impatient, but is there any hope of this getting merged?

Are you going the route without BWT now, which also isn't getting much attention currently. Adding Taproot support there wouldn't do much other than just pass descriptors to Core directly (at least that's how I'd do it if this were merged). At least then I don't think Sparrow would need this if you're just going to do descriptor RPC directly. But agree that someone would definitely need to use descriptor wallets with this crate.

@craigraw
Copy link

craigraw commented Nov 8, 2022

Are you going the route without BWT now, which also isn't getting much attention currently.

Yes, I'm considering giving up with BWT. It doesn't seem like Rust Bitcoin has sufficient community to keep up. I'd prefer a Java library for Sparrow in any case.

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

8 participants