diff --git a/crates/chain/Cargo.toml b/crates/chain/Cargo.toml index dd7d2bb36..38eeb8708 100644 --- a/crates/chain/Cargo.toml +++ b/crates/chain/Cargo.toml @@ -19,7 +19,7 @@ workspace = true bitcoin = { version = "0.32.0", default-features = false } bdk_core = { path = "../core", version = "0.6.2", default-features = false } serde = { version = "1", optional = true, features = ["derive", "rc"] } -miniscript = { version = "12.3.1", optional = true, default-features = false } +miniscript = { git = "https://github.com/rust-bitcoin/rust-miniscript.git", branch = "release-12.x", optional = true, default-features = false } # Feature dependencies rusqlite = { version = "0.31.0", features = ["bundled"], optional = true } diff --git a/crates/esplora/Cargo.toml b/crates/esplora/Cargo.toml index e4c553f77..6a7b97555 100644 --- a/crates/esplora/Cargo.toml +++ b/crates/esplora/Cargo.toml @@ -19,6 +19,7 @@ bdk_core = { path = "../core", version = "0.6.1", default-features = false } esplora-client = { version = "0.12.1", default-features = false } async-trait = { version = "0.1.66", optional = true } futures = { version = "0.3.26", optional = true } +serde_json = { version = "1.0", features = ["alloc"] } [dev-dependencies] esplora-client = { version = "0.12.0" } diff --git a/examples/example_cli/Cargo.toml b/examples/example_cli/Cargo.toml index 0a467db84..7c9629288 100644 --- a/examples/example_cli/Cargo.toml +++ b/examples/example_cli/Cargo.toml @@ -15,4 +15,4 @@ anyhow = "1" clap = { version = "4.5.17", features = ["derive", "env"] } rand = "0.8" serde = { version = "1", features = ["derive"] } -serde_json = "1.0" +serde_json = { version = "1.0", features = ["alloc"] } diff --git a/examples/example_cli/src/lib.rs b/examples/example_cli/src/lib.rs index 07811c45a..d24932ddc 100644 --- a/examples/example_cli/src/lib.rs +++ b/examples/example_cli/src/lib.rs @@ -1,7 +1,7 @@ use bdk_chain::keychain_txout::DEFAULT_LOOKAHEAD; +use bdk_chain::miniscript::descriptor::KeyMapWrapper; use serde_json::json; use std::cmp; -use std::collections::HashMap; use std::env; use std::fmt; use std::str::FromStr; @@ -11,11 +11,10 @@ use anyhow::bail; use anyhow::Context; use bdk_chain::bitcoin::{ absolute, address::NetworkUnchecked, bip32, consensus, constants, hex::DisplayHex, relative, - secp256k1::Secp256k1, transaction, Address, Amount, Network, NetworkKind, PrivateKey, Psbt, - PublicKey, Sequence, Transaction, TxIn, TxOut, + secp256k1::Secp256k1, transaction, Address, Amount, Network, NetworkKind, Psbt, Sequence, + Transaction, TxIn, TxOut, }; use bdk_chain::miniscript::{ - descriptor::{DescriptorSecretKey, SinglePubKey}, plan::{Assets, Plan}, psbt::PsbtExt, Descriptor, DescriptorPublicKey, ForEachKey, @@ -696,27 +695,15 @@ pub fn handle_commands( let secp = Secp256k1::new(); let (_, keymap) = Descriptor::parse_descriptor(&secp, &desc_str)?; + if keymap.is_empty() { bail!("unable to sign") } - // note: we're only looking at the first entry in the keymap - // the idea is to find something that impls `GetKey` - let sign_res = match keymap.iter().next().expect("not empty") { - (DescriptorPublicKey::Single(single_pub), DescriptorSecretKey::Single(prv)) => { - let pk = match single_pub.key { - SinglePubKey::FullKey(pk) => pk, - SinglePubKey::XOnly(_) => unimplemented!("single xonly pubkey"), - }; - let keys: HashMap = [(pk, prv.key)].into(); - psbt.sign(&keys, &secp) - } - (_, DescriptorSecretKey::XPrv(k)) => psbt.sign(&k.xkey, &secp), - _ => unimplemented!("multi xkey signer"), - }; - - let _ = - sign_res.map_err(|errors| anyhow::anyhow!("failed to sign PSBT {errors:?}"))?; + let keymap_wrapper: KeyMapWrapper = keymap.into(); + let _sign_res = psbt + .sign(&keymap_wrapper, &secp) + .map_err(|errors| anyhow::anyhow!("failed to sign PSBT {errors:?}"))?; let mut obj = serde_json::Map::new(); obj.insert("psbt".to_string(), json!(psbt.to_string()));