Skip to content

[codex] fix wallet_balance local wallet address resolution#251

Merged
Scottcjn merged 1 commit into
Scottcjn:mainfrom
codexbountylab:codex/fix-wallet-balance-address
Jul 4, 2026
Merged

[codex] fix wallet_balance local wallet address resolution#251
Scottcjn merged 1 commit into
Scottcjn:mainfrom
codexbountylab:codex/fix-wallet-balance-address

Conversation

@codexbountylab

@codexbountylab codexbountylab commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fix: wallet_balance() should resolve local wallet IDs to their RTC address

Bug

wallet_balance() loads a local wallet from the keystore, but still queries the node with the original wallet_id:

wallet = rustchain_crypto.load_wallet(wallet_id)
r = get_client().get(f"{RUSTCHAIN_NODE}/balance/{wallet_id}")

This breaks the common local-wallet flow because the RustChain balance endpoint expects the wallet address. The neighboring wallet_history() tool already resolves local wallet IDs to wallet["address"], so the two tools are currently inconsistent.

Fix

  • Resolve wallet_id to wallet["address"] when the wallet exists locally.
  • Preserve the existing direct-address flow when the caller passes an RTC address directly.

Tests

  • Extend test_mcp_wallet_balance_with_mock to assert the request path uses the created wallet address.
  • Add test_mcp_wallet_balance_accepts_direct_address to verify the direct-address path still works.

Scope

Small, isolated change:

  • rustchain_mcp/server.py
  • tests/test_wallet_tools.py

Validation

  • Code inspection confirms wallet_history() already normalizes local wallet IDs to addresses, so this change makes wallet_balance() consistent with the existing local-wallet path.
  • Ran targeted tests in a local virtualenv:
    • python -m pytest -q tests/test_wallet_tools.py -k 'test_mcp_wallet_balance_with_mock or test_mcp_wallet_balance_accepts_direct_address'
    • python -m pytest -q tests/test_bottube_endpoints.py -k 'test_wallet_balance_uses_path_param'
  • Result: 3 passed

RTC payout wallet: RTCc78142b4cc31531e913c4082bc5d771eb0a91ac1

@codexbountylab codexbountylab marked this pull request as ready for review July 2, 2026 02:37

@jaxint jaxint left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review

Reviewer: @jaxint
Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

Summary

This PR addresses: [codex] fix wallet_balance local wallet address

Code Review

Changes Reviewed:

  • Files: 2
  • Lines: +29/-6

Assessment: ✅ Approved

The changes follow the project's coding standards and address the issue described in the PR title. The implementation is clean and minimal.

Testing

  • Code changes are minimal and focused
  • No additional test coverage required for this fix

Recommendation

APPROVE - Ready for merge.


Review submitted via RustChain Bounty System
RTC bounty claim: 40 RTC per review (Bounty #73)

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

RTC Reward

This merged PR earned 5 RTC — sent to RTCc78142b4cc31531e913c4082bc5d771eb0a91ac1.

RustChain Bounty Program

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.

3 participants