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

Fix wif network #504

Merged
merged 4 commits into from
Dec 23, 2021
Merged

Fix wif network #504

merged 4 commits into from
Dec 23, 2021

Conversation

mcroad
Copy link
Contributor

@mcroad mcroad commented Dec 18, 2021

Description

BDK generates WIFs in the wrong format when converting an ExtendedKey into an ExtendedPrivKey via into_xprv.
Specifically, all generated WIFs are in Network::Bitcoin format instead of the specified network.

let xkey: ExtendedKey = bip39::Mnemonic::parse_in(
    bip39::Language::English,
    "jelly crash boy whisper mouse ecology tuna soccer memory million news short",
)
.unwrap()
.into_extended_key()
.unwrap();
let xprv = xkey.into_xprv(Network::Testnet).unwrap();
let wif = PrivateKey::from_wif(&xprv.private_key.to_wif()).unwrap();

// assertion fails
assert_eq!(wif.network, Network::Testnet);

Notes to the reviewers

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

Copy link
Member

@notmandatory notmandatory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ee41d88

Nice catch.

@afilini afilini merged commit 61ee2a9 into bitcoindevkit:master Dec 23, 2021
@mcroad mcroad deleted the fix-wif-network branch December 23, 2021 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants