hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Hardhat-ledger should support legacy derivation paths

Open area opened this issue 1 year ago • 2 comments

Describe the feature

As part of the curse of the early adopter, users may have created addresses with Ledger prior to them fully implementing BIP44, when they used a different derivation path. Such users should be able to use hardhat-ledger.

One possibility to capture most of these users (myself included) would be to add a ledgerLegacyDerivationPath option as a boolean in the network configs, alongside ledgerAccounts - or possibly combining them in to a ledgerOptions.

A more general solution that would capture all possible issues would be to allow users to specify the derivation path themselves - e.g. m/44'/60'/x'/0/0. Again, either as a separate option or as part of a combined ledgerOptions property.

Of course, the default behaviour should remain unchanged - most users are not impacted by this.

I need this feature, and it is small, so would be keen to work on a PR myself. I am opening the discussion here to begin with, as requested in CONTRIBUTING.md, with the hope that someone can indicate which of these possibilities is most likely to get accepted.

Search terms

No response

area avatar Jan 25 '24 16:01 area

Thanks for opening this @area. I'm tempted to go with a function, since that would cover other use cases (although tbh I don't know how likely it is that there are use cases besides legacy paths):

ledgerOptions: {
  derivationFunction: (accountNumber) => `44'/60'/${account}'/0/0`
}

What do you think?

cc @alcuadrado

fvictorio avatar Feb 08 '24 11:02 fvictorio

Yep, that would work for me. Making the option a function also makes it easier to adjust messages that output derivation paths than it would be if it were a string.

area avatar Feb 08 '24 14:02 area

I would still like to work on this if the desired implementation could be confirmed by whoever needs to :smile:

area avatar Feb 23 '24 00:02 area

@area you can assume that the function approach is the one you should take.

kanej avatar Feb 23 '24 09:02 kanej

The feature has been added and it will be released on the next hardhat-ledger version. You can read how it works here. Thanks @area!

schaable avatar Apr 15 '24 15:04 schaable

Support for derivation paths was released in @nomicfoundation/[email protected].

kanej avatar Apr 17 '24 15:04 kanej