SDK CLI prints 0 RTC for canonical /wallet/balance responses

Open Beginner friendly
#8,580 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 10 days

@ArtyormSatori is already working on this.

Since Oct 28, 2026.

  • #20 by @satoshinakamoto666666 — open
  • #8596 by @ArtyormSatori — open
  • #8610 by @EzeAlfaro — open
  • #8680 by @satoshinakamoto666666 — closed without merging
  • #8710 by @tedTorus — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli

Research direction

Start with the balance rendering at sdk/python/rustchain_sdk/cli.py lines 108–122 and the client request at sdk/python/rustchain_sdk/client.py lines 347–360. Run the reproduced CLI test with both the canonical response and the legacy control payload; check what the endpoint actually returns before deciding how to handle nonce. Done when canonical amount_rtc displays correctly, the legacy alias still works, and missing balance fields do not display a misleading zero.

Written by the indexing model from the issue text.

Description

Reproduced zero balance display for canonical /wallet/balance responses

Pinned source c3da95d5e6163d7fe06b9d12a7735976392f2318: balance rendering reads result.get("balance", 0) and result.get("nonce", 0), while the client method requests the current GET /wallet/balance?address= endpoint whose documented canonical field is amount_rtc (first-party MCP adapter requires amount_rtc and derives the compatibility aliases from it).

A live read-only GET https://rustchain.org/wallet/balance?miner_id=stmr returns:

{"amount_i64": 21000000, "amount_rtc": 21, "miner_id": "stmr"}

Running the real rustchain wallet balance command against that exact payload prints:

Address:  local-fixture
Balance:  0 RTC
Nonce:    0

A control payload carrying balance: 42, nonce: 3 prints Balance: 42 RTC through the same code path, so the display logic works and the canonical field is simply never read. A wallet holding 21 RTC is reported as holding none, with a zero nonce.

This is the CLI sibling of monitor #68 in Scottcjn/rustchain-monitor, where the same canonical-field drift makes successful balances record as 0.0. The two reports cover separate consumers and separate fixes; RustChain issue #7070/#7085 cover stale routes in tools/cli-wallet and shell scripts, not this SDK display path.

Suggested fix: read amount_rtc (and any nonce the endpoint actually returns), keep the legacy balance key as an intentional alias, and print an explicit unavailable state rather than 0 RTC when the response carries none of the accepted fields.

Reproduction

Save the pinned sdk/python package and its dependencies in an isolated environment, save the script below as repro.py, and run python repro.py /path/to/Rustchain/sdk/python. The public CLI entry point and the real client are exercised over httpx.MockTransport; no live node request, seed, signing or transfer occurs.

import json
import sys
sys.path.insert(0, sys.argv[1])
import httpx
from click.testing import CliRunner
from rustchain_sdk import cli
from rustchain_sdk.client import RustChainClient

CASES = [
    ('live canonical payload (verified from node)', {'amount_i64': 21000000, 'amount_rtc': 21, 'miner_id': 'local-fixture'}),
    ('working-balance control', {'balance': 42, 'nonce': 3, 'miner_id': 'local-fixture'}),
]

def run(payload):
    client = RustChainClient(base_url='https://example.invalid', verify=True)
    client._client = httpx.AsyncClient(base_url='https://example.invalid', transport=httpx.MockTransport(lambda request: httpx.Response(200, json=payload, request=request)))
    original = cli.RustChainClient
    class Fixed:
        async def __aenter__(self):
            return self
        async def __aexit__(self, *args):
            await client.close()
        async def get_balance(self, address):
            return await client.get_balance(address)
    cli.RustChainClient = lambda **kwargs: Fixed()
    try:
        return CliRunner().invoke(cli.main, ['wallet', 'balance', 'local-fixture']).output.strip()
    finally:
        cli.RustChainClient = original

for label, payload in CASES:
    print(label)
    print(run(payload))

Executed output, exit 0:

live canonical payload (verified from node)
Address:  local-fixture
Balance:  0 RTC
Nonce:    0
working-balance control
Address:  local-fixture
Balance:  42 RTC
Nonce:    3

Duplicate screening: Rustchain "cli.py" "balance_rtc" returned 0; broader balance searches returned only stale-route work (7070, 7085, 8318, 8088) and unrelated claims. Novelty and eligibility remain maintainer decisions.

AI assistance disclosure: source inspection, local reproduction and report preparation were AI-assisted. No accounts, credentials, funds or production operations.

Dominant language
Python
Stars
850
Forks
589
Avg merge
11d 7h
Merged PRs (30d)
29

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Scottcjn/Rustchain

All issues in Scottcjn/Rustchain

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.