rin wallet
This commit is contained in:
63
MINE/rin/restore_wallet.sh
Normal file
63
MINE/rin/restore_wallet.sh
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
# RinCoin Wallet Restoration Script
|
||||
# Restores a wallet from a dump file on a new RinCoin node.
|
||||
# Prerequisites: New RinCoin node running in Docker, backup file available.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <path_to_backup_file>"
|
||||
echo "Example: $0 ~/rin_wallet_backups/rin_wallet_backup_20230923.txt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BACKUP_FILE="$1"
|
||||
CONTAINER="rincoin-node"
|
||||
WALLET_NAME="main" # Will be renamed to avoid conflicts
|
||||
NEW_WALLET_NAME="restored_main"
|
||||
|
||||
# Verify backup file exists
|
||||
if [[ ! -f "$BACKUP_FILE" ]]; then
|
||||
echo "Error: Backup file '$BACKUP_FILE' not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if container is running
|
||||
if ! sudo docker ps --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then
|
||||
echo "Error: ${CONTAINER} container is not running. Start it with 'sudo docker start ${CONTAINER}'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Stopping RinCoin node for safe restoration..."
|
||||
sudo docker stop "$CONTAINER"
|
||||
|
||||
echo "Copying backup file into container..."
|
||||
sudo docker cp "$BACKUP_FILE" "$CONTAINER:/tmp/wallet_backup.txt"
|
||||
|
||||
echo "Starting RinCoin node..."
|
||||
sudo docker start "$CONTAINER"
|
||||
|
||||
# Wait for RPC to be ready
|
||||
echo "Waiting for node to fully start..."
|
||||
sleep 10
|
||||
|
||||
echo "Creating new wallet and importing keys..."
|
||||
# Create a new wallet to avoid conflicts
|
||||
sudo docker exec "$CONTAINER" rincoin-cli -datadir=/data -conf=/data/rincoin.conf createwallet "$NEW_WALLET_NAME"
|
||||
|
||||
# Import the dump file
|
||||
sudo docker exec "$CONTAINER" rincoin-cli -datadir=/data -conf=/data/rincoin.conf -rpcwallet="$NEW_WALLET_NAME" importwallet /tmp/wallet_backup.txt
|
||||
|
||||
# Clean up
|
||||
sudo docker exec "$CONTAINER" rm /tmp/wallet_backup.txt
|
||||
|
||||
echo "✅ Wallet restored successfully!"
|
||||
echo "New wallet name: $NEW_WALLET_NAME"
|
||||
echo ""
|
||||
echo "Verify with:"
|
||||
echo "sudo docker exec $CONTAINER rincoin-cli -datadir=/data -conf=/data/rincoin.conf -rpcwallet=$NEW_WALLET_NAME getbalance"
|
||||
echo ""
|
||||
echo "To use this wallet, update scripts to use -rpcwallet=$NEW_WALLET_NAME"
|
||||
echo "Or rename it back: unloadwallet $NEW_WALLET_NAME && loadwallet $WALLET_NAME"
|
||||
|
Reference in New Issue
Block a user