diff --git a/monero-sweep-all.sh b/monero-sweep-all.sh deleted file mode 100755 index a8ae166..0000000 --- a/monero-sweep-all.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# Monero Sweep All Script -# Sweeps ALL unlocked funds from ALL Monero wallet accounts to cold storage -# Based on make_post_sell Makefile sweep-all target - -set -e # Exit on any error - -echo "=== SWEEPING ALL MONERO WALLET FUNDS TO COLD STORAGE ===" -echo "CAUTION: This will send ALL unlocked balance from ALL accounts!" -echo "" - -# Check if COLD_WALLET_ADDRESS is set -if [ -z "${COLD_WALLET_ADDRESS}" ]; then - echo "ERROR: COLD_WALLET_ADDRESS environment variable not set!" - echo "Usage: COLD_WALLET_ADDRESS= ./monero-sweep-all.sh" - exit 1 -fi - -# Check if wallet RPC is accessible -if ! curl --digest -u "test_user:test_pass" -s -X POST http://127.0.0.1:18083/json_rpc \ - -H 'Content-Type: application/json' \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_version"}' >/dev/null 2>&1; then - echo "❌ Monero wallet RPC not accessible at http://127.0.0.1:18083" - echo "Start wallet RPC with:" - echo " make monero-wallet-remote-auth # For testing with auth" - echo " make monero-wallet-remote # For testing without auth" - echo " make monero-wallet # For production with local node" - exit 1 -fi - -echo "✓ Wallet RPC is accessible" -echo "" - -# Get all account balances -echo "Checking ALL account balances..." -all_balance=$(curl --digest -u "test_user:test_pass" -s -X POST http://127.0.0.1:18083/json_rpc \ - -H 'Content-Type: application/json' \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_balance","params":{"all_accounts":true}}' | \ - python3 -c "import sys, json; d=json.load(sys.stdin); result = d.get('result', {}); total_balance = result.get('balance', 0); total_unlocked = result.get('unlocked_balance', 0); accounts = result.get('per_subaddress', []); print('Total balance: {} atomic units ({:.12f} XMR)'.format(total_balance, total_balance/1e12)); print('Total unlocked: {} atomic units ({:.12f} XMR)'.format(total_unlocked, total_unlocked/1e12)); print('Per account breakdown:'); [print(' Account {}:{} - Balance: {:.12f} XMR (unlocked: {:.12f} XMR)'.format(acc.get('account_index', 0), acc.get('address_index', 0), acc.get('balance', 0)/1e12, acc.get('unlocked_balance', 0)/1e12)) for acc in accounts if acc.get('balance', 0) > 0]; print(total_unlocked)") - -total_unlocked=$(echo "$all_balance" | tail -1) - -if [ -z "$total_unlocked" ] || [ "$total_unlocked" = "0" ]; then - echo "No unlocked balance to sweep across all accounts!" - exit 1 -fi - -echo "" -echo "Target address: ${COLD_WALLET_ADDRESS}" -echo "" - -# Confirmation prompt -read -p "Are you sure you want to sweep ALL unlocked funds from ALL accounts? (yes/no): " confirm -if [ "$confirm" != "yes" ]; then - echo "Cancelled." - exit 0 -fi - -echo "" -echo "Getting all accounts for sweeping..." - -# Get all account indices -accounts=$(curl --digest -u "test_user:test_pass" -s -X POST http://127.0.0.1:18083/json_rpc \ - -H 'Content-Type: application/json' \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_accounts"}' | \ - python3 -c "import sys, json; d=json.load(sys.stdin); accounts = d.get('result', {}).get('subaddress_accounts', []); account_indices = [acc.get('account_index', 0) for acc in accounts]; print(','.join(map(str, account_indices)))") - -echo "Found accounts: $accounts" -echo "" - -# Sweep each account -for account in $(echo $accounts | tr ',' ' '); do - echo "Sweeping account $account..." - response=$(curl --digest -u "test_user:test_pass" -s -X POST http://127.0.0.1:18083/json_rpc \ - -H 'Content-Type: application/json' \ - -d "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"sweep_all\",\"params\":{\"address\":\"${COLD_WALLET_ADDRESS}\",\"account_index\":$account,\"subaddr_indices\":[],\"priority\":0,\"get_tx_metadata\":false}}") - - echo "$response" | python3 -c "import sys, json; d=json.load(sys.stdin); r=d.get('result',{}); amounts=r.get('amount_list',[]); fees=r.get('fee_list',[]); hashes=r.get('tx_hash_list',[]); [print('✓ Account $account: {:.12f} XMR (fee: {:.12f}) Hash: {}'.format(amt/1e12, fee/1e12, tx_hash)) for amt, fee, tx_hash in zip(amounts, fees, hashes)] if amounts else print('Account $account: No funds') if 'error' not in d else print('Account $account:', d['error'].get('message','Error'))" -done - -echo "" -echo "All account sweep operations completed!" -echo "" -echo "🔄 Check transaction status:" -echo " make monero-transactions" -echo "" -echo "💰 Verify cold wallet balance at:" -echo " https://xmrchain.net/search?value=${COLD_WALLET_ADDRESS}" \ No newline at end of file