Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: preserve proxy in save_wallet, handle empty private_key
Address cursor bot review:
- save_wallet now reads existing proxy from config before overwriting,
  preventing silent loss of user-configured proxy URL
- resolve_key treats empty string from config as None, so callers get
  the helpful "No wallet configured" message instead of a confusing
  "Invalid private key" error when private_key is absent from config
  • Loading branch information
Marco Monaco committed Feb 25, 2026
commit 27cb3e4b5a058125073ffbddd6ad68d4b27f5939
9 changes: 7 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ pub fn save_wallet(key: &str, chain_id: u64, signature_type: &str) -> Result<()>
fs::set_permissions(&dir, fs::Permissions::from_mode(0o700))?;
}

// Preserve existing proxy setting from config file
let existing_proxy = load_config().and_then(|c| c.proxy);

let config = Config {
private_key: key.to_string(),
chain_id,
signature_type: signature_type.to_string(),
proxy: None,
proxy: existing_proxy,
};
let json = serde_json::to_string_pretty(&config)?;
let path = config_path()?;
Expand Down Expand Up @@ -157,7 +160,9 @@ pub fn resolve_key(cli_flag: Option<&str>) -> (Option<String>, KeySource) {
return (Some(key), KeySource::EnvVar);
}
if let Some(config) = load_config() {
return (Some(config.private_key), KeySource::ConfigFile);
if !config.private_key.is_empty() {
return (Some(config.private_key), KeySource::ConfigFile);
}
}
(None, KeySource::None)
}
Expand Down