Skip to content
Open
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
45 changes: 3 additions & 42 deletions Cargo-latest.lock
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,6 @@ version = "3.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"

[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"

[[package]]
name = "cc"
version = "1.2.34"
Expand Down Expand Up @@ -307,7 +301,6 @@ dependencies = [
"serde",
"serde_json",
"serde_test",
"simplicity-lang",
]

[[package]]
Expand Down Expand Up @@ -342,12 +335,6 @@ dependencies = [
"wasm-bindgen",
]

[[package]]
name = "ghost-cell"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8449d342b1c67f49169e92e71deb7b9b27f30062301a16dbc27a4cc8d2351b7"

[[package]]
name = "hex-conservative"
version = "0.1.2"
Expand Down Expand Up @@ -467,12 +454,13 @@ dependencies = [

[[package]]
name = "miniscript"
version = "12.3.5"
version = "13.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "487906208f38448e186e3deb02f2b8ef046a9078b0de00bdb28bf4fb9b76951c"
checksum = "cd35e2c377504e50159561884b03610711db6c2fec6c89f2b98d94016684726b"
dependencies = [
"bech32 0.11.0",
"bitcoin 0.32.102",
"hex-conservative 1.2.0",
]

[[package]]
Expand Down Expand Up @@ -719,33 +707,6 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"

[[package]]
name = "simplicity-lang"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cff7b10251528d46d9cf60238267911984fedbb0948cccea98dd74fc6bf9f729"
dependencies = [
"bitcoin 0.32.102",
"bitcoin_hashes 1.2.0",
"byteorder",
"elements",
"getrandom",
"ghost-cell",
"hex-conservative 1.2.0",
"miniscript",
"simplicity-sys",
]

[[package]]
name = "simplicity-sys"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "955935733b2735665b4735d9b1361eade6be4c7aea6bca2640345e4c81756f58"
dependencies = [
"bitcoin_hashes 1.2.0",
"cc",
]

[[package]]
name = "syn"
version = "2.0.106"
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ base64 = ["bitcoin/base64", "elements/base64"]
[dependencies]
bitcoin = "0.32.0"
elements = "0.27.0"
bitcoin-miniscript = { package = "miniscript", version = "12.0" }
simplicity = { package = "simplicity-lang", version = "0.9.0", optional = true }
bitcoin-miniscript = { package = "miniscript", version = "13.1" }

# Do NOT use this as a feature! Use the `serde` feature instead.
actual-serde = { package = "serde", version = "1.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion contrib/test_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
FEATURES_WITH_STD=""

# Test all these features without "std" enabled.
FEATURES_WITHOUT_STD="compiler trace serde rand base64 simplicity"
FEATURES_WITHOUT_STD="compiler trace serde rand base64"

# Run these examples.
EXAMPLES="htlc:compiler parse: sign_multisig: verify_tx: xpub_descriptors: taproot:compiler psbt_sign_finalize:base64"
2 changes: 1 addition & 1 deletion src/confidential/elip151.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ mod test {
(&format!("elwsh(multi(2,{xpub}/<0;1>/*,{xpub}/0/<0;1;2>/*))"), Error::MultipathDescLenMismatch),
] {
let err = confidential_descriptor(invalid_desc).unwrap_err();
assert_eq!(err, expected_err);
assert_eq!(format!("{:?}", err), format!("{:?}", expected_err));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error does not implementation partial eq anymore

/*
_i = _i + 1;
println!("* Invalid Test vector {}", _i);
Expand Down
12 changes: 6 additions & 6 deletions src/confidential/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,10 @@ mod tests {
.unwrap(),
};

assert_eq!(
assert!(matches!(
desc.address(&secp, params).unwrap_err(),
Error::Conversion(ConversionError::HardenedChild)
);
));
}

// Same case, reached through `at_derivation_index` on a hardened wildcard blinding
Expand All @@ -605,10 +605,10 @@ mod tests {
let desc = Descriptor::<DescriptorPublicKey, NoExt>::from_str(&desc_str).unwrap();
let definite_desc = desc.at_derivation_index(1).unwrap();

assert_eq!(
assert!(matches!(
definite_desc.address(&secp, params).unwrap_err(),
Error::Conversion(ConversionError::HardenedChild)
);
));
}

#[test]
Expand Down Expand Up @@ -638,10 +638,10 @@ mod tests {
// but we can't enforce this with the Descriptor generic.
let desc_view_str = format!("ct({}/*,elwpkh({}))#ls6mx2ac", xprv, xpub);
let desc_view = Descriptor::<DefiniteDescriptorKey>::from_str(&desc_view_str).unwrap();
assert_eq!(desc_view.address(&secp, params).unwrap_err(), Error::Unexpected("wildcard blinding key".into()));
assert!(matches!(desc_view.address(&secp, params).unwrap_err(), Error::Unexpected(e) if e == "wildcard blinding key"));

let desc_bare_str = format!("ct({}/*,elwpkh({}))#czkz0hwn", xpub, xpub);
let desc_bare = Descriptor::<DefiniteDescriptorKey>::from_str(&desc_bare_str).unwrap();
assert_eq!(desc_bare.address(&secp, params).unwrap_err(), Error::Unexpected("wildcard blinding key".into()));
assert!(matches!(desc_bare.address(&secp, params).unwrap_err(), Error::Unexpected(e) if e == "wildcard blinding key"));
}
}
3 changes: 1 addition & 2 deletions src/descriptor/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
use core::fmt;
use core::iter::FromIterator;

use bitcoin_miniscript::expression::check_valid_chars;

use crate::expression::check_valid_chars;
use crate::Error;

const INPUT_CHARSET: &str = "0123456789()[],'/*abcdefgh@:$%{}IJKLMNOPQRSTUVWXYZ&+-.;<=>?!^_|~ijklmnopqrstuvwxyzABCDEFGH`#\"\\ ";
Expand Down
17 changes: 11 additions & 6 deletions src/descriptor/pegin/dynafed_pegin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl_from_tree!(
// TODO: Confirm with Andrew about the descriptor type for dynafed
// Assuming sh(wsh) for now.

let fed_desc = BtcDescriptor::<PublicKey>::from_tree(&ms_expr)?;
let fed_desc = BtcDescriptor::<PublicKey>::from_tree(ms_expr.root())?;
let elem_desc = Descriptor::<Pk, CovenantExt<CovExtArgs>>::from_tree(&top.args[1])?;
Ok(Pegin::new(fed_desc, elem_desc))
} else {
Expand Down Expand Up @@ -252,7 +252,9 @@ impl<Pk: MiniscriptKey> Pegin<Pk> {
.into_bytes();
let mut t = TranslateTweak(&claim_script[..], secp);

let tweaked_desc = bitcoin_miniscript::TranslatePk::translate_pk(&self.fed_desc, &mut t)
let tweaked_desc = self
.fed_desc
.translate_pk(&mut t)
.expect("Tweaking must succeed");

let res = tweaked_desc.get_satisfaction(satisfier)?;
Expand Down Expand Up @@ -303,7 +305,8 @@ fn bitcoin_witness_script<C: secp256k1_zkp::Verification, Pk: ToPublicKey>(
) -> Result<BtcScript, Error> {
let mut t = TranslateTweak(claim_script, secp);

let tweaked_desc = bitcoin_miniscript::TranslatePk::translate_pk(fed_desc, &mut t)
let tweaked_desc = fed_desc
.translate_pk(&mut t)
.expect("Tweaking must succeed");
Ok(tweaked_desc.explicit_script()?)
}
Expand All @@ -313,12 +316,14 @@ struct TranslateTweak<'a, 'b, C: secp256k1_zkp::Verification>(
&'b secp256k1_zkp::Secp256k1<C>,
);

impl<'a, 'b, Pk, C> bitcoin_miniscript::Translator<Pk, bitcoin::PublicKey, ()>
for TranslateTweak<'a, 'b, C>
impl<'a, 'b, Pk, C> bitcoin_miniscript::Translator<Pk> for TranslateTweak<'a, 'b, C>
where
Pk: MiniscriptKey + ToPublicKey,
C: secp256k1_zkp::Verification,
{
type TargetPk = bitcoin::PublicKey;
type Error = ();

fn pk(&mut self, pk: &Pk) -> Result<bitcoin::PublicKey, ()> {
Ok(tweak_key(&pk.to_public_key(), self.1, self.0))
}
Expand All @@ -342,7 +347,7 @@ mod tests {
type Segwitv0Script =
bitcoin_miniscript::Miniscript<bitcoin::PublicKey, bitcoin_miniscript::Segwitv0>;

let m = Segwitv0Script::parse(&s).unwrap();
let m = Segwitv0Script::decode(&s).unwrap();
assert_eq!(m.encode(), s);
BtcDescriptor::<_>::new_wsh(m).unwrap()
}
Expand Down
8 changes: 5 additions & 3 deletions src/descriptor/pegin/legacy_pegin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use bitcoin::blockdata::{opcodes, script};
use bitcoin::hashes::{hash160, ripemd160, sha256, Hash};
use bitcoin::{self, hashes, ScriptBuf as BtcScript};
use bitcoin_miniscript::miniscript::limits::MAX_PUBKEYS_PER_MULTISIG;
use bitcoin_miniscript::TranslatePk as BtcTranslatePk;
use elements::secp256k1_zkp;

use crate::descriptor::checksum::{self, verify_checksum};
Expand Down Expand Up @@ -237,7 +236,10 @@ impl<Pk: MiniscriptKey> LegacyPegin<Pk> {
};
struct TranslateUnTweak;

impl bitcoin_miniscript::Translator<LegacyPeginKey, bitcoin::PublicKey, ()> for TranslateUnTweak {
impl bitcoin_miniscript::Translator<LegacyPeginKey> for TranslateUnTweak {
type TargetPk = bitcoin::PublicKey;
type Error = ();

fn pk(&mut self, pk: &LegacyPeginKey) -> Result<bitcoin::PublicKey, ()> {
Ok(*pk.as_untweaked())
}
Expand Down Expand Up @@ -349,7 +351,7 @@ impl_from_tree!(
let ms_str = top.args[0].to_string();
let ms_expr = BtcTree::from_str(&ms_str)?;
//
let ms = BtcMiniscript::<LegacyPeginKey, BtcSegwitv0>::from_tree(&ms_expr);
let ms = BtcMiniscript::<LegacyPeginKey, BtcSegwitv0>::from_tree(ms_expr.root());
let desc = Descriptor::<Pk, CovenantExt<CovExtArgs>>::from_tree(&top.args[1]);
Ok(LegacyPegin::from_ms_and_desc(desc?, ms?))
} else {
Expand Down
Loading
Loading