Skip to content

Commit 007c38b

Browse files
committed
bitcoin: Depend on tip of master
1 parent e4a5bff commit 007c38b

File tree

14 files changed

+170
-112
lines changed

14 files changed

+170
-112
lines changed

Cargo.toml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ edition = "2018"
1313
[features]
1414
default = ["std"]
1515
std = ["bitcoin/std", "bitcoin/secp-recovery", "bech32/std"]
16-
no-std = ["bitcoin/no-std", "bech32/alloc"]
16+
no-std = ["bech32/alloc"]
1717
compiler = []
1818
trace = []
1919

@@ -23,15 +23,15 @@ base64 = ["bitcoin/base64"]
2323

2424
[dependencies]
2525
bech32 = { version = "0.11.0", default-features = false }
26-
bitcoin = { version = "0.31.0", default-features = false }
26+
bitcoin = { version = "0.32.0", default-features = false }
2727

2828
# Do NOT use this as a feature! Use the `serde` feature instead.
2929
actual-serde = { package = "serde", version = "1.0.103", optional = true }
3030

3131
[dev-dependencies]
3232
serde_test = "1.0.147"
33-
bitcoin = { version = "0.31.0", features = ["base64"] }
34-
secp256k1 = {version = "0.28.0", features = ["rand-std"]}
33+
bitcoin = { version = "0.32.0", features = ["base64"] }
34+
secp256k1 = {version = "0.29.0", features = ["rand-std"]}
3535

3636
[[example]]
3737
name = "htlc"
@@ -68,3 +68,30 @@ required-features = ["std", "base64", "compiler"]
6868
[workspace]
6969
members = ["bitcoind-tests", "fuzz"]
7070
exclude = ["embedded"]
71+
72+
[patch.crates-io.secp256k1]
73+
path = "/home/tobin/build/github.com/tcharding/rust-secp256k1/test-bitcoin"
74+
75+
[patch.crates-io.bitcoind]
76+
path = "/home/tobin/build/github.com/tcharding/bitcoind/test-bitcoin"
77+
78+
[patch.crates-io.bitcoincore-rpc]
79+
path = "/home/tobin/build/github.com/tcharding/rust-bitcoincore-rpc/test-bitcoin/client"
80+
81+
[patch.crates-io.base58ck]
82+
path = "/home/tobin/build/github.com/tcharding/rust-bitcoin/release/base58"
83+
84+
[patch.crates-io.bitcoin]
85+
path = "/home/tobin/build/github.com/tcharding/rust-bitcoin/release/bitcoin"
86+
87+
[patch.crates-io.bitcoin_hashes]
88+
path = "/home/tobin/build/github.com/tcharding/rust-bitcoin/release/hashes"
89+
90+
[patch.crates-io.bitcoin-internals]
91+
path = "/home/tobin/build/github.com/tcharding/rust-bitcoin/release/internals"
92+
93+
[patch.crates-io.bitcoin-io]
94+
path = "/home/tobin/build/github.com/tcharding/rust-bitcoin/release/io"
95+
96+
[patch.crates-io.bitcoin-units]
97+
path = "/home/tobin/build/github.com/tcharding/rust-bitcoin/release/units"

bitcoind-tests/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ publish = false
99

1010
[dependencies]
1111
miniscript = {path = "../"}
12-
bitcoind = { version = "0.34.0" }
12+
bitcoind = { version = "0.35.0" }
1313
actual-rand = { package = "rand", version = "0.8.4"}
14-
secp256k1 = {version = "0.28.0", features = ["rand-std"]}
14+
secp256k1 = {version = "0.29.0", features = ["rand-std"]}

examples/sign_multisig.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ fn list_of_three_arbitrary_public_keys() -> Vec<bitcoin::PublicKey> {
118118
// a valid signature for this transaction; Miniscript does not verify the validity.
119119
fn random_signature_from_the_blockchain() -> ecdsa::Signature {
120120
ecdsa::Signature {
121-
sig: secp256k1::ecdsa::Signature::from_str(
121+
signature: secp256k1::ecdsa::Signature::from_str(
122122
"3045\
123123
0221\
124124
00f7c3648c390d87578cd79c8016940aa8e3511c4104cb78daa8fb8e429375efc1\
125125
0220\
126126
531d75c136272f127a5dc14acc0722301cbddc222262934151f140da345af177",
127127
)
128128
.unwrap(),
129-
hash_ty: bitcoin::sighash::EcdsaSighashType::All,
129+
sighash_type: bitcoin::sighash::EcdsaSighashType::All,
130130
}
131131
}

examples/verify_tx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ fn main() {
8787

8888
let iter = interpreter.iter_custom(Box::new(|key_sig: &KeySigPair| {
8989
let (pk, ecdsa_sig) = key_sig.as_ecdsa().expect("Ecdsa Sig");
90-
ecdsa_sig.hash_ty == bitcoin::sighash::EcdsaSighashType::All
90+
ecdsa_sig.sighash_type == bitcoin::sighash::EcdsaSighashType::All
9191
&& secp
92-
.verify_ecdsa(&message, &ecdsa_sig.sig, &pk.inner)
92+
.verify_ecdsa(&message, &ecdsa_sig.signature, &pk.inner)
9393
.is_ok()
9494
}));
9595

src/descriptor/key.rs

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use core::str::FromStr;
77
use std::error;
88

99
use bitcoin::bip32::{self, XKeyIdentifier};
10-
use bitcoin::hashes::hex::FromHex;
1110
use bitcoin::hashes::{hash160, ripemd160, sha256, Hash, HashEngine};
1211
use bitcoin::key::XOnlyPublicKey;
1312
use bitcoin::secp256k1::{Secp256k1, Signing, Verification};
@@ -906,21 +905,21 @@ impl<K: InnerXKey> DescriptorXKey<K> {
906905
/// assert_eq!(
907906
/// xpub.matches(&(
908907
/// bip32::Fingerprint::from_str("d34db33f").or(Err(()))?,
909-
/// bip32::DerivationPath::from_str("m/44'/0'/0'/1/42").or(Err(()))?
908+
/// bip32::DerivationPath::from_str("44'/0'/0'/1/42").or(Err(()))?
910909
/// ), &ctx),
911-
/// Some(bip32::DerivationPath::from_str("m/44'/0'/0'/1").or(Err(()))?)
910+
/// Some(bip32::DerivationPath::from_str("44'/0'/0'/1").or(Err(()))?)
912911
/// );
913912
/// assert_eq!(
914913
/// xpub.matches(&(
915914
/// bip32::Fingerprint::from_str("ffffffff").or(Err(()))?,
916-
/// bip32::DerivationPath::from_str("m/44'/0'/0'/1/42").or(Err(()))?
915+
/// bip32::DerivationPath::from_str("44'/0'/0'/1/42").or(Err(()))?
917916
/// ), &ctx),
918917
/// None
919918
/// );
920919
/// assert_eq!(
921920
/// xpub.matches(&(
922921
/// bip32::Fingerprint::from_str("d34db33f").or(Err(()))?,
923-
/// bip32::DerivationPath::from_str("m/44'/0'/0'/100/0").or(Err(()))?
922+
/// bip32::DerivationPath::from_str("44'/0'/0'/100/0").or(Err(()))?
924923
/// ), &ctx),
925924
/// None
926925
/// );
@@ -1234,17 +1233,17 @@ mod test {
12341233
fn test_wildcard() {
12351234
let public_key = DescriptorPublicKey::from_str("[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/2").unwrap();
12361235
assert_eq!(public_key.master_fingerprint().to_string(), "abcdef00");
1237-
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "m/0'/1'/2");
1236+
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "0'/1'/2");
12381237
assert!(!public_key.has_wildcard());
12391238

12401239
let public_key = DescriptorPublicKey::from_str("[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/*").unwrap();
12411240
assert_eq!(public_key.master_fingerprint().to_string(), "abcdef00");
1242-
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "m/0'/1'");
1241+
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "0'/1'");
12431242
assert!(public_key.has_wildcard());
12441243

12451244
let public_key = DescriptorPublicKey::from_str("[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/*h").unwrap();
12461245
assert_eq!(public_key.master_fingerprint().to_string(), "abcdef00");
1247-
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "m/0'/1'");
1246+
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "0'/1'");
12481247
assert!(public_key.has_wildcard());
12491248
}
12501249

