Skip to content

Commit 0f8550c

Browse files
authored
Merge branch 'master' into plan_spend_example_branch
2 parents b4b7d09 + 1f645ad commit 0f8550c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1083
-864
lines changed

.github/workflows/fuzz.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ compile_descriptor,
3939
key: cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
4040
- uses: actions-rs/toolchain@v1
4141
with:
42-
toolchain: 1.58
42+
toolchain: 1.64
4343
override: true
4444
profile: minimal
4545
- name: fuzz

.github/workflows/rust.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ jobs:
5454
- rust: stable
5555
- rust: beta
5656
- rust: nightly
57-
- rust: 1.41.1
58-
- rust: 1.47
57+
- rust: 1.48
5958
steps:
6059
- name: Checkout Crate
6160
uses: actions/checkout@v2

Cargo.toml

-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ no-std = ["hashbrown", "bitcoin/no-std"]
1717
compiler = []
1818
trace = []
1919

20-
unstable = []
2120
serde = ["actual-serde", "bitcoin/serde"]
2221
rand = ["bitcoin/rand"]
2322
base64 = ["bitcoin/base64"]
@@ -34,7 +33,6 @@ actual-serde = { package = "serde", version = "1.0.103", optional = true }
3433
serde_test = "1.0.147"
3534
bitcoin = { version = "0.30.0", features = ["base64"] }
3635
secp256k1 = {version = "0.27.0", features = ["rand-std"]}
37-
actual-base64 = { package = "base64", version = "0.13.0" }
3836

3937
[[example]]
4038
name = "htlc"
@@ -52,10 +50,6 @@ required-features = ["std"]
5250
name = "verify_tx"
5351
required-features = ["std"]
5452

55-
[[example]]
56-
name = "psbt"
57-
required-features = ["std"]
58-
5953
[[example]]
6054
name = "xpub_descriptors"
6155
required-features = ["std"]

