Skip to content

Implement get-address tool#2

Merged
juntao merged 1 commit intomainfrom
feat/get-address
Jan 31, 2026
Merged

Implement get-address tool#2
juntao merged 1 commit intomainfrom
feat/get-address

Conversation

@juntao
Copy link
Member

@juntao juntao commented Jan 31, 2026

Summary

  • Implement get-address CLI tool to read public Ethereum address from wallet keystore
  • No password required - reads only the unencrypted address field
  • Support custom wallet path via --wallet/-w flag
  • Support custom config path via --config/-c flag
  • Return proper exit codes (12 for wallet not found)
  • Add comprehensive README documentation

Test plan

  • Build succeeds: cargo build --release -p get-address
  • All tests pass: cargo test --all
  • Clippy passes: cargo clippy --all -- -D warnings
  • Format check passes: cargo fmt --all -- --check
  • --help shows usage information
  • Returns correct address when given valid wallet
  • Returns exit code 12 when wallet not found

Generated with Claude Code

- Read public address from wallet keystore without decryption
- Support custom wallet path via --wallet/-w flag
- Support custom config path via --config/-c flag
- Return proper exit codes (12 for wallet not found)
- Add comprehensive README documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@juntao juntao requested a review from Copilot January 31, 2026 03:39
@juntao juntao merged commit 3af25c3 into main Jan 31, 2026
15 checks passed
@juntao juntao deleted the feat/get-address branch January 31, 2026 03:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a new CLI tool get-address that retrieves the public Ethereum address from an x402 wallet keystore file without requiring password decryption.

Changes:

  • Added new get-address CLI tool with support for custom wallet and config paths
  • Implemented proper exit code handling (exit code 12 for wallet not found, exit code 1 for other errors)
  • Added comprehensive README documentation covering usage, security considerations, and exit codes

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
get-address/src/main.rs Implements the CLI tool with argument parsing, config loading, and wallet address retrieval with proper exit code handling
get-address/Cargo.toml Adds dependencies for clap (CLI parsing), x402_common (wallet/config functionality), and anyhow
get-address/README.md Provides comprehensive documentation including usage examples, security notes, and exit codes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

[dependencies]
x402_common = { path = "../x402-common" }
clap = { version = "4", features = ["derive"] }
anyhow = "1"
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

The anyhow dependency is declared but never used in the code. The main.rs file uses std::process::ExitCode for error handling instead of anyhow's Result type. Consider removing this unused dependency.

Suggested change
anyhow = "1"

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +33
let wallet_path = if let Some(path) = args.wallet {
Some(path)
} else {
// Try to load config for default wallet path
match Config::load_from(args.config.as_deref()) {
Ok(config) => Some(config.wallet_path()),
Err(_) => None, // Use library default
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

When loading configuration fails, the error is silently ignored. If a user explicitly specifies a config path via --config that contains invalid TOML or has IO errors, they won't be notified of the problem. Consider checking if args.config.is_some() and if so, propagate the error to inform the user about the invalid config file they explicitly specified.

Suggested change
let wallet_path = if let Some(path) = args.wallet {
Some(path)
} else {
// Try to load config for default wallet path
match Config::load_from(args.config.as_deref()) {
Ok(config) => Some(config.wallet_path()),
Err(_) => None, // Use library default
let config_path = args.config.as_deref();
let wallet_path = if let Some(path) = args.wallet.clone() {
Some(path)
} else {
// Try to load config for default wallet path
match Config::load_from(config_path) {
Ok(config) => Some(config.wallet_path()),
Err(e) => {
// If the user explicitly specified a config path, surface the error
if let Some(path) = config_path {
eprintln!(
"Error loading config file '{}': {}",
path.display(),
e
);
return ExitCode::FAILURE;
}
// No explicit config provided: fall back to library default
None
}

Copilot uses AI. Check for mistakes.
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.

1 participant