Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address new clippy lints #1595

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sdk/src/client/api/high_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions sdk/src/client/secret/mnemonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
Expand Down
4 changes: 1 addition & 3 deletions sdk/src/client/secret/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
}
Expand Down
5 changes: 1 addition & 4 deletions sdk/src/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ pub fn hex_to_bech32(hex: &str, bech32_hrp: impl ConvertTo<Hrp>) -> Result<Bech3
/// Transforms a prefix hex encoded public key to a bech32 encoded address
pub fn hex_public_key_to_bech32_address(hex: &str, bech32_hrp: impl ConvertTo<Hrp>) -> Result<Bech32Address> {
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)?)
}

Expand Down
8 changes: 4 additions & 4 deletions sdk/src/wallet/migration/chrysalis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ fn decrypt_record(record_bytes: Vec<u8>, 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)))?;

Expand All @@ -200,7 +200,7 @@ pub(crate) fn to_chrysalis_key(key: &[u8], stronghold: bool) -> Vec<u8> {

let (id, _) = buf.split_at(24);

id.try_into().unwrap()
id.into()
} else {
key.into()
}
Expand Down
Loading