load /set web wallet

This commit is contained in:
Dobromir Popov
2025-09-29 23:32:59 +03:00
parent e272755015
commit 0d34b69fb4
3 changed files with 110 additions and 0 deletions

View File

@@ -44,6 +44,37 @@ if echo "$RESPONSE" | grep -q '"error":null'; then
echo "Loaded wallets:"
echo "$WALLETS" | while read -r wallet; do
echo " - $wallet"
# Get wallet info
WALLET_INFO=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": "getwalletinfo", "method": "getwalletinfo", "params": []}' \
"http://$RPC_HOST:$RPC_PORT/wallet/$wallet")
if echo "$WALLET_INFO" | grep -q '"error":null'; then
# Extract balance
BALANCE=$(echo "$WALLET_INFO" | grep -o '"balance":[0-9.]*' | cut -d: -f2)
# Extract address count
ADDRESS_COUNT=$(echo "$WALLET_INFO" | grep -o '"txcount":[0-9]*' | cut -d: -f2)
echo " Balance: ${BALANCE:-0} RIN"
echo " Transactions: ${ADDRESS_COUNT:-0}"
# Get a few addresses
echo " Sample addresses:"
for i in {1..3}; do
ADDR_RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": "getnewaddress", "method": "getnewaddress", "params": []}' \
"http://$RPC_HOST:$RPC_PORT/wallet/$wallet")
if echo "$ADDR_RESPONSE" | grep -q '"error":null'; then
ADDR=$(echo "$ADDR_RESPONSE" | grep -o '"result":"[^"]*"' | cut -d'"' -f4)
echo " $ADDR"
fi
done
fi
echo ""
done
else
echo "No wallets are currently loaded."