Skip to content

fix: credit withdrawal fees to founder community#2108

Merged
Scottcjn merged 1 commit intoScottcjn:mainfrom
createkr:feat/issue-withdrawal-fee-routing
Apr 6, 2026
Merged

fix: credit withdrawal fees to founder community#2108
Scottcjn merged 1 commit intoScottcjn:mainfrom
createkr:feat/issue-withdrawal-fee-routing

Conversation

@createkr
Copy link
Copy Markdown
Contributor

@createkr createkr commented Apr 6, 2026

Fix: Route withdrawal fees to correct columns (balance_rtc / miner_pk)

Problem

RIP-301 withdrawal fee routing used non-existent columns amount_i64 and miner_id on the balances table. The actual schema has miner_pk and balance_rtc. The UPDATE silently affected 0 rows, burning fees instead of crediting founder_community.

Changes

node/rustchain_v2_integrated_v2.2.1_rip200.py

Three locations fixed:

  1. request_withdrawal() (line ~4033): Fee credit UPDATE now uses balance_rtc / miner_pk. Added INSERT OR IGNORE to ensure the founder_community row exists before crediting.

  2. /api/fee_pool (line ~4109): Community fund balance read now uses balance_rtc / miner_pk. Removed incorrect / 1_000_000 division (the old code treated amount_i64 as micro-units; balance_rtc is already in RTC).

  3. /api/bounty-multiplier (line ~4754): Community fund balance read now uses balance_rtc / miner_pk. Removed incorrect micro-unit conversion.

tests/test_requirements_extra.py

Added test_withdrawal_fee_routed_to_founder_community — a focused regression test that:

  • Creates a balances table with the actual schema (miner_pk, balance_rtc)
  • Simulates the full withdrawal fee routing flow
  • Asserts the fee is credited to founder_community (not burned)
  • Verifies the fee_events audit record is consistent

Verification

pytest tests/test_requirements_extra.py -v
# 4 passed, 0 failed

Scope

Minimal, targeted fix. No refactoring. Only the 3 broken SQL statements and 1 new test.

@createkr
Copy link
Copy Markdown
Contributor Author

createkr commented Apr 6, 2026

For bounty payout, please use RTC wallet: RTC1d48d848a5aa5ecf2c5f01aa5fb64837daaf2f35.

@github-actions github-actions bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related tests Test suite changes size/M PR: 51-200 lines labels Apr 6, 2026
@Scottcjn
Copy link
Copy Markdown
Owner

Scottcjn commented Apr 6, 2026

Merged. Payment: 50 RTC. Addresses #2107.

Withdrawal fees were silently burned due to column name mismatch (amount_i64/miner_id vs balance_rtc/miner_pk). Good catch + regression test included.

@Scottcjn Scottcjn merged commit 8e700da into Scottcjn:main Apr 6, 2026
8 of 9 checks passed
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) node Node server related size/M PR: 51-200 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants