Skip to content

feat(node): add public all-wallet balance export (#8359) - #8487

Open
tariqtharwat-OPS wants to merge 1 commit into
Scottcjn:mainfrom
tariqtharwat-OPS:feat/8359-balance-export
Open

tariqtharwat-OPS wants to merge 1 commit into
Scottcjn:mainfrom
tariqtharwat-OPS:feat/8359-balance-export

Conversation

@tariqtharwat-OPS

Copy link
Copy Markdown

Summary

Closes #8359 by adding a public, read-only, paginated GET /api/balances/export endpoint for complete distribution analysis.

This is a clean implementation from current main that addresses the unresolved maintainer findings on #8361:

  • pagination occurs in SQL before ledger aggregation; duplicate identifiers are not collapsed
  • bounded per-page cache is keyed by current epoch, limit, and offset
  • cache is bypassed when the epoch cannot be determined
  • dedicated, thread-safe, bounded per-IP rate limiter with Retry-After
  • exact wallet classification: bcn_*, native RTC + 40 hex, otherwise hosted_handle
  • founder detection uses the founder_ prefix
  • explicit modern, legacy, and mixed-schema handling without coercing null balances to zero
  • missing optional ledger yields last_activity: null; malformed ledger schema fails visibly
  • public identity/activity disclosure is documented in the API catalog and OpenAPI spec

Response schema

Each item contains:

  • wallet
  • balance_rtc
  • is_founder
  • kind
  • last_activity

Pagination metadata includes count, total, limit, offset, and epoch.

Verification

  • python -m py_compile node/rustchain_v2_integrated_v2.2.1_rip200.py node/tests/test_api_balances_export.py
  • python -m pytest -q node/tests/test_api_balances_export.py node/tests/test_api_miners_rate_limit.py node/tests/test_admin_rate_limit.py node/tests/test_integrated_openapi_balance_schema.py
    • 21 passed, 9 subtests passed
  • python docs/api/validate_openapi.py docs/api/openapi.yaml
    • No errors or warnings
  • git diff --check

The two failures in test_public_api_disclosure.py were reproduced unchanged on upstream main; they predate and are unrelated to this endpoint.

@github-actions

Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Non-doc PRs have a BCOS-L1 or BCOS-L2 label
  • Doc-only PRs are exempt from BCOS tier labels when they only touch docs/**, *.md, or common image/PDF files
  • New code files include an SPDX license header
  • You've tested your changes against the live node

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!

@github-actions github-actions Bot added documentation Improvements or additions to documentation BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) node Node server related tests Test suite changes size/L PR: 201-500 lines labels Sep 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) documentation Improvements or additions to documentation node Node server related size/L PR: 201-500 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Public all-wallet balance export (unblocks rustchain-bounties#1113 distribution analysis)

1 participant