Skip to content

Commit dc1f5ee

Browse files
committed
Merge #43: Update 03 20 2023
20dd79c rust doc fixes (sanket1729) a300697 CI fixes for MSRV and benches (sanket1729) 0ac0326 Add int tests to workflow (sanket1729) 91f5c2d Move elementsd test to separate directory (sanket1729) 25ccd25 Removed previous mistakenly checked in integration tests (sanket1729) 2f84d32 Add README build docs for std and no-std (Steve Myers) d1c71e3 Add build error if both std and no-std features disabled (Steve Myers) 7118c84 Add breaking tests (sanket1729) 0203377 Update multi_a to not include n wrapper (sanket1729) 3502477 Serde for DescriptorPublicKey (Scott Robinson) a0b001b hexify for better error message (Harshil Jani) 76fb99c Fix the CI failing due to `which` crate (Harshil Jani) ebe3245 Fixing the Inclusivity of Z in StrKeyTranslator (Harshil Jani) 360eed7 Add some compiler documentation (sanket1729) 3fcc84c Update TapTree::iter docs (sanket1729) 1e30000 Make checksum pub (sanket1729) cf05787 Remove fixed TODO (sanket1729) e94efbf Clarify that alloy tests don't actually test timelock mixing (sanket1729) 62219d4 Fix CI (sanket1729) 0b482cd Use hash_newtype macro instead of the hash256 module (Tobin C. Harding) 4eaf261 Fix CI (sanket1729) 842ae93 Use p2wpkh_script_code from rust-bitcoin (Tobin C. Harding) 7296f8e Introduce `max_weight_to_satisfy` (志宇) 1477dbb DefiniteDescriptorKey: provide additional methods for converting to a DescriptorPublicKey (Andrew Poelstra) 2c67681 Add base64 feature (Tobin C. Harding) f0f7fd6 fix formatting after #507 (Andrew Poelstra) eeb823f Remove DummyKey (Tobin C. Harding) ebaa31b Enable usage of -D rustdoc::broken-intra-doc-links (Tobin C. Harding) 16b6c76 Improve docs on enumerate_policy_tree (Tobin C. Harding) 90dc766 Do trivial cleanup to main lib docs (Tobin C. Harding) b069239 Take self by value (Tobin C. Harding) 29b6272 Introduce SPDX identifiers (Tobin C. Harding) 8c48538 Clean up DO_NO_STD usage (Tobin C. Harding) cc32761 Use 1.58.0 directly (Tobin C. Harding) 1a098ad Fix spelling mistake it CI job (Tobin C. Harding) 5705902 Remove DO_NO_STD from fuzz job (Tobin C. Harding) 8b85649 Remove MSRV local variable (Tobin C. Harding) 2edc456 Remove --all flag (Tobin C. Harding) 1a09248 Remove flags from shebang line (Tobin C. Harding) fb4c33b Use if let and panic (Tobin C. Harding) b481cba Use allow attribute (Tobin C. Harding) 6b6f808 Use any combinator (Tobin C. Harding) 6088c25 Use {} instead of explicit return (Tobin C. Harding) 06c9617 Remove unnecessary cast (Tobin C. Harding) eb38507 Do not use bool in assert_eq macro (Tobin C. Harding) 3c46e4c Use expect_err (Tobin C. Harding) 9c377b2 Remove useless use of format (Tobin C. Harding) bf44938 Remove unneeded calls to clone (Tobin C. Harding) 227a3a9 Remove identical if blocks (Tobin C. Harding) 45091a8 Remove unneeded explicit lifetimes (Tobin C. Harding) 2e70cd0 Do not manually convert bool to integer (Tobin C. Harding) c4ab53e Use &str not &String (Tobin C. Harding) b81f08c Return result of function call (Tobin C. Harding) fc37f41 Use unwrap_or_default (Tobin C. Harding) f0820ce Remove redundant explicit references (Tobin C. Harding) 64c6e51 Fix pattern matching ref/deref (Tobin C. Harding) a923855 Do not use redundant closures (Tobin C. Harding) 4ab7e7a Use terse struct construction form (Tobin C. Harding) 9d1a984 Remove 'static from &str (Tobin C. Harding) b9df24c Clear block can be collapsed warnings (Tobin C. Harding) 98e47d5 Remove support for 1.29 (Tobin C. Harding) ae0f3d9 desc: check for mismatch in the number of derivation paths between multipath keys (Antoine Poinsot) 131bb5b descriptors: BIP389 multipath descriptors support (Antoine Poinsot) cf401b6 desc keys: add a method to get single-path keys from multipath keys (Antoine Poinsot) b5eb317 desc keys: unit tests for multipath key expressions (Antoine Poinsot) 34472bb desc keys: implement BIP389 multipath key expressions (Antoine Poinsot) e122255 desc keys: make 'at_derivation_index' return an error instead of panicing (Antoine Poinsot) ccd7ef1 desc keys: make parse_xkey_deriv a standalone function (Antoine Poinsot) fb3cb90 desc keys: rename parse_xkey_origin to parse_key_origin (Antoine Poinsot) 60732fb desc keys: make origin key parsing a standalone function (Antoine Poinsot) 8e781ca Derive comparison traits for all secret key types (Scott Robinson) a113e35 Release 9.0.0 (sanket1729) 63ceb5b Add psbt example for sign and finalize (sanket1729) 8f86992 Don't run rawpkh logic through pkh (sanket1729) 815fd1c Bug fix: pkh->pk lookup API (sanket1729) 43abc43 Use expr_raw_pk_h for Terminal::RawPkH (sanket1729) 480c3fd replaced if else return with mapping (BufferOverflow) Pull request description: Includes all updates from the previous 30 PRs since last merge. ACKs for top commit: apoelstra: ACK 20dd79c Tree-SHA512: 029e76111789c66cb1472f342d3eed0625bd46715f832d6f071435dfa9117444b860b235f4bde5543551c687a548f61a49844221c5ae98732a9034c6f69ad3d4
2 parents eaa3ad6 + 20dd79c commit dc1f5ee

