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

Post bip39 updates #464

Merged
merged 2 commits into from
Nov 8, 2021
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- BIP39 implementation dependency, in `keys::bip39` changed from tiny-bip39 to rust-bip39.

## [v0.13.0] - [v0.12.0]

- Exposed `get_tx()` method from `Database` to `Wallet`.
Expand Down
14 changes: 7 additions & 7 deletions src/keys/bip39.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub use bip39::{Language, Mnemonic};
type Seed = [u8; 64];

/// Type describing entropy length (aka word count) in the mnemonic
pub enum WordsCount {
pub enum WordCount {
/// 12 words mnemonic (128 bits entropy)
Words12 = 128,
/// 15 words mnemonic (160 bits entropy)
Expand Down Expand Up @@ -117,7 +117,7 @@ impl<Ctx: ScriptContext> DerivableKey<Ctx> for Mnemonic {
impl<Ctx: ScriptContext> GeneratableKey<Ctx> for Mnemonic {
type Entropy = [u8; 32];

type Options = (WordsCount, Language);
type Options = (WordCount, Language);
type Error = Option<bip39::Error>;

fn generate_with_entropy(
Expand All @@ -141,7 +141,7 @@ mod test {

use crate::keys::{any_network, GeneratableKey, GeneratedKey};

use super::WordsCount;
use super::WordCount;

#[test]
fn test_keys_bip39_mnemonic() {
Expand Down Expand Up @@ -175,7 +175,7 @@ mod test {
fn test_keys_generate_bip39() {
let generated_mnemonic: GeneratedKey<_, miniscript::Segwitv0> =
Mnemonic::generate_with_entropy(
(WordsCount::Words12, Language::English),
(WordCount::Words12, Language::English),
crate::keys::test::TEST_ENTROPY,
)
.unwrap();
Expand All @@ -187,7 +187,7 @@ mod test {

let generated_mnemonic: GeneratedKey<_, miniscript::Segwitv0> =
Mnemonic::generate_with_entropy(
(WordsCount::Words24, Language::English),
(WordCount::Words24, Language::English),
crate::keys::test::TEST_ENTROPY,
)
.unwrap();
Expand All @@ -198,11 +198,11 @@ mod test {
#[test]
fn test_keys_generate_bip39_random() {
let generated_mnemonic: GeneratedKey<_, miniscript::Segwitv0> =
Mnemonic::generate((WordsCount::Words12, Language::English)).unwrap();
Mnemonic::generate((WordCount::Words12, Language::English)).unwrap();
assert_eq!(generated_mnemonic.valid_networks, any_network());

let generated_mnemonic: GeneratedKey<_, miniscript::Segwitv0> =
Mnemonic::generate((WordsCount::Words24, Language::English)).unwrap();
Mnemonic::generate((WordCount::Words24, Language::English)).unwrap();
assert_eq!(generated_mnemonic.valid_networks, any_network());
}
}