diff --git a/docs/CRYPTO.rst b/docs/CRYPTO.rst index c1e1d9f..e95e3ba 100644 --- a/docs/CRYPTO.rst +++ b/docs/CRYPTO.rst @@ -68,7 +68,7 @@ Components **4. Auto-Sweep System** - Immediate sweep to cold storage after confirmation - - Configurable fee reserves for each cryptocurrency + - Perfect accounting to the quote amount (atomic units) - Comprehensive sweep logging and error recovery - Support for restocking fees and overpayment refunds @@ -295,9 +295,11 @@ Hot Wallet Security - Implement proper access controls and monitoring **Fund Management:** -- Minimal funds kept for transaction fees (cryptocurrency-specific) -- Excess funds automatically swept within minutes of confirmation -- See cryptocurrency documentation for specific fee reserves +- Perfect accounting to the quote amount in atomic units +- Customer pays: invoice + calculated fee buffer +- Full payment amount swept to cold storage +- Network fees handled dynamically during sweep operations +- No dust accumulation - exact amounts swept each time Cold Storage Integration ------------------------ diff --git a/docs/DOGECOIN.md b/docs/DOGECOIN.md index 72731a4..38c4a43 100644 --- a/docs/DOGECOIN.md +++ b/docs/DOGECOIN.md @@ -302,26 +302,9 @@ def validate_dogecoin_address(address): return all(c in valid_chars for c in address) ``` -**Auto-Sweep Configuration:** -```python -def auto_sweep_dogecoin_payment(payment, confirmed_amount): - """Sweep confirmed DOGE payment to cold storage.""" - fee_reserve = Decimal('0.01') # Keep 0.01 DOGE for fees - sweep_amount = confirmed_amount - fee_reserve - - if sweep_amount > 0: - # Sweep to shop's configured cold wallet - tx_hash = client.sendtoaddress( - address=payment.shop.cold_wallet_address, - amount=float(sweep_amount), - comment=f"Auto-sweep payment {payment.id}", - comment_to="", - subtractfeefromamount=False - ) - - log.sweep_operation(payment, "DOGE auto-sweep successful", - tx_hash, sweep_amount) -``` +**Auto-Sweep System:** + +The system uses perfect accounting to the quote amount - sweeping exactly what the customer paid (including fee buffers). Quotes are calculated in atomic units (koinu) for precision. After confirmation, the full payment amount is swept to cold storage with network fees paid from the balance. Each shop's funds are swept to their configured cold wallet address immediately after confirmation. This approach prevents dust accumulation in the hot wallet. ## Monitoring and Maintenance @@ -329,15 +312,10 @@ def auto_sweep_dogecoin_payment(payment, confirmed_amount): **Key Metrics:** ```bash -# Node synchronization status -dogecoin-cli getblockchaininfo | grep -E "(blocks|headers|verificationprogress)" - -# Network connectivity -dogecoin-cli getnetworkinfo | grep -E "(connections|version)" - -# Wallet balance and transactions -dogecoin-cli getwalletinfo -dogecoin-cli getbalance +# Use Make commands for monitoring +make dogecoin-status # Check sync status and progress +make dogecoin-config # View/create configuration +make dogecoin-node # Start pruned node ``` **Automated Health Checks:** @@ -412,49 +390,29 @@ grep "Dogecoin RPC connection error" logs/crypto_watcher.log # Check if daemon is running ps aux | grep dogecoind -# Check peer connections -dogecoin-cli getpeerinfo | grep -c '"id"' - -# Force reconnection to peers -dogecoin-cli addnode seed.dogechain.info add -dogecoin-cli addnode seed.multidoge.org add +# Check connection status +make dogecoin-status # Shows peers and sync status ``` **Wallet Issues:** ```bash -# Check wallet loading -dogecoin-cli listwallets - -# Load specific wallet if needed -dogecoin-cli loadwallet make_post_sell_hot_wallet - -# Check wallet integrity -dogecoin-cli getwalletinfo +# Wallet managed by dogecoind configuration +# Check status with: +make dogecoin-status ``` **Address and Transaction Issues:** ```bash -# List all addresses with labels -dogecoin-cli listaddressgroupings - -# Check specific address balance -dogecoin-cli getreceivedbyaddress D1A2B3C4D5E6F7G8H9I0J1K2L3M4N5O6P7 1 - -# List recent transactions -dogecoin-cli listtransactions "*" 50 0 +# Address and transaction tracking handled by crypto_watcher +# View payment activity in logs: +tail -f logs/crypto_watcher.log | grep DOGE ``` **Recovery Procedures:** ```bash -# Backup wallet (regular maintenance) -dogecoin-cli backupwallet /secure/backup/wallet-$(date +%Y%m%d).dat - -# Restore wallet from backup -cp /secure/backup/wallet-20231201.dat ~/.dogecoin/wallet.dat -# Restart dogecoind after restore - -# Rescan blockchain for transactions (if needed) -dogecoin-cli rescanblockchain 0 +# Regular wallet backups are critical +# Store wallet.dat backups in secure location +# Recovery requires restoring wallet.dat and restarting dogecoind ``` ### Emergency Procedures diff --git a/docs/MONERO.rst b/docs/MONERO.rst index dc2de29..43bfa24 100644 --- a/docs/MONERO.rst +++ b/docs/MONERO.rst @@ -258,10 +258,8 @@ Quick Start for Developers # Run Monero-specific tests py.test make_post_sell/tests/test_crypto_watcher.py -k "xmr or monero" - # Test wallet connectivity - curl -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":{}}' + # Test wallet connectivity using Make commands + make test-monero-connection Production Deployment ===================== @@ -325,27 +323,9 @@ Each shop must configure their own cold wallet address for automatic sweep desti return True return False -**Auto-Sweep Configuration:** -:: +**Auto-Sweep System:** - # Automatic sweep after payment confirmation - def auto_sweep_payment(payment, confirmed_amount): - fee_reserve = Decimal('0.001') # Keep for future transactions - sweep_amount = confirmed_amount - fee_reserve - - if sweep_amount > 0: - # Sweep to shop's configured cold wallet - result = client._call("transfer", { - "destinations": [{ - "amount": int(sweep_amount * ATOMIC_UNITS), - "address": payment.shop.cold_wallet_address - }], - "account_index": payment.account_index, - "priority": 1 - }) - - log.sweep_operation(payment, "Auto-sweep successful", - result['tx_hash'], sweep_amount) +The system uses perfect accounting to the quote amount - sweeping exactly what the customer paid (including fee buffers). Quotes are calculated in atomic units (piconero) for precision. After confirmation, the full payment amount is swept to cold storage with network fees deducted from the transfer. Each shop's funds are isolated in separate accounts. This approach prevents dust accumulation since exact amounts are swept. Monitoring and Maintenance ========================== @@ -356,38 +336,13 @@ Wallet Health Monitoring **Key Metrics:** :: - # Wallet synchronization status - curl -s -X POST http://127.0.0.1:18083/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_height"}' | \ - python3 -c "import sys,json; print(f\"Height: {json.load(sys.stdin)['result']['height']}\")" - - # Account balances across all shops - curl -s -X POST http://127.0.0.1:18083/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_balance","params":{"all_accounts":true}}' + # Use Make Post Sell monitoring commands + make monero-transactions # View recent transactions + make crypto-watcher # Monitor payment processing **Automated Health Checks:** -:: - #!/bin/bash - # wallet_health_check.sh - - # Check wallet RPC connectivity - if ! curl -s --max-time 5 http://127.0.0.1:18083/json_rpc > /dev/null; then - echo "CRITICAL: Wallet RPC not responding" - exit 2 - fi - - # Check wallet synchronization - height=$(curl -s -X POST http://127.0.0.1:18083/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_height"}' | \ - python3 -c "import sys,json; print(json.load(sys.stdin)['result']['height'])") - - if [ "$height" -lt 1 ]; then - echo "WARNING: Wallet not synchronized" - exit 1 - fi - - echo "OK: Wallet healthy, height: $height" +Monitor wallet health through the crypto watcher service (``make crypto-watcher``) which handles payment detection and processing. Log Analysis ------------ @@ -431,33 +386,22 @@ Common Issues ------------- **Wallet Synchronization Problems:** -:: - # Check daemon connectivity - curl -s -X POST http://127.0.0.1:18081/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_info"}' - - # Force wallet refresh - curl -s -X POST http://127.0.0.1:18083/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"refresh"}' +- Check that monero-wallet-rpc is running +- Verify remote node connectivity +- Ensure wallet file is accessible **Account/Subaddress Issues:** -:: - # List all accounts - curl -s -X POST http://127.0.0.1:18083/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_accounts"}' - - # Get subaddresses for specific account - curl -s -X POST http://127.0.0.1:18083/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_address","params":{"account_index":1}}' +- Ensure shop account indices are properly assigned +- Check that account creation succeeded during setup +- Verify cold wallet addresses are configured **Payment Tracking Issues:** -:: - # Check transfers for specific account/subaddress - curl -s -X POST http://127.0.0.1:18083/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_transfers","params":{"in":true,"account_index":1,"subaddr_indices":[1]}}' +- Use ``make monero-transactions`` to view recent transfers +- Check crypto_watcher logs for payment detection +- Verify subaddress labels match payment IDs **Recovery Procedures:** :: @@ -468,11 +412,8 @@ Common Issues --wallet-file=data/mps-wallet-restored \ --password-file=data/wallet-password.txt - # Account recreation (if accounts are lost) - # Note: Account indices must match original setup - for shop in shops_with_xmr: - curl -X POST http://127.0.0.1:18083/json_rpc \ - -d "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"create_account\",\"params\":{\"label\":\"mps-shop-${shop.uuid}\"}}" + # Account recreation handled by application + # Account indices stored in database must match wallet Emergency Procedures -------------------- @@ -485,16 +426,8 @@ Emergency Procedures EMERGENCY_ADDRESS="your_emergency_cold_wallet_address" - # Get all accounts - accounts=$(curl -s -X POST http://127.0.0.1:18083/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_accounts"}' | \ - python3 -c "import sys,json; accounts=json.load(sys.stdin)['result']['subaddress_accounts']; print(','.join(str(acc['account_index']) for acc in accounts))") - - # Sweep each account - for account in $(echo $accounts | tr ',' ' '); do - curl -X POST http://127.0.0.1:18083/json_rpc \ - -d "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"sweep_all\",\"params\":{\"address\":\"$EMERGENCY_ADDRESS\",\"account_index\":$account}}" - done + # Use Make command for emergency sweeps + COLD_WALLET_ADDRESS=$EMERGENCY_ADDRESS make sweep-all **Wallet Backup and Recovery:** :: @@ -503,13 +436,8 @@ Emergency Procedures # 1. Backup wallet files cp data/mps-wallet* /secure/backup/location/ - # 2. Backup account configuration - curl -s -X POST http://127.0.0.1:18083/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"get_accounts"}' > account_backup.json - - # 3. Export key images (for recovery) - curl -s -X POST http://127.0.0.1:18083/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"export_key_images"}' > key_images_backup.json + # 2. Account configuration stored in database + # Account indices preserved during recovery Advanced Configuration ====================== @@ -530,12 +458,8 @@ Performance Tuning --log-level=1 **Memory Management:** -:: - # For high-volume shops, optimize memory usage - # Reduce transaction history retention - curl -X POST http://127.0.0.1:18083/json_rpc \ - -d '{"jsonrpc":"2.0","id":"0","method":"set_tx_notes","params":{"txids":["old_tx_id"],"notes":[""]}}' +For high-volume shops, monero-wallet-rpc memory usage is minimal with remote nodes. The wallet only maintains account and subaddress data, not full transaction history. **Database Optimization:** ::