-
Notifications
You must be signed in to change notification settings - Fork 277
Adding importdescriptors
for Descriptor-Based Wallets
#199
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,6 +5,6 @@ authors = ["Steven Roose <[email protected]>"] | |||||
|
||||||
[dependencies] | ||||||
bitcoincore-rpc = { path = "../client" } | ||||||
bitcoin = { version = "0.26", features = [ "use-serde", "rand" ] } | ||||||
bitcoin = { version = "0.27", features = [ "use-serde", "rand" ] } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently So just a rebase is in order and then we can drop the patch version :)
Suggested change
|
||||||
lazy_static = "1.4.0" | ||||||
log = "0.4" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ extern crate lazy_static; | |
extern crate log; | ||
|
||
use std::collections::HashMap; | ||
use std::str::FromStr; | ||
|
||
use bitcoincore_rpc::json; | ||
use bitcoincore_rpc::jsonrpc::error::Error as JsonRpcError; | ||
|
@@ -125,15 +126,13 @@ fn main() { | |
log::set_logger(&LOGGER).map(|()| log::set_max_level(log::LevelFilter::max())).unwrap(); | ||
|
||
let rpc_url = format!("{}/wallet/testwallet", get_rpc_url()); | ||
let auth = get_auth(); | ||
|
||
let cl = Client::new(&rpc_url, auth).unwrap(); | ||
let cl = Client::new(&rpc_url, get_auth()).unwrap(); | ||
|
||
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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be |
||
|
||
test_get_mining_info(&cl); | ||
test_get_blockchain_info(&cl); | ||
|
@@ -203,6 +202,11 @@ fn main() { | |
//TODO load_wallet(&self, wallet: &str) -> Result<json::LoadWalletResult> { | ||
//TODO unload_wallet(&self, wallet: Option<&str>) -> Result<()> { | ||
//TODO backup_wallet(&self, destination: Option<&str>) -> Result<()> { | ||
|
||
let rpc_url = format!("{}/wallet/testdescriptorwallet", get_rpc_url()); | ||
let desc_cl = Client::new(&rpc_url, get_auth()).unwrap(); | ||
|
||
test_descriptor_wallet(&desc_cl); | ||
test_stop(cl); | ||
} | ||
|
||
|
@@ -905,6 +909,7 @@ fn test_create_wallet(cl: &Client) { | |
blank: Option<bool>, | ||
passphrase: Option<&'a str>, | ||
avoid_reuse: Option<bool>, | ||
descriptors: Option<bool>, | ||
} | ||
|
||
let mut wallet_params = vec![ | ||
|
@@ -914,20 +919,23 @@ fn test_create_wallet(cl: &Client) { | |
blank: None, | ||
passphrase: None, | ||
avoid_reuse: None, | ||
descriptors: None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
}, | ||
WalletParams { | ||
name: wallet_names[1], | ||
disable_private_keys: Some(true), | ||
blank: None, | ||
passphrase: None, | ||
avoid_reuse: None, | ||
descriptors: None, | ||
}, | ||
WalletParams { | ||
name: wallet_names[2], | ||
disable_private_keys: None, | ||
blank: Some(true), | ||
passphrase: None, | ||
avoid_reuse: None, | ||
descriptors: None, | ||
}, | ||
]; | ||
|
||
|
@@ -938,13 +946,15 @@ fn test_create_wallet(cl: &Client) { | |
blank: None, | ||
passphrase: Some("pass"), | ||
avoid_reuse: None, | ||
descriptors: None, | ||
}); | ||
wallet_params.push(WalletParams { | ||
name: wallet_names[4], | ||
disable_private_keys: None, | ||
blank: None, | ||
passphrase: None, | ||
avoid_reuse: Some(true), | ||
descriptors: None, | ||
}); | ||
} | ||
|
||
|
@@ -956,6 +966,7 @@ fn test_create_wallet(cl: &Client) { | |
wallet_param.blank, | ||
wallet_param.passphrase, | ||
wallet_param.avoid_reuse, | ||
wallet_param.descriptors, | ||
) | ||
.unwrap(); | ||
|
||
|
@@ -1050,3 +1061,25 @@ fn test_getblocktemplate(cl: &Client) { | |
fn test_stop(cl: Client) { | ||
println!("Stopping: '{}'", cl.stop().unwrap()); | ||
} | ||
|
||
fn test_descriptor_wallet(cl: &Client) { | ||
cl.create_wallet( | ||
"testdescriptorwallet", | ||
Some(false), | ||
Some(true), | ||
Some(""), | ||
Some(false), | ||
Some(true), | ||
) | ||
.unwrap(); | ||
|
||
cl.import_descriptors( | ||
vec![ | ||
json::ImportDescriptorRequest::new("wpkh(tprv8ZgxMBicQKsPeRBCAfUGsZhyHy9dwWyPqhSJmaMnMJQWWtt8L2SkTeHaiF82CUCGtiTiHAs3cMkjdKckGKiCWeYtvMPF1jDTWYTryRMicpx/86h/1h/0h/0/*)#ymr4jlz6", false), | ||
json::ImportDescriptorRequest::new("wpkh(tprv8ZgxMBicQKsPeRBCAfUGsZhyHy9dwWyPqhSJmaMnMJQWWtt8L2SkTeHaiF82CUCGtiTiHAs3cMkjdKckGKiCWeYtvMPF1jDTWYTryRMicpx/86h/1h/0h/1/*)#40x502jz", true), | ||
] | ||
).unwrap(); | ||
|
||
let add = cl.get_new_address(None, Some(json::AddressType::Bech32)).unwrap(); | ||
assert_eq!(add, Address::from_str("bcrt1q7crcza94drr00skmu5x0n00rhmwnthde2frhwk").unwrap()); | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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" ] } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
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.