code moved from scripts repo;
dump works
This commit is contained in:
50
rin/wallet/cmd/create_wallet.sh
Normal file
50
rin/wallet/cmd/create_wallet.sh
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to create a new wallet on the RinCoin node
|
||||
# Usage: ./create_wallet.sh <wallet_name> [rpc_user] [rpc_password] [rpc_host] [rpc_port]
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <wallet_name> [rpc_user] [rpc_password] [rpc_host] [rpc_port]"
|
||||
echo "Example: $0 main"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WALLET_NAME=$1
|
||||
RPC_USER=${2:-"rinrpc"}
|
||||
RPC_PASSWORD=${3:-"745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90"}
|
||||
RPC_HOST=${4:-"localhost"}
|
||||
RPC_PORT=${5:-"9556"}
|
||||
|
||||
# JSON-RPC request to create wallet
|
||||
RPC_REQUEST='{
|
||||
"jsonrpc": "2.0",
|
||||
"id": "createwallet",
|
||||
"method": "createwallet",
|
||||
"params": ["'"$WALLET_NAME"'", false, false, "", false, false, true]
|
||||
}'
|
||||
|
||||
echo "Creating wallet '$WALLET_NAME' 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 result
|
||||
RESULT=$(echo "$RESPONSE" | jq -r '.result' 2>/dev/null)
|
||||
if [ "$RESULT" != "null" ]; then
|
||||
echo "Wallet '$WALLET_NAME' created successfully!"
|
||||
echo "Result: $RESULT"
|
||||
else
|
||||
echo "Unexpected response: $RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user