Skip to content

Commit

Permalink
Upgrade bitcoin/miniscript dependencies
Browse files Browse the repository at this point in the history
- Upgrade bitcoin to to v0.31.0-rc1

`rust-miniscript` does not require any changes to upgrade to use bitcoin
v0.31.0-rc1.

Upgrade highlights a weakness in the `rust-miniscript` API,
`TapTree::combine` is useful to us, it could be public.

see: rust-bitcoin/rust-miniscript#617
  • Loading branch information
tcharding committed Oct 13, 2023
1 parent 3569acc commit e67c6e8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ members = [

[workspace.package]
authors = ["Bitcoin Dev Kit Developers"]

[patch.crates-io.miniscript]
path = "/home/tobin/build/github.com/tcharding/rust-miniscript/10-13-upgrade-bitcoin"

[patch.crates-io.bitcoin]
path = "/home/tobin/build/github.com/tcharding/rust-bitcoin/10-10-release-0.31.0-rc1/bitcoin"
3 changes: 1 addition & 2 deletions crates/bdk/src/descriptor/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,13 @@ macro_rules! impl_sortedmulti {
#[macro_export]
macro_rules! parse_tap_tree {
( @merge $tree_a:expr, $tree_b:expr) => {{
use $crate::alloc::sync::Arc;
use $crate::miniscript::descriptor::TapTree;

$tree_a
.and_then(|tree_a| Ok((tree_a, $tree_b?)))
.and_then(|((a_tree, mut a_keymap, a_networks), (b_tree, b_keymap, b_networks))| {
a_keymap.extend(b_keymap.into_iter());
Ok((TapTree::Tree(Arc::new(a_tree), Arc::new(b_tree)), a_keymap, $crate::keys::merge_networks(&a_networks, &b_networks)))
Ok((TapTree::combine(a_tree, b_tree), a_keymap, $crate::keys::merge_networks(&a_networks, &b_networks)))
})

}};
Expand Down
2 changes: 1 addition & 1 deletion crates/bdk/src/descriptor/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ impl ExtractPolicy for Descriptor<DescriptorPublicKey> {
let key_spend_sig =
miniscript::Tap::make_signature(tr.internal_key(), signers, build_sat, secp);

if tr.taptree().is_none() {
if tr.tap_tree().is_none() {
Ok(Some(key_spend_sig))
} else {
let mut items = vec![key_spend_sig];
Expand Down
2 changes: 1 addition & 1 deletion crates/bdk/src/keys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<Ctx: ScriptContext> DescriptorKey<Ctx> {
Ok((public, KeyMap::default(), valid_networks))
}
DescriptorKey::Secret(secret, valid_networks, _) => {
let mut key_map = KeyMap::with_capacity(1);
let mut key_map = KeyMap::new();

let public = secret
.to_public(secp)
Expand Down
6 changes: 3 additions & 3 deletions example-crates/example_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Context;
use bdk_coin_select::{coin_select_bnb, CoinSelector, CoinSelectorOpt, WeightedValue};
use bdk_file_store::Store;
use serde::{de::DeserializeOwned, Serialize};
use std::{cmp::Reverse, collections::HashMap, path::PathBuf, sync::Mutex, time::Duration};
use std::{cmp::Reverse, collections::BTreeMap, path::PathBuf, sync::Mutex, time::Duration};

use bdk_chain::{
bitcoin::{
Expand Down Expand Up @@ -189,7 +189,7 @@ impl core::fmt::Display for Keychain {
pub fn create_tx<A: Anchor, O: ChainOracle>(
graph: &mut KeychainTxGraph<A>,
chain: &O,
keymap: &HashMap<DescriptorPublicKey, DescriptorSecretKey>,
keymap: &BTreeMap<DescriptorPublicKey, DescriptorSecretKey>,
cs_algorithm: CoinSelectionAlgo,
address: Address,
value: u64,
Expand Down Expand Up @@ -434,7 +434,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args, A: Anchor, O: ChainO
graph: &Mutex<KeychainTxGraph<A>>,
db: &Mutex<Database<C>>,
chain: &Mutex<O>,
keymap: &HashMap<DescriptorPublicKey, DescriptorSecretKey>,
keymap: &BTreeMap<DescriptorPublicKey, DescriptorSecretKey>,
network: Network,
broadcast: impl FnOnce(S, &Transaction) -> anyhow::Result<()>,
cmd: Commands<CS, S>,
Expand Down

0 comments on commit e67c6e8

Please sign in to comment.