From badeb44c8386ff9c37516700082ce98c34a22a54 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:27:13 +1000 Subject: [PATCH 01/13] Remove unnecessary cast Remove build error: error: casting integer literal to `u8` is unnecessary --- bitcoind-tests/tests/setup/test_util.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bitcoind-tests/tests/setup/test_util.rs b/bitcoind-tests/tests/setup/test_util.rs index 56e204988..bfd634c42 100644 --- a/bitcoind-tests/tests/setup/test_util.rs +++ b/bitcoind-tests/tests/setup/test_util.rs @@ -99,13 +99,13 @@ impl TestData { // generate a fixed data for n keys pub(crate) fn new_fixed_data(n: usize) -> Self { let (sks, pks, x_only_keypairs, x_only_pks) = setup_keys(n); - let sha256_pre = [0x12 as u8; 32]; + let sha256_pre = [0x12_u8; 32]; let sha256 = sha256::Hash::hash(&sha256_pre); - let hash256_pre = [0x34 as u8; 32]; + let hash256_pre = [0x34_u8; 32]; let hash256 = hash256::Hash::hash(&hash256_pre); - let hash160_pre = [0x56 as u8; 32]; + let hash160_pre = [0x56_u8; 32]; let hash160 = hash160::Hash::hash(&hash160_pre); - let ripemd160_pre = [0x78 as u8; 32]; + let ripemd160_pre = [0x78_u8; 32]; let ripemd160 = ripemd160::Hash::hash(&ripemd160_pre); let pubdata = PubData { pks, sha256, hash256, ripemd160, hash160, x_only_pks }; From ccc808ae6a0c9f7d3d7ae0b38c78decd8d7d1b66 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:29:42 +1000 Subject: [PATCH 02/13] Use iterator instead of array access Clear clippy warning: the loop variable `i` is only used to index `sks` --- bitcoind-tests/tests/setup/test_util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitcoind-tests/tests/setup/test_util.rs b/bitcoind-tests/tests/setup/test_util.rs index bfd634c42..361be5214 100644 --- a/bitcoind-tests/tests/setup/test_util.rs +++ b/bitcoind-tests/tests/setup/test_util.rs @@ -86,8 +86,8 @@ fn setup_keys( let mut x_only_keypairs = vec![]; let mut x_only_pks = vec![]; - for i in 0..n { - let keypair = bitcoin::secp256k1::Keypair::from_secret_key(&secp_sign, &sks[i]); + for sk in &sks { + let keypair = bitcoin::secp256k1::Keypair::from_secret_key(&secp_sign, &sk); let (xpk, _parity) = XOnlyPublicKey::from_keypair(&keypair); x_only_keypairs.push(keypair); x_only_pks.push(xpk); From 6a2577f0eef445b5d9f4f4ca1fb150d43d48b4d1 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:31:26 +1000 Subject: [PATCH 03/13] Remove useless let binding --- bitcoind-tests/tests/setup/test_util.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bitcoind-tests/tests/setup/test_util.rs b/bitcoind-tests/tests/setup/test_util.rs index 361be5214..b7f6799bb 100644 --- a/bitcoind-tests/tests/setup/test_util.rs +++ b/bitcoind-tests/tests/setup/test_util.rs @@ -148,8 +148,7 @@ pub fn parse_insane_ms( let ms = Miniscript::::from_str_insane(&ms).expect("only parsing valid minsicripts"); let mut translator = StrTranslatorLoose(0, pubdata); - let ms = ms.translate_pk(&mut translator).unwrap(); - ms + ms.translate_pk(&mut translator).unwrap() } // Translate Str to DescriptorPublicKey @@ -291,6 +290,5 @@ fn subs_hash_frag(ms: &str, pubdata: &PubData) -> String { let ms = ms.replace("hash256(H!)", &format!("hash256({})", rand_hash32.to_lower_hex_string())); let ms = ms.replace("ripemd160(H!)", &format!("ripemd160({})", rand_hash20.to_lower_hex_string())); - let ms = ms.replace("hash160(H!)", &format!("hash160({})", rand_hash20.to_lower_hex_string())); - ms + ms.replace("hash160(H!)", &format!("hash160({})", rand_hash20.to_lower_hex_string())) } From 7218e5eba8c60378f713f94b9ff5242af944efd1 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:33:54 +1000 Subject: [PATCH 04/13] Remove redundant field names Clippy emits: warning: redundant field names in struct initialization As suggested, remove redundant field names. --- bitcoind-tests/tests/test_desc.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bitcoind-tests/tests/test_desc.rs b/bitcoind-tests/tests/test_desc.rs index 92b9ea89c..0597517b6 100644 --- a/bitcoind-tests/tests/test_desc.rs +++ b/bitcoind-tests/tests/test_desc.rs @@ -177,8 +177,7 @@ pub fn test_desc_satisfy( rand::thread_rng().fill_bytes(&mut aux_rand); let schnorr_sig = secp.sign_schnorr_with_aux_rand(&msg, &internal_keypair, &aux_rand); - psbt.inputs[0].tap_key_sig = - Some(taproot::Signature { sig: schnorr_sig, hash_ty: hash_ty }); + psbt.inputs[0].tap_key_sig = Some(taproot::Signature { sig: schnorr_sig, hash_ty }); } else { // No internal key } @@ -205,7 +204,7 @@ pub fn test_desc_satisfy( x_only_pks[xonly_keypairs.iter().position(|&x| x == keypair).unwrap()]; psbt.inputs[0] .tap_script_sigs - .insert((x_only_pk, leaf_hash), taproot::Signature { sig, hash_ty: hash_ty }); + .insert((x_only_pk, leaf_hash), taproot::Signature { sig, hash_ty }); } } _ => { @@ -256,7 +255,7 @@ pub fn test_desc_satisfy( assert!(secp.verify_ecdsa(&msg, &sig, &pk.inner).is_ok()); psbt.inputs[0] .partial_sigs - .insert(pk, ecdsa::Signature { sig, hash_ty: hash_ty }); + .insert(pk, ecdsa::Signature { sig, hash_ty }); } } } From 5e0df214089a74182d714f79201f2ecca551202c Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:35:53 +1000 Subject: [PATCH 05/13] Use single quotes Clippy emits: warning: single-character string constant used as pattern As suggested, use single quotes. --- bitcoind-tests/tests/setup/test_util.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bitcoind-tests/tests/setup/test_util.rs b/bitcoind-tests/tests/setup/test_util.rs index b7f6799bb..9f4b7a134 100644 --- a/bitcoind-tests/tests/setup/test_util.rs +++ b/bitcoind-tests/tests/setup/test_util.rs @@ -157,15 +157,15 @@ struct StrDescPubKeyTranslator<'a>(usize, &'a PubData); impl<'a> Translator for StrDescPubKeyTranslator<'a> { fn pk(&mut self, pk_str: &String) -> Result { - let avail = !pk_str.ends_with("!"); + let avail = !pk_str.ends_with('!'); if avail { self.0 = self.0 + 1; - if pk_str.starts_with("K") { + if pk_str.starts_with('K') { Ok(DescriptorPublicKey::Single(SinglePub { origin: None, key: SinglePubKey::FullKey(self.1.pks[self.0]), })) - } else if pk_str.starts_with("X") { + } else if pk_str.starts_with('X') { Ok(DescriptorPublicKey::Single(SinglePub { origin: None, key: SinglePubKey::XOnly(self.1.x_only_pks[self.0]), @@ -210,15 +210,15 @@ struct StrTranslatorLoose<'a>(usize, &'a PubData); impl<'a> Translator for StrTranslatorLoose<'a> { fn pk(&mut self, pk_str: &String) -> Result { - let avail = !pk_str.ends_with("!"); + let avail = !pk_str.ends_with('!'); if avail { self.0 = self.0 + 1; - if pk_str.starts_with("K") { + if pk_str.starts_with('K') { Ok(DescriptorPublicKey::Single(SinglePub { origin: None, key: SinglePubKey::FullKey(self.1.pks[self.0]), })) - } else if pk_str.starts_with("X") { + } else if pk_str.starts_with('X') { Ok(DescriptorPublicKey::Single(SinglePub { origin: None, key: SinglePubKey::XOnly(self.1.x_only_pks[self.0]), From f9907b038c1b874fb4da608c9ebcbfe2f5512a49 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:37:07 +1000 Subject: [PATCH 06/13] Use += operator Clippy emits: warning: manual implementation of an assign operation As suggested, use += operator. --- bitcoind-tests/tests/setup/test_util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitcoind-tests/tests/setup/test_util.rs b/bitcoind-tests/tests/setup/test_util.rs index 9f4b7a134..e3f2d3c9d 100644 --- a/bitcoind-tests/tests/setup/test_util.rs +++ b/bitcoind-tests/tests/setup/test_util.rs @@ -159,7 +159,7 @@ impl<'a> Translator for StrDescPubKeyTranslator fn pk(&mut self, pk_str: &String) -> Result { let avail = !pk_str.ends_with('!'); if avail { - self.0 = self.0 + 1; + self.0 += 1; if pk_str.starts_with('K') { Ok(DescriptorPublicKey::Single(SinglePub { origin: None, @@ -212,7 +212,7 @@ impl<'a> Translator for StrTranslatorLoose<'a> fn pk(&mut self, pk_str: &String) -> Result { let avail = !pk_str.ends_with('!'); if avail { - self.0 = self.0 + 1; + self.0 += 1; if pk_str.starts_with('K') { Ok(DescriptorPublicKey::Single(SinglePub { origin: None, From e361cfc396585c8260bf61806343a9cdb6cdb88d Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:39:32 +1000 Subject: [PATCH 07/13] Remove unneeded return statement Clippy emits: warning: unneeded `return` statement As suggested, remove unneeded return statement. --- bitcoind-tests/tests/test_desc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoind-tests/tests/test_desc.rs b/bitcoind-tests/tests/test_desc.rs index 0597517b6..2dc0e5754 100644 --- a/bitcoind-tests/tests/test_desc.rs +++ b/bitcoind-tests/tests/test_desc.rs @@ -297,7 +297,7 @@ pub fn test_desc_satisfy( // Assert that the confirmations are > 0. let num_conf = cl.get_transaction(&txid, None).unwrap().info.confirmations; assert!(num_conf > 0); - return Ok(tx.input[0].witness.clone()); + Ok(tx.input[0].witness.clone()) } // Find all secret corresponding to the known public keys in ms From 7ed6680fb84ff1056a3dcbc06b9e9f8e2e29da07 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:42:24 +1000 Subject: [PATCH 08/13] Do not mutate local variable Clippy emits: warning: field assignment outside of initializer for an instance created with Default::default() As suggested use `..Default::default()` instead of mutating. --- bitcoind-tests/tests/test_cpp.rs | 22 +++++++++++++--------- bitcoind-tests/tests/test_desc.rs | 14 ++++++++------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/bitcoind-tests/tests/test_cpp.rs b/bitcoind-tests/tests/test_cpp.rs index 031a5d673..cf86c602c 100644 --- a/bitcoind-tests/tests/test_cpp.rs +++ b/bitcoind-tests/tests/test_cpp.rs @@ -120,12 +120,14 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) { }; // figure out the outpoint from the txid let (outpoint, witness_utxo) = get_vout(&cl, txid, btc(1.0)); - let mut txin = TxIn::default(); - txin.previous_output = outpoint; - // set the sequence to a non-final number for the locktime transactions to be - // processed correctly. - // We waited 50 blocks, keep 49 for safety - txin.sequence = Sequence::from_height(49); + let txin = TxIn { + previous_output: outpoint, + // set the sequence to a non-final number for the locktime transactions to be + // processed correctly. + // We waited 50 blocks, keep 49 for safety + sequence: Sequence::from_height(49), + ..Default::default() + }; psbt.unsigned_tx.input.push(txin); // Get a new script pubkey from the node so that // the node wallet tracks the receiving transaction @@ -138,9 +140,11 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) { value: Amount::from_sat(99_999_000), script_pubkey: addr.script_pubkey(), }); - let mut input = psbt::Input::default(); - input.witness_utxo = Some(witness_utxo); - input.witness_script = Some(desc.explicit_script().unwrap()); + let input = psbt::Input { + witness_utxo: Some(witness_utxo), + witness_script: Some(desc.explicit_script().unwrap()), + ..Default::default() + }; psbt.inputs.push(input); psbt.update_input_with_descriptor(0, &desc).unwrap(); psbt.outputs.push(psbt::Output::default()); diff --git a/bitcoind-tests/tests/test_desc.rs b/bitcoind-tests/tests/test_desc.rs index 2dc0e5754..bc3c01522 100644 --- a/bitcoind-tests/tests/test_desc.rs +++ b/bitcoind-tests/tests/test_desc.rs @@ -119,12 +119,14 @@ pub fn test_desc_satisfy( }; // figure out the outpoint from the txid let (outpoint, witness_utxo) = get_vout(&cl, txid, btc(1.0), derived_desc.script_pubkey()); - let mut txin = TxIn::default(); - txin.previous_output = outpoint; - // set the sequence to a non-final number for the locktime transactions to be - // processed correctly. - // We waited 2 blocks, keep 1 for safety - txin.sequence = Sequence::from_height(1); + let txin = TxIn { + previous_output: outpoint, + // set the sequence to a non-final number for the locktime transactions to be + // processed correctly. + // We waited 2 blocks, keep 1 for safety + sequence: Sequence::from_height(1), + ..Default::default() + }; psbt.unsigned_tx.input.push(txin); // Get a new script pubkey from the node so that // the node wallet tracks the receiving transaction From c20be39458273e9410bbe64c892c014423c4460d Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:48:37 +1000 Subject: [PATCH 09/13] Remove explicit reference Clippy emits: warning: this expression creates a reference which is immediately dereferenced by the compiler As suggested, remove explicit reference. --- bitcoind-tests/tests/test_cpp.rs | 4 ++-- bitcoind-tests/tests/test_desc.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bitcoind-tests/tests/test_cpp.rs b/bitcoind-tests/tests/test_cpp.rs index cf86c602c..37252a918 100644 --- a/bitcoind-tests/tests/test_cpp.rs +++ b/bitcoind-tests/tests/test_cpp.rs @@ -119,7 +119,7 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) { outputs: vec![], }; // figure out the outpoint from the txid - let (outpoint, witness_utxo) = get_vout(&cl, txid, btc(1.0)); + let (outpoint, witness_utxo) = get_vout(cl, txid, btc(1.0)); let txin = TxIn { previous_output: outpoint, // set the sequence to a non-final number for the locktime transactions to be @@ -146,7 +146,7 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) { ..Default::default() }; psbt.inputs.push(input); - psbt.update_input_with_descriptor(0, &desc).unwrap(); + psbt.update_input_with_descriptor(0, desc).unwrap(); psbt.outputs.push(psbt::Output::default()); psbts.push(psbt); } diff --git a/bitcoind-tests/tests/test_desc.rs b/bitcoind-tests/tests/test_desc.rs index bc3c01522..80418cd4a 100644 --- a/bitcoind-tests/tests/test_desc.rs +++ b/bitcoind-tests/tests/test_desc.rs @@ -81,7 +81,7 @@ pub fn test_desc_satisfy( .unwrap(); assert_eq!(blocks.len(), 1); - let definite_desc = test_util::parse_test_desc(&descriptor, &testdata.pubdata) + let definite_desc = test_util::parse_test_desc(descriptor, &testdata.pubdata) .map_err(|_| DescError::DescParseError)? .at_derivation_index(0) .unwrap(); @@ -118,7 +118,7 @@ pub fn test_desc_satisfy( outputs: vec![], }; // figure out the outpoint from the txid - let (outpoint, witness_utxo) = get_vout(&cl, txid, btc(1.0), derived_desc.script_pubkey()); + let (outpoint, witness_utxo) = get_vout(cl, txid, btc(1.0), derived_desc.script_pubkey()); let txin = TxIn { previous_output: outpoint, // set the sequence to a non-final number for the locktime transactions to be @@ -213,7 +213,7 @@ pub fn test_desc_satisfy( // Non-tr descriptors // Ecdsa sigs let sks_reqd = match derived_desc { - Descriptor::Bare(bare) => find_sks_ms(&bare.as_inner(), testdata), + Descriptor::Bare(bare) => find_sks_ms(bare.as_inner(), testdata), Descriptor::Pkh(pk) => find_sk_single_key(*pk.as_inner(), testdata), Descriptor::Wpkh(pk) => find_sk_single_key(*pk.as_inner(), testdata), Descriptor::Sh(sh) => match sh.as_inner() { @@ -222,7 +222,7 @@ pub fn test_desc_satisfy( let ms = Miniscript::from_ast(smv.sorted_node()).unwrap(); find_sks_ms(&ms, testdata) } - miniscript::descriptor::WshInner::Ms(ref ms) => find_sks_ms(&ms, testdata), + miniscript::descriptor::WshInner::Ms(ref ms) => find_sks_ms(ms, testdata), }, miniscript::descriptor::ShInner::Wpkh(pk) => { find_sk_single_key(*pk.as_inner(), testdata) @@ -231,14 +231,14 @@ pub fn test_desc_satisfy( let ms = Miniscript::from_ast(smv.sorted_node()).unwrap(); find_sks_ms(&ms, testdata) } - miniscript::descriptor::ShInner::Ms(ms) => find_sks_ms(&ms, testdata), + miniscript::descriptor::ShInner::Ms(ms) => find_sks_ms(ms, testdata), }, Descriptor::Wsh(wsh) => match wsh.as_inner() { miniscript::descriptor::WshInner::SortedMulti(ref smv) => { let ms = Miniscript::from_ast(smv.sorted_node()).unwrap(); find_sks_ms(&ms, testdata) } - miniscript::descriptor::WshInner::Ms(ref ms) => find_sks_ms(&ms, testdata), + miniscript::descriptor::WshInner::Ms(ref ms) => find_sks_ms(ms, testdata), }, Descriptor::Tr(_tr) => unreachable!("Tr checked earlier"), }; From f939367b244f5603835590b9829f55f698c35ebb Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:52:47 +1000 Subject: [PATCH 10/13] Remove useless conversion Clippy emits: warning: useless conversion to the same type: `setup::miniscript::bitcoin::absolute::LockTime` As suggested, remove useless conversion. --- bitcoind-tests/tests/test_cpp.rs | 4 +--- bitcoind-tests/tests/test_desc.rs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/bitcoind-tests/tests/test_cpp.rs b/bitcoind-tests/tests/test_cpp.rs index 37252a918..1373e523f 100644 --- a/bitcoind-tests/tests/test_cpp.rs +++ b/bitcoind-tests/tests/test_cpp.rs @@ -105,9 +105,7 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) { let mut psbt = Psbt { unsigned_tx: Transaction { version: transaction::Version::TWO, - lock_time: absolute::LockTime::from_time(1_603_866_330) - .expect("valid timestamp") - .into(), // 10/28/2020 @ 6:25am (UTC) + lock_time: absolute::LockTime::from_time(1_603_866_330).expect("valid timestamp"), // 10/28/2020 @ 6:25am (UTC) input: vec![], output: vec![], }, diff --git a/bitcoind-tests/tests/test_desc.rs b/bitcoind-tests/tests/test_desc.rs index 80418cd4a..7b5316961 100644 --- a/bitcoind-tests/tests/test_desc.rs +++ b/bitcoind-tests/tests/test_desc.rs @@ -104,9 +104,7 @@ pub fn test_desc_satisfy( let mut psbt = Psbt { unsigned_tx: Transaction { version: transaction::Version::TWO, - lock_time: absolute::LockTime::from_time(1_603_866_330) - .expect("valid timestamp") - .into(), // 10/28/2020 @ 6:25am (UTC) + lock_time: absolute::LockTime::from_time(1_603_866_330).expect("valid timestamp"), // 10/28/2020 @ 6:25am (UTC) input: vec![], output: vec![], }, From a1a5467175dade2243c248c6e54d8522d1273f9c Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:55:23 +1000 Subject: [PATCH 11/13] Remove clone call from Copy type Found with clippy, just use `Copy`. --- bitcoind-tests/tests/test_desc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitcoind-tests/tests/test_desc.rs b/bitcoind-tests/tests/test_desc.rs index 7b5316961..d7cd83539 100644 --- a/bitcoind-tests/tests/test_desc.rs +++ b/bitcoind-tests/tests/test_desc.rs @@ -160,7 +160,7 @@ pub fn test_desc_satisfy( let internal_key_present = x_only_pks .iter() .position(|&x| x.to_public_key() == *tr.internal_key()); - let internal_keypair = internal_key_present.map(|idx| xonly_keypairs[idx].clone()); + let internal_keypair = internal_key_present.map(|idx| xonly_keypairs[idx]); let prevouts = [witness_utxo]; let prevouts = sighash::Prevouts::All(&prevouts); @@ -188,7 +188,7 @@ pub fn test_desc_satisfy( let leaf_hash = TapLeafHash::from_script(&ms.encode(), LeafVersion::TapScript); ms.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].clone(), leaf_hash)) + i.map(|idx| (xonly_keypairs[idx], leaf_hash)) }) }) .collect(); From ef868cc7b5f9a652494fc808ea90ac29a91b7f0f Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:56:54 +1000 Subject: [PATCH 12/13] Use unwrap_or_else instead of expect Clippy emits: warning: use of `expect` followed by a function call As suggested, use `unwrap_or_else` with `panic!`. --- bitcoind-tests/tests/test_cpp.rs | 2 +- bitcoind-tests/tests/test_desc.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bitcoind-tests/tests/test_cpp.rs b/bitcoind-tests/tests/test_cpp.rs index 1373e523f..ca04dbceb 100644 --- a/bitcoind-tests/tests/test_cpp.rs +++ b/bitcoind-tests/tests/test_cpp.rs @@ -215,7 +215,7 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) { // Check whether the node accepts the transactions let txid = cl .send_raw_transaction(&tx) - .expect(&format!("{} send tx failed for ms {}", i, ms)); + .unwrap_or_else(|_| panic!("{} send tx failed for ms {}", i, ms)); spend_txids.push(txid); } } diff --git a/bitcoind-tests/tests/test_desc.rs b/bitcoind-tests/tests/test_desc.rs index d7cd83539..90dd7c0d2 100644 --- a/bitcoind-tests/tests/test_desc.rs +++ b/bitcoind-tests/tests/test_desc.rs @@ -286,7 +286,7 @@ pub fn test_desc_satisfy( // Check whether the node accepts the transactions let txid = cl .send_raw_transaction(&tx) - .expect(&format!("send tx failed for desc {}", definite_desc)); + .unwrap_or_else(|_| panic!("send tx failed for desc {}", definite_desc)); // Finally mine the blocks and await confirmations let _blocks = cl From b9a207bfd58b8f961c44976e6ff72b8940bf9f21 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 3 May 2024 13:58:03 +1000 Subject: [PATCH 13/13] Use is_err instead of redundant pattern matching Clippy emits: warning: redundant pattern matching, consider using `is_err()` As suggested, use `is_err()`. --- bitcoind-tests/tests/test_desc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoind-tests/tests/test_desc.rs b/bitcoind-tests/tests/test_desc.rs index 90dd7c0d2..24abb1e6a 100644 --- a/bitcoind-tests/tests/test_desc.rs +++ b/bitcoind-tests/tests/test_desc.rs @@ -276,7 +276,7 @@ pub fn test_desc_satisfy( println!("Testing descriptor: {}", definite_desc); // Finalize the transaction using psbt // Let miniscript do it's magic! - if let Err(_) = psbt.finalize_mut(&secp) { + if psbt.finalize_mut(&secp).is_err() { return Err(DescError::PsbtFinalizeError); } let tx = psbt.extract(&secp).expect("Extraction error");