Skip to content

Add --hd-path flag to keys add --secure-store - #2539

Merged
fnando merged 2 commits into
mainfrom
keys-add-hd-path
Apr 30, 2026
Merged

Add --hd-path flag to keys add --secure-store#2539
fnando merged 2 commits into
mainfrom
keys-add-hd-path

Conversation

@fnando

@fnando fnando commented Apr 30, 2026

Copy link
Copy Markdown
Member

What

Adds a --hd-path <usize> flag to stellar keys add, mirroring the one on stellar 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-store already accepts --hd-path, but keys add --secure-store did not — so users importing an existing seed phrase were stuck with index 0 regardless of which account they actually wanted. Spotted by @leighmcculloch during review of #2533, where the call site in keys/add.rs was passing None as a placeholder.

Closes #2536.

Known limitations

--hd-path is still silently dropped when keys generate (and now keys 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.

Copilot AI review requested due to automatic review settings April 30, 2026 17:15
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Apr 30, 2026
@fnando fnando self-assigned this Apr 30, 2026
@fnando fnando moved this from Backlog (Not Ready) to Needs Review in DevX Apr 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-path flag to keys add and threaded it into secure_store::save_secret(...).
  • Expanded secure-store integration test coverage to verify hd_path and cached public_key persistence 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.

Comment thread FULL_HELP_DOCS.md Outdated
Comment thread cmd/soroban-cli/src/commands/keys/add.rs Outdated
@fnando
fnando enabled auto-merge (squash) April 30, 2026 17:25
Comment thread cmd/soroban-cli/src/commands/keys/add.rs
@fnando
fnando merged commit 343069b into main Apr 30, 2026
211 checks passed
@fnando
fnando deleted the keys-add-hd-path branch April 30, 2026 21:17
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in DevX Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add --hd-path flag to keys add --secure-store

3 participants