Skip to content

Derivation Path refactor #571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 4, 2025
Merged

Derivation Path refactor #571

merged 6 commits into from
Apr 4, 2025

Conversation

tclemos
Copy link
Contributor

@tclemos tclemos commented Apr 1, 2025

close shttps://github.com/0xPolygon/devtools/issues/182

The topics below are applied to polycli wallet command.

  • Changes the default value for --addresses from 10 to 1
  • When --addresses is 1, the derivation path is the same as provided by --path
  • When --addresses is greater than 1, it will use the value provided by --path to provide sequential derivation paths starting from the provided one, extended to at least five parts and evolving one by one using the last part as the start index, see examples below.

Examples:

  • for --addresses 1 and:
    • --path m/44'/60'/0, generates: m/44'/60'/0
    • --path m/44'/60'/1'/0, generates: m/44'/60'/1'/0
    • --path m/44'/60'/2'/0/3, generates: m/44'/60'/2'/0/3
    • --path m/44'/60'/3'/0/7/9, generates: m/44'/60'/3'/0/7/9
  • for --addresses 3 and:
    • --path m/44'/60'/0, generates: m/44'/60'/0'/0/0, m/44'/60'/0'/0/1, m/44'/60'/0'/0/2
    • --path m/44'/60'/1'/0, generates: m/44'/60'/1'/0/0, m/44'/60'/1'/0/1, m/44'/60'/1'/0/2
    • --path m/44'/60'/2'/0/3, generates: m/44'/60'/2'/0/3, m/44'/60'/2'/0/4, m/44'/60'/2'/0/5
    • --path m/44'/60'/3'/0/7/9, generates: m/44'/60'/3'/0/7/9, m/44'/60'/3'/0/7/10, m/44'/60'/3'/0/7/11

For more examples, please check the test TestDerivationPath file hdwallet/hdwallet_test.go

more details about derivation path:

@tclemos tclemos self-assigned this Apr 1, 2025
@tclemos tclemos requested a review from leovct April 1, 2025 01:44
@tclemos tclemos requested a review from praetoriansentry April 1, 2025 18:09
@tclemos tclemos merged commit 9cd3015 into main Apr 4, 2025
13 checks passed
@tclemos tclemos deleted the thiago/derivation-path branch April 4, 2025 16:45
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