Skip to content

RPC: Prevent address balance overflow - #1322

Open
Tabakkui wants to merge 1 commit into
RavenProject:developfrom
Tabakkui:fix/issue-1227-address-balance-overflow
Open

Tabakkui wants to merge 1 commit into
RavenProject:developfrom
Tabakkui:fix/issue-1227-address-balance-overflow

Conversation

@Tabakkui

Copy link
Copy Markdown

Problem

getaddressbalance accumulated the lifetime received value in signed CAmount (int64_t). Addresses with more than INT64_MAX received satoshis wrapped into a negative RPC result, as reported in #1227.

Approach

Accumulate positive address-index deltas in checked uint64_t storage for both the RVN and includeAssets paths. Return an RPC error rather than wrapping if the unsigned range is exceeded. Keep the current numeric JSON representation.

Test plan

  • rpc_received_amount_overflow_test covers crossing the signed boundary, ignoring negative deltas for received, and rejecting unsigned overflow.
  • received-overflow-helper: PASS from an UBSan-enabled helper smoke test.
  • Legacy signed probe reproduces UBSan signed-overflow failure.
  • git diff --cached --check passed.
  • Full Ravencoin build/Boost test binary was not available in this Pi checkout; no full build was forced here.

Fixes #1227

Accumulate positive address-index received deltas in an unsigned type with overflow checks so large cumulative totals cannot wrap into negative RPC results. Cover the signed-boundary and uint64 overflow cases with a unit test.
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