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

bip32: Add DerivationPath type #233

Merged
merged 4 commits into from Feb 15, 2019

Conversation

Projects
None yet
3 participants
@stevenroose
Copy link
Collaborator

stevenroose commented Feb 7, 2019

Replaces #185.

@dongcarl

This comment has been minimized.

Copy link
Member

dongcarl commented Feb 11, 2019

@stevenroose Could you force push again? I think Travis is buggy.

@dongcarl

This comment has been minimized.

Copy link
Member

dongcarl commented Feb 11, 2019

Possible followup PR: Implement FromIterator and ToIterator, make the wrapped Vec not public.

@sgeisler

This comment has been minimized.

Copy link
Member

sgeisler commented Feb 11, 2019

Possible followup PR: Implement FromIterator and ToIterator, make the wrapped Vec not public.

Here it might even make sense to implement the different index/range traits, so you could select sub-paths:

let first_key = DerivationPath::from_str("m/84'/0'/0'/0/0")?;
let next_key = first_key[..4].child(first_key[4] + 1);

@stevenroose stevenroose force-pushed the stevenroose:derivation-path branch 2 times, most recently from 94d33c4 to 15ab50c Feb 12, 2019

Show resolved Hide resolved src/util/bip32.rs
Show resolved Hide resolved src/util/bip32.rs
Show resolved Hide resolved src/util/bip32.rs

@stevenroose stevenroose force-pushed the stevenroose:derivation-path branch from 15ab50c to 745481d Feb 13, 2019

Show resolved Hide resolved src/util/bip32.rs Outdated
Show resolved Hide resolved src/util/bip32.rs Outdated
Show resolved Hide resolved src/util/bip32.rs
Show resolved Hide resolved src/util/bip32.rs Outdated

stevenroose added some commits Feb 14, 2019

bip32: ChildNumber constructors return Result
They can produce an error if the index is out of range.
bip32: Introduce DerivationPath type
Implements Display and FromStr for easy usage with serialized types.

@stevenroose stevenroose force-pushed the stevenroose:derivation-path branch from 745481d to dce81b6 Feb 14, 2019

bip32: Add additional methods and traits to DerivationPath
- From<&[ChildNumber]> (cloning)
- AsRef<[ChildNumber]>
- std::iter::FromIterator<ChildNumber>
- std::iter::IntoIterator<ChildNumber>
- std::ops::Index (returning &[ChildNumber])

Also add two methods:
- child(&self, ChildNumber) -> DerivationPath
- into_child(self, ChildNumber) -> DerivationPath
@sgeisler
Copy link
Member

sgeisler left a comment

Addressed all comments, LGTM.

@dongcarl
Copy link
Member

dongcarl left a comment

LGTM

@dongcarl dongcarl merged commit d5331e5 into rust-bitcoin:master Feb 15, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment