Conversation
1a9aafc to
bfdb2b7
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The changelog entry should explicitly flag the wire-format breaking change for force_small_change_as_fee, and a small naming clarity fix is needed in the new conversion code.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
This PR tightens validation and error handling for the API server transfer flow by changing force_small_change_as_fee from a free-form string into a typed u64 (shannons), aligning the API behavior with CLI validation and preventing panics in downstream parsing.
Changes:
- Change
force_small_change_as_feein the API server transfer args toOption<u64>and convert it back viaHumanCapacityfor internal CLI-compatible handling. - Propagate parse failures in
WalletSubCommand::transferinstead ofunwrap()-ing and potentially panicking. - Prevent overflow in the
--max-tx-feesuggestion calculation by using saturating arithmetic, and document the field in the API docs.
| File | Description |
|---|---|
| src/subcommands/wallet.rs | Avoids panic by propagating parse errors; prevents overflow in fee suggestion capacity math. |
| src/subcommands/api_server.rs | Makes force_small_change_as_fee typed (u64) at the JSON-RPC boundary and adds unit tests for deserialization/conversion. |
| docs/API-Server.md | Documents force_small_change_as_fee and clarifies its unit (Shannon). |
| CHANGELOG.md | Notes the fixes in Unreleased (should also call out the breaking wire-format change). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new API documentation for force_small_change_as_fee should explicitly show it is a JSON string (quoted) to prevent client-side type mistakes, and there is also a small typo in the transfer log message.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (2)
Resolved since last review (1)
The API server's `transfer` method took `force_small_change_as_fee` as a free-form string and passed it straight through to `WalletSubCommand::transfer`, while the equivalent `--max-tx-fee` CLI flag is validated by clap. Validate it in the RPC method before any wallet lock is taken, so a value that cannot be parsed as a capacity is reported as invalid params, and propagate the parse error in `WalletSubCommand::transfer` rather than assuming success. The field keeps its wire format: an optional capacity string in CKB, for example "0.001". Also saturates the capacity arithmetic behind the `--max-tx-fee` suggestion, and documents the field in docs/API-Server.md.
bfdb2b7 to
8e05718
Compare
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The change is small, self-contained, consistent with existing parsing/error-handling conventions, and covered by new tests with docs and changelog updated.
Review effort: Balanced
Findings: None

The API server's
transfermethod acceptedforce_small_change_as_feeas a free-form string and passed it straight through toWalletSubCommand::transfer, while the equivalent--max-tx-feeCLI flag is validated by clap.Changes
ApiRpc::transfervalidatesforce_small_change_as_feebefore any wallet lock is taken, so a value that cannot be parsed as a capacity is reported as-32602.WalletSubCommand::transferpropagates the parse error rather than assuming success.--max-tx-feesuggestion.docs/API-Server.md.Compatibility
No wire-format change:
force_small_change_as_feestays an optional capacity string in CKB, the same unit as the--max-tx-feeCLI flag. Existing clients are unaffected.Tests
Three unit tests cover the validation and the field's wire format: