Skip to content

Commit 1918c57

Browse files
committed
Merge #89: Fix a bunch of clippy lints and get CI working again
e151a85 ci: bump fuzz MSRV to 1.65 (Andrew Poelstra) b10c7a2 ci: add one more pin (Andrew Poelstra) 7c977b5 ForEachKey: clean up Concrete impl, remove Semantic impl (Andrew Poelstra) 8bc9311 doc: improve list of fields covered by sighash (Andrew Poelstra) 97b2229 clippy: unnecessary vecs (Andrew Poelstra) 8894215 clippy: miscellaneous simple fixes (Andrew Poelstra) fcb2c3d clippy: canonical partial_cmp implementations (Andrew Poelstra) bb88c18 clippy: replace fold calls with try_fold (Andrew Poelstra) 9815ca7 rustc: silence some "dead code" warnings (Andrew Poelstra) 4bab769 rustfmt: change to new notation (Andrew Poelstra) de4e2ec cargo: lint unused cfg parameters (Andrew Poelstra) Pull request description: Probably needs #88 to go in in parallel. ACKs for top commit: RCasatta: utACK e151a85 Tree-SHA512: 80260fa8b38c543b437230b1f6e2464ef97a1755ff3565ae8204f7fbfe55fe0b5a197632de48dce8bc2e0170d0e30f5a3676314f62ce61cee8b5b0c6b7c83487
2 parents 9898534 + e151a85 commit 1918c57

File tree

23 files changed

+69
-104
lines changed

23 files changed

+69
-104
lines changed

.github/workflows/fuzz.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ roundtrip_confidential,
4040
key: cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
4141
- uses: actions-rs/toolchain@v1
4242
with:
43-
toolchain: 1.58
43+
toolchain: 1.65
4444
override: true
4545
profile: minimal
4646
- name: fuzz

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ bitcoin = { version = "0.31.0", features = ["base64"] }
3535
secp256k1 = {version = "0.28.0", features = ["rand-std"]}
3636
actual-base64 = { package = "base64", version = "0.13.0" }
3737

38+
[lints.rust]
39+
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(miniscript_bench)'] }
3840

3941
[[example]]
4042
name = "htlc"

contrib/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ rustc --version
1111
if cargo --version | grep "1\.58"; then
1212
cargo update -p byteorder --precise 1.4.3
1313
cargo update -p cc --precise 1.0.94
14+
cargo update -p ppv-lite86 --precise 0.2.17
1415
fi
1516

1617
# Format if told to

examples/sign_multisig.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ fn main() {
4646
}],
4747
};
4848

