NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.29k stars 1.41k forks source link

Hardhat-ledger should support legacy derivation paths #4790

Closed area closed 6 months ago

area commented 9 months ago

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

fvictorio commented 9 months ago

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

area commented 9 months ago

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 commented 8 months ago

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

kanej commented 8 months ago

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

schaable commented 6 months ago

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!

kanej commented 6 months ago

Support for derivation paths was released in @nomicfoundation/hardhat-ledger@1.0.3.