wip walet restore/list/ debug restore
This commit is contained in:
@@ -60,19 +60,29 @@ if echo "$RESPONSE" | grep -q '"error":null'; then
|
||||
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"
|
||||
# Get used addresses
|
||||
echo " Used addresses:"
|
||||
ADDRESSES_RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"jsonrpc": "2.0", "id": "listreceivedbyaddress", "method": "listreceivedbyaddress", "params": [0, true, true]}' \
|
||||
"http://$RPC_HOST:$RPC_PORT/wallet/$wallet")
|
||||
|
||||
if echo "$ADDRESSES_RESPONSE" | grep -q '"error":null'; then
|
||||
# Extract addresses from the response
|
||||
ADDRESSES=$(echo "$ADDRESSES_RESPONSE" | grep -o '"address":"[^"]*"' | cut -d'"' -f4 | head -5)
|
||||
|
||||
if [ -n "$ADDRESSES" ]; then
|
||||
echo "$ADDRESSES" | while read -r addr; do
|
||||
if [ -n "$addr" ]; then
|
||||
echo " $addr"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo " (No used addresses found)"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo " (Could not retrieve addresses - wallet may be empty)"
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user