Summary
Similar to the improvements made to forest-cli in PR #6011, the forest-wallet binary should implement stricter address validation to improve user experience and prevent invalid address inputs.
Background
PR #6011 implemented stricter checks for address arguments in forest-cli by:
- Using typed addresses (
StrictAddress) instead of raw strings for safer input handling
- Adding early network detection before CLI parsing to ensure correct network context during validation
- Migrating CLI to an asynchronous runtime for improved responsiveness
Current State
The forest-wallet binary currently handles addresses in the following commands but uses runtime string-to-address conversion instead of compile-time type safety:
balance: address parameter
export: address parameter
has: key parameter (address)
delete: address parameter
set-default: key parameter (address)
sign: address parameter
verify: address parameter
send: from and target_address parameters
All these currently accept String parameters and convert using StrictAddress::from_str() at runtime.
Proposed Changes
- Update command definitions: Change string parameters to
StrictAddress types for all address-handling commands
- Add early network detection: Implement similar network detection logic as in
forest-cli before CLI parsing
- Migrate to async runtime: Follow the same pattern as
forest-cli for consistent architecture
Commands to Update
Balance { address: StrictAddress }
Export { address: StrictAddress }
Has { key: StrictAddress }
Delete { address: StrictAddress }
SetDefault { key: StrictAddress }
Sign { address: StrictAddress }
Verify { address: StrictAddress }
Send { from: Option<StrictAddress>, target_address: StrictAddress }
Benefits
- Early validation of address arguments before command execution
- Better error messages for invalid addresses
- Consistent user experience across Forest CLI tools
- Reduced runtime errors due to invalid address formats
References
Summary
Similar to the improvements made to
forest-cliin PR #6011, theforest-walletbinary should implement stricter address validation to improve user experience and prevent invalid address inputs.Background
PR #6011 implemented stricter checks for address arguments in
forest-cliby:StrictAddress) instead of raw strings for safer input handlingCurrent State
The
forest-walletbinary currently handles addresses in the following commands but uses runtime string-to-address conversion instead of compile-time type safety:balance: address parameterexport: address parameterhas: key parameter (address)delete: address parameterset-default: key parameter (address)sign: address parameterverify: address parametersend: from and target_address parametersAll these currently accept
Stringparameters and convert usingStrictAddress::from_str()at runtime.Proposed Changes
StrictAddresstypes for all address-handling commandsforest-clibefore CLI parsingforest-clifor consistent architectureCommands to Update
Balance { address: StrictAddress }Export { address: StrictAddress }Has { key: StrictAddress }Delete { address: StrictAddress }SetDefault { key: StrictAddress }Sign { address: StrictAddress }Verify { address: StrictAddress }Send { from: Option<StrictAddress>, target_address: StrictAddress }Benefits
References
forest-cli#6011