45 lines
1.1 KiB
Bash
45 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Script to list all loaded wallets on the RinCoin node
|
|
# Usage: ./list_wallets.sh [rpc_user] [rpc_password] [rpc_host] [rpc_port]
|
|
|
|
RPC_USER=${1:-"rinrpc"}
|
|
RPC_PASSWORD=${2:-"745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90"}
|
|
RPC_HOST=${3:-"localhost"}
|
|
RPC_PORT=${4:-"9556"}
|
|
|
|
# JSON-RPC request to list wallets
|
|
RPC_REQUEST='{
|
|
"jsonrpc": "2.0",
|
|
"id": "listwallets",
|
|
"method": "listwallets",
|
|
"params": []
|
|
}'
|
|
|
|
echo "Listing loaded wallets on RinCoin node..."
|
|
|
|
# Make the RPC call
|
|
RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$RPC_REQUEST" \
|
|
"http://$RPC_HOST:$RPC_PORT")
|
|
|
|
# Check for errors
|
|
ERROR=$(echo "$RESPONSE" | jq -r '.error' 2>/dev/null)
|
|
if [ "$ERROR" != "null" ] && [ -n "$ERROR" ]; then
|
|
echo "Error: $(echo "$ERROR" | jq -r '.message')"
|
|
exit 1
|
|
fi
|
|
|
|
# Get wallet list
|
|
WALLETS=$(echo "$RESPONSE" | jq -r '.result[]' 2>/dev/null)
|
|
if [ -n "$WALLETS" ]; then
|
|
echo "Loaded wallets:"
|
|
echo "$WALLETS" | while read -r wallet; do
|
|
echo " - $wallet"
|
|
done
|
|
else
|
|
echo "No wallets are currently loaded."
|
|
fi
|
|
|