Skip to content
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
2 changes: 1 addition & 1 deletion key-wallet/examples/basic_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() -> core::result::Result<(), Box<dyn std::error::Error>> {

// 5. Create account derivation
println!("\n5. Deriving addresses...");
let account_derivation = AccountDerivation::new(account.clone());
let account_derivation = AccountDerivation::new(account);

// Derive first 5 receive addresses
println!(" Receive addresses:");
Expand Down
18 changes: 6 additions & 12 deletions key-wallet/src/bip32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,9 @@ pub enum KeyDerivationType {
BLS = 1,
}

impl Into<u32> for KeyDerivationType {
fn into(self) -> u32 {
match self {
impl From<KeyDerivationType> for u32 {
fn from(val: KeyDerivationType) -> Self {
match val {
KeyDerivationType::ECDSA => 0,
KeyDerivationType::BLS => 1,
}
Expand Down Expand Up @@ -985,7 +985,7 @@ impl IntoDerivationPath for String {
}
}

impl<'a> IntoDerivationPath for &'a str {
impl IntoDerivationPath for &str {
fn into_derivation_path(self) -> Result<DerivationPath, Error> {
self.parse()
}
Expand Down Expand Up @@ -1443,10 +1443,7 @@ impl ExtendedPrivKey {
let parent_fingerprint = data[5..9].try_into().expect("4 bytes for fingerprint");

let hardening_byte = data[9];
let is_hardened = match hardening_byte {
0x00 => false,
_ => true,
};
let is_hardened = !matches!(hardening_byte, 0x00);

let child_number_bytes = data[10..42].try_into().expect("32 bytes for child number");
let child_number = if is_hardened {
Expand Down Expand Up @@ -1778,10 +1775,7 @@ impl ExtendedPubKey {
let parent_fingerprint = data[5..9].try_into().expect("4 bytes for fingerprint");

let hardening_byte = data[9];
let is_hardened = match hardening_byte {
0x00 => false,
_ => true,
};
let is_hardened = !matches!(hardening_byte, 0x00);

let child_number_bytes = data[10..42].try_into().expect("32 bytes for child number");
let child_number = if is_hardened {
Expand Down
6 changes: 2 additions & 4 deletions key-wallet/src/derivation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ impl AccountDerivation {
let path = format!("m/0/{}", index)
.parse::<DerivationPath>()
.map_err(|e| Error::InvalidDerivationPath(e.to_string()))?;
let priv_key = self.account_key.derive_priv(&self.secp, &path)
.map_err(Error::Bip32)?;
let priv_key = self.account_key.derive_priv(&self.secp, &path).map_err(Error::Bip32)?;
Ok(ExtendedPubKey::from_priv(&self.secp, &priv_key))
}

Expand All @@ -168,8 +167,7 @@ impl AccountDerivation {
let path = format!("m/1/{}", index)
.parse::<DerivationPath>()
.map_err(|e| Error::InvalidDerivationPath(e.to_string()))?;
let priv_key = self.account_key.derive_priv(&self.secp, &path)
.map_err(Error::Bip32)?;
let priv_key = self.account_key.derive_priv(&self.secp, &path).map_err(Error::Bip32)?;
Ok(ExtendedPubKey::from_priv(&self.secp, &priv_key))
}
}
Expand Down
2 changes: 1 addition & 1 deletion key-wallet/src/dip9.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<const N: usize> IndexConstPath<N> {

pub fn append(&self, child_number: ChildNumber) -> DerivationPath {
let root_derivation_path = DerivationPath::from(self.indexes.as_ref());
root_derivation_path.extend(&[child_number]);
root_derivation_path.extend([child_number]);
root_derivation_path
}

Expand Down
2 changes: 1 addition & 1 deletion key-wallet/tests/address_tests.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Address tests

use std::str::FromStr;
use bitcoin_hashes::{hash160, Hash};
use key_wallet::address::{Address, AddressGenerator, AddressType};
use key_wallet::derivation::HDWallet;
use key_wallet::Network;
use secp256k1::{PublicKey, Secp256k1};
use std::str::FromStr;

#[test]
fn test_p2pkh_address_creation() {
Expand Down
Loading