diff --git a/addresses/src/lib.rs b/addresses/src/lib.rs index 15b64efdc..06c99f4e9 100644 --- a/addresses/src/lib.rs +++ b/addresses/src/lib.rs @@ -21,6 +21,7 @@ // Exclude lints we don't think are valuable. #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #![allow(clippy::manual_range_contains)] // More readable than clippy's format. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` extern crate alloc; diff --git a/base58/src/lib.rs b/base58/src/lib.rs index b19759284..be1026fbd 100644 --- a/base58/src/lib.rs +++ b/base58/src/lib.rs @@ -21,6 +21,7 @@ #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #![allow(clippy::manual_range_contains)] // More readable than clippy's format. #![allow(clippy::incompatible_msrv)] // Has FPs and we're testing it which is more reliable anyway. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` extern crate alloc; diff --git a/bitcoin/examples/bip32.rs b/bitcoin/examples/bip32.rs index 7cde6c646..41f3791ea 100644 --- a/bitcoin/examples/bip32.rs +++ b/bitcoin/examples/bip32.rs @@ -22,7 +22,7 @@ fn main() { } let seed_hex = &args[1]; - println!("Seed: {}", seed_hex); + println!("Seed: {seed_hex}"); println!("Using mainnet network"); let seed = Vec::from_hex(seed_hex).unwrap(); @@ -34,19 +34,19 @@ fn main() { // calculate root key from seed let root = Xpriv::new_master(NetworkKind::Main, &seed); - println!("Root key: {}", root); + println!("Root key: {root}"); // derive child xpub let path = "84h/0h/0h".parse::().unwrap(); let child = root.derive_xpriv(&secp, &path).expect("only deriving three steps"); - println!("Child at {}: {}", path, child); + println!("Child at {path}: {child}"); let xpub = Xpub::from_xpriv(&secp, &child); - println!("Public key at {}: {}", path, xpub); + println!("Public key at {path}: {xpub}"); // generate first receiving address at m/0/0 // manually creating indexes this time let zero = ChildNumber::ZERO_NORMAL; let public_key = xpub.derive_xpub(&secp, &[zero, zero]).unwrap().public_key; let address = Address::p2wpkh(CompressedPublicKey(public_key), KnownHrp::Mainnet); - println!("First receiving address: {}", address); + println!("First receiving address: {address}"); } diff --git a/bitcoin/examples/create-p2wpkh-address.rs b/bitcoin/examples/create-p2wpkh-address.rs index b8ec758f8..e92ffe531 100644 --- a/bitcoin/examples/create-p2wpkh-address.rs +++ b/bitcoin/examples/create-p2wpkh-address.rs @@ -19,6 +19,6 @@ fn main() { // Create a Bitcoin P2WPKH address. let address = Address::p2wpkh(public_key, Network::Bitcoin); - println!("Private Key: {}", private_key); - println!("Address: {}", address); + println!("Private Key: {private_key}"); + println!("Address: {address}"); } diff --git a/bitcoin/examples/ecdsa-psbt-simple.rs b/bitcoin/examples/ecdsa-psbt-simple.rs index 21b9f6cad..73f209bb2 100644 --- a/bitcoin/examples/ecdsa-psbt-simple.rs +++ b/bitcoin/examples/ecdsa-psbt-simple.rs @@ -244,8 +244,8 @@ fn main() { // BOOM! Transaction signed and ready to broadcast. let signed_tx = psbt.extract_tx().expect("valid transaction"); let serialized_signed_tx = consensus::encode::serialize_hex(&signed_tx); - println!("Transaction Details: {:#?}", signed_tx); + println!("Transaction Details: {signed_tx:#?}"); // check with: // bitcoin-cli decoderawtransaction true - println!("Raw Transaction: {}", serialized_signed_tx); + println!("Raw Transaction: {serialized_signed_tx}"); } diff --git a/bitcoin/examples/ecdsa-psbt.rs b/bitcoin/examples/ecdsa-psbt.rs index 1abdf6751..0ac297654 100644 --- a/bitcoin/examples/ecdsa-psbt.rs +++ b/bitcoin/examples/ecdsa-psbt.rs @@ -87,7 +87,7 @@ fn main() -> Result<()> { tx.verify(|_| Some(previous_output())).expect("failed to verify transaction"); let hex = encode::serialize_hex(&tx); - println!("You should now be able to broadcast the following transaction: \n\n{}", hex); + println!("You should now be able to broadcast the following transaction: \n\n{hex}"); Ok(()) } diff --git a/bitcoin/examples/handshake.rs b/bitcoin/examples/handshake.rs index db5a4fb17..4382de02a 100644 --- a/bitcoin/examples/handshake.rs +++ b/bitcoin/examples/handshake.rs @@ -19,7 +19,7 @@ fn main() { let str_address = &args[1]; let address: SocketAddr = str_address.parse().unwrap_or_else(|error| { - eprintln!("error parsing address: {:?}", error); + eprintln!("error parsing address: {error:?}"); process::exit(1); }); diff --git a/bitcoin/examples/script.rs b/bitcoin/examples/script.rs index de72033d4..ee8be6ee0 100644 --- a/bitcoin/examples/script.rs +++ b/bitcoin/examples/script.rs @@ -22,14 +22,14 @@ fn main() { assert_eq!(decoded, script_code); // Writes the script as human-readable eg, OP_DUP OP_HASH160 OP_PUSHBYTES_20 ... - println!("human-readable script: {}", script_code); + println!("human-readable script: {script_code}"); // We do not implement parsing scripts from human-readable format. // let decoded = s.parse::().unwrap(); // This is equivalent to consensus encoding i.e., includes the length prefix. - let hex_lower_hex_trait = format!("{:x}", script_code); - println!("hex created using `LowerHex`: {}", hex_lower_hex_trait); + let hex_lower_hex_trait = format!("{script_code:x}"); + println!("hex created using `LowerHex`: {hex_lower_hex_trait}"); // The `deserialize_hex` function requires the length prefix. assert_eq!(encode::deserialize_hex::(&hex_lower_hex_trait).unwrap(), script_code); @@ -43,7 +43,7 @@ fn main() { // This is consensus encoding i.e., includes the length prefix. let hex_inherent = script_code.to_hex_string(); // Defined in `ScriptExt`. - println!("hex created using inherent `to_hex_string`: {}", hex_inherent); + println!("hex created using inherent `to_hex_string`: {hex_inherent}"); // The inverse of `to_hex_string` is `from_hex`. let decoded = ScriptBuf::from_hex(&hex_inherent).unwrap(); // Defined in `ScriptBufExt`. @@ -54,7 +54,7 @@ fn main() { // We also support encode/decode using `consensus::encode` functions. let encoded = encode::serialize_hex(&script_code); - println!("hex created using consensus::encode::serialize_hex: {}", encoded); + println!("hex created using consensus::encode::serialize_hex: {encoded}"); let decoded: ScriptBuf = encode::deserialize_hex(&encoded).unwrap(); assert_eq!(decoded, script_code); diff --git a/bitcoin/examples/sighash.rs b/bitcoin/examples/sighash.rs index 1055a52f7..bfa82216e 100644 --- a/bitcoin/examples/sighash.rs +++ b/bitcoin/examples/sighash.rs @@ -24,7 +24,7 @@ fn compute_sighash_p2wpkh(raw_tx: &[u8], inp_idx: usize, amount: Amount) { let tx: Transaction = consensus::deserialize(raw_tx).unwrap(); let inp = &tx.input[inp_idx]; let witness = &inp.witness; - println!("Witness: {:?}", witness); + println!("Witness: {witness:?}"); // BIP-141: The witness must consist of exactly 2 items (≤ 520 bytes each). The first one a // signature, and the second one a public key. @@ -38,16 +38,16 @@ fn compute_sighash_p2wpkh(raw_tx: &[u8], inp_idx: usize, amount: Amount) { //this is nothing but a standard P2PKH script OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG: let pk = CompressedPublicKey::from_slice(pk_bytes).expect("failed to parse pubkey"); let wpkh = pk.wpubkey_hash(); - println!("Script pubkey hash: {:x}", wpkh); + println!("Script pubkey hash: {wpkh:x}"); let spk = ScriptBuf::new_p2wpkh(wpkh); let mut cache = sighash::SighashCache::new(&tx); let sighash = cache .p2wpkh_signature_hash(inp_idx, &spk, amount, sig.sighash_type) .expect("failed to compute sighash"); - println!("SegWit p2wpkh sighash: {:x}", sighash); + println!("SegWit p2wpkh sighash: {sighash:x}"); let msg = secp256k1::Message::from(sighash); - println!("Message is {:x}", msg); + println!("Message is {msg:x}"); let secp = secp256k1::Secp256k1::verification_only(); pk.verify(&secp, msg, sig).unwrap() } @@ -63,7 +63,7 @@ fn compute_sighash_legacy(raw_tx: &[u8], inp_idx: usize, script_pubkey_bytes_opt let tx: Transaction = consensus::deserialize(raw_tx).unwrap(); let inp = &tx.input[inp_idx]; let script_sig = &inp.script_sig; - println!("scriptSig is: {}", script_sig); + println!("scriptSig is: {script_sig}"); let cache = sighash::SighashCache::new(&tx); //In the P2SH case we get scriptPubKey from scriptSig of the spending input. //The scriptSig that corresponds to an M of N multisig should be: PUSHBYTES_0 PUSHBYTES_K0 ... PUSHBYTES_Km PUSHBYTES_X @@ -83,8 +83,7 @@ fn compute_sighash_legacy(raw_tx: &[u8], inp_idx: usize, script_pubkey_bytes_opt let pushbytes_0 = instructions.remove(0).unwrap(); assert!( pushbytes_0.push_bytes().unwrap().as_bytes().is_empty(), - "first in ScriptSig must be PUSHBYTES_0 got {:?}", - pushbytes_0 + "first in ScriptSig must be PUSHBYTES_0 got {pushbytes_0:?}" ); //All other scriptSig instructions must be signatures @@ -109,7 +108,7 @@ fn compute_sighash_p2wsh(raw_tx: &[u8], inp_idx: usize, amount: Amount) { let tx: Transaction = consensus::deserialize(raw_tx).unwrap(); let inp = &tx.input[inp_idx]; let witness = &inp.witness; - println!("witness {:?}", witness); + println!("witness {witness:?}"); //last element is called witnessScript according to BIP141. It supersedes scriptPubKey. let witness_script_bytes: &[u8] = witness.last().expect("out of bounds"); @@ -122,7 +121,7 @@ fn compute_sighash_p2wsh(raw_tx: &[u8], inp_idx: usize, amount: Amount) { let sig = ecdsa::Signature::from_slice(sig_bytes).expect("failed to parse sig"); let sig_len = sig_bytes.len() - 1; //last byte is EcdsaSighashType sighash flag //ECDSA signature in DER format lengths are between 70 and 72 bytes - assert!((70..=72).contains(&sig_len), "signature length {} out of bounds", sig_len); + assert!((70..=72).contains(&sig_len), "signature length {sig_len} out of bounds"); //here we assume that all sighash_flags are the same. Can they be different? let sighash = cache .p2wsh_signature_hash(inp_idx, witness_script, amount, sig.sighash_type) diff --git a/bitcoin/examples/sign-tx-segwit-v0.rs b/bitcoin/examples/sign-tx-segwit-v0.rs index b163a24b0..e9a49385d 100644 --- a/bitcoin/examples/sign-tx-segwit-v0.rs +++ b/bitcoin/examples/sign-tx-segwit-v0.rs @@ -82,7 +82,7 @@ fn main() { let tx = sighasher.into_transaction(); // BOOM! Transaction signed and ready to broadcast. - println!("{:#?}", tx); + println!("{tx:#?}"); } /// An example of keys controlled by the transaction sender. diff --git a/bitcoin/examples/sign-tx-taproot.rs b/bitcoin/examples/sign-tx-taproot.rs index 2abb4d580..00cedd4f1 100644 --- a/bitcoin/examples/sign-tx-taproot.rs +++ b/bitcoin/examples/sign-tx-taproot.rs @@ -81,7 +81,7 @@ fn main() { let tx = sighasher.into_transaction(); // BOOM! Transaction signed and ready to broadcast. - println!("{:#?}", tx); + println!("{tx:#?}"); } /// An example of keys controlled by the transaction sender. diff --git a/bitcoin/examples/taproot-psbt-simple.rs b/bitcoin/examples/taproot-psbt-simple.rs index d2ca8f9e2..0105dc59f 100644 --- a/bitcoin/examples/taproot-psbt-simple.rs +++ b/bitcoin/examples/taproot-psbt-simple.rs @@ -244,8 +244,8 @@ fn main() { // BOOM! Transaction signed and ready to broadcast. let signed_tx = psbt.extract_tx().expect("valid transaction"); let serialized_signed_tx = consensus::encode::serialize_hex(&signed_tx); - println!("Transaction Details: {:#?}", signed_tx); + println!("Transaction Details: {signed_tx:#?}"); // check with: // bitcoin-cli decoderawtransaction true - println!("Raw Transaction: {}", serialized_signed_tx); + println!("Raw Transaction: {serialized_signed_tx}"); } diff --git a/bitcoin/examples/taproot-psbt.rs b/bitcoin/examples/taproot-psbt.rs index 75bb0b8b2..040b0857e 100644 --- a/bitcoin/examples/taproot-psbt.rs +++ b/bitcoin/examples/taproot-psbt.rs @@ -125,8 +125,7 @@ fn main() -> Result<(), Box> { ], )?); println!( - "\nYou should now be able to broadcast the following transaction: \n\n{}", - tx_hex_string + "\nYou should now be able to broadcast the following transaction: \n\n{tx_hex_string}" ); println!("\nEND EXAMPLE 1\n"); @@ -147,7 +146,7 @@ fn main() -> Result<(), Box> { )?; let tx_hex = encode::serialize_hex(&tx); - println!("Inheritance funding tx hex:\n\n{}", tx_hex); + println!("Inheritance funding tx hex:\n\n{tx_hex}"); // You can now broadcast the transaction hex: // bt sendrawtransaction ... // @@ -160,7 +159,7 @@ fn main() -> Result<(), Box> { to_address, )?; let spending_tx_hex = encode::serialize_hex(&spending_tx); - println!("\nInheritance spending tx hex:\n\n{}", spending_tx_hex); + println!("\nInheritance spending tx hex:\n\n{spending_tx_hex}"); // If you try to broadcast now, the transaction will be rejected as it is timelocked. // First mine 900 blocks so we're sure we are over the 1000 block locktime: // bt generatetoaddress 900 $(bt-benefactor getnewaddress '' 'bech32m') @@ -185,7 +184,7 @@ fn main() -> Result<(), Box> { )?; let tx_hex = encode::serialize_hex(&tx); - println!("Inheritance funding tx hex:\n\n{}", tx_hex); + println!("Inheritance funding tx hex:\n\n{tx_hex}"); // You can now broadcast the transaction hex: // bt sendrawtransaction ... // @@ -200,7 +199,7 @@ fn main() -> Result<(), Box> { let (tx, _) = benefactor.refresh_tx(1000)?; let tx_hex = encode::serialize_hex(&tx); - println!("\nRefreshed inheritance tx hex:\n\n{}\n", tx_hex); + println!("\nRefreshed inheritance tx hex:\n\n{tx_hex}\n"); println!("\nEND EXAMPLE 3\n"); println!("----------------\n"); diff --git a/bitcoin/src/lib.rs b/bitcoin/src/lib.rs index 4265be8db..e5bddd50d 100644 --- a/bitcoin/src/lib.rs +++ b/bitcoin/src/lib.rs @@ -39,6 +39,7 @@ #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #![allow(clippy::manual_range_contains)] // More readable than clippy's format. #![allow(clippy::incompatible_msrv)] // Has FPs and we're testing it which is more reliable anyway. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` // We only support machines with index size of 4 bytes or more. // diff --git a/chacha20_poly1305/src/lib.rs b/chacha20_poly1305/src/lib.rs index 7777e0935..043f6877b 100644 --- a/chacha20_poly1305/src/lib.rs +++ b/chacha20_poly1305/src/lib.rs @@ -16,6 +16,7 @@ // Exclude lints we don't think are valuable. #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #![allow(clippy::manual_range_contains)] // More readable than clippy's format. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` #[cfg(feature = "alloc")] extern crate alloc; diff --git a/hashes/src/lib.rs b/hashes/src/lib.rs index b3962214c..3e8c41a6d 100644 --- a/hashes/src/lib.rs +++ b/hashes/src/lib.rs @@ -66,6 +66,7 @@ // Exclude lints we don't think are valuable. #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #![allow(clippy::manual_range_contains)] // More readable than clippy's format. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` #[cfg(feature = "alloc")] extern crate alloc; diff --git a/hashes/tests/api.rs b/hashes/tests/api.rs index 5de01d551..a85eb5547 100644 --- a/hashes/tests/api.rs +++ b/hashes/tests/api.rs @@ -8,6 +8,8 @@ #![allow(dead_code)] #![allow(unused_imports)] +// Exclude lints we don't think are valuable. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` // Import using module style e.g., `sha256::Hash`. use bitcoin_hashes::{ diff --git a/hashes/tests/regression.rs b/hashes/tests/regression.rs index 31aeec5f8..dccff1714 100644 --- a/hashes/tests/regression.rs +++ b/hashes/tests/regression.rs @@ -5,6 +5,8 @@ //! Test input data and expected hashes is the same as in `io/src/hash.rs`. #![cfg(feature = "hex")] +// Exclude lints we don't think are valuable. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` use bitcoin_hashes::{ hash160, ripemd160, sha1, sha256, sha256d, sha256t, sha384, sha512, sha512_256, siphash24, diff --git a/internals/build.rs b/internals/build.rs index 7ac6c70fd..fff95c4b9 100644 --- a/internals/build.rs +++ b/internals/build.rs @@ -1,3 +1,6 @@ +// Exclude lints we don't think are valuable. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` + const MAX_USED_VERSION: u64 = 80; use std::io; diff --git a/internals/src/lib.rs b/internals/src/lib.rs index 35c179142..e86dfda69 100644 --- a/internals/src/lib.rs +++ b/internals/src/lib.rs @@ -15,6 +15,7 @@ // Exclude lints we don't think are valuable. #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #![allow(clippy::manual_range_contains)] // More readable than clippy's format. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` #[cfg(feature = "alloc")] extern crate alloc; diff --git a/internals/src/slice.rs b/internals/src/slice.rs index e6ce027d2..630946f34 100644 --- a/internals/src/slice.rs +++ b/internals/src/slice.rs @@ -10,8 +10,9 @@ pub trait SliceExt { /// Note that `N` must not be zero: /// /// ```compile_fail + /// # use bitcoin_internals::slice::SliceExt; /// let slice = [1, 2, 3]; - /// let fail = slice.as_chunks::<0>(); + /// let _fail = slice.bitcoin_as_chunks::<0>(); /// ``` fn bitcoin_as_chunks(&self) -> (&[[Self::Item; N]], &[Self::Item]); @@ -20,8 +21,9 @@ pub trait SliceExt { /// Note that `N` must not be zero: /// /// ```compile_fail + /// # use bitcoin_internals::slice::SliceExt; /// let mut slice = [1, 2, 3]; - /// let fail = slice.as_chunks_mut::<0>(); + /// let _fail = slice.bitcoin_as_chunks_mut::<0>(); /// ``` fn bitcoin_as_chunks_mut( &mut self, diff --git a/io/src/lib.rs b/io/src/lib.rs index f92ec11f3..e5bf1e1eb 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -24,6 +24,7 @@ // Exclude lints we don't think are valuable. #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #![allow(clippy::manual_range_contains)] // More readable than clippy's format. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` #[cfg(feature = "alloc")] extern crate alloc; diff --git a/nightly-version b/nightly-version index 0fd7fce97..50d4a2244 100644 --- a/nightly-version +++ b/nightly-version @@ -1 +1 @@ -nightly-2025-04-11 +nightly-2025-05-02 diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index f9dafc05a..b3b15958a 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -16,6 +16,8 @@ #![warn(missing_docs)] #![warn(deprecated_in_future)] #![doc(test(attr(warn(unused))))] +// Exclude lints we don't think are valuable. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` #[cfg(feature = "alloc")] extern crate alloc; diff --git a/units/src/lib.rs b/units/src/lib.rs index 41c33b017..30327ba30 100644 --- a/units/src/lib.rs +++ b/units/src/lib.rs @@ -25,6 +25,8 @@ #![warn(missing_docs)] #![warn(deprecated_in_future)] #![doc(test(attr(warn(unused))))] +// Exclude lints we don't think are valuable. +#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")` #[cfg(feature = "alloc")] extern crate alloc;