Files
scripts/MINE/rin/test_address_validation.sh
2025-09-02 12:04:28 +03:00

79 lines
2.7 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Test RinCoin Address Validation and Behavior
echo "=== RinCoin Address Validation Test ==="
echo ""
# Kill any existing processes
./MINE/rin/kill_stratum_proxy.sh
echo "🧪 Testing different address types with RinCoin node:"
echo ""
echo "1⃣ Valid RinCoin address:"
curl -s -u rinrpc:745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90 \
-H 'content-type: text/plain' \
--data '{"jsonrpc":"1.0","id":"curl","method":"validateaddress","params":["rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q"]}' \
http://127.0.0.1:9556/ | jq '.result'
echo ""
echo "2⃣ Invalid BTC address:"
curl -s -u rinrpc:745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90 \
-H 'content-type: text/plain' \
--data '{"jsonrpc":"1.0","id":"curl","method":"validateaddress","params":["bc1qjn4m6rmrveuxhk02a5qhe4r6kdcsvvt3vhdn9j"]}' \
http://127.0.0.1:9556/ | jq '.result'
echo ""
echo "3⃣ Invalid Litecoin address:"
curl -s -u rinrpc:745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90 \
-H 'content-type: text/plain' \
--data '{"jsonrpc":"1.0","id":"curl","method":"validateaddress","params":["LQnYyekHhQ7nMUTGJ1ZnYz8s9QJ2mKLM9P"]}' \
http://127.0.0.1:9556/ | jq '.result'
echo ""
echo "4⃣ Test generatetoaddress with invalid address:"
curl -s -u rinrpc:745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90 \
-H 'content-type: text/plain' \
--data '{"jsonrpc":"1.0","id":"curl","method":"generatetoaddress","params":[1, "bc1qjn4m6rmrveuxhk02a5qhe4r6kdcsvvt3vhdn9j", 1]}' \
http://127.0.0.1:9556/ | jq '.error'
echo ""
echo "🚀 Starting mining pool to test address validation..."
./MINE/rin/start_mining_pool.sh &
POOL_PID=$!
echo ""
echo "⏳ Waiting for pool to start..."
sleep 5
echo ""
echo "🧪 Testing pool with different address types:"
echo ""
echo "Test 1: Valid RinCoin address"
echo "Expected: ✅ Accept connection"
timeout 5s ./cpuminer -a rinhash -o stratum+tcp://127.0.0.1:3333 -u rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q -p x -t 1
echo ""
echo "Test 2: Invalid BTC address"
echo "Expected: ❌ Reject connection"
timeout 5s ./cpuminer -a rinhash -o stratum+tcp://127.0.0.1:3333 -u bc1qjn4m6rmrveuxhk02a5qhe4r6kdcsvvt3vhdn9j -p x -t 1
echo ""
echo "Test 3: Traditional username (no address)"
echo "Expected: ⚠️ Accept but warn no address"
timeout 5s ./cpuminer -a rinhash -o stratum+tcp://127.0.0.1:3333 -u user.worker -p x -t 1
echo ""
echo "🧹 Cleaning up..."
kill $POOL_PID 2>/dev/null
./MINE/rin/kill_stratum_proxy.sh
echo ""
echo "📋 Summary:"
echo "✅ Valid RinCoin addresses (rin1q...) - Accepted"
echo "❌ Invalid addresses (bc1q..., LQnY...) - Rejected"
echo "⚠️ Traditional usernames - Accepted but no rewards"
echo "💰 Block rewards always go to pool address, then distributed"