Some content is hidden

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

76 files changed

+2079
-1616
lines changed

.github/workflows/rust.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ jobs:
66
lint_fuzz_stable:
77
name: Lint + Fuzz
88
runs-on: ubuntu-latest
9-
strategy:
10-
matrix:
11-
rust:
12-
- 1.58.0
139
steps:
1410
- name: Checkout Crate
1511
uses: actions/checkout@v2
@@ -19,7 +15,7 @@ jobs:
1915
uses: actions-rs/toolchain@v1
2016
with:
2117
profile: minimal
22-
toolchain: ${{ matrix.rust }}
18+
toolchain: 1.58.0
2319
override: true
2420
- name: Running fuzzer
2521
env:
@@ -48,6 +44,23 @@ jobs:
4844
DO_DOCS: true
4945
run: ./contrib/test.sh
5046

47+
Int-tests:
48+
name: Integration tests
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout Crate
52+
uses: actions/checkout@v2
53+
- name: Checkout Toolchain
54+
uses: actions-rs/toolchain@v1
55+
with:
56+
profile: minimal
57+
toolchain: stable
58+
override: true
59+
- name: Running integration tests
60+
env:
61+
DO_BITCOIND_TESTS: true
62+
run: ./contrib/test.sh
63+
5164
Tests:
5265
name: Tests
5366
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 9.0.0 - November 5, 2022
2+
3+
- Fixed a bug dealing with dissatisfying pkh inside thresh
4+
- Changed the signature of `Satisfier::lookup_raw_pkh_pk` API. Only custom implementations
5+
of `Satisfier` need to be updated. The psbt APIs are unchanged.
6+
- Fixed a bug related to display of `raw_pk_h`. These descriptors are experimental
7+
and only usable by opting via `ExtParams` while parsing string.
18
# 8.0.0 - October 20, 2022
29

310
This release contains several significant API overhauls, as well as a bump

Cargo.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,24 @@ trace = []
1717
unstable = []
1818
serde = ["actual-serde", "bitcoin/serde"]
1919
rand = ["bitcoin/rand"]
20+
base64 = ["bitcoin/base64"]
2021

2122
[dependencies]
2223
bitcoin = "0.29.1"
2324
elements = "0.21.0"
24-
bitcoin-miniscript = { package = "miniscript", version = "9.0" }
25+
bitcoin-miniscript = { package = "miniscript", version = "9.0", git = "https://github.com/rust-bitcoin/rust-miniscript", rev = "1351c20a5ead4f308e18bce88cc01983c7d0e876" }
2526

