Skip to content

Commit b0cd8c1

Browse files
committed
Merge #498: Fix a load of non-controversial clippy warnings
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) Pull request description: I've attempted to only do the easy, and non-controversial ones in this PR. Each warning is a separate patch (except `clone` warnings). `rustfmt` run on each patch. ACKs for top commit: sanket1729: ACK 6b6f808 apoelstra: ACK 6b6f808 Tree-SHA512: 1289ee2950107bf4cd0d8a09d91dd2c2ed98defcd4d9bffdd506ea144e1df07df5c18e485ae5745b878cf8d32b131764c8953bbc784193369d8dd7e6b8ca6ad8
2 parents f531bb3 + 6b6f808 commit b0cd8c1

File tree

15 files changed

+104
-134
lines changed

15 files changed

+104
-134
lines changed

src/descriptor/key.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl fmt::Display for DescriptorSecretKey {
138138
DescriptorSecretKey::MultiXPrv(ref xprv) => {
139139
maybe_fmt_master_id(f, &xprv.origin)?;
140140
xprv.xkey.fmt(f)?;
141-
fmt_derivation_paths(f, &xprv.derivation_paths.paths())?;
141+
fmt_derivation_paths(f, xprv.derivation_paths.paths())?;
142142
match xprv.wildcard {
143143
Wildcard::None => {}
144144
Wildcard::Unhardened => write!(f, "/*")?,
@@ -302,7 +302,7 @@ impl fmt::Display for DescriptorPublicKey {
302302
DescriptorPublicKey::MultiXPub(ref xpub) => {
303303
maybe_fmt_master_id(f, &xpub.origin)?;
304304
xpub.xkey.fmt(f)?;
305-
fmt_derivation_paths(f, &xpub.derivation_paths.paths())?;
305+
fmt_derivation_paths(f, xpub.derivation_paths.paths())?;
306306
match xpub.wildcard {
307307
Wildcard::None => {}
308308
Wildcard::Unhardened => write!(f, "/*")?,
@@ -453,10 +453,7 @@ impl FromStr for DescriptorPublicKey {
453453
Ok(DescriptorPublicKey::XPub(DescriptorXKey {
454454
origin,
455455
xkey: xpub,
456-
derivation_path: derivation_paths
457-
.into_iter()
458-
.next()
459-
.unwrap_or_else(|| bip32::DerivationPath::default()),
456+
derivation_path: derivation_paths.into_iter().next().unwrap_or_default(),
460457
wildcard,
461458
}))
462459
}
@@ -716,10 +713,7 @@ impl FromStr for DescriptorSecretKey {
716713
Ok(DescriptorSecretKey::XPrv(DescriptorXKey {
717714
origin,
718715
xkey: xpriv,
719-
derivation_path: derivation_paths
720-
.into_iter()
721-
.next()
722-
.unwrap_or_else(|| bip32::DerivationPath::default()),
716+
derivation_path: derivation_paths.into_iter().next().unwrap_or_default(),
723717
wildcard,
724718
}))
725719
}
@@ -1078,11 +1072,9 @@ impl FromStr for DefiniteDescriptorKey {
10781072

10791073
fn from_str(s: &str) -> Result<Self, Self::Err> {
10801074
let inner = DescriptorPublicKey::from_str(s)?;
1081-
Ok(
1082-
DefiniteDescriptorKey::new(inner).ok_or(DescriptorKeyParseError(
1083-
"cannot parse key with a wilcard as a DerivedDescriptorKey",
1084-
))?,
1085-
)
1075+
DefiniteDescriptorKey::new(inner).ok_or(DescriptorKeyParseError(
1076+
"cannot parse key with a wilcard as a DerivedDescriptorKey",
1077+
))
10861078
}
10871079
}
10881080

@@ -1253,23 +1245,23 @@ mod test {
12531245
public_key.full_derivation_path().unwrap().to_string(),
12541246
"m/0'/1'/2"
12551247
);
1256-
assert_eq!(public_key.has_wildcard(), false);
1248+
assert!(!public_key.has_wildcard());
12571249

12581250
let public_key = DescriptorPublicKey::from_str("[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/*").unwrap();
12591251
assert_eq!(public_key.master_fingerprint().to_string(), "abcdef00");
12601252
assert_eq!(
12611253
public_key.full_derivation_path().unwrap().to_string(),
12621254
"m/0'/1'"
12631255
);
1264-
assert_eq!(public_key.has_wildcard(), true);
1256+
assert!(public_key.has_wildcard());
12651257

12661258
let public_key = DescriptorPublicKey::from_str("[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/*h").unwrap();
12671259
assert_eq!(public_key.master_fingerprint().to_string(), "abcdef00");
12681260
assert_eq!(
12691261
public_key.full_derivation_path().unwrap().to_string(),
12701262
"m/0'/1'"
12711263
);
1272-
assert_eq!(public_key.has_wildcard(), true);
1264+
assert!(public_key.has_wildcard());
12731265
}
12741266

12751267
#[test]
@@ -1284,7 +1276,7 @@ mod test {
12841276
public_key.full_derivation_path().unwrap().to_string(),
12851277
"m/0'/1'/2"
12861278
);
1287-
assert_eq!(public_key.has_wildcard(), false);
1279+
assert!(!public_key.has_wildcard());
12881280

12891281
let secret_key = DescriptorSecretKey::from_str("tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0'/1'/2'").unwrap();
12901282
let public_key = secret_key.to_public(&secp).unwrap();

src/descriptor/mod.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ impl Descriptor<DescriptorPublicKey> {
584584
secp: &secp256k1::Secp256k1<C>,
585585
index: u32,
586586
) -> Result<Descriptor<bitcoin::PublicKey>, ConversionError> {
587-
self.at_derivation_index(index)?.derived_descriptor(&secp)
587+
self.at_derivation_index(index)?.derived_descriptor(secp)
588588
}
589589

590590
/// Parse a descriptor that may contain secret keys
@@ -596,7 +596,7 @@ impl Descriptor<DescriptorPublicKey> {
596596
s: &str,
597597
) -> Result<(Descriptor<DescriptorPublicKey>, KeyMap), Error> {
598598
fn parse_key<C: secp256k1::Signing>(
599-
s: &String,
599+
s: &str,
600600
key_map: &mut KeyMap,
601601
secp: &secp256k1::Secp256k1<C>,
602602
) -> Result<DescriptorPublicKey, Error> {
@@ -865,7 +865,7 @@ impl Descriptor<DefiniteDescriptorKey> {
865865
&mut self,
866866
pk: &DefiniteDescriptorKey,
867867
) -> Result<bitcoin::PublicKey, ConversionError> {
868-
pk.derive_public_key(&self.0)
868+
pk.derive_public_key(self.0)
869869
}
870870

871871
translate_hash_clone!(DefiniteDescriptorKey, bitcoin::PublicKey, ConversionError);
@@ -964,11 +964,10 @@ mod tests {
964964
use crate::{hex_script, Descriptor, DummyKey, Error, Miniscript, Satisfier};
965965

966966
type StdDescriptor = Descriptor<PublicKey>;
967-
const TEST_PK: &'static str =
968-
"pk(020000000000000000000000000000000000000000000000000000000000000002)";
967+
const TEST_PK: &str = "pk(020000000000000000000000000000000000000000000000000000000000000002)";
969968

970969
fn roundtrip_descriptor(s: &str) {
971-
let desc = Descriptor::<DummyKey>::from_str(&s).unwrap();
970+
let desc = Descriptor::<DummyKey>::from_str(s).unwrap();
972971
let output = desc.to_string();
973972
let normalize_aliases = s.replace("c:pk_k(", "pk(").replace("c:pk_h(", "pkh(");
974973
assert_eq!(
@@ -1031,9 +1030,9 @@ mod tests {
10311030

10321031
#[test]
10331032
pub fn script_pubkey() {
1034-
let bare = StdDescriptor::from_str(&format!(
1035-
"multi(1,020000000000000000000000000000000000000000000000000000000000000002)"
1036-
))
1033+
let bare = StdDescriptor::from_str(
1034+
"multi(1,020000000000000000000000000000000000000000000000000000000000000002)",
1035+
)
10371036
.unwrap();
10381037
assert_eq!(
10391038
bare.script_pubkey(),
@@ -1233,7 +1232,7 @@ mod tests {
12331232
sequence: Sequence::from_height(100),
12341233
witness: Witness::default(),
12351234
};
1236-
let bare = Descriptor::new_bare(ms.clone()).unwrap();
1235+
let bare = Descriptor::new_bare(ms).unwrap();
12371236

12381237
bare.satisfy(&mut txin, &satisfier).expect("satisfaction");
12391238
assert_eq!(
@@ -1757,8 +1756,8 @@ mod tests {
17571756
"sh(multi(2,[00000000/111'/222]xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0))##tjq09x4t"
17581757
);
17591758

1760-
Descriptor::parse_descriptor(&secp, "sh(multi(2,[00000000/111'/222]xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc,xprv9uPDJpEQgRQfDcW7BkF7eTya6RPxXeJCqCJGHuCJ4GiRVLzkTXBAJMu2qaMWPrS7AANYqdq6vcBcBUdJCVVFceUvJFjaPdGZ2y9WACViL4L/0))#ggrsrxfy").expect("Valid descriptor with checksum");
1761-
Descriptor::parse_descriptor(&secp, "sh(multi(2,[00000000/111'/222]xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0))#tjg09x5t").expect("Valid descriptor with checksum");
1759+
Descriptor::parse_descriptor(secp, "sh(multi(2,[00000000/111'/222]xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc,xprv9uPDJpEQgRQfDcW7BkF7eTya6RPxXeJCqCJGHuCJ4GiRVLzkTXBAJMu2qaMWPrS7AANYqdq6vcBcBUdJCVVFceUvJFjaPdGZ2y9WACViL4L/0))#ggrsrxfy").expect("Valid descriptor with checksum");
1760+
Descriptor::parse_descriptor(secp, "sh(multi(2,[00000000/111'/222]xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0))#tjg09x5t").expect("Valid descriptor with checksum");
17621761
}
17631762

17641763
#[test]
@@ -1788,7 +1787,7 @@ pk(03f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8))";
17881787
let secp = &secp256k1::Secp256k1::signing_only();
17891788
let descriptor_str = "wpkh(xprv9s21ZrQH143K4CTb63EaMxja1YiTnSEWKMbn23uoEnAzxjdUJRQkazCAtzxGm4LSoTSVTptoV9RbchnKPW9HxKtZumdyxyikZFDLhogJ5Uj/44'/0'/0'/0/*)#v20xlvm9";
17901789
let (descriptor, keymap) =
1791-
Descriptor::<DescriptorPublicKey>::parse_descriptor(&secp, descriptor_str).unwrap();
1790+
Descriptor::<DescriptorPublicKey>::parse_descriptor(secp, descriptor_str).unwrap();
17921791

17931792
let expected = "wpkh([a12b02f4/44'/0'/0']xpub6BzhLAQUDcBUfHRQHZxDF2AbcJqp4Kaeq6bzJpXrjrWuK26ymTFwkEFbxPra2bJ7yeZKbDjfDeFwxe93JMqpo5SsPJH6dZdvV9kMzJkAZ69/0/*)#u37l7u8u";
17941793
assert_eq!(expected, descriptor.to_string());

src/descriptor/sortedmulti.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> SortedMultiVec<Pk, Ctx> {
112112
}
113113

114114
impl<Pk: MiniscriptKey, Ctx: ScriptContext> ForEachKey<Pk> for SortedMultiVec<Pk, Ctx> {
115-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool
115+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool
116116
where
117117
Pk: 'a,
118118
{
119-
self.pks.iter().all(|key| pred(key))
119+
self.pks.iter().all(pred)
120120
}
121121
}
122122

@@ -258,11 +258,11 @@ mod tests {
258258

259259
let mut pks = Vec::new();
260260
for _ in 0..over {
261-
pks.push(pk.clone());
261+
pks.push(pk);
262262
}
263263

264264
let res: Result<SortedMultiVec<PublicKey, Legacy>, Error> = SortedMultiVec::new(0, pks);
265-
let error = res.err().expect("constructor should err");
265+
let error = res.expect_err("constructor should err");
266266

267267
match error {
268268
Error::BadDescriptor(_) => {} // ok

src/descriptor/tr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ where
354354
fn next(&mut self) -> Option<Self::Item> {
355355
while !self.stack.is_empty() {
356356
let (depth, last) = self.stack.pop().expect("Size checked above");
357-
match &*last {
358-
TapTree::Tree(l, r) => {
357+
match *last {
358+
TapTree::Tree(ref l, ref r) => {
359359
self.stack.push((depth + 1, r));
360360
self.stack.push((depth + 1, l));
361361
}

src/interpreter/inner.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ pub(super) enum Inner {
107107
/// Parses an `Inner` and appropriate `Stack` from completed transaction data,
108108
/// as well as the script that should be used as a scriptCode in a sighash
109109
/// Tr outputs don't have script code and return None.
110+
#[allow(clippy::collapsible_else_if)]
110111
pub(super) fn from_txdata<'txin>(
111112
spk: &bitcoin::Script,
112113
script_sig: &'txin bitcoin::Script,
@@ -819,7 +820,7 @@ mod tests {
819820
from_txdata(&spk, &script_sig, &empty_wit).expect("parse txdata");
820821
assert_eq!(inner, Inner::Script(miniscript, ScriptType::Sh));
821822
assert_eq!(stack, Stack::from(vec![]));
822-
assert_eq!(script_code, Some(redeem_script.clone()));
823+
assert_eq!(script_code, Some(redeem_script));
823824

824825
// nonempty witness
825826
let wit = Witness::from_vec(vec![vec![]]);

src/interpreter/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,10 +1143,10 @@ mod tests {
11431143
) -> Iter<'elem, 'txin> {
11441144
Iter {
11451145
verify_sig: verify_fn,
1146-
stack: stack,
1146+
stack,
11471147
public_key: None,
11481148
state: vec![NodeEvaluationState {
1149-
node: &ms,
1149+
node: ms,
11501150
n_evaluated: 0,
11511151
n_satisfied: 0,
11521152
}],
@@ -1163,7 +1163,7 @@ mod tests {
11631163
let after = no_checks_ms(&format!("after({})", 1000));
11641164
let older = no_checks_ms(&format!("older({})", 1000));
11651165
//Hashes
1166-
let preimage = [0xab as u8; 32];
1166+
let preimage = [0xab; 32];
11671167
let sha256_hash = sha256::Hash::hash(&preimage);
11681168
let sha256 = no_checks_ms(&format!("sha256({})", sha256_hash));
11691169
let hash256_hash = hash256::Hash::hash(&preimage);
@@ -1235,7 +1235,7 @@ mod tests {
12351235
sah256_satisfied.unwrap(),
12361236
vec![SatisfiedConstraint::HashLock {
12371237
hash: HashLockType::Sha256(sha256_hash),
1238-
preimage: preimage,
1238+
preimage,
12391239
}]
12401240
);
12411241

@@ -1247,7 +1247,7 @@ mod tests {
12471247
sha256d_satisfied.unwrap(),
12481248
vec![SatisfiedConstraint::HashLock {
12491249
hash: HashLockType::Hash256(hash256_hash),
1250-
preimage: preimage,
1250+
preimage,
12511251
}]
12521252
);
12531253

@@ -1259,7 +1259,7 @@ mod tests {
12591259
hash160_satisfied.unwrap(),
12601260
vec![SatisfiedConstraint::HashLock {
12611261
hash: HashLockType::Hash160(hash160_hash),
1262-
preimage: preimage,
1262+
preimage,
12631263
}]
12641264
);
12651265

@@ -1271,7 +1271,7 @@ mod tests {
12711271
ripemd160_satisfied.unwrap(),
12721272
vec![SatisfiedConstraint::HashLock {
12731273
hash: HashLockType::Ripemd160(ripemd160_hash),
1274-
preimage: preimage
1274+
preimage,
12751275
}]
12761276
);
12771277

@@ -1319,7 +1319,7 @@ mod tests {
13191319
},
13201320
SatisfiedConstraint::HashLock {
13211321
hash: HashLockType::Sha256(sha256_hash),
1322-
preimage: preimage,
1322+
preimage,
13231323
}
13241324
]
13251325
);
@@ -1344,7 +1344,7 @@ mod tests {
13441344
},
13451345
SatisfiedConstraint::HashLock {
13461346
hash: HashLockType::Sha256(sha256_hash),
1347-
preimage: preimage,
1347+
preimage,
13481348
}
13491349
]
13501350
);
@@ -1383,7 +1383,7 @@ mod tests {
13831383
or_b_satisfied.unwrap(),
13841384
vec![SatisfiedConstraint::HashLock {
13851385
hash: HashLockType::Sha256(sha256_hash),
1386-
preimage: preimage,
1386+
preimage,
13871387
}]
13881388
);
13891389

src/miniscript/astelem.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
113113
&& c.real_for_each_key(pred)
114114
}
115115
Terminal::Thresh(_, ref subs) => subs.iter().all(|sub| sub.real_for_each_key(pred)),
116-
Terminal::Multi(_, ref keys) | Terminal::MultiA(_, ref keys) => {
117-
keys.iter().all(|key| pred(key))
118-
}
116+
Terminal::Multi(_, ref keys) | Terminal::MultiA(_, ref keys) => keys.iter().all(pred),
119117
}
120118
}
121119

@@ -131,10 +129,10 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
131129
Terminal::RawPkH(ref p) => Terminal::RawPkH(*p),
132130
Terminal::After(n) => Terminal::After(n),
133131
Terminal::Older(n) => Terminal::Older(n),
134-
Terminal::Sha256(ref x) => Terminal::Sha256(t.sha256(&x)?),
135-
Terminal::Hash256(ref x) => Terminal::Hash256(t.hash256(&x)?),
136-
Terminal::Ripemd160(ref x) => Terminal::Ripemd160(t.ripemd160(&x)?),
137-
Terminal::Hash160(ref x) => Terminal::Hash160(t.hash160(&x)?),
132+
Terminal::Sha256(ref x) => Terminal::Sha256(t.sha256(x)?),
133+
Terminal::Hash256(ref x) => Terminal::Hash256(t.hash256(x)?),
134+
Terminal::Ripemd160(ref x) => Terminal::Ripemd160(t.ripemd160(x)?),
135+
Terminal::Hash160(ref x) => Terminal::Hash160(t.hash160(x)?),
138136
Terminal::True => Terminal::True,
139137
Terminal::False => Terminal::False,
140138
Terminal::Alt(ref sub) => Terminal::Alt(Arc::new(sub.real_translate_pk(t)?)),
@@ -624,7 +622,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
624622
Terminal::RawPkH(ref hash) => builder
625623
.push_opcode(opcodes::all::OP_DUP)
626624
.push_opcode(opcodes::all::OP_HASH160)
627-
.push_slice(&hash)
625+
.push_slice(hash)
628626
.push_opcode(opcodes::all::OP_EQUALVERIFY),
629627
Terminal::After(t) => builder
630628
.push_int(t.to_u32().into())
@@ -637,28 +635,28 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
637635
.push_int(32)
638636
.push_opcode(opcodes::all::OP_EQUALVERIFY)
639637
.push_opcode(opcodes::all::OP_SHA256)
640-
.push_slice(&Pk::to_sha256(&h))
638+
.push_slice(&Pk::to_sha256(h))
641639
.push_opcode(opcodes::all::OP_EQUAL),
642640
Terminal::Hash256(ref h) => builder
643641
.push_opcode(opcodes::all::OP_SIZE)
644642
.push_int(32)
645643
.push_opcode(opcodes::all::OP_EQUALVERIFY)
646644
.push_opcode(opcodes::all::OP_HASH256)
647-
.push_slice(&Pk::to_hash256(&h))
645+
.push_slice(&Pk::to_hash256(h))
648646
.push_opcode(opcodes::all::OP_EQUAL),
649647
Terminal::Ripemd160(ref h) => builder
650648
.push_opcode(opcodes::all::OP_SIZE)
651649
.push_int(32)
652650
.push_opcode(opcodes::all::OP_EQUALVERIFY)
653651
.push_opcode(opcodes::all::OP_RIPEMD160)
654-
.push_slice(&Pk::to_ripemd160(&h))
652+
.push_slice(&Pk::to_ripemd160(h))
655653
.push_opcode(opcodes::all::OP_EQUAL),
656654
Terminal::Hash160(ref h) => builder
657655
.push_opcode(opcodes::all::OP_SIZE)
658656
.push_int(32)
659657
.push_opcode(opcodes::all::OP_EQUALVERIFY)
660658
.push_opcode(opcodes::all::OP_HASH160)
661-
.push_slice(&Pk::to_hash160(&h))
659+
.push_slice(&Pk::to_hash160(h))
662660
.push_opcode(opcodes::all::OP_EQUAL),
663661
Terminal::True => builder.push_opcode(opcodes::OP_TRUE),
664662
Terminal::False => builder.push_opcode(opcodes::OP_FALSE),
@@ -777,7 +775,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
777775
Terminal::Check(ref sub) => sub.node.script_size() + 1,
778776
Terminal::DupIf(ref sub) => sub.node.script_size() + 3,
779777
Terminal::Verify(ref sub) => {
780-
sub.node.script_size() + if sub.ext.has_free_verify { 0 } else { 1 }
778+
sub.node.script_size() + usize::from(!sub.ext.has_free_verify)
781779
}
782780
Terminal::NonZero(ref sub) => sub.node.script_size() + 4,
783781
Terminal::ZeroNotEqual(ref sub) => sub.node.script_size() + 1,

0 commit comments

Comments
 (0)