Visitar URL original
fix(locator): normalize default derivation path when checking hd-path… · stellar/stellar-cli@d423f60 · GitHub
Skip to content

Commit d423f60

Browse files
committed
fix(locator): normalize default derivation path when checking hd-path override
Compare effective and persisted paths using unwrap_or_default() so None and Some(0) are recognized as the same default derivation path, matching the normalization across the rest of the codebase (e.g. secret.rs). Also ensure the original persisted_hd_path representation is preserved on disk.
1 parent 69cb691 commit d423f60

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎cmd/soroban-cli/src/config/locator.rs‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,16 @@ impl Args {
373373
});
374374
// Best-effort write-back: if persistence fails we still return the
375375
// freshly-derived value so the current call succeeds. Only persist the
376-
// cache when deriving for the identity's own default hd_path. A one-off
377-
// override with `--hd-path N` must not permanently mutate the identity on disk.
378-
if hd_path.is_none() || hd_path == *persisted_hd_path {
379-
let _ = self.write_key(key_or_name, &migrated);
376+
// cache when deriving for the identity's own default hd_path (normalizing
377+
// None and Some(0) as the same path, consistent with the rest of the codebase).
378+
// A one-off override with `--hd-path N` must not permanently mutate the identity on disk.
379+
if effective.unwrap_or_default() == persisted_hd_path.unwrap_or_default() {
380+
let to_persist = Key::Secret(Secret::SecureStore {
381+
entry_name: entry_name.clone(),
382+
public_key: Some(format!("{pk}")),
383+
hd_path: *persisted_hd_path,
384+
});
385+
let _ = self.write_key(key_or_name, &to_persist);
380386
}
381387
return Ok(migrated);
382388
}

0 commit comments

Comments
 (0)