Fix pycoin exception when create from mnemonic - #51
Closed
MansooreSoltani wants to merge 1 commit into
Closed
Conversation
Pycoin returns invalid int for format parameter without resolve `{id}`. This fix the issue
mchardysam
pushed a commit
that referenced
this pull request
Jul 31, 2026
HD_PATH is "44'/714'/0'/0/{id}" and the {id} was never substituted, so
subkey_for_path() got a literal "{id}" and pycoin raised "ValueError:
invalid literal for int() with base 10: '{id}'". Every call failed,
including create_random_wallet(), and the child argument did nothing.
Fixes #61, same fix as @MansooreSoltani's #51.
Also zero pads the private key to 64 hex chars. format(exponent, 'x')
drops leading zeros, so roughly 1 in 256 keys came out short and
bytearray.fromhex() then choked on an odd length string.
test_initialise_from_mnemonic already pinned the expected key for this
mnemonic and it passes, so child 0 still derives what it always did.
Added vectors for children 1 and 2 and a padding check over 25 children.
Owner
|
@MansooreSoltani thanks for this, and sorry it sat here so long. You were right about the cause. I've landed the same fix on master in 1011b97, with test vectors for children 1 and 2 so it can't silently regress, plus a zero pad on the private key hex which was a related problem. Closing this since it's in, but the catch was yours. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pycoin returns invalid int for format parameter without resolve
{id}. This fix the issue