Skip to content

Commit 8bcd517

Browse files
committed
Test bitcoin v0.32.0-rc1
Test the latest bitcoin release candidate. Includes bumping the version numbers so we can use this branch to test crates further up the stack. Requires the `rc-fixes` branch.
1 parent 9eb4375 commit 8bcd517

File tree

15 files changed

+131
-68
lines changed

15 files changed

+131
-68
lines changed

Cargo.toml

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "miniscript"
3-
version = "11.0.0"
3+
version = "12.0.0"
44
authors = ["Andrew Poelstra <[email protected]>, Sanket Kanjalkar <[email protected]>"]
55
license = "CC0-1.0"
66
homepage = "https://github.com/rust-bitcoin/rust-miniscript/"
@@ -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-rc1", 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-rc1", features = ["base64"] }
34+
secp256k1 = {version = "0.29.0", features = ["rand-std"]}
3535

3636
[[example]]
3737
name = "htlc"
@@ -68,3 +68,35 @@ required-features = ["std", "base64", "compiler"]
6868
[workspace]
6969
members = ["bitcoind-tests", "fuzz"]
7070
exclude = ["embedded"]
71+
72+
[patch.crates-io.bitcoind]
73+
git = "https://github.com/tcharding/bitcoind/"
74+
branch = "test-bitcoin"
75+
76+
[patch.crates-io.bitcoincore-rpc]
77+
git = "https://github.com/tcharding/rust-bitcoincore-rpc"
78+
branch = "test-bitcoin"
79+
80+
[patch.crates-io.base58ck]
81+
git = "https://github.com/rust-bitcoin/rust-bitcoin"
82+
branch = "rc1-fixes"
83+
84+
[patch.crates-io.bitcoin]
85+
git = "https://github.com/rust-bitcoin/rust-bitcoin"
86+
branch = "rc1-fixes"
87+
88+
[patch.crates-io.bitcoin_hashes]
89+
git = "https://github.com/rust-bitcoin/rust-bitcoin"
90+
branch = "rc1-fixes"
91+
92+
[patch.crates-io.bitcoin-internals]
93+
git = "https://github.com/rust-bitcoin/rust-bitcoin"
94+
branch = "rc1-fixes"
95+
96+
[patch.crates-io.bitcoin-io]
97+
git = "https://github.com/rust-bitcoin/rust-bitcoin"
98+
branch = "rc1-fixes"
99+
100+
[patch.crates-io.bitcoin-units]
101+
git = "https://github.com/rust-bitcoin/rust-bitcoin"
102+
branch = "rc1-fixes"

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: 0 additions & 1 deletion
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};

src/descriptor/mod.rs

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

15351535
satisfier.insert(
15361536
a,
1537-
bitcoin::ecdsa::Signature { sig: sig_a, hash_ty: EcdsaSighashType::All },
1537+
bitcoin::ecdsa::Signature { signature: sig_a, sighash_type: EcdsaSighashType::All },
15381538
);
15391539
satisfier.insert(
15401540
b,
1541-
bitcoin::ecdsa::Signature { sig: sig_b, hash_ty: EcdsaSighashType::All },
1541+
bitcoin::ecdsa::Signature { signature: sig_b, sighash_type: EcdsaSighashType::All },
15421542
);
15431543

15441544
satisfier

src/descriptor/segwitv0.rs

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

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

388394
/// 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)]

