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

BIP44 improvements: new with coin_type, removed impl Default #217

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
5 changes: 5 additions & 0 deletions .changes/bip44-new-coin-type.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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