Repository navigation
fix(sdk): allow fractional RTC amount and fee in CLI wallet send (#8564) - #8598
Open
ArtyormSatori wants to merge 2 commits into
Open
ArtyormSatori wants to merge 2 commits into
ArtyormSatori wants to merge 2 commits into
Conversation
Contributor
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
Scottcjn
requested changes
Nov 3, 2026
Scottcjn
left a comment
Owner
There was a problem hiding this comment.
Thanks for adding fractional sends. Amounts that get signed can't go through binary floats:
- Parse
amountandfeeasDecimal(or integer base units) and refuse any value that isn't exact at chain scale before signing.0.01as a float is not 0.01, and the test currently asserts the float value. - Reject non-finite values,
amount <= 0andfee < 0before sign/submit. - HTTP 200 with
status: "pending"shouldn't exit 0 as a completed send. Report it as pending and use a distinct exit code, or wait for settlement.
Please add tests for each rejection case.
ArtyormSatori
pushed a commit
to ArtyormSatori/Rustchain
that referenced
this pull request
Nov 3, 2026
Contributor
|
This PR is quite large (XL). Consider splitting into smaller, focused PRs for faster review. Large PRs take longer to review and have higher risk of issues. |
Contributor
Author
|
Addressed all review points in e0c85dc:
|
ArtyormSatori
pushed a commit
to ArtyormSatori/Rustchain
that referenced
this pull request
Nov 3, 2026
…, and pending status exit code
ArtyormSatori
force-pushed
the
fix/cli-wallet-send-fractional-rtc-8564
branch
from
November 3, 2026 03:22
714edad to
1aa74e5
Compare
Scottcjn
added a commit
that referenced
this pull request
Nov 19, 2026
…ounts (fixes #8618) (#8623) RustChainWallet.sign_transfer took float(amount)/float(fee) with no precision check. The node stores balances as integer micro-RTC (amount_i64, ACCOUNT_UNIT=1_000_000) and quantizes amount_rtc with Decimal(str(x)) rounded DOWN (node/payout_preflight.py), so anything finer than 0.000001 RTC was signed by the user and then silently dropped by the node. - new rustchain_sdk.amounts: to_micro_rtc() parses str/int/Decimal/float exactly (floats via their shortest repr), rejects non-finite, negative, zero amounts, >6 decimal places and values >= 1e9 RTC (beyond which the float wire format can no longer carry 6 exact decimals) - sign_transfer validates before signing and derives the wire/signature float from the exact integer; returns amount_i64/fee_i64; drops a duplicate 'fee' dict key; payload is now JSON-safe for Decimal input - exported to_micro_rtc / micro_rtc_to_str / MICRO_RTC_PER_RTC so the CLI (#8564 work) can parse user input with the same rules - tests include a cross-check against node/payout_preflight.py: same amount_i64 and a byte-identical rebuilt signed message cli.py is deliberately untouched to avoid colliding with the open #8564 PRs (#8598, #8610). Co-authored-by: Scott <scottbphone12@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…n#8564) - Update Click argument amount to type=float in wallet send command - Update --fee option to type=float with default=0.0 - Update type annotations in wallet_send and _wallet_send - Add CLI unit tests covering fractional and integer values, JSON output, and validation
…chain scale, and handle pending status
ArtyormSatori
force-pushed
the
fix/cli-wallet-send-fractional-rtc-8564
branch
from
November 26, 2026 18:23
1aa74e5 to
cfc92a7
Compare
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.
BCOS Checklist (Required For Non-Doc PRs)
BCOS-L1orBCOS-L2(also accepted:bcos:l1,bcos:l2)# SPDX-License-Identifier: MIT)Summary
Fixes #8564:
rustchain wallet sendCLI command rejects fractional amounts (e.g.0.5RTC) and fees withInvalid value for 'AMOUNT': '0.5' is not a valid integer.What Changed
sdk/python/rustchain_sdk/cli.py:@click.argument("amount", type=float)inwallet_send(previouslytype=int).@click.option("--fee", type=float, default=0.0)inwallet_send(previouslytype=int, default=0).wallet_sendand_wallet_sendfrominttofloat.sdk/python/rustchain_sdk/tests/test_cli.py:TestCliWalletSendcovering fractional amount and fee, integer amount compatibility, JSON output format, and invalid non-numeric validation.Testing / Evidence
Test execution with pytest:
Full SDK test suite:
CLI mechanical verification:
Before:
$ python -m rustchain_sdk.cli wallet send <from> <to> 0.5 --fee 0.01Error: Invalid value for 'AMOUNT': '0.5' is not a valid integer.After:
$ python -m rustchain_sdk.cli wallet send <from> <to> 0.5 --fee 0.01Amount and fee are accepted as floats and submitted to the signed transfer endpoint.
Claimant: @ArtyormSatori
Native RTC Wallet:
RTC22ad34877d8c24944c0601a8594e9d8166e8bc56