src/interpreter/mod.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl<'txin> Interpreter<'txin> {
218218
KeySigPair::Ecdsa(key, ecdsa_sig) => {
219219
let script_pubkey = self.script_code.as_ref().expect("Legacy have script code");
220220
let msg = if self.is_legacy() {
221-
let sighash_u32 = ecdsa_sig.hash_ty.to_u32();
221+
let sighash_u32 = ecdsa_sig.sighash_type.to_u32();
222222
let sighash =
223223
cache.legacy_signature_hash(input_idx, script_pubkey, sighash_u32);
224224
sighash.map(|hash| secp256k1::Message::from_digest(hash.to_byte_array()))
@@ -227,11 +227,12 @@ impl<'txin> Interpreter<'txin> {
227227
Some(txout) => txout.borrow().value,
228228
None => return false,
229229
};
230-
let sighash = cache.segwit_signature_hash(
230+
// TODO: Don't manually handle the script code.
231+
let sighash = cache.p2wsh_signature_hash(
231232
input_idx,
232233
script_pubkey,
233234
amt,
234-
ecdsa_sig.hash_ty,
235+
ecdsa_sig.sighash_type,
235236
);
236237
sighash.map(|hash| secp256k1::Message::from_digest(hash.to_byte_array()))
237238
} else {
@@ -240,12 +241,12 @@ impl<'txin> Interpreter<'txin> {
240241
};
241242

242243
let success =
243-
msg.map(|msg| secp.verify_ecdsa(&msg, &ecdsa_sig.sig, &key.inner).is_ok());
244+
msg.map(|msg| secp.verify_ecdsa(&msg, &ecdsa_sig.signature, &key.inner).is_ok());
244245
success.unwrap_or(false) // unwrap_or checks for errors, while success would have checksig results
245246
}
246247
KeySigPair::Schnorr(xpk, schnorr_sig) => {
247248
let sighash_msg = if self.is_taproot_v1_key_spend() {
248-
cache.taproot_key_spend_signature_hash(input_idx, prevouts, schnorr_sig.hash_ty)
249+
cache.taproot_key_spend_signature_hash(input_idx, prevouts, schnorr_sig.sighash_type)
249250
} else if self.is_taproot_v1_script_spend() {
250251
let tap_script = self.script_code.as_ref().expect(
251252
"Internal Hack: Saving leaf script instead\
@@ -259,7 +260,7 @@ impl<'txin> Interpreter<'txin> {
259260
input_idx,
260261
prevouts,
261262
leaf_hash,
262-
schnorr_sig.hash_ty,
263+
schnorr_sig.sighash_type,
263264
)
264265
} else {
265266
// schnorr sigs in ecdsa descriptors
@@ -268,7 +269,7 @@ impl<'txin> Interpreter<'txin> {
268269
let msg =
269270
sighash_msg.map(|hash| secp256k1::Message::from_digest(hash.to_byte_array()));
270271
let success =
271-
msg.map(|msg| secp.verify_schnorr(&schnorr_sig.sig, &msg, xpk).is_ok());
272+
msg.map(|msg| secp.verify_schnorr(&schnorr_sig.signature, &msg, xpk).is_ok());
272273
success.unwrap_or(false) // unwrap_or_default checks for errors, while success would have checksig results
273274
}
274275
}
@@ -1069,12 +1070,12 @@ mod tests {
10691070
inner: secp256k1::PublicKey::from_secret_key(&secp, &sk),
10701071
compressed: true,
10711072
};
1072-
let sig = secp.sign_ecdsa(&msg, &sk);
1073+
let signature = secp.sign_ecdsa(&msg, &sk);
10731074
ecdsa_sigs.push(bitcoin::ecdsa::Signature {
1074-
sig,
1075-
hash_ty: bitcoin::sighash::EcdsaSighashType::All,
1075+
signature,
1076+
sighash_type: bitcoin::sighash::EcdsaSighashType::All,
10761077
});
1077-
let mut sigser = sig.serialize_der().to_vec();
1078+
let mut sigser = signature.serialize_der().to_vec();
10781079
sigser.push(0x01); // sighash_all
10791080
pks.push(pk);
10801081
der_sigs.push(sigser);
@@ -1084,8 +1085,8 @@ mod tests {
10841085
x_only_pks.push(x_only_pk);
10851086
let schnorr_sig = secp.sign_schnorr_with_aux_rand(&msg, &keypair, &[0u8; 32]);
10861087
let schnorr_sig = bitcoin::taproot::Signature {
1087-
sig: schnorr_sig,
1088-
hash_ty: bitcoin::sighash::TapSighashType::Default,
1088+
signature: schnorr_sig,
1089+
sighash_type: bitcoin::sighash::TapSighashType::Default,
10891090
};
10901091
ser_schnorr_sigs.push(schnorr_sig.to_vec());
10911092
schnorr_sigs.push(schnorr_sig);
@@ -1100,10 +1101,10 @@ mod tests {
11001101
let secp_ref = &secp;
11011102
let vfyfn = |pksig: &KeySigPair| match pksig {
11021103
KeySigPair::Ecdsa(pk, ecdsa_sig) => secp_ref
1103-
.verify_ecdsa(&sighash, &ecdsa_sig.sig, &pk.inner)
1104+
.verify_ecdsa(&sighash, &ecdsa_sig.signature, &pk.inner)
11041105
.is_ok(),
11051106
KeySigPair::Schnorr(xpk, schnorr_sig) => secp_ref
1106-
.verify_schnorr(&schnorr_sig.sig, &sighash, xpk)
1107+
.verify_schnorr(&schnorr_sig.signature, &sighash, xpk)
11071108
.is_ok(),
11081109
};
11091110

src/lib.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ pub enum Error {
430430
/// rust-bitcoin script error
431431
Script(script::Error),
432432
/// rust-bitcoin address error
433-
AddrError(bitcoin::address::Error),
433+
AddrError(bitcoin::address::ParseError),
434+
/// rust-bitcoin p2sh address error
435+
AddrP2shError(bitcoin::address::P2shError),
434436
/// A `CHECKMULTISIG` opcode was preceded by a number > 20
435437
CmsTooManyKeys(u32),
436438
/// A tapscript multi_a cannot support more than Weight::MAX_BLOCK/32 keys
@@ -513,6 +515,7 @@ impl fmt::Display for Error {
513515
},
514516
Error::Script(ref e) => fmt::Display::fmt(e, f),
515517
Error::AddrError(ref e) => fmt::Display::fmt(e, f),
518+
Error::AddrP2shError(ref e) => fmt::Display::fmt(e, f),
516519
Error::CmsTooManyKeys(n) => write!(f, "checkmultisig with {} keys", n),
517520
Error::Unprintable(x) => write!(f, "unprintable character 0x{:02x}", x),
518521
Error::ExpectedChar(c) => write!(f, "expected {}", c),
@@ -593,6 +596,7 @@ impl error::Error for Error {
593596
| MultipathDescLenMismatch => None,
594597
Script(e) => Some(e),
595598
AddrError(e) => Some(e),
599+
AddrP2shError(e) => Some(e),
596600
Secp(e) => Some(e),
597601
#[cfg(feature = "compiler")]
598602
CompilerError(e) => Some(e),
@@ -635,8 +639,13 @@ impl From<bitcoin::secp256k1::Error> for Error {
635639
}
636640

637641
#[doc(hidden)]
638-
impl From<bitcoin::address::Error> for Error {
639-
fn from(e: bitcoin::address::Error) -> Error { Error::AddrError(e) }
642+
impl From<bitcoin::address::ParseError> for Error {
643+
fn from(e: bitcoin::address::ParseError) -> Error { Error::AddrError(e) }
644+
}
645+
646+
#[doc(hidden)]
647+
impl From<bitcoin::address::P2shError> for Error {
648+
fn from(e: bitcoin::address::P2shError) -> Error { Error::AddrP2shError(e) }
640649
}
641650

642651
#[doc(hidden)]

src/miniscript/decode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl ParseableKey for bitcoin::secp256k1::XOnlyPublicKey {
4848
#[derive(Debug, Clone, PartialEq, Eq)]
4949
pub enum KeyParseError {
5050
/// Bitcoin PublicKey parse error
51-
FullKeyParseError(bitcoin::key::Error),
51+
FullKeyParseError(bitcoin::key::FromSliceError),
5252
/// Xonly key parse Error
5353
XonlyKeyParseError(bitcoin::secp256k1::Error),
5454
}

src/miniscript/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,8 +1289,8 @@ mod tests {
12891289
_h: &TapLeafHash,
12901290
) -> Option<bitcoin::taproot::Signature> {
12911291
Some(bitcoin::taproot::Signature {
1292-
sig: self.0,
1293-
hash_ty: bitcoin::sighash::TapSighashType::Default,
1292+
signature: self.0,
1293+
sighash_type: bitcoin::sighash::TapSighashType::Default,
12941294
})
12951295
}
12961296
}
@@ -1420,8 +1420,8 @@ mod tests {
14201420
) -> Option<bitcoin::taproot::Signature> {
14211421
if pk == &self.1 {
14221422
Some(bitcoin::taproot::Signature {
1423-
sig: self.0,
1424-
hash_ty: bitcoin::sighash::TapSighashType::Default,
1423+
signature: self.0,
1424+
sighash_type: bitcoin::sighash::TapSighashType::Default,
14251425
})
14261426
} else {
14271427
None

src/policy/compiler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ mod tests {
13361336
#[test]
13371337
#[allow(clippy::needless_range_loop)]
13381338
fn compile_misc() {
1339-
let (keys, sig) = pubkeys_and_a_sig(10);
1339+
let (keys, signature) = pubkeys_and_a_sig(10);
13401340
let key_pol: Vec<BPolicy> = keys.iter().map(|k| Concrete::Key(*k)).collect();
13411341

13421342
let policy: BPolicy = Concrete::Key(keys[0]);
@@ -1424,7 +1424,7 @@ mod tests {
14241424
assert_eq!(abs.minimum_n_keys(), Some(3));
14251425

14261426
let bitcoinsig =
1427-
bitcoin::ecdsa::Signature { sig, hash_ty: bitcoin::sighash::EcdsaSighashType::All };
1427+
bitcoin::ecdsa::Signature { signature, sighash_type: bitcoin::sighash::EcdsaSighashType::All };
14281428
let sigvec = bitcoinsig.to_vec();
14291429

14301430
let no_sat = BTreeMap::<bitcoin::PublicKey, bitcoin::ecdsa::Signature>::new();

0 commit comments

Comments
 (0)