Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 7.0.0 #359

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 7.0.0-rc.1 - March 14, 2022
# 7.0.0 - April 20, 2022

- Fixed miniscript type system bug. This is a security vulnerability and users are strongly encouraged to upgrade.
See this (link)[https://github.com/rust-bitcoin/rust-miniscript/pull/349/commits/db97c39afa4053c2c3917f04392f6e24964b3972] for details.
- Support for `tr` descriptors with miniscript leaves and multi_a fragment
- Changes to MiniscriptKey and ToPublicKey traits for x-only keys support
- Add `PsbtExt` trait for psbt operations
Expand All @@ -15,7 +17,7 @@
- Overhaul the interpreter API to provide simpler APIs `iter(prevouts)` and `iter_assume_sig()`
so that it no longer takes a closure input.
- Add interpreter support for taproot transactions.
- Works with rust-bitcoin 0.28.0-rc.1
- Works with rust-bitcoin 0.28.0
# 6.0.1 - Aug 5, 2021

- The `lift` method on a Miniscript node was fixed. It would previously mix up
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "miniscript"
version = "7.0.0-rc.2"
version = "7.0.0"
authors = ["Andrew Poelstra <[email protected]>, Sanket Kanjalkar <[email protected]>"]
repository = "https://github.com/apoelstra/miniscript"
description = "Miniscript: a subset of Bitcoin Script designed for analysis"
Expand All @@ -15,7 +15,7 @@ use-serde = ["bitcoin/use-serde", "serde"]
rand = ["bitcoin/rand"]

[dependencies]
bitcoin = "0.28.0-rc.2"
bitcoin = "0.28.0"

[dependencies.serde]
version = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/sign_multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn main() {
531d75c136272f127a5dc14acc0722301cbddc222262934151f140da345af177",
)
.unwrap(),
hash_ty: bitcoin::EcdsaSigHashType::All,
hash_ty: bitcoin::EcdsaSighashType::All,
};

let descriptor_str = format!(
Expand Down
2 changes: 1 addition & 1 deletion examples/verify_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ fn main() {

let iter = interpreter.iter_custom(Box::new(|key_sig: &KeySigPair| {
let (pk, ecdsa_sig) = key_sig.as_ecdsa().expect("Ecdsa Sig");
ecdsa_sig.hash_ty == bitcoin::EcdsaSigHashType::All
ecdsa_sig.hash_ty == bitcoin::EcdsaSighashType::All
&& secp
.verify_ecdsa(&message, &ecdsa_sig.sig, &pk.inner)
.is_ok()
Expand Down
4 changes: 2 additions & 2 deletions integration_test/src/test_cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
.collect();
// Get the required sighash message
let amt = btc(1).as_sat();
let mut sighash_cache = bitcoin::util::sighash::SigHashCache::new(&psbts[i].unsigned_tx);
let sighash_ty = bitcoin::EcdsaSigHashType::All;
let mut sighash_cache = bitcoin::util::sighash::SighashCache::new(&psbts[i].unsigned_tx);
let sighash_ty = bitcoin::EcdsaSighashType::All;
let sighash = sighash_cache
.segwit_signature_hash(0, &ms.encode(), amt, sighash_ty)
.unwrap();
Expand Down
8 changes: 4 additions & 4 deletions integration_test/src/test_desc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use bitcoin::blockdata::witness::Witness;
use bitcoin::secp256k1;
use bitcoin::util::psbt::PartiallySignedTransaction as Psbt;
use bitcoin::util::sighash::SigHashCache;
use bitcoin::util::sighash::SighashCache;
use bitcoin::util::taproot::{LeafVersion, TapLeafHash};
use bitcoin::util::{psbt, sighash};
use bitcoin::{self, Amount, OutPoint, SchnorrSig, Script, Transaction, TxIn, TxOut, Txid};
Expand Down Expand Up @@ -119,11 +119,11 @@ pub fn test_desc_satisfy(cl: &Client, testdata: &TestData, desc: &str) -> Witnes
// AKA the signer role of psbt
// Get all the pubkeys and the corresponding secret keys

let mut sighash_cache = SigHashCache::new(&psbt.unsigned_tx);
let mut sighash_cache = SighashCache::new(&psbt.unsigned_tx);
match derived_desc {
Descriptor::Tr(ref tr) => {
// Fixme: take a parameter
let hash_ty = sighash::SchnorrSigHashType::Default;
let hash_ty = sighash::SchnorrSighashType::Default;

let internal_key_present = x_only_pks
.iter()
Expand Down Expand Up @@ -226,7 +226,7 @@ pub fn test_desc_satisfy(cl: &Client, testdata: &TestData, desc: &str) -> Witnes
.to_secp_msg();

// Fixme: Take a parameter
let hash_ty = bitcoin::EcdsaSigHashType::All;
let hash_ty = bitcoin::EcdsaSighashType::All;

// Finally construct the signature and add to psbt
for sk in sks_reqd {
Expand Down
8 changes: 4 additions & 4 deletions src/descriptor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ mod tests {
use bitcoin::hashes::hex::{FromHex, ToHex};
use bitcoin::hashes::{hash160, sha256};
use bitcoin::util::bip32;
use bitcoin::{self, secp256k1, EcdsaSigHashType, PublicKey};
use bitcoin::{self, secp256k1, EcdsaSighashType, PublicKey};
use descriptor::key::Wildcard;
use descriptor::{
DescriptorPublicKey, DescriptorSecretKey, DescriptorSinglePub, DescriptorXKey,
Expand Down Expand Up @@ -1128,7 +1128,7 @@ mod tests {
if *pk == self.pk {
Some(bitcoin::EcdsaSig {
sig: self.sig,
hash_ty: bitcoin::EcdsaSigHashType::All,
hash_ty: bitcoin::EcdsaSighashType::All,
})
} else {
None
Expand Down Expand Up @@ -1397,14 +1397,14 @@ mod tests {
a,
bitcoin::EcdsaSig {
sig: sig_a,
hash_ty: EcdsaSigHashType::All,
hash_ty: EcdsaSighashType::All,
},
);
satisfier.insert(
b,
bitcoin::EcdsaSig {
sig: sig_b,
hash_ty: EcdsaSigHashType::All,
hash_ty: EcdsaSighashType::All,
},
);

Expand Down
8 changes: 4 additions & 4 deletions src/descriptor/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,14 @@ pub struct TapTreeIter<'a, Pk: MiniscriptKey>
where
Pk: 'a,
{
stack: Vec<(usize, &'a TapTree<Pk>)>,
stack: Vec<(u8, &'a TapTree<Pk>)>,
}

impl<'a, Pk> Iterator for TapTreeIter<'a, Pk>
where
Pk: MiniscriptKey + 'a,
{
type Item = (usize, &'a Miniscript<Pk, Tap>);
type Item = (u8, &'a Miniscript<Pk, Tap>);

fn next(&mut self) -> Option<Self::Item> {
while !self.stack.is_empty() {
Expand Down Expand Up @@ -681,8 +681,8 @@ impl<P: MiniscriptKey, Q: MiniscriptKey> TranslatePk<P, Q> for Tr<P> {
}

// Helper function to compute the len of control block at a given depth
fn control_block_len(depth: usize) -> usize {
TAPROOT_CONTROL_BASE_SIZE + depth * TAPROOT_CONTROL_NODE_SIZE
fn control_block_len(depth: u8) -> usize {
TAPROOT_CONTROL_BASE_SIZE + (depth as usize) * TAPROOT_CONTROL_NODE_SIZE
}

// Helper function to get a script spend satisfaction
Expand Down
8 changes: 4 additions & 4 deletions src/interpreter/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ pub enum Error {
/// MultiSig missing at least `1` witness elements out of `k + 1` required
InsufficientSignaturesMultiSig,
/// Invalid Sighash type
InvalidSchnorrSigHashType(Vec<u8>),
InvalidSchnorrSighashType(Vec<u8>),
/// ecdsa Signature failed to verify
InvalidEcdsaSignature(bitcoin::PublicKey),
/// Signature failed to verify
InvalidSchnorrSignature(bitcoin::XOnlyPublicKey),
/// Last byte of this signature isn't a standard sighash type
NonStandardSigHash(Vec<u8>),
NonStandardSighash(Vec<u8>),
/// Miniscript error
Miniscript(::Error),
/// MultiSig requires 1 extra zero element apart from the `k` signatures
Expand Down Expand Up @@ -212,7 +212,7 @@ impl fmt::Display for Error {
}
Error::IncorrectWScriptHash => f.write_str("witness script did not match scriptpubkey"),
Error::InsufficientSignaturesMultiSig => f.write_str("Insufficient signatures for CMS"),
Error::InvalidSchnorrSigHashType(ref sig) => {
Error::InvalidSchnorrSighashType(ref sig) => {
write!(
f,
"Invalid sighash type for schnorr signature '{}'",
Expand All @@ -221,7 +221,7 @@ impl fmt::Display for Error {
}
Error::InvalidEcdsaSignature(pk) => write!(f, "bad ecdsa signature with pk {}", pk),
Error::InvalidSchnorrSignature(pk) => write!(f, "bad schnorr signature with pk {}", pk),
Error::NonStandardSigHash(ref sig) => {
Error::NonStandardSighash(ref sig) => {
write!(
f,
"Non standard sighash type for signature '{}'",
Expand Down
6 changes: 3 additions & 3 deletions src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl<'txin> Interpreter<'txin> {
sighash::Prevouts::All(prevouts) => prevouts.get(input_index),
}
}
let mut cache = bitcoin::util::sighash::SigHashCache::new(tx);
let mut cache = bitcoin::util::sighash::SighashCache::new(tx);
match sig {
KeySigPair::Ecdsa(key, ecdsa_sig) => {
let script_pubkey = self.script_code.as_ref().expect("Legacy have script code");
Expand Down Expand Up @@ -1076,7 +1076,7 @@ mod tests {
let sig = secp.sign_ecdsa(&msg, &sk);
ecdsa_sigs.push(bitcoin::EcdsaSig {
sig,
hash_ty: bitcoin::EcdsaSigHashType::All,
hash_ty: bitcoin::EcdsaSighashType::All,
});
let mut sigser = sig.serialize_der().to_vec();
sigser.push(0x01); // sighash_all
Expand All @@ -1088,7 +1088,7 @@ mod tests {
let schnorr_sig = secp.sign_schnorr_with_aux_rand(&msg, &keypair, &[0u8; 32]);
let schnorr_sig = bitcoin::SchnorrSig {
sig: schnorr_sig,
hash_ty: bitcoin::SchnorrSigHashType::Default,
hash_ty: bitcoin::SchnorrSighashType::Default,
};
ser_schnorr_sigs.push(schnorr_sig.to_vec());
schnorr_sigs.push(schnorr_sig);
Expand Down
2 changes: 1 addition & 1 deletion src/miniscript/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ mod tests {
) -> Option<bitcoin::SchnorrSig> {
Some(bitcoin::SchnorrSig {
sig: self.0,
hash_ty: bitcoin::SchnorrSigHashType::Default,
hash_ty: bitcoin::SchnorrSighashType::Default,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/policy/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ mod tests {

let bitcoinsig = bitcoin::EcdsaSig {
sig,
hash_ty: bitcoin::EcdsaSigHashType::All,
hash_ty: bitcoin::EcdsaSighashType::All,
};
let sigvec = bitcoinsig.to_vec();

Expand Down
Loading