Files
mines/rin/wallet/cmd/create_wallet.sh
Dobromir Popov dc8f69c5c3 code moved from scripts repo;
dump works
2025-09-29 22:23:38 +03:00

51 lines
1.3 KiB
Bash

#!/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