49-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
50-
let public_keys = vec![
49+
#[rustfmt::skip]
50+
let public_keys = [
5151
bitcoin::PublicKey::from_slice(&[2; 33]).expect("key 1"),
5252
bitcoin::PublicKey::from_slice(&[
5353
0x02,

src/confidential/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ mod tests {
408408
ConfidentialTest {
409409
key: Key::Bare(single_ct_key.clone()),
410410
descriptor: crate::Descriptor::new_wpkh(single_spk_key).unwrap(),
411-
descriptor_str: format!("ct(02dce16018bbbb8e36de7b394df5b5166e9adb7498be7d881a85a09aeecf76b623,elwpkh(03774eec7a3d550d18e9f89414152025b3b0ad6a342b19481f702d843cff06dfc4))#h5e0p6m9"),
411+
descriptor_str: "ct(02dce16018bbbb8e36de7b394df5b5166e9adb7498be7d881a85a09aeecf76b623,elwpkh(03774eec7a3d550d18e9f89414152025b3b0ad6a342b19481f702d843cff06dfc4))#h5e0p6m9".to_string(),
412412
conf_addr: "lq1qq0r6pegudzm0tzpszelc34qjln4fdxawgwmgnza63wwpzdy6jrm0grmqvvk2ce5ksnxcs9ecgtnryt7xg3406y5ccl0k2glns",
413413
unconf_addr: "ex1qpasxxt9vv6tgfnvgzuuy9e3j9lryg6hawrval4",
414414
},

src/descriptor/csfs_cov/cov.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//! 1. nVersion of the transaction (4-byte little endian)
2626
//! 2. hashPrevouts (32-byte hash)
2727
//! 3. hashSequence (32-byte hash)
28-
//! 3b. ELEMENTS EXTRA hashIssuances (32-byte hash)
28+
//! 3. ELEMENTS EXTRA hashIssuances (32-byte hash)
2929
//! 4. outpoint (32-byte hash + 4-byte little endian)
3030
//! 5. scriptCode of the input (serialized as scripts inside CTxOuts)
3131
//! 6. value of the output spent by this input (8-byte little endian)

src/descriptor/csfs_cov/mod.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
//! 1. nVersion of the transaction (4-byte little endian)
2727
//! 2. hashPrevouts (32-byte hash)
2828
//! 3. hashSequence (32-byte hash)
29-
//! 3b. ELEMENTS EXTRA hashIssuances (32-byte hash)
29+
//! 3. ELEMENTS EXTRA hashIssuances (32-byte hash)
3030
//! 4. outpoint (32-byte hash + 4-byte little endian)
3131
//! 5. scriptCode of the input (serialized as scripts inside CTxOuts)
3232
//! 6. value of the output spent by this input (8-byte little endian)
@@ -373,13 +373,6 @@ mod tests {
373373
.to_string(),
374374
"ert1qamjdykcfzkcsvc9z32a6qcz3mwr85a3k7z7qf2uaufem2q3lsjxqj4y4fy"
375375
);
376-
377-
println!(
378-
"{}",
379-
desc.address(&elements::AddressParams::ELEMENTS)
380-
.unwrap()
381-
.to_string()
382-
);
383376
}
384377
#[test]
385378
fn spend_tx() {

src/descriptor/csfs_cov/script_internals.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ impl CovOperations for script::Builder {
6767
.push_opcode(all::OP_ENDIF)
6868
}
6969

70+
#[rustfmt::skip]
7071
fn verify_cov(self, key: &bitcoin::PublicKey) -> Self {
72+
use elements::opcodes::all::{OP_CAT, OP_SWAP};
73+
7174
let mut builder = self;
7275
// The miniscript is of type B, which should have pushed 1
7376
// onto the stack if it satisfied correctly.(which it should)
@@ -100,25 +103,22 @@ impl CovOperations for script::Builder {
100103
builder = builder.push_opcode(all::OP_TOALTSTACK);
101104
// alt_stk = [bitcoinsig]
102105
// stk = [ecsig i10 i9 i8 i7 i6 i5 i4 i3b i3 i2 i1]
103-
// Ignore fmt skip because it butchers these lines
104-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
105-
{
106-
// Do the size checks on all respective items in sighash calculation
107-
use elements::opcodes::all::{OP_CAT, OP_SWAP};
108-
builder = builder.chk_size(4).push_opcode(OP_SWAP); // item 1: ver
109-
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 2: hashprevouts
110-
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 3: hashsequence
111-
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 3b: hashissuances
112-
builder = builder.chk_size(36).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 4: outpoint
113-
// Item 5: Script code is of constant size because we only consider everything after
114-
// codeseparator. This will be replaced with a push slice in a later commit
115-
builder = builder.chk_size(3).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 5: script code
116-
builder = builder.chk_amt().push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 6: check confAmt
117-
builder = builder.chk_size(4).push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 7: sequence
118-
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 8: hashoutputs
119-
builder = builder.chk_size(4).push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 9: nlocktime
120-
builder = builder.chk_size(4).push_opcode(OP_CAT); //item 10: sighash type
121-
}
106+
107+
// Do the size checks on all respective items in sighash calculation
108+
builder = builder.chk_size(4).push_opcode(OP_SWAP); // item 1: ver
109+
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 2: hashprevouts
110+
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 3: hashsequence
111+
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 3b: hashissuances
112+
builder = builder.chk_size(36).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 4: outpoint
113+
// Item 5: Script code is of constant size because we only consider everything after
114+
// codeseparator. This will be replaced with a push slice in a later commit
115+
builder = builder.chk_size(3).push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 5: script code
116+
builder = builder.chk_amt().push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 6: check confAmt
117+
builder = builder.chk_size(4).push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 7: sequence
118+
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 8: hashoutputs
119+
builder = builder.chk_size(4).push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 9: nlocktime
120+
builder = builder.chk_size(4).push_opcode(OP_CAT); //item 10: sighash type
121+
122122
// Now sighash is on the top of the stack
123123
// alt_stk = [bitcoinsig]
124124
// stk = [ecsig (i1||i2||i3||i3b||i4||i5||i6||i7||i8||i9||i10)]

src/descriptor/key.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,7 @@ fn parse_xkey_deriv<K: InnerXKey>(
874874
// step all the vectors of indexes contain a single element. If it did though, one of the
875875
// vectors contains more than one element.
876876
// Now transform this list of vectors of steps into distinct derivation paths.
877-
.fold(Ok(Vec::new()), |paths, index_list| {
878-
let mut paths = paths?;
877+
.try_fold(Vec::new(), |mut paths, index_list| {
879878
let mut index_list = index_list?.into_iter();
880879
let first_index = index_list
881880
.next()
@@ -948,7 +947,7 @@ impl<K: InnerXKey> DescriptorXKey<K> {
948947
Some((fingerprint, ref path)) => (
949948
fingerprint,
950949
path.into_iter()
951-
.chain(self.derivation_path.into_iter())
950+
.chain(&self.derivation_path)
952951
.collect(),
953952
),
954953
None => (

src/descriptor/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,6 @@ impl<Ext: Extension + ParseableExt> Descriptor<DescriptorPublicKey, Ext> {
10161016
///
10171017
/// For multipath descriptors it will return as many descriptors as there is
10181018
/// "parallel" paths. For regular descriptors it will just return itself.
1019-
#[allow(clippy::blocks_in_if_conditions)]
10201019
pub fn into_single_descriptors(self) -> Result<Vec<Self>, Error> {
10211020
// All single-path descriptors contained in this descriptor.
10221021
let mut descriptors = Vec::new();

0 commit comments

Comments
 (0)