load /set web wallet
This commit is contained in:
49
rin/wallet/cmd/load_wallet.sh
Normal file
49
rin/wallet/cmd/load_wallet.sh
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user