wip walet restore/list/ debug restore
This commit is contained in:
@@ -60,7 +60,62 @@ General-purpose RPC call script for any RIN RPC method.
|
||||
./rpc_call.sh getnewaddress myaccount
|
||||
./rpc_call.sh listtransactions "*" 10
|
||||
./rpc_call.sh validateaddress rin1qvj0yyt9phvled9kxflju3p687a4s7kareglpk5
|
||||
./rpc_call.sh loadwallet
|
||||
./rpc_call.sh loadwallet
|
||||
```
|
||||
|
||||
### list_wallets.sh
|
||||
List all loaded wallets with balance, transaction count, and used addresses.
|
||||
|
||||
```bash
|
||||
./list_wallets.sh
|
||||
```
|
||||
|
||||
### load_wallet.sh
|
||||
Load a specific wallet by name.
|
||||
|
||||
```bash
|
||||
./load_wallet.sh main
|
||||
./load_wallet.sh my-wall
|
||||
```
|
||||
|
||||
### set_web_wallet.sh
|
||||
Set which wallet the web interface should use.
|
||||
|
||||
```bash
|
||||
./set_web_wallet.sh main
|
||||
```
|
||||
|
||||
### find_address.sh
|
||||
Check if an address belongs to any loaded wallet.
|
||||
|
||||
```bash
|
||||
./find_address.sh rin1qvj0yyt9phvled9kxflju3p687a4s7kareglpk5
|
||||
```
|
||||
|
||||
### dump_wallet.sh
|
||||
Create a secure backup of all private keys in a wallet.
|
||||
|
||||
```bash
|
||||
./dump_wallet.sh
|
||||
```
|
||||
|
||||
### restore_wallet.sh
|
||||
Restore a wallet from a backup dump file.
|
||||
|
||||
```bash
|
||||
./restore_wallet.sh ~/rin_wallet_backups/rin_wallet_backup_20230923.txt
|
||||
./restore_wallet.sh ~/rin_wallet_backups/rin_wallet_backup_20230923.txt my_restored_wallet
|
||||
```
|
||||
|
||||
### restore_from_seed.sh
|
||||
Restore a wallet from just the master private key.
|
||||
|
||||
```bash
|
||||
# Auto-generate wallet name
|
||||
./restore_from_seed.sh "xprv9s21ZrQH143K3bjynHVk6hBTZLmV9wjqWScL3UyENBYK6RaFo75zu5jnWQtBi932zKbD7c2WARWLJNjBbE3Td2Cc44ym3dmp343qKKFXwxS"
|
||||
|
||||
# Specify custom wallet name
|
||||
./restore_from_seed.sh "xprv9s21ZrQH143K3bjynHVk6hBTZLmV9wjqWScL3UyENBYK6RaFo75zu5jnWQtBi932zKbD7c2WARWLJNjBbE3Td2Cc44ym3dmp343qKKFXwxS" my_restored_wallet
|
||||
```
|
||||
|
||||
## Default RPC Configuration
|
||||
|
||||
@@ -60,19 +60,29 @@ if echo "$RESPONSE" | grep -q '"error":null'; then
|
||||
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"
|
||||
# Get used addresses
|
||||
echo " Used addresses:"
|
||||
ADDRESSES_RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"jsonrpc": "2.0", "id": "listreceivedbyaddress", "method": "listreceivedbyaddress", "params": [0, true, true]}' \
|
||||
"http://$RPC_HOST:$RPC_PORT/wallet/$wallet")
|
||||
|
||||
if echo "$ADDRESSES_RESPONSE" | grep -q '"error":null'; then
|
||||
# Extract addresses from the response
|
||||
ADDRESSES=$(echo "$ADDRESSES_RESPONSE" | grep -o '"address":"[^"]*"' | cut -d'"' -f4 | head -5)
|
||||
|
||||
if [ -n "$ADDRESSES" ]; then
|
||||
echo "$ADDRESSES" | while read -r addr; do
|
||||
if [ -n "$addr" ]; then
|
||||
echo " $addr"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo " (No used addresses found)"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo " (Could not retrieve addresses - wallet may be empty)"
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
done
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
# RinCoin Wallet Restoration from Master Seed Script
|
||||
# Restores a wallet from just the master private key (xprv...)
|
||||
# Usage: ./restore_from_seed.sh "xprv9s21ZrQH143K3bjynHVk6hBTZLmV9wjqWScL3UyENBYK6RaFo75zu5jnWQtBi932zKbD7c2WARWLJNjBbE3Td2Cc44ym3dmp343qKKFXwxS"
|
||||
# Usage: ./restore_from_seed.sh "xprv9s21ZrQH143K3bjynHVk6hBTZLmV9wjqWScL3UyENBYK6RaFo75zu5jnWQtBi932zKbD7c2WARWLJNjBbE3Td2Cc44ym3dmp343qKKFXwxS" [wallet_name]
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 \"<master_private_key>\""
|
||||
if [[ $# -lt 1 ]] || [[ $# -gt 2 ]]; then
|
||||
echo "Usage: $0 \"<master_private_key>\" [wallet_name]"
|
||||
echo "Example: $0 \"xprv9s21ZrQH143K3bjynHVk6hBTZLmV9wjqWScL3UyENBYK6RaFo75zu5jnWQtBi932zKbD7c2WARWLJNjBbE3Td2Cc44ym3dmp343qKKFXwxS\""
|
||||
echo "Example: $0 \"xprv9s21ZrQH143K3bjynHVk6hBTZLmV9wjqWScL3UyENBYK6RaFo75zu5jnWQtBi932zKbD7c2WARWLJNjBbE3Td2Cc44ym3dmp343qKKFXwxS\" my_restored_wallet"
|
||||
echo ""
|
||||
echo "To get the master key from your backup file:"
|
||||
echo "grep 'extended private masterkey' ~/rin_wallet_backups/rin_wallet_backup_*.txt"
|
||||
@@ -16,8 +17,12 @@ if [[ $# -ne 1 ]]; then
|
||||
fi
|
||||
|
||||
MASTER_KEY="$1"
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
WALLET_NAME="restored_from_seed_${TIMESTAMP}"
|
||||
if [[ $# -eq 2 ]]; then
|
||||
WALLET_NAME="$2"
|
||||
else
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
WALLET_NAME="restored_from_seed_${TIMESTAMP}"
|
||||
fi
|
||||
|
||||
# RPC Configuration
|
||||
RPC_USER="rinrpc"
|
||||
@@ -37,26 +42,25 @@ if ! pgrep -f "rincoind" > /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Checking if wallet already exists..."
|
||||
echo "Checking if wallet '$WALLET_NAME' already exists..."
|
||||
|
||||
# First try to load existing wallet
|
||||
LOAD_RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"jsonrpc": "2.0", "id": "loadwallet", "method": "loadwallet", "params": ["restored_from_seed"]}' \
|
||||
-d '{"jsonrpc": "2.0", "id": "loadwallet", "method": "loadwallet", "params": ["'$WALLET_NAME'"]}' \
|
||||
"http://$RPC_HOST:$RPC_PORT")
|
||||
|
||||
echo "Load response: $LOAD_RESPONSE"
|
||||
|
||||
if echo "$LOAD_RESPONSE" | grep -q '"error":null'; then
|
||||
echo "✓ Existing wallet 'restored_from_seed' loaded successfully"
|
||||
WALLET_NAME="restored_from_seed"
|
||||
echo "✓ Existing wallet '$WALLET_NAME' loaded successfully"
|
||||
else
|
||||
echo "Creating new wallet for seed restoration..."
|
||||
|
||||
# Create a new wallet
|
||||
# Create a new HD wallet (same format as main wallet)
|
||||
CREATE_RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"jsonrpc": "2.0", "id": "createwallet", "method": "createwallet", "params": ["'$WALLET_NAME'", false, true, "", false, false, true]}' \
|
||||
-d '{"jsonrpc": "2.0", "id": "createwallet", "method": "createwallet", "params": ["'$WALLET_NAME'", false, false, "", false, false, true]}' \
|
||||
"http://$RPC_HOST:$RPC_PORT")
|
||||
|
||||
if echo "$CREATE_RESPONSE" | grep -q '"error":null'; then
|
||||
@@ -80,10 +84,10 @@ if echo "$IMPORT_RESPONSE" | grep -q '"error":null'; then
|
||||
else
|
||||
echo "Import response: $IMPORT_RESPONSE"
|
||||
|
||||
# Alternative: Try sethdseed with newkeypool=false (don't replace existing keys)
|
||||
# Alternative: Try sethdseed with newkeypool=true (flush old keys and set new seed)
|
||||
SEED_RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"jsonrpc": "2.0", "id": "sethdseed", "method": "sethdseed", "params": [false, "'$MASTER_KEY'"]}' \
|
||||
-d '{"jsonrpc": "2.0", "id": "sethdseed", "method": "sethdseed", "params": [true, "'$MASTER_KEY'"]}' \
|
||||
"http://$RPC_HOST:$RPC_PORT/wallet/$WALLET_NAME")
|
||||
|
||||
if echo "$SEED_RESPONSE" | grep -q '"error":null'; then
|
||||
@@ -95,6 +99,19 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# Rescan the blockchain to find existing transactions
|
||||
echo "Rescanning blockchain to find existing transactions..."
|
||||
RESCAN_RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"jsonrpc": "2.0", "id": "rescanblockchain", "method": "rescanblockchain", "params": []}' \
|
||||
"http://$RPC_HOST:$RPC_PORT/wallet/$WALLET_NAME")
|
||||
|
||||
if echo "$RESCAN_RESPONSE" | grep -q '"error":null'; then
|
||||
echo "✓ Blockchain rescan completed"
|
||||
else
|
||||
echo "Warning: Blockchain rescan failed or is still in progress: $RESCAN_RESPONSE"
|
||||
fi
|
||||
|
||||
echo "Generating addresses from seed..."
|
||||
|
||||
# Generate some addresses to populate the wallet
|
||||
@@ -116,11 +133,12 @@ echo "✅ Wallet restored from master key successfully!"
|
||||
echo "Wallet name: $WALLET_NAME"
|
||||
echo ""
|
||||
echo "Important notes:"
|
||||
echo "- The wallet will automatically detect transactions as it syncs"
|
||||
echo "- You may need to rescan the blockchain to find old transactions"
|
||||
echo "- Run: ./rin/wallet/cmd/check_balance.sh to see if funds appear"
|
||||
echo "- The wallet has been restored and blockchain rescan has been initiated"
|
||||
echo "- It may take several minutes for the rescan to complete and funds to appear"
|
||||
echo "- Monitor the node logs for rescan progress"
|
||||
echo "- Run: ./rin/wallet/cmd/check_balance.sh to check current balance"
|
||||
echo ""
|
||||
echo "To rescan blockchain (if needed):"
|
||||
echo "To manually trigger rescan again (if needed):"
|
||||
echo "curl -s -u \"$RPC_USER:$RPC_PASSWORD\" -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"id\": \"rescanblockchain\", \"method\": \"rescanblockchain\", \"params\": []}' \"http://$RPC_HOST:$RPC_PORT/wallet/$WALLET_NAME\""
|
||||
echo ""
|
||||
echo "Check balance with:"
|
||||
|
||||
@@ -46,11 +46,11 @@ echo "Backup file copied to: $DAEMON_BACKUP_FILE"
|
||||
|
||||
echo "Creating new wallet and importing keys..."
|
||||
|
||||
# Create a new wallet to avoid conflicts
|
||||
CREATE_RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"jsonrpc": "2.0", "id": "createwallet", "method": "createwallet", "params": ["'$NEW_WALLET_NAME'", false, false, "", false, false, true]}' \
|
||||
"http://$RPC_HOST:$RPC_PORT")
|
||||
# Create a new wallet to avoid conflicts (match original wallet settings)
|
||||
CREATE_RESPONSE=$(curl -s -u "$RPC_USER:$RPC_PASSWORD" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"jsonrpc": "2.0", "id": "createwallet", "method": "createwallet", "params": ["'$NEW_WALLET_NAME'", false, true, "", false, false, true]}' \
|
||||
"http://$RPC_HOST:$RPC_PORT")
|
||||
|
||||
if echo "$CREATE_RESPONSE" | grep -q '"error":null'; then
|
||||
echo "✓ New wallet '$NEW_WALLET_NAME' created successfully"
|
||||
|
||||
Reference in New Issue
Block a user