README.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Build](https://github.com/rust-bitcoin/rust-miniscript/workflows/Continuous%20integration/badge.svg)
22

3-
**Minimum Supported Rust Version:** 1.41.1
3+
**Minimum Supported Rust Version:** 1.48.0
44

55
# Miniscript
66

@@ -40,18 +40,10 @@ The cargo feature `std` is enabled by default. At least one of the features `std
4040
Enabling the `no-std` feature does not disable `std`. To disable the `std` feature you must disable default features. The `no-std` feature only enables additional features required for this crate to be usable without `std`. Both can be enabled without conflict.
4141

4242
## Minimum Supported Rust Version (MSRV)
43-
This library should always compile with any combination of features (minus
44-
`no-std`) on **Rust 1.41.1** or **Rust 1.47** with `no-std`.
43+
This library should always compile with any combination of features on **Rust 1.48.0**.
4544

4645
Some dependencies do not play nicely with our MSRV, if you are running the tests
47-
you may need to pin as follows:
48-
49-
```
50-
cargo update --package url --precise 2.2.2
51-
cargo update --package form_urlencoded --precise 1.0.1
52-
cargo update -p once_cell --precise 1.13.1
53-
cargo update -p bzip2 --precise 0.4.2
54-
```
46+
you may need to pin some dependencies. See `./contrib/test.sh` for current pinning.
5547

5648
## Contributing
5749

@@ -61,6 +53,11 @@ architectural mismatches. If you have any questions or ideas you want to discuss
6153
please join us in
6254
[##miniscript](https://web.libera.chat/?channels=##miniscript) on Libera.
6355

56+
## Benchmarks
57+
58+
We use a custom Rust compiler configuration conditional to guard the bench mark code. To run the
59+
bench marks use: `RUSTFLAGS='--cfg=bench' cargo +nightly bench`.
60+
6461

6562
## Release Notes
6663

clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.41.1"
1+
msrv = "1.48.0"

contrib/test.sh

+24-12
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,28 @@ FEATURES="compiler serde rand base64"
77
cargo --version
88
rustc --version
99

10+
# Cache the toolchain we are using.
11+
NIGHTLY=false
12+
if cargo --version | grep nightly; then
13+
NIGHTLY=true
14+
fi
15+
1016
# Format if told to
1117
if [ "$DO_FMT" = true ]
1218
then
1319
rustup component add rustfmt
1420
cargo fmt -- --check
1521
fi
1622

17-
# Pin dependencies required to build with Rust 1.41.1
18-
if cargo --version | grep "1\.41\.0"; then
19-
cargo update -p once_cell --precise 1.13.1
20-
cargo update -p serde --precise 1.0.156
21-
fi
22-
23-
# Pin dependencies required to build with Rust 1.47.0
24-
if cargo --version | grep "1\.47\.0"; then
23+
# Pin dependencies required to build with Rust 1.48.0
24+
if cargo --version | grep "1\.48\.0"; then
2525
cargo update -p once_cell --precise 1.13.1
26-
cargo update -p serde --precise 1.0.156
26+
cargo update -p quote --precise 1.0.28
27+
cargo update -p proc-macro2 --precise 1.0.63
28+
cargo update -p serde_json --precise 1.0.99
29+
cargo update -p serde --precise 1.0.152
30+
cargo update -p log --precise 0.4.18
31+
cargo update -p serde_test --precise 1.0.152
2732
fi
2833

2934
# Test bitcoind integration tests if told to (this only works with the stable toolchain)
@@ -56,7 +61,6 @@ then
5661
cargo run --example parse
5762
cargo run --example sign_multisig
5863
cargo run --example verify_tx > /dev/null
59-
cargo run --example psbt
6064
cargo run --example xpub_descriptors
6165
cargo run --example taproot --features=compiler
6266
cargo run --example psbt_sign_finalize --features=base64
@@ -80,10 +84,18 @@ then
8084
done
8185
fi
8286

83-
# Bench if told to (this only works with the nightly toolchain)
87+
# Bench if told to, only works with non-stable toolchain (nightly, beta).
8488
if [ "$DO_BENCH" = true ]
8589
then
86-
cargo bench --features="unstable compiler"
90+
if [ "$NIGHTLY" = false ]; then
91+
if [ -n "$RUSTUP_TOOLCHAIN" ]; then
92+
echo "RUSTUP_TOOLCHAIN is set to a non-nightly toolchain but DO_BENCH requires a nightly toolchain"
93+
else
94+
echo "DO_BENCH requires a nightly toolchain"
95+
fi
96+
exit 1
97+
fi
98+
RUSTFLAGS='--cfg=bench' cargo bench
8799
fi
88100

89101
# Build the docs if told to (this only works with the nightly toolchain)

examples/htlc.rs

+5-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
// Miniscript
2-
// Written in 2019 by
3-
// Thomas Eizinger <[email protected]>
4-
//
5-
// To the extent possible under law, the author(s) have dedicated all
6-
// copyright and related and neighboring rights to this software to
7-
// the public domain worldwide. This software is distributed without
8-
// any warranty.
9-
//
10-
// You should have received a copy of the CC0 Public Domain Dedication
11-
// along with this software.
12-
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
13-
//
1+
// Written by Thomas Eizinger <[email protected]>
2+
// SPDX-License-Identifier: CC0-1.0
143

154
//! Example: Create an HTLC with miniscript using the policy compiler
165
176
use std::str::FromStr;
187

19-
use bitcoin::Network;
8+
use miniscript::bitcoin::Network;
209
use miniscript::descriptor::Wsh;
2110
use miniscript::policy::{Concrete, Liftable};
2211

@@ -51,7 +40,7 @@ fn main() {
5140
"or(and(pk(022222222222222222222222222222222222222222222222222222222222222222),sha256(1111111111111111111111111111111111111111111111111111111111111111)),and(pk(020202020202020202020202020202020202020202020202020202020202020202),older(4444)))"
5241
);
5342

54-
// Get the scriptPpubkey for this Wsh descriptor.
43+
// Get the scriptPubkey for this Wsh descriptor.
5544
assert_eq!(
5645
format!("{:x}", htlc_descriptor.script_pubkey()),
5746
"0020d853877af928a8d2a569c9c0ed14bd16f6a80ce9cccaf8a6150fd8f7f8867ae2"
@@ -63,7 +52,7 @@ fn main() {
6352
"21022222222222222222222222222222222222222222222222222222222222222222ac6476a91451814f108670aced2d77c1805ddd6634bc9d473188ad025c11b26782012088a82011111111111111111111111111111111111111111111111111111111111111118768"
6453
);
6554

66-
// Get the address for this Wsh descriptor.v
55+
// Get the address for this Wsh descriptor.
6756
assert_eq!(
6857
format!("{}", htlc_descriptor.address(Network::Bitcoin)),
6958
"bc1qmpfcw7he9z5d9ftfe8qw699azmm2sr8fen903fs4plv007yx0t3qxfmqv5"

examples/parse.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
// Miniscript
2-
// Written in 2019 by
3-
// Andrew Poelstra <[email protected]>
4-
//
5-
// To the extent possible under law, the author(s) have dedicated all
6-
// copyright and related and neighboring rights to this software to
7-
// the public domain worldwide. This software is distributed without
8-
// any warranty.
9-
//
10-
// You should have received a copy of the CC0 Public Domain Dedication
11-
// along with this software.
12-
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
13-
//
1+
// SPDX-License-Identifier: CC0-1.0
142

153
//! Example: Parsing a descriptor from a string.
164

examples/psbt_sign_finalize.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
13
use std::collections::BTreeMap;
24
use std::str::FromStr;
35

4-
use actual_base64 as base64;
5-
use bitcoin::sighash::SighashCache;
6-
use bitcoin::PrivateKey;
76
use miniscript::bitcoin::consensus::encode::deserialize;
87
use miniscript::bitcoin::hashes::hex::FromHex;
9-
use miniscript::bitcoin::psbt::PartiallySignedTransaction as Psbt;
8+
use miniscript::bitcoin::psbt::{self, Psbt};
9+
use miniscript::bitcoin::sighash::SighashCache;
1010
use miniscript::bitcoin::{
11-
self, psbt, secp256k1, Address, Network, OutPoint, Script, Sequence, Transaction, TxIn, TxOut,
11+
self, base64, secp256k1, Address, Network, OutPoint, PrivateKey, Script, Sequence, Transaction,
12+
TxIn, TxOut,
1213
};
1314
use miniscript::plan::Assets;
1415
use miniscript::psbt::{PsbtExt, PsbtInputExt};

examples/sign_multisig.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
// Miniscript
2-
// Written in 2019 by
3-
// Andrew Poelstra <[email protected]>
4-
//
5-
// To the extent possible under law, the author(s) have dedicated all
6-
// copyright and related and neighboring rights to this software to
7-
// the public domain worldwide. This software is distributed without
8-
// any warranty.
9-
//
10-
// You should have received a copy of the CC0 Public Domain Dedication
11-
// along with this software.
12-
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
13-
//
1+
// SPDX-License-Identifier: CC0-1.0
142

153
//! Example: Signing a 2-of-3 multisignature.
164

examples/taproot.rs

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
13
use std::collections::HashMap;
24
use std::str::FromStr;
35

4-
use bitcoin::address::WitnessVersion;
5-
use bitcoin::key::XOnlyPublicKey;
6-
use bitcoin::secp256k1::{rand, KeyPair};
7-
use bitcoin::Network;
6+
use miniscript::bitcoin::address::WitnessVersion;
7+
use miniscript::bitcoin::key::{KeyPair, XOnlyPublicKey};
8+
use miniscript::bitcoin::secp256k1::rand;
9+
use miniscript::bitcoin::Network;
810
use miniscript::descriptor::DescriptorType;
911
use miniscript::policy::Concrete;
1012
use miniscript::{translate_hash_fail, Descriptor, Miniscript, Tap, TranslatePk, Translator};
@@ -21,9 +23,8 @@ impl Translator<String, XOnlyPublicKey, ()> for StrPkTranslator {
2123
self.pk_map.get(pk).copied().ok_or(())
2224
}
2325

24-
// We don't need to implement these methods as we are not using them in the policy
25-
// Fail if we encounter any hash fragments.
26-
// See also translate_hash_clone! macro
26+
// We don't need to implement these methods as we are not using them in the policy.
27+
// Fail if we encounter any hash fragments. See also translate_hash_clone! macro.
2728
translate_hash_fail!(String, XOnlyPublicKey, ());
2829
}
2930

@@ -39,7 +40,7 @@ fn main() {
3940
.replace(&[' ', '\n', '\t'][..], "");
4041

4142
let _ms = Miniscript::<String, Tap>::from_str("and_v(v:ripemd160(H),pk(A))").unwrap();
42-
let pol: Concrete<String> = Concrete::from_str(&pol_str).unwrap();
43+
let pol = Concrete::<String>::from_str(&pol_str).unwrap();
4344
// In case we can't find an internal key for the given policy, we set the internal key to
4445
// a random pubkey as specified by BIP341 (which are *unspendable* by any party :p)
4546
let desc = pol.compile_tr(Some("UNSPENDABLE_KEY".to_string())).unwrap();
@@ -52,7 +53,7 @@ fn main() {
5253
// Check whether the descriptors are safe.
5354
assert!(desc.sanity_check().is_ok());
5455

55-
// Descriptor Type and Version should match respectively for Taproot
56+
// Descriptor type and version should match respectively for taproot
5657
let desc_type = desc.desc_type();
5758
assert_eq!(desc_type, DescriptorType::Tr);
5859
assert_eq!(desc_type.segwit_version().unwrap(), WitnessVersion::V1);
@@ -99,11 +100,12 @@ fn main() {
99100

100101
let real_desc = desc.translate_pk(&mut t).unwrap();
101102

102-
// Max Satisfaction Weight for compilation, corresponding to the script-path spend
103-
// `multi_a(2,PUBKEY_1,PUBKEY_2) at taptree depth 1, having
104-
// Max Witness Size = varint(control_block_size) + control_block size +
105-
// varint(script_size) + script_size + max_satisfaction_size
106-
// = 1 + 65 + 1 + 70 + 132 = 269
103+
// Max satisfaction weight for compilation, corresponding to the script-path spend
104+
// `multi_a(2,PUBKEY_1,PUBKEY_2) at taptree depth 1, having:
105+
//
106+
// max_witness_size = varint(control_block_size) + control_block size +
107+
// varint(script_size) + script_size + max_satisfaction_size
108+
// = 1 + 65 + 1 + 70 + 132 = 269
107109
let max_sat_wt = real_desc.max_weight_to_satisfy().unwrap();
108110
assert_eq!(max_sat_wt, 269);
109111

examples/verify_tx.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
// Miniscript
2-
// Written in 2019 by
3-
// Andrew Poelstra <[email protected]>
4-
//
5-
// To the extent possible under law, the author(s) have dedicated all
6-
// copyright and related and neighboring rights to this software to
7-
// the public domain worldwide. This software is distributed without
8-
// any warranty.
9-
//
10-
// You should have received a copy of the CC0 Public Domain Dedication
11-
// along with this software.
12-
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
13-
//
1+
// SPDX-License-Identifier: CC0-1.0
142

153
//! Example: Verifying a signed transaction.
164
175
use std::str::FromStr;
186

19-
use bitcoin::consensus::Decodable;
20-
use bitcoin::secp256k1::{self, Secp256k1};
21-
use bitcoin::{absolute, sighash, Sequence};
7+
use miniscript::bitcoin::consensus::Decodable;
8+
use miniscript::bitcoin::secp256k1::{self, Secp256k1};
9+
use miniscript::bitcoin::{absolute, sighash, Sequence};
2210
use miniscript::interpreter::KeySigPair;
2311

2412
fn main() {

examples/xpub_descriptors.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
// Miniscript
2-
// Written in 2019 by
3-
// Andrew Poelstra <[email protected]>
4-
//
5-
// To the extent possible under law, the author(s) have dedicated all
6-
// copyright and related and neighboring rights to this software to
7-
// the public domain worldwide. This software is distributed without
8-
// any warranty.
9-
//
10-
// You should have received a copy of the CC0 Public Domain Dedication
11-
// along with this software.
12-
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
13-
//
1+
// SPDX-License-Identifier: CC0-1.0
142

153
//! Example: Parsing a xpub and getting an address.
164

fuzz/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cargo-fuzz = true
1212
honggfuzz = { version = "0.5.55", default-features = false }
1313
miniscript = { path = "..", features = [ "compiler" ] }
1414

15-
regex = "1.4"
15+
regex = "1.0"
1616

1717
[[bin]]
1818
name = "roundtrip_miniscript_str"

0 commit comments

Comments
 (0)