Files
mines/rin/wallet/cmd/load_wallet.sh
2025-09-29 23:32:59 +03:00

50 lines
1.5 KiB
Bash

#!/bin/bash
# Script to load a specific wallet by name
# Usage: ./load_wallet.sh <wallet_name>
if [[ $# -ne 1 ]]; then
echo "Usage: $0 <wallet_name>"
echo "Example: $0 main"
echo "Example: $0 my-wall"
exit 1
fi
WALLET_NAME="$1"
# RPC Configuration
RPC_USER="rinrpc"
RPC_PASSWORD="745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90"
RPC_HOST="localhost"
RPC_PORT="9556"
echo "Loading wallet: $WALLET_NAME"
LOAD_RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": "loadwallet", "method": "loadwallet", "params": ["'$WALLET_NAME'"]}' \
"http://$RPC_HOST:$RPC_PORT")
echo "Response: $LOAD_RESPONSE"
if echo "$LOAD_RESPONSE" | grep -q '"error":null'; then
echo "✓ Wallet '$WALLET_NAME' loaded successfully"
# Show balance
BALANCE_RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": "getbalance", "method": "getbalance", "params": []}' \
"http://$RPC_HOST:$RPC_PORT/wallet/$WALLET_NAME")
if echo "$BALANCE_RESPONSE" | grep -q '"error":null'; then
BALANCE=$(echo "$BALANCE_RESPONSE" | grep -o '"result":[0-9.]*' | cut -d: -f2)
echo "Balance: $BALANCE RIN"
fi
elif echo "$LOAD_RESPONSE" | grep -q "already loaded"; then
echo "✓ Wallet '$WALLET_NAME' is already loaded"
else
echo "❌ Failed to load wallet '$WALLET_NAME'"
echo "Make sure the wallet exists in the data directory"
fi