load /set web wallet
This commit is contained in:
@@ -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."
|
||||
|
||||
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
|
||||
30
rin/wallet/cmd/set_web_wallet.sh
Normal file
30
rin/wallet/cmd/set_web_wallet.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to set which wallet the web interface uses
|
||||
# Usage: ./set_web_wallet.sh <wallet_name>
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <wallet_name>"
|
||||
echo "Example: $0 main"
|
||||
echo "Example: $0 my-wall"
|
||||
echo ""
|
||||
echo "This sets the RIN_WALLET_NAME environment variable for the web wallet"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WALLET_NAME="$1"
|
||||
|
||||
echo "Setting web wallet to use: $WALLET_NAME"
|
||||
echo ""
|
||||
echo "To use this wallet with the web interface:"
|
||||
echo "1. Stop the current web wallet (Ctrl+C)"
|
||||
echo "2. Start it with:"
|
||||
echo " RIN_WALLET_NAME=$WALLET_NAME ./rin/wallet/web/start_web_wallet.sh"
|
||||
echo ""
|
||||
echo "Or set it permanently in your environment:"
|
||||
echo " export RIN_WALLET_NAME=$WALLET_NAME"
|
||||
echo " ./rin/wallet/web/start_web_wallet.sh"
|
||||
echo ""
|
||||
echo "Current web wallet configuration:"
|
||||
echo " Default wallet: main"
|
||||
echo " New wallet: $WALLET_NAME"
|
||||
Reference in New Issue
Block a user