Add --hd-path flag to keys add --secure-store - #2539
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds --hd-path <usize> support to stellar keys add when importing a seed phrase into the OS secure store, aligning behavior with stellar keys generate and enabling correct derivation/caching for non-default BIP-32 indices.
Changes:
- Added
--hd-pathflag tokeys addand threaded it intosecure_store::save_secret(...). - Expanded secure-store integration test coverage to verify
hd_pathand cachedpublic_keypersistence in identity TOML. - Updated generated CLI help docs to include the new flag for
keys add.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/soroban-cli/src/commands/keys/add.rs | Introduces --hd-path option and passes it to secure-store save logic. |
| cmd/crates/soroban-test/tests/it/integration/secure_store.rs | Adds integration assertions for keys add --secure-store --hd-path caching/persistence behavior. |
| FULL_HELP_DOCS.md | Documents the new --hd-path option under stellar keys add. |
fnando
enabled auto-merge (squash)
April 30, 2026 17:25
leighmcculloch
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
--hd-path <usize>flag tostellar keys add, mirroring the one onstellar keys generate. When combined with--secure-store, the flag controls which BIP-32 derivation index is used to compute and cache the public key on disk, and is persisted in the identity TOML.Why
keys generate --secure-storealready accepts--hd-path, butkeys add --secure-storedid not — so users importing an existing seed phrase were stuck with index0regardless of which account they actually wanted. Spotted by @leighmcculloch during review of #2533, where the call site inkeys/add.rswas passingNoneas a placeholder.Closes #2536.
Known limitations
--hd-pathis still silently dropped whenkeys generate(and nowkeys add) stores a plain seed phrase (no--secure-store, no--as-secret). That is tracked separately in #2538 and will be addressed in a follow-up PR.