Skip to content

Fix pycoin exception when create from mnemonic - #51

Closed
MansooreSoltani wants to merge 1 commit into
mchardysam:masterfrom
MansooreSoltani:master
Closed

Fix pycoin exception when create from mnemonic#51
MansooreSoltani wants to merge 1 commit into
mchardysam:masterfrom
MansooreSoltani:master

Conversation

@MansooreSoltani

Copy link
Copy Markdown

Pycoin returns invalid int for format parameter without resolve {id}. This fix the issue

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.
@mchardysam

Copy link
Copy Markdown
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.

@mchardysam mchardysam closed this Jul 31, 2026
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.

2 participants