Skip to content

Simplicity descriptors #50

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

Merged
merged 13 commits into from
Aug 20, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, beta, nightly, 1.48.0]
rust: [stable, beta, nightly, 1.58.0]
steps:
- name: Checkout Crate
uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ base64 = ["bitcoin/base64"]
bitcoin = "0.30.0"
elements = "0.22.0"
bitcoin-miniscript = { package = "miniscript", version = "10.0" }
simplicity = { git = "https://github.com/uncomputable/rust-simplicity", branch = "policy-fixes" }

# Do NOT use this as a feature! Use the `serde` feature instead.
actual-serde = { package = "serde", version = "1.0", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Build](https://github.com/ElementsProject/elements-miniscript/workflows/Continuous%20integration/badge.svg)

**Minimum Supported Rust Version:** 1.48.0
**Minimum Supported Rust Version:** 1.58.0

*This crate uses "2018" edition

Expand Down Expand Up @@ -40,7 +40,7 @@ Enabling the `no-std` feature does not disable `std`. To disable the `std` featu
To run the benchmarks run `RUSTFLAGS=--cfg=miniscript_bench cargo +nightly bench --all-features`.

## Minimum Supported Rust Version (MSRV)
This library should always compile with any combination of features on **Rust 1.48.0**.
This library should always compile with any combination of features on **Rust 1.58.0**.


Some dependencies do not play nicely with our MSRV, if you are running the tests
Expand Down
8 changes: 4 additions & 4 deletions bitcoind-tests/tests/test_arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use elements::pset::PartiallySignedTransaction as Psbt;
use elements::sighash::SigHashCache;
use elements::taproot::{LeafVersion, TapLeafHash};
use elements::taproot::TapLeafHash;
use elements::{
confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, Script, Sequence,
TxIn, TxOut, Txid,
Expand Down Expand Up @@ -107,9 +107,9 @@ pub fn test_desc_satisfy(cl: &ElementsD, testdata: &TestData, desc: &str) -> Vec
// ------------------ script spend -------------
let x_only_keypairs_reqd: Vec<(secp256k1::KeyPair, TapLeafHash)> = tr
.iter_scripts()
.flat_map(|(_depth, ms)| {
let leaf_hash = TapLeafHash::from_script(&ms.encode(), LeafVersion::default());
ms.iter_pk().filter_map(move |pk| {
.flat_map(|(_depth, script)| {
let leaf_hash = TapLeafHash::from_script(&script.encode(), script.version());
script.iter_pk().filter_map(move |pk| {
let i = x_only_pks.iter().position(|&x| x.to_public_key() == pk);
i.map(|idx| (xonly_keypairs[idx], leaf_hash))
})
Expand Down
8 changes: 4 additions & 4 deletions bitcoind-tests/tests/test_csfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use elements::pset::PartiallySignedTransaction as Psbt;
use elements::sighash::SigHashCache;
use elements::taproot::{LeafVersion, TapLeafHash};
use elements::taproot::TapLeafHash;
use elements::{
confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, Script, Sequence,
TxIn, TxOut, Txid,
Expand Down Expand Up @@ -108,9 +108,9 @@ pub fn test_desc_satisfy(cl: &ElementsD, testdata: &TestData, desc: &str) -> Vec
// ------------------ script spend -------------
let x_only_keypairs_reqd: Vec<(secp256k1::KeyPair, TapLeafHash)> = tr
.iter_scripts()
.flat_map(|(_depth, ms)| {
let leaf_hash = TapLeafHash::from_script(&ms.encode(), LeafVersion::default());
ms.iter_pk().filter_map(move |pk| {
.flat_map(|(_depth, script)| {
let leaf_hash = TapLeafHash::from_script(&script.encode(), script.version());
script.iter_pk().filter_map(move |pk| {
let i = x_only_pks.iter().position(|&x| x.to_public_key() == pk);
i.map(|idx| (xonly_keypairs[idx], leaf_hash))
})
Expand Down
8 changes: 4 additions & 4 deletions bitcoind-tests/tests/test_desc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{error, fmt};
use elements::hashes::{sha256d, Hash};
use elements::pset::PartiallySignedTransaction as Psbt;
use elements::sighash::SigHashCache;
use elements::taproot::{LeafVersion, TapLeafHash};
use elements::taproot::TapLeafHash;
use elements::{
confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, SchnorrSig, Script,
Sequence, TxIn, TxOut, Txid,
Expand Down Expand Up @@ -178,9 +178,9 @@ pub fn test_desc_satisfy(
// ------------------ script spend -------------
let x_only_keypairs_reqd: Vec<(secp256k1::KeyPair, TapLeafHash)> = tr
.iter_scripts()
.flat_map(|(_depth, ms)| {
let leaf_hash = TapLeafHash::from_script(&ms.encode(), LeafVersion::default());
ms.iter_pk().filter_map(move |pk| {
.flat_map(|(_depth, script)| {
let leaf_hash = TapLeafHash::from_script(&script.encode(), script.version());
script.iter_pk().filter_map(move |pk| {
let i = x_only_pks.iter().position(|&x| x.to_public_key() == pk);
i.map(|idx| (xonly_keypairs[idx], leaf_hash))
})
Expand Down
8 changes: 4 additions & 4 deletions bitcoind-tests/tests/test_introspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use elements::pset::PartiallySignedTransaction as Psbt;
use elements::sighash::SigHashCache;
use elements::taproot::{LeafVersion, TapLeafHash};
use elements::taproot::TapLeafHash;
use elements::{
confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, Script, Sequence,
TxIn, TxOut, Txid,
Expand Down Expand Up @@ -107,9 +107,9 @@ pub fn test_desc_satisfy(cl: &ElementsD, testdata: &TestData, desc: &str) -> Vec
// ------------------ script spend -------------
let x_only_keypairs_reqd: Vec<(secp256k1::KeyPair, TapLeafHash)> = tr
.iter_scripts()
.flat_map(|(_depth, ms)| {
let leaf_hash = TapLeafHash::from_script(&ms.encode(), LeafVersion::default());
ms.iter_pk().filter_map(move |pk| {
.flat_map(|(_depth, script)| {
let leaf_hash = TapLeafHash::from_script(&script.encode(), script.version());
script.iter_pk().filter_map(move |pk| {
let i = x_only_pks.iter().position(|&x| x.to_public_key() == pk);
i.map(|idx| (xonly_keypairs[idx], leaf_hash))
})
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.48.0"
msrv = "1.58.0"
4 changes: 2 additions & 2 deletions contrib/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ FEATURES="compiler serde rand base64"
cargo --version
rustc --version

# Pin dependencies required to build with Rust 1.48
if cargo --version | grep "1\.48"; then
# Pin dependencies required to build with Rust 1.58
if cargo --version | grep "1\.58"; then
cargo update -p quote --precise 1.0.28
cargo update -p proc-macro2 --precise 1.0.63
cargo update -p serde_json --precise 1.0.99
Expand Down
5 changes: 3 additions & 2 deletions examples/taproot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use miniscript::policy::Concrete;
use miniscript::{
translate_hash_fail, Descriptor, Miniscript, NoExt, Tap, TranslatePk, Translator,
};
use miniscript::descriptor::TapLeafScript;
use secp256k1::{rand, KeyPair};

// Refer to https://github.com/sanket1729/adv_btc_workshop/blob/master/workshop.md#creating-a-taproot-descriptor
Expand Down Expand Up @@ -70,14 +71,14 @@ fn main() {
iter.next().unwrap(),
(
1,
&Miniscript::<String, Tap, NoExt>::from_str("and_v(vc:pk_k(In),older(9))").unwrap()
TapLeafScript::Miniscript(&Miniscript::<String, Tap, NoExt>::from_str("and_v(vc:pk_k(In),older(9))").unwrap())
)
);
assert_eq!(
iter.next().unwrap(),
(
1,
&Miniscript::<String, Tap, NoExt>::from_str("multi_a(2,hA,S)").unwrap()
TapLeafScript::Miniscript(&Miniscript::<String, Tap, NoExt>::from_str("multi_a(2,hA,S)").unwrap())
)
);
assert_eq!(iter.next(), None);
Expand Down
2 changes: 1 addition & 1 deletion src/descriptor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub use self::key::{
DescriptorMultiXKey, DescriptorPublicKey, DescriptorSecretKey, DescriptorXKey, InnerXKey,
SinglePriv, SinglePub, SinglePubKey, Wildcard,
};
pub use self::tr::{TapTree, Tr};
pub use self::tr::{TapTree, Tr, TapLeafScript};
/// Alias type for a map of public key to secret key
///
/// This map is returned whenever a descriptor that contains secrets is parsed using
Expand Down
Loading