Repository navigation
CLI: readable wallet commands (status, balance, address, send) - #896
Open
awizardxch wants to merge 1 commit into
Open
awizardxch wants to merge 1 commit into
awizardxch wants to merge 1 commit into
Conversation
A first step for xch-dev#397: `sage wallet` takes arguments in the units people use and prints output people can read, over the same RPC client `sage rpc` uses. - status / balance / address: the logged-in wallet, sync progress, XCH and token balances, receive address. --json prints the RPC responses. - send <address> <amount> [--fee] [--asset] [--memo] [--yes]: amounts in whole units, parsed exactly (no floating point; more decimals than the asset has is an error, not a rounding). The wallet builds the transaction unsubmitted, the CLI shows what leaves the wallet as read from that transaction, asks, then signs and submits those exact coin spends with sign_coin_spends. With no terminal to confirm on it refuses unless --yes is given. The CLI also runs on a 16 MiB-stack thread: the rpc command's clap tree and handler future overflowed the 1 MiB main stack of a Windows debug build, so even `sage --help` crashed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A first increment for #397, following the steps Rigidity described there: convert user arguments into the
sage-apitypes, call the RPC (several requests where a command needs them), and format the output into something more readable than JSON.sage wallet--jsonon any of them prints the RPC responses instead.sage rpc <endpoint> '<json>'is unchanged.How
sendstays safe0.25is parsed digit by digit at the asset's precision: 12 for XCH, read from the wallet'sunit; a CAT's own fromget_token. There's no floating point. More decimals than the asset has is an error, not a rounding. Signs, exponents, separators and overflow are refused. Unit tests cover all of these.auto_submit: false. The CLI prints what leaves the wallet, the fee and the number of coins spent, all read from the built transaction's summary rather than echoed from the arguments, so a wrong address or amount shows before anything is signed. On confirmation, the CLI signs and submits those same coin spends withsign_coin_spends. It never re-requests the send, which could select different coins than the ones shown.sendrefuses unless--yesis given.Also: the CLI no longer overflows its stack
On upstream
main, a Windows debug build ofsageoverflows its stack on any command,sage --helpincluded. Therpccommand's clap tree (one subcommand per endpoint) and its handler future outgrow the 1 MiB main-thread stack. The CLI now runs on a 16 MiB thread, with the same size for the tokio workers. After the change,sage --help,sage wallet --helpandsage rpc …all start normally.Tests
cargo test -p sage-cli: 5 tests for amount parsing and formatting (exact parsing, refusing to round, refusing non-amounts and overflow, formatting without trailing zeros, round trips).cargo clippy -p sage-cli --all-targetsandcargo fmt --checkare clean.sage --help,sage wallet --help, andsage rpc get_versionreaching the client (no wallet RPC was running here, so it reports the connection error instead of crashing).Next steps for #397 (not in this PR)
More commands in the same style: offers (
make,take,cancel, list), NFTs, coin management (split,combine), and transactions. Plus a shared table/text formatter if the command count grows.🤖 Generated with Claude Code