Skip to content

Commit f4e3ba3

Browse files
Update bdk to bitcoin 0.30.0
1 parent 853d361 commit f4e3ba3

File tree

23 files changed

+562
-380
lines changed

23 files changed

+562
-380
lines changed

crates/bdk/Cargo.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ rust-version = "1.57"
1515
[dependencies]
1616
log = "0.4"
1717
rand = "^0.8"
18-
miniscript = { version = "9", features = ["serde"], default-features = false }
19-
bitcoin = { version = "0.29", features = ["serde", "base64", "rand"], default-features = false }
18+
miniscript = { version = "10.0.0", features = ["serde"], default-features = false }
19+
bitcoin = { version = "0.30.0", features = ["serde", "base64", "rand-std"], default-features = false }
2020
serde = { version = "^1.0", features = ["derive"] }
2121
serde_json = { version = "^1.0" }
2222
bdk_chain = { path = "../chain", version = "0.5.0", features = ["miniscript", "serde"], default-features = false }
2323

2424
# Optional dependencies
25-
hwi = { version = "0.5", optional = true, features = [ "use-miniscript"] }
25+
hwi = { version = "0.7.0", optional = true, features = [ "miniscript"] }
2626
bip39 = { version = "1.0.1", optional = true }
2727

2828
[target.'cfg(target_arch = "wasm32")'.dependencies]
@@ -46,8 +46,6 @@ dev-getrandom-wasm = ["getrandom/js"]
4646
[dev-dependencies]
4747
lazy_static = "1.4"
4848
env_logger = "0.7"
49-
# Move back to importing from rust-bitcoin once https://github.com/rust-bitcoin/rust-bitcoin/pull/1342 is released
50-
base64 = "^0.13"
5149
assert_matches = "1.5.0"
5250

5351
[package.metadata.docs.rs]

