#!/usr/bin/env bash
set -euo pipefail

# End-to-end test for Electrum-BTCQ.
# Prerequisites:
#   - btcqd running on regtest
#   - btcq-electrs running and synced
#   - Both accessible on localhost

ELECTRUM="python3 run_electrum_btcq --regtest"

echo "=== Creating wallet ==="
$ELECTRUM create
echo "PASS: wallet created"

echo "=== Getting seed ==="
SEED=$($ELECTRUM getseed)
echo "Seed: $SEED"
echo "PASS: seed retrieved"

echo "=== Getting address ==="
ADDR=$($ELECTRUM getunusedaddress)
echo "Address: $ADDR"
[[ "$ADDR" == btcqrt1* ]] && echo "PASS: correct prefix" || echo "FAIL: wrong prefix"

echo "=== Checking balance ==="
BAL=$($ELECTRUM getbalance)
echo "Balance: $BAL"
echo "PASS: balance query works"

echo "=== Done ==="
