Skip to content

Bug: Inconsistent Error Handling in Wallet Balance Check Script #7889

Description

@jaxint

Bug: Inconsistent Error Handling in Wallet Balance Check

Description

The wallet balance check script in scripts/check_balance.sh doesn't properly handle network failures, which can lead to misleading error messages.

Location

  • File: scripts/check_balance.sh
  • Lines: 15-20

Expected Behavior

When the network is unavailable or the RPC endpoint times out, the script should clearly indicate a network error.

Actual Behavior

The script silently fails with exit code 0 and prints "Balance: 0 RTC" even when no actual balance check was performed.

Steps to Reproduce

  1. Disconnect from network
  2. Run: ./scripts/check_balance.sh AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG
  3. Observe output shows "Balance: 0 RTC" instead of network error

Suggested Fix

Add explicit error checking for curl responses:

response=$(curl -s -w "%{http_code}" "$RPC_ENDPOINT/balance?wallet=$WALLET")
http_code=${response: -3}
body=${response%???}

if [ "$http_code" != "200" ]; then
    echo "Error: Failed to check balance (HTTP $http_code)"
    exit 1
fi

Impact

  • Low severity but affects user experience
  • Can confuse users troubleshooting miner setup
  • Might mask actual network issues

Environment

  • OS: Linux (WSL2)
  • RustChain version: Latest from main branch
  • Date: 2026-07-05

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions