Skip to content

Commit feafaac

Browse files
committed
Merge #1023: Update rust bitcoin
1da3b30 ci: Pin rustls to keep the MSRV (Daniela Brozzoni) 792b39f Explicitly deny multipath keys (Daniela Brozzoni) b73385d Update wallet_electrum to rust-bitcoin 0.30.0 (Daniela Brozzoni) 3dac3f9 Update example_electrum to rust-bitcoin 0.30.0 (Daniela Brozzoni) 2949bdc Update example_cli to rust-bitcoin 0.30.0 (Daniela Brozzoni) 468d2a0 Update tmp_plan to rust-bitcoin 0.30.0 (Daniela Brozzoni) b8ac16d Update coin_select to rust-bitcoin 0.30.0 (Daniela Brozzoni) 6c29e53 Update wallet_esplora and wallet_esplora_async to... ...rust-bitcoin 0.30.0 (Daniela Brozzoni) 6eb0795 Update crates/esplora to rust-bitcoin 0.30.0 (Daniela Brozzoni) 91b0f0b Update crates/electrum to bitcoin 0.30.0 (Daniela Brozzoni) f4e3ba3 Update bdk to bitcoin 0.30.0 (Daniela Brozzoni) 853d361 Update bdk_chain to bitcoin 0.30.0 (Daniela Brozzoni) Pull request description: ### Description Updates to rust-bitcoin 0.30.0 and miniscript 0.10.0 Not covered in this PR: - #1036. Although the latter is deprecated, I think it's better if I update it in a separate PR, as this one is pretty big already. - #1037 - #1038 Heads up, I'm explicitly denying multipath descriptors until we have better tests for them. See the commit message of 23fba7a ### Changelog notice - Update to `rust-bitcoin` 0.30.0 and `miniscript` 10.0.0 ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing ACKs for top commit: evanlinjin: ACK 1da3b30 Tree-SHA512: ff1457ed711f9f8cdb446ea10aaf124632f539c02406da94317d8dc38013b321217d3bdcb2df4bd72b2ed92116b52e9c6b98ee91d4d508a579c67449a7caa549
2 parents d73669e + 1da3b30 commit feafaac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+800
-552
lines changed

.github/workflows/cont_integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
uses: Swatinem/[email protected]
3030
- name: Pin dependencies for MSRV
3131
if: matrix.rust.version == '1.57.0'
32-
run: cargo update -p log --precise "0.4.18" && cargo update -p tempfile --precise "3.6.0"
32+
run: cargo update -p log --precise "0.4.18" && cargo update -p tempfile --precise "3.6.0" && cargo update -p rustls:0.21.6 --precise "0.21.1"
3333
- name: Build
3434
run: cargo build ${{ matrix.features }}
3535
- name: Test

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ To build with the MSRV you will need to pin dependencies as follows:
6161
```
6262
# log 0.4.19 has MSRV 1.60.0+
6363
cargo update -p log --precise "0.4.18"
64-
# tempfile 3.7.0 has MSRV 1.63.0
64+
# tempfile 3.7.0 has MSRV 1.63.0+
6565
cargo update -p tempfile --precise "3.6.0"
66+
# rustls 0.21.2 has MSRV 1.60.0+
67+
cargo update -p rustls:0.21.6 --precise "0.21.1"
6668
```

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: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub enum Error {
2222
InvalidDescriptorChecksum,
2323
/// The descriptor contains hardened derivation steps on public extended keys
2424
HardenedDerivationXpub,
25+
/// The descriptor contains multipath keys
26+
MultiPath,
2527

2628
/// Error thrown while working with [`keys`](crate::keys)
2729
Key(crate::keys::KeyError),
@@ -32,11 +34,11 @@ pub enum Error {
3234
InvalidDescriptorCharacter(u8),
3335

3436
/// BIP32 error
35-
Bip32(bitcoin::util::bip32::Error),
37+
Bip32(bitcoin::bip32::Error),
3638
/// Error during base58 decoding
37-
Base58(bitcoin::util::base58::Error),
39+
Base58(bitcoin::base58::Error),
3840
/// Key-related error
39-
Pk(bitcoin::util::key::Error),
41+
Pk(bitcoin::key::Error),
4042
/// Miniscript error
4143
Miniscript(miniscript::Error),
4244
/// Hex decoding error
@@ -64,6 +66,10 @@ impl fmt::Display for Error {
6466
f,
6567
"The descriptor contains hardened derivation steps on public extended keys"
6668
),
69+
Self::MultiPath => write!(
70+
f,
71+
"The descriptor contains multipath keys, which are not supported yet"
72+
),
6773
Self::Key(err) => write!(f, "Key error: {}", err),
6874
Self::Policy(err) => write!(f, "Policy error: {}", err),
6975
Self::InvalidDescriptorCharacter(char) => {
@@ -81,9 +87,9 @@ impl fmt::Display for Error {
8187
#[cfg(feature = "std")]
8288
impl std::error::Error for Error {}
8389

84-
impl_error!(bitcoin::util::bip32::Error, Bip32);
85-
impl_error!(bitcoin::util::base58::Error, Base58);
86-
impl_error!(bitcoin::util::key::Error, Pk);
90+
impl_error!(bitcoin::bip32::Error, Bip32);
91+
impl_error!(bitcoin::base58::Error, Base58);
92+
impl_error!(bitcoin::key::Error, Pk);
8793
impl_error!(miniscript::Error, Miniscript);
8894
impl_error!(bitcoin::hashes::hex::Error, Hex);
8995
impl_error!(crate::descriptor::policy::PolicyError, Policy);

0 commit comments

Comments
 (0)