2627
# Do NOT use this as a feature! Use the `serde` feature instead.
2728
actual-serde = { package = "serde", version = "1.0", optional = true }
2829

2930
[dev-dependencies]
3031
serde_json = "1.0"
31-
elementsd = {version = "0.6.0", features=["0_21_0","bitcoind_22_0"]}
3232
actual-rand = { package = "rand", version = "0.8.4"}
33+
serde_test = "1.0.147"
34+
bitcoin = { version = "0.29.2", features = ["base64"] }
3335
secp256k1 = {version = "0.24.0", features = ["rand-std"]}
36+
actual-base64 = { package = "base64", version = "0.13.0" }
37+
3438

3539
[[example]]
3640
name = "htlc"
@@ -51,3 +55,7 @@ name = "xpub_descriptors"
5155
[[example]]
5256
name = "taproot"
5357
required-features = ["compiler"]
58+
59+
[[example]]
60+
name = "psbt_sign_finalize"
61+
required-features = ["base64"]

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ coins in a given Bitcoin transaction
2929
More information can be found in [the documentation](https://docs.rs/elements-miniscript)
3030
or in [the `examples/` directory](https://github.com/ElementsProject/elements-miniscript/tree/master/examples)
3131

32+
## Building
33+
34+
The cargo feature `std` is enabled by default. At least one of the features `std` or `no-std` or both must be enabled.
35+
36+
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.
3237

3338
## Minimum Supported Rust Version (MSRV)
3439
This library should always compile with any combination of features on **Rust 1.41.1**.
@@ -52,6 +57,14 @@ architectural mismatches. If you have any questions or ideas you want to discuss
5257
please join us in
5358
[##miniscript](https://web.libera.chat/?channels=##miniscript) on Libera.
5459

55-
# Release Notes
60+
61+
## Release Notes
5662

5763
See [CHANGELOG.md](CHANGELOG.md).
64+
65+
66+
## Licensing
67+
68+
The code in this project is licensed under the [Creative Commons CC0 1.0
69+
Universal license](LICENSE). We use the [SPDX license list](https://spdx.org/licenses/) and [SPDX
70+
IDs](https://spdx.dev/ids/).

bitcoind-tests/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "bitcoind-tests"
3+
version = "0.1.0"
4+
authors = ["sanket1729 <[email protected]>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
elements-miniscript = {path = "../"}
11+
elementsd = {version = "0.6.0", features=["0_21_0","bitcoind_22_0"]}
12+
actual-rand = { package = "rand", version = "0.8.4"}
13+
secp256k1 = {version = "0.24.0", features = ["rand-std"]}
File renamed without changes.

tests/setup/mod.rs renamed to bitcoind-tests/tests/setup/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub extern crate elements_miniscript;
22

33
use std::str::FromStr;
4-
4+
use miniscript::elements;
55
use elements::encode::{deserialize, serialize_hex};
66
use elements::hashes::hex::FromHex;
77
use elements::BlockHash;

tests/setup/test_util.rs renamed to bitcoind-tests/tests/setup/test_util.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
use std::collections::HashMap;
2121
use std::str::FromStr;
2222

23-
use bitcoin::hashes::hex::ToHex;
24-
use bitcoin::hashes::{hash160, ripemd160, sha256, Hash};
25-
use bitcoin::secp256k1;
23+
use miniscript::{elements, bitcoin};
24+
use elements::hashes::hex::ToHex;
25+
use elements::hashes::{hash160, ripemd160, sha256, Hash};
26+
use elements::secp256k1_zkp as secp256k1;
2627
use elements::hashes::hex::FromHex;
2728
use elements::{confidential, encode, AddressParams, BlockHash};
2829
use miniscript::descriptor::{SinglePub, SinglePubKey};

tests/test_arith.rs renamed to bitcoind-tests/tests/test_arith.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
//! Arith expression fragment integration tests
44
//!
55
6+
use miniscript::elements;
67
use elements::pset::PartiallySignedTransaction as Psbt;
78
use elements::sighash::SigHashCache;
89
use elements::taproot::{LeafVersion, TapLeafHash};
910
use elements::{
10-
self, confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, Script,
11+
confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, Script,
1112
Sequence, TxIn, TxOut, Txid,
1213
};
1314
use elementsd::ElementsD;
@@ -44,7 +45,8 @@ pub fn test_desc_satisfy(cl: &ElementsD, testdata: &TestData, desc: &str) -> Vec
4445

4546
let definite_desc = test_util::parse_test_desc(&desc, &testdata.pubdata)
4647
.unwrap()
47-
.at_derivation_index(0);
48+
.at_derivation_index(0)
49+
.unwrap();
4850

4951
let derived_desc = definite_desc.derived_descriptor(&secp).unwrap();
5052
let desc_address = derived_desc.address(&PARAMS).unwrap(); // No blinding

tests/test_cpp.rs renamed to bitcoind-tests/tests/test_cpp.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
use std::fs::File;
88
use std::io::{self, BufRead};
99
use std::path::Path;
10+
use miniscript::{elements, bitcoin};
1011

1112
use bitcoin::hashes::{sha256d, Hash};
1213
use bitcoin::secp256k1::{self, Secp256k1};
1314
use elements::pset::PartiallySignedTransaction as Psbt;
1415
use elements::{
15-
self, confidential, pset as psbt, secp256k1_zkp, AssetIssuance, LockTime, OutPoint, Script,
16+
confidential, pset as psbt, secp256k1_zkp, AssetIssuance, LockTime, OutPoint, Script,
1617
Sequence, TxIn, TxInWitness, TxOut, TxOutWitness, Txid,
1718
};
1819
use elements_miniscript as miniscript;

tests/test_csfs.rs renamed to bitcoind-tests/tests/test_csfs.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
//! CheckSigFromStack integration tests
44
//!
55
6+
use miniscript::{elements, bitcoin};
67
use elements::pset::PartiallySignedTransaction as Psbt;
78
use elements::sighash::SigHashCache;
89
use elements::taproot::{LeafVersion, TapLeafHash};
910
use elements::{
10-
self, confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, Script,
11+
confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, Script,
1112
Sequence, TxIn, TxOut, Txid,
1213
};
1314
use elementsd::ElementsD;
@@ -44,7 +45,8 @@ pub fn test_desc_satisfy(cl: &ElementsD, testdata: &TestData, desc: &str) -> Vec
4445

4546
let definite_desc = test_util::parse_test_desc(&desc, &testdata.pubdata)
4647
.unwrap()
47-
.at_derivation_index(0);
48+
.at_derivation_index(0)
49+
.unwrap();
4850

4951
let derived_desc = definite_desc.derived_descriptor(&secp).unwrap();
5052
let desc_address = derived_desc.address(&PARAMS).unwrap(); // No blinding

tests/test_desc.rs renamed to bitcoind-tests/tests/test_desc.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
77
use std::{error, fmt};
88

9+
use miniscript::{elements, bitcoin};
910
use elements::hashes::{sha256d, Hash};
1011
use elements::pset::PartiallySignedTransaction as Psbt;
1112
use elements::sighash::SigHashCache;
1213
use elements::taproot::{LeafVersion, TapLeafHash};
1314
use elements::{
14-
self, confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, SchnorrSig,
15+
confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, SchnorrSig,
1516
Script, Sequence, TxIn, TxOut, Txid,
1617
};
1718
use elementsd::ElementsD;
@@ -77,7 +78,8 @@ pub fn test_desc_satisfy(
7778

7879
let definite_desc = test_util::parse_test_desc(&descriptor, &testdata.pubdata)
7980
.map_err(|_| DescError::DescParseError)?
80-
.at_derivation_index(0);
81+
.at_derivation_index(0)
82+
.unwrap();
8183

8284
let derived_desc = definite_desc.derived_descriptor(&secp).unwrap();
8385
let desc_address = derived_desc.address(&PARAMS); // No blinding
@@ -384,6 +386,10 @@ fn test_descs(cl: &ElementsD, testdata: &TestData) {
384386
let result = test_desc_satisfy(cl, testdata, "tr(X!,{pk(X1!),pk(X2!)})");
385387
assert_eq!(result, Err(DescError::PsbtFinalizeError));
386388

389+
// Test 10: Test taproot desc with ZERO known keys
390+
let result = test_desc_satisfy(cl, testdata, "tr(X!,j:multi_a(3,X1!,X2,X3,X4))");
391+
assert_eq!(result, Err(DescError::DescParseError));
392+
387393
// Test 11: Test taproot with insufficient known keys
388394
let result = test_desc_satisfy(cl, testdata, "tr(X!,{pk(X1!),multi_a(3,X2!,X3,X4)})");
389395
assert_eq!(result, Err(DescError::PsbtFinalizeError));

tests/test_introspect.rs renamed to bitcoind-tests/tests/test_introspect.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
//! Arith expression fragment integration tests
44
//!
55
6+
use miniscript::elements;
67
use elements::pset::PartiallySignedTransaction as Psbt;
78
use elements::sighash::SigHashCache;
89
use elements::taproot::{LeafVersion, TapLeafHash};
910
use elements::{
10-
self, confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, Script,
11+
confidential, pset as psbt, secp256k1_zkp as secp256k1, sighash, OutPoint, Script,
1112
Sequence, TxIn, TxOut, Txid,
1213
};
1314
use elementsd::ElementsD;
@@ -44,7 +45,8 @@ pub fn test_desc_satisfy(cl: &ElementsD, testdata: &TestData, desc: &str) -> Vec
4445

4546
let definite_desc = test_util::parse_test_desc(&desc, &testdata.pubdata)
4647
.unwrap()
47-
.at_derivation_index(0);
48+
.at_derivation_index(0)
49+
.unwrap();
4850

4951
let derived_desc = definite_desc.derived_descriptor(&secp).unwrap();
5052
let desc_address = derived_desc.address(&PARAMS).unwrap(); // No blinding

contrib/test.sh

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,23 @@
1-
#!/bin/sh -ex
1+
#!/bin/sh
22

3-
set -e
3+
set -ex
44

5-
FEATURES="compiler serde rand"
6-
7-
cargo update -p serde --precise 1.0.142
8-
cargo update -p serde_derive --precise 1.0.142
5+
FEATURES="compiler serde rand base64"
96

107
cargo --version
118
rustc --version
129

13-
# Work out if we are using a nightly toolchain.
14-
MSRV=false
10+
# Pin dependencies required to build with Rust 1.41.1
1511
if cargo --version | grep "1\.41\.0"; then
16-
MSRV=true
17-
fi
18-
19-
if cargo --version | grep "1\.47\.0"; then
20-
cargo update -p once_cell --precise 1.13.1
21-
fi
22-
23-
# form_urlencoded 1.1.0 breaks MSRV.
24-
if [ "$MSRV" = true ]; then
25-
cargo update -p url --precise 2.2.2
26-
cargo update -p form_urlencoded --precise 1.0.1
27-
cargo update -p once_cell --precise 1.13.1
28-
cargo update -p bzip2 --precise 0.4.2
29-
cargo update -p which --precise 4.3.0
12+
cargo update -p serde --precise 1.0.156
13+
cargo update -p syn --precise 1.0.107
3014
fi
3115

3216
# Format if told to
3317
if [ "$DO_FMT" = true ]
3418
then
3519
rustup component add rustfmt
36-
cargo fmt --all -- --check
20+
cargo fmt -- --check
3721
fi
3822

3923
# Fuzz if told to
@@ -47,6 +31,15 @@ then
4731
exit 0
4832
fi
4933

34+
# Test bitcoind integration tests if told to (this only works with the stable toolchain)
35+
if [ "$DO_BITCOIND_TESTS" = true ]; then
36+
cd bitcoind-tests
37+
cargo test --verbose
38+
39+
# Exit integration tests, do not run other tests.
40+
exit 0
41+
fi
42+
5043
# Defaults / sanity checks
5144
cargo test
5245

@@ -69,6 +62,7 @@ then
6962
cargo run --example verify_tx > /dev/null
7063
cargo run --example xpub_descriptors
7164
cargo run --example taproot --features=compiler
65+
cargo run --example psbt_sign_finalize --features=base64
7266
fi
7367

7468
# Bench if told to (this only works with the nightly toolchain)
@@ -79,7 +73,7 @@ fi
7973

8074
# Build the docs if told to (this only works with the nightly toolchain)
8175
if [ "$DO_DOCS" = true ]; then
82-
RUSTDOCFLAGS="--cfg docsrs" cargo doc --all --features="$FEATURES"
76+
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly rustdoc --features="$FEATURES" -- -D rustdoc::broken-intra-doc-links
8377
fi
8478

8579
exit 0

0 commit comments

Comments
 (0)