@@ -1256,32 +1255,32 @@ mod test {
12561255
let public_key = secret_key.to_public(&secp).unwrap();
12571256
assert_eq!(public_key.to_string(), "[2cbe2a6d/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/2");
12581257
assert_eq!(public_key.master_fingerprint().to_string(), "2cbe2a6d");
1259-
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "m/0'/1'/2");
1258+
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "0'/1'/2");
12601259
assert!(!public_key.has_wildcard());
12611260

12621261
let secret_key = DescriptorSecretKey::from_str("tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0'/1'/2'").unwrap();
12631262
let public_key = secret_key.to_public(&secp).unwrap();
12641263
assert_eq!(public_key.to_string(), "[2cbe2a6d/0'/1'/2']tpubDDPuH46rv4dbFtmF6FrEtJEy1CvLZonyBoVxF6xsesHdYDdTBrq2mHhm8AbsPh39sUwL2nZyxd6vo4uWNTU9v4t893CwxjqPnwMoUACLvMV");
12651264
assert_eq!(public_key.master_fingerprint().to_string(), "2cbe2a6d");
1266-
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "m/0'/1'/2'");
1265+
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "0'/1'/2'");
12671266

12681267
let secret_key = DescriptorSecretKey::from_str("tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0/1/2").unwrap();
12691268
let public_key = secret_key.to_public(&secp).unwrap();
12701269
assert_eq!(public_key.to_string(), "tpubD6NzVbkrYhZ4WQdzxL7NmJN7b85ePo4p6RSj9QQHF7te2RR9iUeVSGgnGkoUsB9LBRosgvNbjRv9bcsJgzgBd7QKuxDm23ZewkTRzNSLEDr/0/1/2");
12711270
assert_eq!(public_key.master_fingerprint().to_string(), "2cbe2a6d");
1272-
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "m/0/1/2");
1271+
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "0/1/2");
12731272

12741273
let secret_key = DescriptorSecretKey::from_str("[aabbccdd]tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0/1/2").unwrap();
12751274
let public_key = secret_key.to_public(&secp).unwrap();
12761275
assert_eq!(public_key.to_string(), "[aabbccdd]tpubD6NzVbkrYhZ4WQdzxL7NmJN7b85ePo4p6RSj9QQHF7te2RR9iUeVSGgnGkoUsB9LBRosgvNbjRv9bcsJgzgBd7QKuxDm23ZewkTRzNSLEDr/0/1/2");
12771276
assert_eq!(public_key.master_fingerprint().to_string(), "aabbccdd");
1278-
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "m/0/1/2");
1277+
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "0/1/2");
12791278

12801279
let secret_key = DescriptorSecretKey::from_str("[aabbccdd/90']tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0'/1'/2").unwrap();
12811280
let public_key = secret_key.to_public(&secp).unwrap();
12821281
assert_eq!(public_key.to_string(), "[aabbccdd/90'/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/2");
12831282
assert_eq!(public_key.master_fingerprint().to_string(), "aabbccdd");
1284-
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "m/90'/0'/1'/2");
1283+
assert_eq!(public_key.full_derivation_path().unwrap().to_string(), "90'/0'/1'/2");
12851284
}
12861285

