From a5e2b92a82a4fd4f65329bbccf14911c67044df1 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 13 Sep 2026 17:14:15 +0700 Subject: [PATCH] chore: bump pinned Rust toolchain to 1.98.1 Move rust-toolchain.toml from 1.95.0 to 1.98.1 and fix the clippy lints the newer toolchain raises under -D warnings. MSRV stays 1.89. Co-Authored-By: Claude Fable 5.1 --- dash-network/build.rs | 2 +- dash-spv-ffi/build.rs | 2 +- dash/examples/taproot-psbt.rs | 2 +- dash/src/amount.rs | 11 +++++------ dash/src/bip158.rs | 6 ++---- dash/src/taproot.rs | 8 +++++--- hashes/src/ripemd160.rs | 9 ++++----- hashes/src/sha1.rs | 9 ++++----- hashes/src/sha256.rs | 13 ++++++------- hashes/src/sha512.rs | 9 ++++----- internals/src/hex/display.rs | 6 +++--- internals/src/hex/mod.rs | 4 ++-- key-wallet-ffi/build.rs | 2 +- key-wallet/src/managed_account/address_pool.rs | 2 +- key-wallet/src/psbt/raw.rs | 2 +- rpc-integration-test/src/main.rs | 9 --------- rust-toolchain.toml | 2 +- 17 files changed, 42 insertions(+), 56 deletions(-) diff --git a/dash-network/build.rs b/dash-network/build.rs index 7bcf382a6..269c85272 100644 --- a/dash-network/build.rs +++ b/dash-network/build.rs @@ -23,7 +23,7 @@ fn generate_bindings() { fs::create_dir_all(&include_dir).unwrap(); - let output_path = include_dir.join(format!("{}.h", &crate_name)); + let output_path = include_dir.join(format!("{}.h", crate_name)); let config_path = Path::new(&crate_dir).join("cbindgen.toml"); let config = cbindgen::Config::from_file(&config_path).expect("Failed to read cbindgen.toml"); diff --git a/dash-spv-ffi/build.rs b/dash-spv-ffi/build.rs index 29549edbb..2ea7dafa8 100644 --- a/dash-spv-ffi/build.rs +++ b/dash-spv-ffi/build.rs @@ -18,7 +18,7 @@ fn main() { fs::create_dir_all(&include_dir).unwrap(); - let output_path = include_dir.join(format!("{}.h", &crate_name)); + let output_path = include_dir.join(format!("{}.h", crate_name)); let config_path = Path::new(&crate_dir).join("cbindgen.toml"); let config = cbindgen::Config::from_file(&config_path).expect("Failed to read cbindgen.toml"); diff --git a/dash/examples/taproot-psbt.rs b/dash/examples/taproot-psbt.rs index 6485fd5bb..3efba28e8 100644 --- a/dash/examples/taproot-psbt.rs +++ b/dash/examples/taproot-psbt.rs @@ -724,7 +724,7 @@ impl BeneficiaryWallet { // FINALIZER psbt.inputs.iter_mut().for_each(|input| { let mut script_witness: Witness = Witness::new(); - for (_, signature) in input.tap_script_sigs.iter() { + for signature in input.tap_script_sigs.values() { script_witness.push(signature.to_vec()); } for (control_block, (script, _)) in input.tap_scripts.iter() { diff --git a/dash/src/amount.rs b/dash/src/amount.rs index 5300ece1d..18b5929fb 100644 --- a/dash/src/amount.rs +++ b/dash/src/amount.rs @@ -379,15 +379,14 @@ fn fmt_satoshi_in( let mut num_after_decimal_point = 0; let mut norm_nb_decimals = 0; let mut num_before_decimal_point = satoshi; - let trailing_decimal_zeros; let mut exp = 0; - match precision.cmp(&0) { + let trailing_decimal_zeros = match precision.cmp(&0) { // We add the number of zeroes to the end Ordering::Greater => { if satoshi > 0 { exp = precision as usize; } - trailing_decimal_zeros = options.precision.unwrap_or(0); + options.precision.unwrap_or(0) } Ordering::Less => { let precision = unsigned_abs(precision); @@ -406,10 +405,10 @@ fn fmt_satoshi_in( } // compute requested precision let opt_precision = options.precision.unwrap_or(0); - trailing_decimal_zeros = opt_precision.saturating_sub(norm_nb_decimals); + opt_precision.saturating_sub(norm_nb_decimals) } - Ordering::Equal => trailing_decimal_zeros = options.precision.unwrap_or(0), - } + Ordering::Equal => options.precision.unwrap_or(0), + }; let total_decimals = norm_nb_decimals + trailing_decimal_zeros; // Compute expected width of the number let mut num_width = if total_decimals > 0 { diff --git a/dash/src/bip158.rs b/dash/src/bip158.rs index 46df3c61b..37c1465e8 100644 --- a/dash/src/bip158.rs +++ b/dash/src/bip158.rs @@ -203,10 +203,8 @@ impl<'a, W: io::Write> BlockFilterWriter<'a, W> { .flat_map(|t| t.input.iter().map(|i| &i.previous_output)) .map(script_for_coin) { - match script { - Ok(script) => self.add_element(script.borrow().as_bytes()), - Err(e) => return Err(e), - } + let script = script?; + self.add_element(script.borrow().as_bytes()); } Ok(()) } diff --git a/dash/src/taproot.rs b/dash/src/taproot.rs index d6eb7b4b9..d1b02dfce 100644 --- a/dash/src/taproot.rs +++ b/dash/src/taproot.rs @@ -1184,10 +1184,12 @@ impl TaprootMerkleBranch { Err(TaprootError::InvalidMerkleTreeDepth(sl.len() / TAPROOT_CONTROL_NODE_SIZE)) } else { let inner = sl - .chunks_exact(TAPROOT_CONTROL_NODE_SIZE) + .as_chunks::() + .0 + .iter() .map(|chunk| { TapNodeHash::from_slice(chunk) - .expect("chunks_exact always returns the correct size") + .expect("as_chunks always returns the correct size") }) .collect(); @@ -1491,7 +1493,7 @@ impl fmt::Display for LeafVersion { match (self, f.alternate()) { (LeafVersion::TapScript, true) => f.write_str("tapscript"), (LeafVersion::TapScript, false) => fmt::Display::fmt(&TAPROOT_LEAF_TAPSCRIPT, f), - (LeafVersion::Future(version), true) => write!(f, "future_script_{:#02x}", version.0), + (LeafVersion::Future(version), true) => write!(f, "future_script_{:#x}", version.0), (LeafVersion::Future(version), false) => fmt::Display::fmt(version, f), } } diff --git a/hashes/src/ripemd160.rs b/hashes/src/ripemd160.rs index be9fbca67..4e532cb1f 100644 --- a/hashes/src/ripemd160.rs +++ b/hashes/src/ripemd160.rs @@ -20,7 +20,6 @@ //! RIPEMD160 implementation. //! -use core::convert::TryInto; use core::ops::Index; use core::slice::SliceIndex; use core::{cmp, str}; @@ -87,8 +86,8 @@ impl crate::HashEngine for HashEngine { #[cfg(not(fuzzing))] fn midstate(&self) -> [u8; 20] { let mut ret = [0; 20]; - for (val, ret_bytes) in self.h.iter().zip(ret.chunks_exact_mut(4)) { - ret_bytes.copy_from_slice(&(*val).to_le_bytes()); + for (val, ret_bytes) in self.h.iter().zip(ret.as_chunks_mut::<4>().0) { + *ret_bytes = val.to_le_bytes(); } ret } @@ -214,8 +213,8 @@ impl HashEngine { debug_assert_eq!(self.buffer.len(), BLOCK_SIZE); let mut w = [0u32; 16]; - for (w_val, buff_bytes) in w.iter_mut().zip(self.buffer.chunks_exact(4)) { - *w_val = u32::from_le_bytes(buff_bytes.try_into().expect("4 byte slice")) + for (w_val, buff_bytes) in w.iter_mut().zip(self.buffer.as_chunks::<4>().0) { + *w_val = u32::from_le_bytes(*buff_bytes) } process_block!(self.h, w, diff --git a/hashes/src/sha1.rs b/hashes/src/sha1.rs index 9d060de42..6bcaf0616 100644 --- a/hashes/src/sha1.rs +++ b/hashes/src/sha1.rs @@ -15,7 +15,6 @@ //! SHA1 implementation. //! -use core::convert::TryInto; use core::ops::Index; use core::slice::SliceIndex; use core::{cmp, str}; @@ -74,8 +73,8 @@ impl crate::HashEngine for HashEngine { #[cfg(not(fuzzing))] fn midstate(&self) -> [u8; 20] { let mut ret = [0; 20]; - for (val, ret_bytes) in self.h.iter().zip(ret.chunks_exact_mut(4)) { - ret_bytes.copy_from_slice(&val.to_be_bytes()) + for (val, ret_bytes) in self.h.iter().zip(ret.as_chunks_mut::<4>().0) { + *ret_bytes = val.to_be_bytes() } ret } @@ -102,8 +101,8 @@ impl HashEngine { debug_assert_eq!(self.buffer.len(), BLOCK_SIZE); let mut w = [0u32; 80]; - for (w_val, buff_bytes) in w.iter_mut().zip(self.buffer.chunks_exact(4)) { - *w_val = u32::from_be_bytes(buff_bytes.try_into().expect("4 bytes slice")) + for (w_val, buff_bytes) in w.iter_mut().zip(self.buffer.as_chunks::<4>().0) { + *w_val = u32::from_be_bytes(*buff_bytes) } for i in 16..80 { w[i] = (w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]).rotate_left(1); diff --git a/hashes/src/sha256.rs b/hashes/src/sha256.rs index 51ce18397..fac3b2737 100644 --- a/hashes/src/sha256.rs +++ b/hashes/src/sha256.rs @@ -15,7 +15,6 @@ //! SHA256 implementation. //! -use core::convert::TryInto; use core::ops::Index; use core::slice::SliceIndex; use core::{cmp, str}; @@ -89,8 +88,8 @@ impl crate::HashEngine for HashEngine { #[cfg(not(fuzzing))] fn midstate(&self) -> Midstate { let mut ret = [0; 32]; - for (val, ret_bytes) in self.h.iter().zip(ret.chunks_exact_mut(4)) { - ret_bytes.copy_from_slice(&val.to_be_bytes()); + for (val, ret_bytes) in self.h.iter().zip(ret.as_chunks_mut::<4>().0) { + *ret_bytes = val.to_be_bytes(); } Midstate(ret) } @@ -407,8 +406,8 @@ impl HashEngine { assert!(length.is_multiple_of(BLOCK_SIZE), "length is no multiple of the block size"); let mut ret = [0; 8]; - for (ret_val, midstate_bytes) in ret.iter_mut().zip(midstate[..].chunks_exact(4)) { - *ret_val = u32::from_be_bytes(midstate_bytes.try_into().expect("4 byte slice")); + for (ret_val, midstate_bytes) in ret.iter_mut().zip(midstate[..].as_chunks::<4>().0) { + *ret_val = u32::from_be_bytes(*midstate_bytes); } HashEngine { @@ -423,8 +422,8 @@ impl HashEngine { debug_assert_eq!(self.buffer.len(), BLOCK_SIZE); let mut w = [0u32; 16]; - for (w_val, buff_bytes) in w.iter_mut().zip(self.buffer.chunks_exact(4)) { - *w_val = u32::from_be_bytes(buff_bytes.try_into().expect("4 byte slice")); + for (w_val, buff_bytes) in w.iter_mut().zip(self.buffer.as_chunks::<4>().0) { + *w_val = u32::from_be_bytes(*buff_bytes); } let mut a = self.h[0]; diff --git a/hashes/src/sha512.rs b/hashes/src/sha512.rs index 5f1a79ff2..4c02a3865 100644 --- a/hashes/src/sha512.rs +++ b/hashes/src/sha512.rs @@ -20,7 +20,6 @@ //! SHA512 implementation. //! -use core::convert::TryInto; use core::ops::Index; use core::slice::SliceIndex; use core::{cmp, str}; @@ -59,8 +58,8 @@ impl crate::HashEngine for HashEngine { #[cfg(not(fuzzing))] fn midstate(&self) -> [u8; 64] { let mut ret = [0; 64]; - for (val, ret_bytes) in self.h.iter().zip(ret.chunks_exact_mut(8)) { - ret_bytes.copy_from_slice(&val.to_be_bytes()); + for (val, ret_bytes) in self.h.iter().zip(ret.as_chunks_mut::<8>().0) { + *ret_bytes = val.to_be_bytes(); } ret } @@ -159,8 +158,8 @@ impl HashEngine { debug_assert_eq!(self.buffer.len(), BLOCK_SIZE); let mut w = [0u64; 16]; - for (w_val, buff_bytes) in w.iter_mut().zip(self.buffer.chunks_exact(8)) { - *w_val = u64::from_be_bytes(buff_bytes.try_into().expect("8 byte slice")); + for (w_val, buff_bytes) in w.iter_mut().zip(self.buffer.as_chunks::<8>().0) { + *w_val = u64::from_be_bytes(*buff_bytes); } let mut a = self.h[0]; diff --git a/internals/src/hex/display.rs b/internals/src/hex/display.rs index 1b82988e8..af1faacf9 100644 --- a/internals/src/hex/display.rs +++ b/internals/src/hex/display.rs @@ -143,13 +143,13 @@ impl<'a> DisplayByteSlice<'a> { let mut buf = [0u8; 1024]; let mut encoder = super::BufEncoder::new(&mut buf); - let mut chunks = self.bytes.chunks_exact(512); - for chunk in &mut chunks { + let (chunks, remainder) = self.bytes.as_chunks::<512>(); + for chunk in chunks { encoder.put_bytes(chunk, case); f.write_str(encoder.as_str())?; encoder.clear(); } - encoder.put_bytes(chunks.remainder(), case); + encoder.put_bytes(remainder, case); f.write_str(encoder.as_str()) } } diff --git a/internals/src/hex/mod.rs b/internals/src/hex/mod.rs index 1f9d61876..6169e881b 100644 --- a/internals/src/hex/mod.rs +++ b/internals/src/hex/mod.rs @@ -30,8 +30,8 @@ impl Case { #[inline] #[rustfmt::skip] pub(crate) fn table(self) -> &'static [u8; 16] { - static LOWER: [u8; 16] = [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'a', b'b', b'c', b'd', b'e', b'f']; - static UPPER: [u8; 16] = [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'A', b'B', b'C', b'D', b'E', b'F']; + static LOWER: [u8; 16] = *b"0123456789abcdef"; + static UPPER: [u8; 16] = *b"0123456789ABCDEF"; match self { Case::Lower => &LOWER, diff --git a/key-wallet-ffi/build.rs b/key-wallet-ffi/build.rs index 29549edbb..2ea7dafa8 100644 --- a/key-wallet-ffi/build.rs +++ b/key-wallet-ffi/build.rs @@ -18,7 +18,7 @@ fn main() { fs::create_dir_all(&include_dir).unwrap(); - let output_path = include_dir.join(format!("{}.h", &crate_name)); + let output_path = include_dir.join(format!("{}.h", crate_name)); let config_path = Path::new(&crate_dir).join("cbindgen.toml"); let config = cbindgen::Config::from_file(&config_path).expect("Failed to read cbindgen.toml"); diff --git a/key-wallet/src/managed_account/address_pool.rs b/key-wallet/src/managed_account/address_pool.rs index 346455abb..c17583fca 100644 --- a/key-wallet/src/managed_account/address_pool.rs +++ b/key-wallet/src/managed_account/address_pool.rs @@ -922,7 +922,7 @@ impl AddressPool { { let mut found = Vec::new(); - for (_, info) in self.addresses.iter_mut() { + for info in self.addresses.values_mut() { if !info.is_used() && check_fn(&info.address) { info.mark_used(); self.used_indices.insert(info.index); diff --git a/key-wallet/src/psbt/raw.rs b/key-wallet/src/psbt/raw.rs index b97c580df..20aae577e 100644 --- a/key-wallet/src/psbt/raw.rs +++ b/key-wallet/src/psbt/raw.rs @@ -86,7 +86,7 @@ impl Key { let key_byte_size: u64 = byte_size - 1; if key_byte_size > MAX_VEC_SIZE as u64 { - return Err(encode::Error::OversizedVectorAllocation { + Err(encode::Error::OversizedVectorAllocation { requested: key_byte_size as usize, max: MAX_VEC_SIZE, })?; diff --git a/rpc-integration-test/src/main.rs b/rpc-integration-test/src/main.rs index edd429c4e..5f3038961 100644 --- a/rpc-integration-test/src/main.rs +++ b/rpc-integration-test/src/main.rs @@ -1515,15 +1515,6 @@ fn test_get_protx_info(cl: &Client) { let protx_info = cl.get_protx_info(&pro_tx_hash, None).unwrap(); let ProTxInfo { - pro_tx_hash: _, - collateral_hash: _, - collateral_index: _, - collateral_address: _, - operator_reward: _, - state: _, - confirmations: _, - wallet: _, - meta_info: _, .. } = protx_info; } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6360c1888..68c0ea297 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.95.0" +channel = "1.98.1" components = ["rustfmt", "clippy"]