mikeshultz/ledger-eth-lib

Regex bip32 eth patterns

Closed this issue · 3 comments

Your bip32 path regex might be incorrect

it only allows for paths
44'/60'/[one digit]'/[one digit]/[one digit]

whereas ledger generates valid eth addresses for any eth path
meaning

it should allow for paths
44'/60'/[any amount digit]'/[any amount digit]/[any amount digit]

This is the current regex
BIP32_ETH_PATTERN = r"^44'/60'/[0-9]'/[0-9]/[0-9]$"
BIP32_LEGACY_LEDGER_PATTERN = r"^44'/60'/[0-9]'/[0-9]$"

This is the fixed regex
BIP32_ETH_PATTERN = r"^44'/60'/[0-9]+'/[0-9]+/[0-9]+$"
BIP32_LEGACY_LEDGER_PATTERN = r"^44'/60'/[0-9]+'/[0-9]+$"

Will fix this when I get a chance. Out of curiosity, did you run into this because you use '>10' accounts on your ledger?

Thanks for the report!

Not specifically, i ran into this issue because of unit tests i've got setup, i doubt that most people will run into this issue.

i use the btchip library by ledgerHQ to get the first 20 addresses (because of gap limit) for each crypto type that i am interested in, so btc, ltc, eth and bch

eth follows the same ruleset, so it's purely by chance

btw thanks for all the work put into this library!

ps. do you have a crypto tip jar?

Thank you for the issue and PR. This change is in v0.1.3