From 0575616127d08f363d948cd61e7c2d43fd678444 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Wed, 8 Nov 2023 09:31:25 +0100 Subject: [PATCH] Address new clippy lints --- sdk/src/client/api/high_level.rs | 3 +-- sdk/src/client/secret/mnemonic.rs | 4 +--- sdk/src/client/secret/private_key.rs | 4 +--- sdk/src/client/utils.rs | 5 +---- sdk/src/wallet/migration/chrysalis.rs | 8 ++++---- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/sdk/src/client/api/high_level.rs b/sdk/src/client/api/high_level.rs index 6fb23cf63c..3338cd02b3 100644 --- a/sdk/src/client/api/high_level.rs +++ b/sdk/src/client/api/high_level.rs @@ -202,11 +202,10 @@ impl Client { let mut total_already_spent = 0; let mut selected_inputs = Vec::new(); - for (_offset, output_wrapper) in basic_outputs + for output_wrapper in basic_outputs .into_iter() // Max inputs is 128 .take(INPUT_COUNT_MAX.into()) - .enumerate() { // Break if we have enough funds and don't create dust for the remainder if total_already_spent == amount || total_already_spent >= amount { diff --git a/sdk/src/client/secret/mnemonic.rs b/sdk/src/client/secret/mnemonic.rs index 8638e8b122..29a7e91734 100644 --- a/sdk/src/client/secret/mnemonic.rs +++ b/sdk/src/client/secret/mnemonic.rs @@ -62,9 +62,7 @@ impl SecretManage for MnemonicSecretManager { .to_bytes(); // Hash the public key to get the address - let result = Blake2b256::digest(public_key).try_into().map_err(|_e| { - crate::client::Error::Blake2b256("hashing the public key while generating the address failed.") - })?; + let result = Blake2b256::digest(public_key).into(); crate::client::Result::Ok(Ed25519Address::new(result)) }) diff --git a/sdk/src/client/secret/private_key.rs b/sdk/src/client/secret/private_key.rs index 7b11ab0ce9..89cf77fd91 100644 --- a/sdk/src/client/secret/private_key.rs +++ b/sdk/src/client/secret/private_key.rs @@ -47,9 +47,7 @@ impl SecretManage for PrivateKeySecretManager { let public_key = self.0.public_key().to_bytes(); // Hash the public key to get the address - let result = Blake2b256::digest(public_key).try_into().map_err(|_e| { - crate::client::Error::Blake2b256("hashing the public key while generating the address failed.") - })?; + let result = Blake2b256::digest(public_key).into(); crate::client::Result::Ok(vec![Ed25519Address::new(result)]) } diff --git a/sdk/src/client/utils.rs b/sdk/src/client/utils.rs index 2500b5e48f..73e1d21dc1 100644 --- a/sdk/src/client/utils.rs +++ b/sdk/src/client/utils.rs @@ -43,11 +43,8 @@ pub fn hex_to_bech32(hex: &str, bech32_hrp: impl ConvertTo) -> Result) -> Result { let public_key: [u8; Ed25519Address::LENGTH] = prefix_hex::decode(hex)?; + let address = Ed25519Address::new(Blake2b256::digest(public_key).into()); - let address = Blake2b256::digest(public_key) - .try_into() - .map_err(|_e| Error::Blake2b256("hashing the public key failed."))?; - let address: Ed25519Address = Ed25519Address::new(address); Ok(Address::Ed25519(address).try_to_bech32(bech32_hrp)?) } diff --git a/sdk/src/wallet/migration/chrysalis.rs b/sdk/src/wallet/migration/chrysalis.rs index 41ff1e934f..5543ca4c30 100644 --- a/sdk/src/wallet/migration/chrysalis.rs +++ b/sdk/src/wallet/migration/chrysalis.rs @@ -179,12 +179,12 @@ fn decrypt_record(record_bytes: Vec, encryption_key: &[u8; 32]) -> crate::wa let mut pt = vec![0; ct.len()]; // we can unwrap here since we know the lengths are valid XChaCha20Poly1305::decrypt( - encryption_key.try_into().unwrap(), - &nonce.try_into().unwrap(), + encryption_key.into(), + &nonce.into(), &[], &mut pt, &ct, - tag.as_slice().try_into().unwrap(), + tag.as_slice().into(), ) .map_err(|e| Error::Migration(format!("{:?}", e)))?; @@ -200,7 +200,7 @@ pub(crate) fn to_chrysalis_key(key: &[u8], stronghold: bool) -> Vec { let (id, _) = buf.split_at(24); - id.try_into().unwrap() + id.into() } else { key.into() }