crates/bdk/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ fn main() {
137137
<!-- use bdk::electrum_client::Client; -->
138138
<!-- use bdk::wallet::AddressIndex::New; -->
139139

140-
<!-- use base64; -->
140+
<!-- use bitcoin::base64; -->
141141
<!-- use bdk::bitcoin::consensus::serialize; -->
142142
<!-- use bdk::bitcoin::Network; -->
143143

@@ -174,7 +174,7 @@ fn main() {
174174
<!-- ```rust,no_run -->
175175
<!-- use bdk::{Wallet, SignOptions}; -->
176176

177-
<!-- use base64; -->
177+
<!-- use bitcoin::base64; -->
178178
<!-- use bdk::bitcoin::consensus::deserialize; -->
179179
<!-- use bdk::bitcoin::Network; -->
180180

crates/bdk/examples/mnemonic_to_descriptors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// You may not use this file except in accordance with one or both of these
77
// licenses.
88

9+
use bdk::bitcoin::bip32::DerivationPath;
910
use bdk::bitcoin::secp256k1::Secp256k1;
10-
use bdk::bitcoin::util::bip32::DerivationPath;
1111
use bdk::bitcoin::Network;
1212
use bdk::descriptor;
1313
use bdk::descriptor::IntoWalletDescriptor;

crates/bdk/src/descriptor/dsl.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -516,13 +516,14 @@ macro_rules! descriptor {
516516
use $crate::miniscript::descriptor::{Descriptor, DescriptorPublicKey};
517517

518518
$crate::impl_top_level_pk!(Pkh, $crate::miniscript::Legacy, $key)
519+
.and_then(|(a, b, c)| Ok((a.map_err(|e| miniscript::Error::from(e))?, b, c)))
519520
.map(|(a, b, c)| (Descriptor::<DescriptorPublicKey>::Pkh(a), b, c))
520521
});
521522
( wpkh ( $key:expr ) ) => ({
522523
use $crate::miniscript::descriptor::{Descriptor, DescriptorPublicKey};
523524

524525
$crate::impl_top_level_pk!(Wpkh, $crate::miniscript::Segwitv0, $key)
525-
.and_then(|(a, b, c)| Ok((a?, b, c)))
526+
.and_then(|(a, b, c)| Ok((a.map_err(|e| miniscript::Error::from(e))?, b, c)))
526527
.map(|(a, b, c)| (Descriptor::<DescriptorPublicKey>::Wpkh(a), b, c))
527528
});
528529
( sh ( wpkh ( $key:expr ) ) ) => ({
@@ -532,7 +533,7 @@ macro_rules! descriptor {
532533
use $crate::miniscript::descriptor::{Descriptor, DescriptorPublicKey, Sh};
533534

534535
$crate::impl_top_level_pk!(Wpkh, $crate::miniscript::Segwitv0, $key)
535-
.and_then(|(a, b, c)| Ok((a?, b, c)))
536+
.and_then(|(a, b, c)| Ok((a.map_err(|e| miniscript::Error::from(e))?, b, c)))
536537
.and_then(|(a, b, c)| Ok((Descriptor::<DescriptorPublicKey>::Sh(Sh::new_wpkh(a.into_inner())?), b, c)))
537538
});
538539
( sh ( $( $minisc:tt )* ) ) => ({
@@ -702,7 +703,7 @@ macro_rules! fragment {
702703
$crate::keys::make_pkh($key, &secp)
703704
});
704705
( after ( $value:expr ) ) => ({
705-
$crate::impl_leaf_opcode_value!(After, $crate::bitcoin::PackedLockTime($value)) // TODO!! https://github.com/rust-bitcoin/rust-bitcoin/issues/1302
706+
$crate::impl_leaf_opcode_value!(After, $crate::miniscript::AbsLockTime::from_consensus($value))
706707
});
707708
( older ( $value:expr ) ) => ({
708709
$crate::impl_leaf_opcode_value!(Older, $crate::bitcoin::Sequence($value)) // TODO!!
@@ -796,7 +797,6 @@ macro_rules! fragment {
796797
#[cfg(test)]
797798
mod test {
798799
use alloc::string::ToString;
799-
use bitcoin::hashes::hex::ToHex;
800800
use bitcoin::secp256k1::Secp256k1;
801801
use miniscript::descriptor::{DescriptorPublicKey, KeyMap};
802802
use miniscript::{Descriptor, Legacy, Segwitv0};
@@ -805,8 +805,8 @@ mod test {
805805

806806
use crate::descriptor::{DescriptorError, DescriptorMeta};
807807
use crate::keys::{DescriptorKey, IntoDescriptorKey, ValidNetworks};
808+
use bitcoin::bip32;
808809
use bitcoin::network::constants::Network::{Bitcoin, Regtest, Signet, Testnet};
809-
use bitcoin::util::bip32;
810810
use bitcoin::PrivateKey;
811811

812812
// test the descriptor!() macro
@@ -822,18 +822,15 @@ mod test {
822822
assert_eq!(desc.is_witness(), is_witness);
823823
assert_eq!(!desc.has_wildcard(), is_fixed);
824824
for i in 0..expected.len() {
825-
let index = i as u32;
826-
let child_desc = if !desc.has_wildcard() {
827-
desc.at_derivation_index(0)
828-
} else {
829-
desc.at_derivation_index(index)
830-
};
825+
let child_desc = desc
826+
.at_derivation_index(i as u32)
827+
.expect("i is not hardened");
831828
let address = child_desc.address(Regtest);
832829
if let Ok(address) = address {
833830
assert_eq!(address.to_string(), *expected.get(i).unwrap());
834831
} else {
835832
let script = child_desc.script_pubkey();
836-
assert_eq!(script.to_hex().as_str(), *expected.get(i).unwrap());
833+
assert_eq!(script.to_hex_string(), *expected.get(i).unwrap());
837834
}
838835
}
839836
}
@@ -1178,9 +1175,7 @@ mod test {
11781175
}
11791176

11801177
#[test]
1181-
#[should_panic(
1182-
expected = "Miniscript(ContextError(CompressedOnly(\"04b4632d08485ff1df2db55b9dafd23347d1c47a457072a1e87be26896549a87378ec38ff91d43e8c2092ebda601780485263da089465619e0358a5c1be7ac91f4\")))"
1183-
)]
1178+
#[should_panic(expected = "Miniscript(ContextError(UncompressedKeysNotAllowed))")]
11841179
fn test_dsl_miniscript_checks() {
11851180
let mut uncompressed_pk =
11861181
PrivateKey::from_wif("L5EZftvrYaSudiozVRzTqLcHLNDoVn7H5HSfM9BAN6tMJX8oTWz6").unwrap();

crates/bdk/src/descriptor/error.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ pub enum Error {
3232
InvalidDescriptorCharacter(u8),
3333

3434
/// BIP32 error
35-
Bip32(bitcoin::util::bip32::Error),
35+
Bip32(bitcoin::bip32::Error),
3636
/// Error during base58 decoding
37-
Base58(bitcoin::util::base58::Error),
37+
Base58(bitcoin::base58::Error),
3838
/// Key-related error
39-
Pk(bitcoin::util::key::Error),
39+
Pk(bitcoin::key::Error),
4040
/// Miniscript error
4141
Miniscript(miniscript::Error),
4242
/// Hex decoding error
@@ -81,9 +81,9 @@ impl fmt::Display for Error {
8181
#[cfg(feature = "std")]
8282
impl std::error::Error for Error {}
8383

84-
impl_error!(bitcoin::util::bip32::Error, Bip32);
85-
impl_error!(bitcoin::util::base58::Error, Base58);
86-
impl_error!(bitcoin::util::key::Error, Pk);
84+
impl_error!(bitcoin::bip32::Error, Bip32);
85+
impl_error!(bitcoin::base58::Error, Base58);
86+
impl_error!(bitcoin::key::Error, Pk);
8787
impl_error!(miniscript::Error, Miniscript);
8888
impl_error!(bitcoin::hashes::hex::Error, Hex);
8989
impl_error!(crate::descriptor::policy::PolicyError, Policy);

0 commit comments

Comments
 (0)