12871286
#[test]
@@ -1323,10 +1322,10 @@ mod test {
13231322
assert_eq!(
13241323
xpub.derivation_paths.paths(),
13251324
&vec![
1326-
bip32::DerivationPath::from_str("m/2/0").unwrap(),
1327-
bip32::DerivationPath::from_str("m/2/1").unwrap(),
1328-
bip32::DerivationPath::from_str("m/2/42").unwrap(),
1329-
bip32::DerivationPath::from_str("m/2/9854").unwrap()
1325+
bip32::DerivationPath::from_str("2/0").unwrap(),
1326+
bip32::DerivationPath::from_str("2/1").unwrap(),
1327+
bip32::DerivationPath::from_str("2/42").unwrap(),
1328+
bip32::DerivationPath::from_str("2/9854").unwrap()
13301329
],
13311330
);
13321331
assert_eq!(
@@ -1338,9 +1337,9 @@ mod test {
13381337
assert_eq!(
13391338
xpub.derivation_paths.paths(),
13401339
&vec![
1341-
bip32::DerivationPath::from_str("m/2/0/0/5/10").unwrap(),
1342-
bip32::DerivationPath::from_str("m/2/1/0/5/10").unwrap(),
1343-
bip32::DerivationPath::from_str("m/2/9854/0/5/10").unwrap()
1340+
bip32::DerivationPath::from_str("2/0/0/5/10").unwrap(),
1341+
bip32::DerivationPath::from_str("2/1/0/5/10").unwrap(),
1342+
bip32::DerivationPath::from_str("2/9854/0/5/10").unwrap()
13441343
],
13451344
);
13461345
assert_eq!(
@@ -1353,9 +1352,9 @@ mod test {
13531352
assert_eq!(
13541353
xpub.derivation_paths.paths(),
13551354
&vec![
1356-
bip32::DerivationPath::from_str("m/2/0/3456/9876").unwrap(),
1357-
bip32::DerivationPath::from_str("m/2/1/3456/9876").unwrap(),
1358-
bip32::DerivationPath::from_str("m/2/9854/3456/9876").unwrap()
1355+
bip32::DerivationPath::from_str("2/0/3456/9876").unwrap(),
1356+
bip32::DerivationPath::from_str("2/1/3456/9876").unwrap(),
1357+
bip32::DerivationPath::from_str("2/9854/3456/9876").unwrap()
13591358
],
13601359
);
13611360
assert_eq!(
@@ -1368,8 +1367,8 @@ mod test {
13681367
assert_eq!(
13691368
xpub.derivation_paths.paths(),
13701369
&vec![
1371-
bip32::DerivationPath::from_str("m/0").unwrap(),
1372-
bip32::DerivationPath::from_str("m/1").unwrap(),
1370+
bip32::DerivationPath::from_str("0").unwrap(),
1371+
bip32::DerivationPath::from_str("1").unwrap(),
13731372
],
13741373
);
13751374
assert_eq!(
@@ -1383,8 +1382,8 @@ mod test {
13831382
assert_eq!(
13841383
xpub.derivation_paths.paths(),
13851384
&vec![
1386-
bip32::DerivationPath::from_str("m/9478'/0'/8'").unwrap(),
1387-
bip32::DerivationPath::from_str("m/9478h/1h/8h").unwrap(),
1385+
bip32::DerivationPath::from_str("9478'/0'/8'").unwrap(),
1386+
bip32::DerivationPath::from_str("9478h/1h/8h").unwrap(),
13881387
],
13891388
);
13901389
assert_eq!(
@@ -1399,8 +1398,8 @@ mod test {
13991398
assert_eq!(
14001399
desc_key.full_derivation_paths(),
14011400
vec![
1402-
bip32::DerivationPath::from_str("m/0'/1'/9478'/0'/8'").unwrap(),
1403-
bip32::DerivationPath::from_str("m/0'/1'/9478'/1/8'").unwrap(),
1401+
bip32::DerivationPath::from_str("0'/1'/9478'/0'/8'").unwrap(),
1402+
bip32::DerivationPath::from_str("0'/1'/9478'/1/8'").unwrap(),
14041403
],
14051404
);
14061405
assert_eq!(desc_key.into_single_keys(), vec![DescriptorPublicKey::from_str("[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/9478'/0'/8h/*'").unwrap(), DescriptorPublicKey::from_str("[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/9478'/1/8h/*'").unwrap()]);
@@ -1410,10 +1409,10 @@ mod test {
14101409
assert_eq!(
14111410
xprv.derivation_paths.paths(),
14121411
&vec![
1413-
bip32::DerivationPath::from_str("m/2/0").unwrap(),
1414-
bip32::DerivationPath::from_str("m/2/1").unwrap(),
1415-
bip32::DerivationPath::from_str("m/2/42").unwrap(),
1416-
bip32::DerivationPath::from_str("m/2/9854").unwrap()
1412+
bip32::DerivationPath::from_str("2/0").unwrap(),
1413+
bip32::DerivationPath::from_str("2/1").unwrap(),
1414+
bip32::DerivationPath::from_str("2/42").unwrap(),
1415+
bip32::DerivationPath::from_str("2/9854").unwrap()
14171416
],
14181417
);
14191418
assert_eq!(
@@ -1424,9 +1423,9 @@ mod test {
14241423
assert_eq!(
14251424
xprv.derivation_paths.paths(),
14261425
&vec![
1427-
bip32::DerivationPath::from_str("m/2/0/0/5/10").unwrap(),
1428-
bip32::DerivationPath::from_str("m/2/1/0/5/10").unwrap(),
1429-
bip32::DerivationPath::from_str("m/2/9854/0/5/10").unwrap()
1426+
bip32::DerivationPath::from_str("2/0/0/5/10").unwrap(),
1427+
bip32::DerivationPath::from_str("2/1/0/5/10").unwrap(),
1428+
bip32::DerivationPath::from_str("2/9854/0/5/10").unwrap()
14301429
],
14311430
);
14321431
assert_eq!(
@@ -1438,9 +1437,9 @@ mod test {
14381437
assert_eq!(
14391438
xprv.derivation_paths.paths(),
14401439
&vec![
1441-
bip32::DerivationPath::from_str("m/2/0/3456/9876").unwrap(),
1442-
bip32::DerivationPath::from_str("m/2/1/3456/9876").unwrap(),
1443-
bip32::DerivationPath::from_str("m/2/9854/3456/9876").unwrap()
1440+
bip32::DerivationPath::from_str("2/0/3456/9876").unwrap(),
1441+
bip32::DerivationPath::from_str("2/1/3456/9876").unwrap(),
1442+
bip32::DerivationPath::from_str("2/9854/3456/9876").unwrap()
14441443
],
14451444
);
14461445
assert_eq!(
@@ -1452,8 +1451,8 @@ mod test {
14521451
assert_eq!(
14531452
xprv.derivation_paths.paths(),
14541453
&vec![
1455-
bip32::DerivationPath::from_str("m/0").unwrap(),
1456-
bip32::DerivationPath::from_str("m/1").unwrap(),
1454+
bip32::DerivationPath::from_str("0").unwrap(),
1455+
bip32::DerivationPath::from_str("1").unwrap(),
14571456
],
14581457
);
14591458
assert_eq!(
@@ -1465,8 +1464,8 @@ mod test {
14651464
assert_eq!(
14661465
xprv.derivation_paths.paths(),
14671466
&vec![
1468-
bip32::DerivationPath::from_str("m/9478'/0'/8'").unwrap(),
1469-
bip32::DerivationPath::from_str("m/9478h/1h/8h").unwrap(),
1467+
bip32::DerivationPath::from_str("9478'/0'/8'").unwrap(),
1468+
bip32::DerivationPath::from_str("9478h/1h/8h").unwrap(),
14701469
],
14711470
);
14721471
assert_eq!(

src/descriptor/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,8 +1266,8 @@ mod tests {
12661266
) -> Option<bitcoin::ecdsa::Signature> {
12671267
if *pk == self.pk {
12681268
Some(bitcoin::ecdsa::Signature {
1269-
sig: self.sig,
1270-
hash_ty: bitcoin::sighash::EcdsaSighashType::All,
1269+
signature: self.sig,
1270+
sighash_type: bitcoin::sighash::EcdsaSighashType::All,
12711271
})
12721272
} else {
12731273
None
@@ -1533,11 +1533,11 @@ mod tests {
15331533

15341534
satisfier.insert(
15351535
a,
1536-
bitcoin::ecdsa::Signature { sig: sig_a, hash_ty: EcdsaSighashType::All },
1536+
bitcoin::ecdsa::Signature { signature: sig_a, sighash_type: EcdsaSighashType::All },
15371537
);
15381538
satisfier.insert(
15391539
b,
1540-
bitcoin::ecdsa::Signature { sig: sig_b, hash_ty: EcdsaSighashType::All },
1540+
bitcoin::ecdsa::Signature { signature: sig_b, sighash_type: EcdsaSighashType::All },
15411541
);
15421542

15431543
satisfier

src/descriptor/segwitv0.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,21 @@ impl<Pk: MiniscriptKey> Wpkh<Pk> {
371371
impl<Pk: MiniscriptKey + ToPublicKey> Wpkh<Pk> {
372372
/// Obtains the corresponding script pubkey for this descriptor.
373373
pub fn script_pubkey(&self) -> ScriptBuf {
374-
let addr = Address::p2wpkh(&self.pk.to_public_key(), Network::Bitcoin)
375-
.expect("wpkh descriptors have compressed keys");
374+
use core::convert::TryFrom;
375+
let pk = self.pk.to_public_key();
376+
let compressed = bitcoin::key::CompressedPublicKey::try_from(pk).expect("TODO: Handle compressed key");
377+
378+
let addr = Address::p2wpkh(&compressed, Network::Bitcoin);
376379
addr.script_pubkey()
377380
}
378381

379382
/// Obtains the corresponding script pubkey for this descriptor.
380383
pub fn address(&self, network: Network) -> Address {
381-
Address::p2wpkh(&self.pk.to_public_key(), network)
382-
.expect("Rust Miniscript types don't allow uncompressed pks in segwit descriptors")
384+
use core::convert::TryFrom;
385+
let pk = self.pk.to_public_key();
386+
let compressed = bitcoin::key::CompressedPublicKey::try_from(pk).expect("TODO: Handle compressed key");
387+
388+
Address::p2wpkh(&compressed, network)
383389
}
384390

385391
/// Obtains the underlying miniscript for this descriptor.

src/interpreter/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub enum Error {
9595
/// Schnorr Signature error
9696
SchnorrSig(bitcoin::taproot::SigFromSliceError),
9797
/// Errors in signature hash calculations
98-
SighashError(bitcoin::sighash::Error),
98+
SighashError(bitcoin::sighash::InvalidSighashTypeError),
9999
/// Taproot Annex Unsupported
100100
TapAnnexUnsupported,
101101
/// An uncompressed public key was encountered in a context where it is
@@ -242,8 +242,8 @@ impl From<secp256k1::Error> for Error {
242242
}
243243

244244
#[doc(hidden)]
245-
impl From<bitcoin::sighash::Error> for Error {
246-
fn from(e: bitcoin::sighash::Error) -> Error { Error::SighashError(e) }
245+
impl From<bitcoin::sighash::InvalidSighashTypeError> for Error {
246+
fn from(e: bitcoin::sighash::InvalidSighashTypeError) -> Error { Error::SighashError(e) }
247247
}
248248

249249
#[doc(hidden)]

0 commit comments

Comments
 (0)