Skip to content

Commit

Permalink
bip44: new with coin_type, removed impl Default (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
semenov-vladyslav committed Jul 13, 2023
1 parent 12ec85c commit e8db042
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/bip44-new-coin-type.md
@@ -0,0 +1,5 @@
---
"iota-crypto": minor
---

BIP44 improvements: made coin_type a mandatory constructor parameter, removed Default impl.
11 changes: 8 additions & 3 deletions src/keys/bip44.rs
Expand Up @@ -48,7 +48,7 @@ pub mod secp256k1 {
///
/// For Secp256k1 ECDSA secret keys the final chain is as follows (the first three segments are hardened):
/// m / purpose' / coin_type' / account' / change / address_index
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Bip44 {
pub coin_type: u32,
Expand All @@ -60,8 +60,13 @@ pub struct Bip44 {
impl Bip44 {
pub const PURPOSE: u32 = 44;

pub fn new() -> Self {
Self::default()
pub fn new(coin_type: u32) -> Self {
Self {
coin_type,
account: 0,
change: 0,
address_index: 0,
}
}

pub fn with_coin_type(mut self, s: u32) -> Self {
Expand Down

0 comments on commit e8db042

Please sign in to comment.