diff --git a/MINE/rin/README.md b/MINE/rin/README.md index 97fcf50..d8f6f1d 100644 --- a/MINE/rin/README.md +++ b/MINE/rin/README.md @@ -151,6 +151,8 @@ Your Stratum proxy can be enhanced to work as a **full mining pool** that distri # 2. Miners connect with: ./cpuminer -a rinhash -o stratum+tcp://YOUR_IP:3333 -u username.workername -p x + +cd /mnt/shared/DEV/repos/d-popov.com/scripts/MINE/rin && python3 stratum_proxy.py --submit-all-blocks ``` ### **Pool vs Solo Mining:** diff --git a/MINE/rin/mining_log.txt b/MINE/rin/mining_log.txt index 070a8c4..68e4b6d 100644 --- a/MINE/rin/mining_log.txt +++ b/MINE/rin/mining_log.txt @@ -1,10 +1,10 @@ ================================================================================ RinCoin Mining Log ================================================================================ -Started: 2025-09-23 11:51:14 +Started: 2025-09-23 13:26:20 Target Address: rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q Stratum: 0.0.0.0:3334 RPC: 127.0.0.1:9556 ================================================================================ -[2025-09-23 11:51:14] ๐Ÿ’ฐ Wallet Balance: 25.00000000 RIN +[2025-09-23 13:26:20] ๐Ÿ’ฐ Wallet Balance: 25.00000000 RIN diff --git a/MINE/rin/start_mining_with_address.sh b/MINE/rin/start_mining_with_address.sh deleted file mode 100644 index 5b135ad..0000000 --- a/MINE/rin/start_mining_with_address.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash - -# Start RinCoin Solo Mining with Custom Address -# Usage: ./start_mining_with_address.sh [rincoin_address] [threads] - -# Default values -DEFAULT_ADDRESS="rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q" -DEFAULT_THREADS="28" - -# Parse arguments -RINCOIN_ADDRESS="${1:-$DEFAULT_ADDRESS}" -THREADS="${2:-$DEFAULT_THREADS}" - -echo "=== RinCoin Solo Mining Setup ===" -echo "RinCoin Address: $RINCOIN_ADDRESS" -echo "Threads: $THREADS" -echo "" - -# Validate RinCoin address format -if [[ ! "$RINCOIN_ADDRESS" =~ ^rin1[a-zA-Z0-9]{25,}$ ]]; then - echo "โŒ Error: Invalid RinCoin address format: $RINCOIN_ADDRESS" - echo "RinCoin addresses should start with 'rin1' and be ~30 characters long" - exit 1 -fi - -# Check if RinCoin node is running -if ! sudo docker ps | grep -q "rincoin-node"; then - echo "โŒ Error: rincoin-node container is not running!" - echo "Please start it first: sudo docker start rincoin-node" - exit 1 -fi - -echo "โœ… RinCoin node is running" - -# Check dependencies -if ! command -v python3 &> /dev/null; then - echo "โŒ Error: python3 is not installed!" - exit 1 -fi - -python3 -c "import requests" 2>/dev/null || { - echo "Installing python3-requests..." - sudo apt-get update && sudo apt-get install -y python3-requests -} - -echo "โœ… Dependencies ready" -echo "" - -# Create temporary proxy script with custom address -TEMP_PROXY="/tmp/rincoin_proxy_${RANDOM}.py" -sed "s/target_address='[^']*'/target_address='$RINCOIN_ADDRESS'/" MINE/rin/stratum_proxy.py > "$TEMP_PROXY" - -echo "๐Ÿš€ Starting Stratum Proxy with address: $RINCOIN_ADDRESS" -echo "" - -# Start proxy in background -python3 "$TEMP_PROXY" & -PROXY_PID=$! - -# Wait for proxy to start -sleep 3 - -echo "๐Ÿ“‹ Mining Commands:" -echo "" -echo "1. For Docker container mining:" -echo "sudo docker exec -it amd-strix-halo-llama-rocm bash -c \"/mnt/dl/rinhash/cpuminer-opt-rin/cpuminer -a rinhash -o stratum+tcp://172.17.0.1:3333 -u user -p pass -t $THREADS\"" -echo "" -echo "2. For native mining (if cpuminer is installed locally):" -echo "/home/db/Downloads/rinhash/cpuminer-opt-rin/cpuminer -a rinhash -o stratum+tcp://127.0.0.1:3333 -u user -p pass -t $THREADS" -echo "" -echo "๐Ÿ’ก Tips:" -echo "- Use 172.17.0.1:3333 from Docker containers" -echo "- Use 127.0.0.1:3333 from host system" -echo "- All block rewards will go to: $RINCOIN_ADDRESS" -echo "" -echo "Press Ctrl+C to stop the proxy and mining" - -# Wait for user to stop -trap "echo ''; echo 'Stopping proxy...'; kill $PROXY_PID 2>/dev/null; rm -f '$TEMP_PROXY'; exit 0" INT - -wait $PROXY_PID diff --git a/MINE/rin/stratum_proxy copy.py b/MINE/rin/stratum_proxy copy.py deleted file mode 100644 index 5b43c29..0000000 --- a/MINE/rin/stratum_proxy copy.py +++ /dev/null @@ -1,550 +0,0 @@ -#!/usr/bin/env python3 -""" -RinCoin Stratum Proxy Server - PRODUCTION VERSION -Bridges cpuminer-opt-rin (Stratum protocol) to RinCoin node (RPC protocol) -For real solo mining with actual block construction and submission -""" - -import socket -import threading -import json -import time -import requests -import hashlib -import struct -import binascii -from requests.auth import HTTPBasicAuth - -class RinCoinStratumProxy: - def __init__(self, stratum_host='0.0.0.0', stratum_port=3333, - rpc_host='127.0.0.1', rpc_port=9556, - rpc_user='rinrpc', rpc_password='745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90', - target_address='rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q'): - - self.stratum_host = stratum_host - self.stratum_port = stratum_port - self.rpc_host = rpc_host - self.rpc_port = rpc_port - self.rpc_user = rpc_user - self.rpc_password = rpc_password - self.target_address = target_address - - self.clients = {} - self.job_counter = 0 - self.current_job = None - self.running = True - self.extranonce1_counter = 0 - - print(f"๐Ÿ”ฅ RinCoin PRODUCTION Stratum Proxy Server") - print(f"Stratum: {stratum_host}:{stratum_port}") - print(f"RPC: {rpc_host}:{rpc_port}") - print(f"Target: {target_address}") - - def rpc_call(self, method, params=[]): - """Make RPC call to RinCoin node""" - try: - url = f"http://{self.rpc_host}:{self.rpc_port}/" - headers = {'content-type': 'text/plain'} - auth = HTTPBasicAuth(self.rpc_user, self.rpc_password) - - payload = { - "jsonrpc": "1.0", - "id": "stratum_proxy", - "method": method, - "params": params - } - - response = requests.post(url, json=payload, headers=headers, auth=auth, timeout=10) - - if response.status_code == 200: - result = response.json() - if 'error' in result and result['error'] is not None: - print(f"RPC Error: {result['error']}") - return None - return result.get('result') - else: - print(f"HTTP Error: {response.status_code}") - return None - - except Exception as e: - print(f"RPC Call Error: {e}") - return None - - def create_coinbase_tx(self, template, extranonce1, extranonce2): - """Create coinbase transaction""" - try: - # Get coinbase value (block reward + fees) - coinbase_value = template.get('coinbasevalue', 2500000000) # 25 RIN in satoshis - - # Create coinbase transaction - # Version (4 bytes) - coinbase_tx = struct.pack(' 1: - if len(tx_hashes) % 2 == 1: - tx_hashes.append(tx_hashes[-1]) # Duplicate last hash if odd number - - new_level = [] - for i in range(0, len(tx_hashes), 2): - combined = tx_hashes[i] + tx_hashes[i + 1] - hash_result = hashlib.sha256(hashlib.sha256(combined).digest()).digest() - new_level.append(hash_result) - tx_hashes = new_level - - return tx_hashes[0] if tx_hashes else b'\x00' * 32 - - def get_block_template(self): - """Get new block template from RinCoin node""" - try: - template = self.rpc_call("getblocktemplate", [{"rules": ["segwit"]}]) - if not template: - return None - - self.job_counter += 1 - - # Calculate target from bits - bits = template.get('bits', '1d00ffff') - target = self.bits_to_target(bits) - - # Prepare transaction list (without coinbase) - transactions = template.get('transactions', []) - tx_hashes = [bytes.fromhex(tx['hash'])[::-1] for tx in transactions] # Reverse for little-endian - - job = { - "job_id": f"job_{self.job_counter:08x}", - "template": template, - "prevhash": template.get("previousblockhash", "0" * 64), - "version": template.get('version', 1), - "bits": bits, - "ntime": int(time.time()), - "target": target, - "transactions": transactions, - "tx_hashes": tx_hashes, - "height": template.get('height', 0), - "coinbasevalue": template.get('coinbasevalue', 2500000000) - } - - self.current_job = job - print(f"๐Ÿ“ฆ New job: {job['job_id']} | Height: {job['height']} | Reward: {job['coinbasevalue']/100000000:.2f} RIN") - return job - - except Exception as e: - print(f"Get block template error: {e}") - return None - - def bits_to_target(self, bits_hex): - """Convert bits to target (difficulty)""" - try: - bits = int(bits_hex, 16) - exponent = bits >> 24 - mantissa = bits & 0xffffff - target = mantissa * (256 ** (exponent - 3)) - return f"{target:064x}" - except: - return "0000ffff00000000000000000000000000000000000000000000000000000000" - - def construct_block_header(self, job, extranonce1, extranonce2, ntime, nonce): - """Construct block header for submission""" - try: - # Create coinbase transaction - coinbase_tx = self.create_coinbase_tx(job['template'], extranonce1, extranonce2) - if not coinbase_tx: - return None, None - - # Calculate coinbase hash - coinbase_hash = hashlib.sha256(hashlib.sha256(coinbase_tx).digest()).digest()[::-1] # Reverse for little-endian - - # Create full transaction list (coinbase + other transactions) - all_tx_hashes = [coinbase_hash] + job['tx_hashes'] - - # Calculate merkle root - merkle_root = self.calculate_merkle_root(all_tx_hashes) - - # Construct block header (80 bytes) - header = b'' - header += struct.pack(' {self.target_address}") - return True, "Block accepted" - else: - print(f"โŒ Block rejected: {result}") - return False, f"Block rejected: {result}" - else: - # Valid share but not a block - return True, "Share accepted" - - except Exception as e: - print(f"Block submission error: {e}") - return False, f"Submission error: {e}" - - def send_stratum_response(self, client, msg_id, result, error=None): - """Send Stratum response to client""" - try: - response = { - "id": msg_id, - "result": result, - "error": error - } - - message = json.dumps(response) + "\n" - client.send(message.encode('utf-8')) - except Exception as e: - print(f"Send response error: {e}") - - def send_stratum_notification(self, client, method, params): - """Send Stratum notification to client""" - try: - notification = { - "id": None, - "method": method, - "params": params - } - - message = json.dumps(notification) + "\n" - client.send(message.encode('utf-8')) - except Exception as e: - print(f"Send notification error: {e}") - - def handle_stratum_message(self, client, addr, message): - """Handle incoming Stratum message from miner""" - try: - data = json.loads(message.strip()) - method = data.get("method") - msg_id = data.get("id") - params = data.get("params", []) - - if method == "mining.subscribe": - # Generate unique extranonce1 for this connection - self.extranonce1_counter += 1 - extranonce1 = f"ex{self.extranonce1_counter:06x}" - - # Store extranonce1 for this client - if addr not in self.clients: - self.clients[addr] = {} - self.clients[addr]['extranonce1'] = extranonce1 - - # Subscribe response - self.send_stratum_response(client, msg_id, [ - [["mining.set_difficulty", "subscription_id"], ["mining.notify", "subscription_id"]], - extranonce1, - 4 # extranonce2 size - ]) - - # Send difficulty (simplified - always 1 for now) - self.send_stratum_notification(client, "mining.set_difficulty", [1]) - - # Send initial job - if self.current_job: - self.send_job_to_client(client, self.current_job) - else: - # Get new job if none exists - if self.get_block_template(): - self.send_job_to_client(client, self.current_job) - - elif method == "mining.authorize": - # Authorization (accept any user/pass for now) - username = params[0] if params else "anonymous" - self.clients[addr]['username'] = username - self.send_stratum_response(client, msg_id, True) - print(f"[{addr}] Authorized as {username}") - - elif method == "mining.submit": - # Submit share/block - if len(params) >= 5: - username = params[0] - job_id = params[1] - extranonce2 = params[2] - ntime = params[3] - nonce = params[4] - - print(f"[{addr}] Submit: job={job_id}, nonce={nonce}") - - # Validate submission - if self.current_job and job_id == self.current_job['job_id']: - extranonce1 = self.clients[addr].get('extranonce1', 'ex000000') - - # Validate and potentially submit block - success, message = self.validate_and_submit_block( - self.current_job, extranonce1, extranonce2, ntime, nonce - ) - - if success: - self.send_stratum_response(client, msg_id, True) - if "Block accepted" in message: - # Broadcast new job after block found - threading.Thread(target=self.update_job_after_block, daemon=True).start() - else: - self.send_stratum_response(client, msg_id, False, message) - else: - self.send_stratum_response(client, msg_id, False, "Stale job") - else: - self.send_stratum_response(client, msg_id, False, "Invalid parameters") - - else: - print(f"[{addr}] Unknown method: {method}") - self.send_stratum_response(client, msg_id, None, "Unknown method") - - except json.JSONDecodeError: - print(f"[{addr}] Invalid JSON: {message}") - except Exception as e: - print(f"[{addr}] Message handling error: {e}") - - def send_job_to_client(self, client, job): - """Send mining job to specific client""" - try: - self.send_stratum_notification(client, "mining.notify", [ - job["job_id"], - job["prevhash"], - "", # coinb1 (empty - we handle coinbase internally) - "", # coinb2 (empty - we handle coinbase internally) - [], # merkle_branch (empty - we calculate merkle root) - f"{job['version']:08x}", - job["bits"], - f"{job['ntime']:08x}", - True # clean_jobs - ]) - except Exception as e: - print(f"Failed to send job: {e}") - - def update_job_after_block(self): - """Update job after a block is found""" - time.sleep(2) # Brief delay to let network propagate - if self.get_block_template(): - self.broadcast_new_job() - - def broadcast_new_job(self): - """Broadcast new job to all connected clients""" - if not self.current_job: - return - - print(f"๐Ÿ“ก Broadcasting job {self.current_job['job_id']} to {len(self.clients)} clients") - - for addr, client_data in list(self.clients.items()): - try: - if 'socket' in client_data: - self.send_job_to_client(client_data['socket'], self.current_job) - except Exception as e: - print(f"Failed to send job to {addr}: {e}") - - def handle_client(self, client, addr): - """Handle individual client connection""" - print(f"[{addr}] Connected") - if addr not in self.clients: - self.clients[addr] = {} - self.clients[addr]['socket'] = client - - try: - while self.running: - data = client.recv(4096) - if not data: - break - - # Handle multiple messages in one packet - messages = data.decode('utf-8').strip().split('\n') - for message in messages: - if message: - self.handle_stratum_message(client, addr, message) - - except Exception as e: - print(f"[{addr}] Client error: {e}") - finally: - client.close() - if addr in self.clients: - del self.clients[addr] - print(f"[{addr}] Disconnected") - - def job_updater(self): - """Periodically update mining jobs""" - while self.running: - try: - time.sleep(30) # Update every 30 seconds - - old_height = self.current_job['height'] if self.current_job else 0 - - if self.get_block_template(): - new_height = self.current_job['height'] - if new_height > old_height: - print(f"๐Ÿ†• New block detected! Broadcasting new job...") - self.broadcast_new_job() - - except Exception as e: - print(f"Job updater error: {e}") - - def start(self): - """Start the Stratum proxy server""" - try: - # Test RPC connection - blockchain_info = self.rpc_call("getblockchaininfo") - if not blockchain_info: - print("โŒ Failed to connect to RinCoin node!") - return - - print(f"โœ… Connected to RinCoin node") - print(f"๐Ÿ“Š Current height: {blockchain_info.get('blocks', 'unknown')}") - print(f"โ›“๏ธ Chain: {blockchain_info.get('chain', 'unknown')}") - - # Get initial block template - if not self.get_block_template(): - print("โŒ Failed to get initial block template!") - return - - # Start job updater thread - job_thread = threading.Thread(target=self.job_updater, daemon=True) - job_thread.start() - - # Start Stratum server - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - server_socket.bind((self.stratum_host, self.stratum_port)) - server_socket.listen(10) - - print(f"๐Ÿš€ PRODUCTION Stratum proxy ready!") - print(f"๐Ÿ“ก Listening on {self.stratum_host}:{self.stratum_port}") - print(f"๐Ÿ’ฐ Mining to: {self.target_address}") - print(f"โšก Current job: {self.current_job['job_id']}") - print("") - print("๐Ÿ”ง Miner command:") - print(f"./cpuminer -a rinhash -o stratum+tcp://{self.stratum_host}:{self.stratum_port} -u worker1 -p x -t 4") - print("") - - while self.running: - try: - client, addr = server_socket.accept() - client_thread = threading.Thread( - target=self.handle_client, - args=(client, addr), - daemon=True - ) - client_thread.start() - except KeyboardInterrupt: - print("\n๐Ÿ›‘ Shutting down...") - self.running = False - break - except Exception as e: - print(f"Server error: {e}") - - except Exception as e: - print(f"Failed to start server: {e}") - finally: - print("๐Ÿ’ค Server stopped") - -if __name__ == "__main__": - proxy = RinCoinStratumProxy() - proxy.start() \ No newline at end of file diff --git a/MINE/rin/stratum_proxy.py b/MINE/rin/stratum_proxy.py index 64ebb95..aff5ee6 100644 --- a/MINE/rin/stratum_proxy.py +++ b/MINE/rin/stratum_proxy.py @@ -18,7 +18,8 @@ class RinCoinStratumProxy: def __init__(self, stratum_host='0.0.0.0', stratum_port=3334, rpc_host='127.0.0.1', rpc_port=9556, rpc_user='rinrpc', rpc_password='745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90', - target_address='rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q'): + target_address='rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q', + submit_all_blocks=False): self.stratum_host = stratum_host self.stratum_port = stratum_port @@ -27,6 +28,7 @@ class RinCoinStratumProxy: self.rpc_user = rpc_user self.rpc_password = rpc_password self.target_address = target_address + self.submit_all_blocks = submit_all_blocks # If True, submit even invalid blocks for testing self.clients = {} self.job_counter = 0 @@ -406,8 +408,8 @@ class RinCoinStratumProxy: diff1_target = 0x00000000FFFF0000000000000000000000000000000000000000000000000000 optimal_difficulty = (estimated_hashrate * diff1_target) / (target_shares_per_second * (2**256)) - # More practical approach: start with network difficulty scaled down - optimal_difficulty = max(network_diff * 0.001, 0.0001) # 0.1% of network, min 0.0001 + # More practical approach: start with network difficulty scaled way down for solo mining + optimal_difficulty = max(network_diff * 0.00001, 0.000001) # 0.001% of network, min 0.000001 print(f" ๐Ÿ“Š New client {addr}: Network diff {network_diff:.6f}, starting with {optimal_difficulty:.6f}") return optimal_difficulty @@ -442,9 +444,9 @@ class RinCoinStratumProxy: elif difficulty_multiplier < (1.0 / max_change): new_difficulty = current_difficulty / max_change - # Bounds checking - min_difficulty = network_diff * 0.00001 # 0.001% of network minimum - max_difficulty = network_diff * 0.1 # 10% of network maximum + # Bounds checking for solo mining + min_difficulty = max(network_diff * 0.000001, 0.000001) # 0.0001% of network minimum + max_difficulty = network_diff * 0.01 # 1% of network maximum new_difficulty = max(min_difficulty, min(max_difficulty, new_difficulty)) print(f" ๐Ÿ“Š {addr}: {share_count} shares in {mining_duration:.0f}s ({actual_share_rate:.4f}/s), adjusting {current_difficulty:.6f} โ†’ {new_difficulty:.6f}") @@ -582,9 +584,12 @@ class RinCoinStratumProxy: self.stats['total_shares'] += 1 self.stats['rejected_shares'] += 1 - # Check if it's also a valid network block - if meets_network_target: - print(f" ๐ŸŽ‰ BLOCK FOUND! Hash: {block_hash_hex}") + # Check if it's also a valid network block OR if we should submit all blocks for testing + if meets_network_target or self.submit_all_blocks: + if meets_network_target: + print(f" ๐ŸŽ‰ VALID BLOCK FOUND! Hash: {block_hash_hex}") + else: + print(f" ๐Ÿงช TEST BLOCK SUBMISSION! Hash: {block_hash_hex} (submit_all_blocks=True)") print(f" ๐Ÿ’ฐ Reward: {job['coinbasevalue']/100000000:.2f} RIN -> {address}") print(f" ๐Ÿ“Š Block height: {job['height']}") print(f" ๐Ÿ” Difficulty: {share_difficulty:.6f} (target: {network_difficulty:.6f})") @@ -1132,5 +1137,13 @@ class RinCoinStratumProxy: print("Server stopped") if __name__ == "__main__": - proxy = RinCoinStratumProxy() + import sys + + # Check for submit_all_blocks parameter + submit_all = False + if len(sys.argv) > 1 and sys.argv[1] == "--submit-all-blocks": + submit_all = True + print("๐Ÿงช TEST MODE: Will submit ALL blocks for validation (submit_all_blocks=True)") + + proxy = RinCoinStratumProxy(submit_all_blocks=submit_all) proxy.start() diff --git a/MINE/rin/stratum_proxy_debug.py b/MINE/rin/stratum_proxy_debug.py deleted file mode 100644 index e9e4bd6..0000000 --- a/MINE/rin/stratum_proxy_debug.py +++ /dev/null @@ -1,705 +0,0 @@ -#!/usr/bin/env python3 -""" -RinCoin Stratum Proxy Server - FIXED VERSION -Fixed block hash calculation and validation issues -""" - -import socket -import threading -import json -import time -import requests -import hashlib -import struct -from requests.auth import HTTPBasicAuth - -class RinCoinStratumProxy: - def __init__(self, stratum_host='0.0.0.0', stratum_port=3334, - rpc_host='127.0.0.1', rpc_port=9556, - rpc_user='rinrpc', rpc_password='745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90', - target_address='rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q'): - - self.stratum_host = stratum_host - self.stratum_port = stratum_port - self.rpc_host = rpc_host - self.rpc_port = rpc_port - self.rpc_user = rpc_user - self.rpc_password = rpc_password - self.target_address = target_address - - self.clients = {} - self.job_counter = 0 - self.current_job = None - self.running = True - self.extranonce1_counter = 0 - - # Logging setup - self.log_file = "mining_log.txt" - self.init_log_file() - - print(f"RinCoin Stratum Proxy Server") - print(f"Stratum: {stratum_host}:{stratum_port}") - print(f"RPC: {rpc_host}:{rpc_port}") - print(f"Target: {target_address}") - - def init_log_file(self): - """Initialize mining log file with header""" - try: - with open(self.log_file, 'w') as f: - f.write("=" * 80 + "\n") - f.write("RinCoin Mining Log\n") - f.write("=" * 80 + "\n") - f.write(f"Started: {time.strftime('%Y-%m-%d %H:%M:%S')}\n") - f.write(f"Target Address: {self.target_address}\n") - f.write(f"Stratum: {self.stratum_host}:{self.stratum_port}\n") - f.write(f"RPC: {self.rpc_host}:{self.rpc_port}\n") - f.write("=" * 80 + "\n\n") - except Exception as e: - print(f"Failed to initialize log file: {e}") - - def log_hash_found(self, hash_hex, difficulty, height, reward, nonce, ntime): - """Log found hash to file""" - try: - timestamp = time.strftime('%Y-%m-%d %H:%M:%S') - with open(self.log_file, 'a') as f: - f.write(f"[{timestamp}] ๐ŸŽ‰ HASH FOUND!\n") - f.write(f" Hash: {hash_hex}\n") - f.write(f" Difficulty: {difficulty:.6f}\n") - f.write(f" Height: {height}\n") - f.write(f" Reward: {reward:.8f} RIN\n") - f.write(f" Nonce: {nonce}\n") - f.write(f" Time: {ntime}\n") - f.write("-" * 40 + "\n") - except Exception as e: - print(f"Failed to log hash: {e}") - - def log_wallet_balance(self): - """Log current wallet balance to file""" - try: - balance = self.rpc_call("getbalance") - if balance is not None: - timestamp = time.strftime('%Y-%m-%d %H:%M:%S') - with open(self.log_file, 'a') as f: - f.write(f"[{timestamp}] ๐Ÿ’ฐ Wallet Balance: {balance:.8f} RIN\n") - except Exception as e: - print(f"Failed to log wallet balance: {e}") - - def rpc_call(self, method, params=[]): - """Make RPC call to RinCoin node""" - try: - url = f"http://{self.rpc_host}:{self.rpc_port}/" - headers = {'content-type': 'text/plain'} - auth = HTTPBasicAuth(self.rpc_user, self.rpc_password) - - payload = { - "jsonrpc": "1.0", - "id": "stratum_proxy", - "method": method, - "params": params - } - - response = requests.post(url, json=payload, headers=headers, auth=auth, timeout=30) - - if response.status_code == 200: - result = response.json() - if 'error' in result and result['error'] is not None: - print(f"RPC Error: {result['error']}") - return None - return result.get('result') - else: - print(f"HTTP Error: {response.status_code}") - return None - - except Exception as e: - print(f"RPC Call Error: {e}") - return None - - def encode_varint(self, n): - """Encode integer as Bitcoin-style varint""" - if n < 0xfd: - return bytes([n]) - elif n <= 0xffff: - return b"\xfd" + struct.pack(' bytes: - outputs_blob = b'' - outputs_list = [] - # Main output - outputs_list.append(struct.pack(' 1: - if len(hashes) % 2 == 1: - hashes.append(hashes[-1]) # Duplicate last hash if odd - - next_level = [] - for i in range(0, len(hashes), 2): - combined = hashes[i] + hashes[i + 1] - next_level.append(hashlib.sha256(hashlib.sha256(combined).digest()).digest()) - - hashes = next_level - - return hashes[0] if hashes else b'\x00' * 32 - - except Exception as e: - print(f"Merkle root calculation error: {e}") - return b'\x00' * 32 - - def bits_to_target(self, bits_hex): - """Convert bits to target - FIXED VERSION""" - try: - bits = int(bits_hex, 16) - exponent = bits >> 24 - mantissa = bits & 0xffffff - - # Bitcoin target calculation - if exponent <= 3: - target = mantissa >> (8 * (3 - exponent)) - else: - target = mantissa << (8 * (exponent - 3)) - - return f"{target:064x}" - except Exception as e: - print(f"Bits to target error: {e}") - return "0000ffff00000000000000000000000000000000000000000000000000000000" - - def get_block_template(self): - """Get new block template and create Stratum job""" - try: - template = self.rpc_call("getblocktemplate", [{"rules": ["segwit", "mweb"]}]) - if not template: - return None - - self.job_counter += 1 - - job = { - "job_id": f"job_{self.job_counter:08x}", - "template": template, - "prevhash": template.get("previousblockhash", "0" * 64), - "version": template.get('version', 1), - "bits": template.get('bits', '1d00ffff'), - "ntime": f"{int(time.time()):08x}", - "target": self.bits_to_target(template.get('bits', '1d00ffff')), - "height": template.get('height', 0), - "coinbasevalue": template.get('coinbasevalue', 0), - "transactions": template.get('transactions', []) - } - - self.current_job = job - timestamp = time.strftime("%Y-%m-%d %H:%M:%S") - network_difficulty = self.calculate_network_difficulty(job['target']) - print(f"[{timestamp}] ๐Ÿ†• NEW JOB: {job['job_id']} | Height: {job['height']} | Reward: {job['coinbasevalue']/100000000:.2f} RIN") - print(f" ๐ŸŽฏ Network Difficulty: {network_difficulty:.6f} | Bits: {job['bits']}") - print(f" ๐Ÿ“ Target: {job['target'][:16]}... | Transactions: {len(job['transactions'])}") - return job - - except Exception as e: - print(f"Get block template error: {e}") - return None - - def calculate_share_difficulty(self, hash_hex, target_hex): - """Calculate actual share difficulty from hash - FIXED""" - try: - hash_int = int(hash_hex, 16) - - if hash_int == 0: - return float('inf') # Perfect hash - - # Bitcoin-style difficulty calculation using difficulty 1 target - # Difficulty 1 target for mainnet - diff1_target = 0x00000000FFFF0000000000000000000000000000000000000000000000000000 - - # Share difficulty = how much harder this hash was compared to diff 1 - difficulty = diff1_target / hash_int - - return difficulty - except Exception as e: - print(f"Difficulty calculation error: {e}") - return 0.0 - - def calculate_network_difficulty(self, target_hex): - """Calculate network difficulty from target - FIXED""" - try: - target_int = int(target_hex, 16) - - # Bitcoin difficulty 1.0 target - diff1_target = 0x00000000FFFF0000000000000000000000000000000000000000000000000000 - - # Network difficulty = how much harder than difficulty 1.0 - network_difficulty = diff1_target / target_int - - return network_difficulty - except Exception as e: - print(f"Network difficulty calculation error: {e}") - return 1.0 - - def submit_share(self, job, extranonce1, extranonce2, ntime, nonce, target_address=None): - """Validate share and submit block if valid - FIXED VERSION""" - try: - # Use provided address or default - address = target_address or self.target_address - - # Build coinbase (with and without witness) - coinbase_wit, coinbase_nowit = self.build_coinbase_transaction_for_address( - job['template'], extranonce1, extranonce2, address) - if not coinbase_wit or not coinbase_nowit: - return False, "Coinbase construction failed" - - # Calculate coinbase txid (non-witness serialization) - coinbase_txid = hashlib.sha256(hashlib.sha256(coinbase_nowit).digest()).digest()[::-1] - - # Calculate merkle root - merkle_root = self.calculate_merkle_root(coinbase_txid, job['transactions']) - - # Build block header - FIXED ENDIANNESS - header = b'' - header += struct.pack(' 0 else 0 - - # Progress indicator based on percentage - if meets_target: - progress_icon = "๐ŸŽ‰" # Block found! - elif difficulty_percentage >= 50: - progress_icon = "๐Ÿ”ฅ" # Very close - elif difficulty_percentage >= 10: - progress_icon = "โšก" # Getting warm - elif difficulty_percentage >= 1: - progress_icon = "๐Ÿ’ซ" # Some progress - else: - progress_icon = "๐Ÿ“Š" # Low progress - - print(f"[{timestamp}] {progress_icon} SHARE: job={job['job_id']} | nonce={nonce} | hash={block_hash_hex[:16]}...") - print(f" ๐ŸŽฏ Share Diff: {share_difficulty:.2e} | Network Diff: {network_difficulty:.6f}") - print(f" ๐Ÿ“ˆ Progress: {difficulty_percentage:.4f}% of network difficulty") - print(f" ๐Ÿ“ Target: {job['target'][:16]}... | Height: {job['height']}") - print(f" โฐ Time: {ntime} | Extranonce: {extranonce1}:{extranonce2}") - print(f" ๐Ÿ” Hash vs Target: {hash_int} {'<=' if meets_target else '>'} {target_int}") - - if not meets_target: - # Share doesn't meet target - reject but still useful for debugging - print(f" โŒ Share rejected (hash > target)") - return False, "Share too high" - - # Valid block! Build full block and submit - print(f" ๐ŸŽ‰ BLOCK FOUND! Hash: {block_hash_hex}") - print(f" ๐Ÿ’ฐ Reward: {job['coinbasevalue']/100000000:.2f} RIN -> {address}") - print(f" ๐Ÿ“Š Block height: {job['height']}") - print(f" ๐Ÿ” Difficulty: {share_difficulty:.6f} (target: {network_difficulty:.6f})") - - # Log the found hash - reward_rin = job['coinbasevalue'] / 100000000 - self.log_hash_found(block_hash_hex, share_difficulty, job['height'], reward_rin, nonce, ntime) - - # Build complete block - block = header - - # Transaction count - tx_count = 1 + len(job['transactions']) - block += self.encode_varint(tx_count) - - # Add coinbase transaction (witness variant for block body) - block += coinbase_wit - - # Add other transactions - for tx in job['transactions']: - block += bytes.fromhex(tx['data']) - - # Submit block - block_hex = block.hex() - print(f" ๐Ÿ“ฆ Submitting block of size {len(block_hex)//2} bytes...") - - result = self.rpc_call("submitblock", [block_hex]) - - if result is None: - print(f" โœ… Block accepted by network!") - # Log wallet balance after successful block submission - self.log_wallet_balance() - return True, "Block found and submitted" - else: - print(f" โŒ Block rejected: {result}") - print(f" ๐Ÿ” Debug: Block size {len(block_hex)//2} bytes, {len(job['transactions'])} transactions") - return False, f"Block rejected: {result}" - - except Exception as e: - print(f"Share submission error: {e}") - return False, f"Submission error: {e}" - - def send_stratum_response(self, client, msg_id, result, error=None): - """Send Stratum response to client""" - try: - response = { - "id": msg_id, - "result": result, - "error": error - } - message = json.dumps(response) + "\n" - client.send(message.encode('utf-8')) - except Exception as e: - print(f"Send response error: {e}") - - def send_stratum_notification(self, client, method, params): - """Send Stratum notification to client""" - try: - notification = { - "id": None, - "method": method, - "params": params - } - message = json.dumps(notification) + "\n" - client.send(message.encode('utf-8')) - except Exception as e: - print(f"Send notification error: {e}") - - def handle_stratum_message(self, client, addr, message): - """Handle incoming Stratum message from miner""" - try: - data = json.loads(message.strip()) - method = data.get("method") - msg_id = data.get("id") - params = data.get("params", []) - - if method == "mining.subscribe": - # Generate unique extranonce1 for this connection - self.extranonce1_counter += 1 - extranonce1 = f"{self.extranonce1_counter:08x}" - - # Store extranonce1 for this client - if addr not in self.clients: - self.clients[addr] = {} - self.clients[addr]['extranonce1'] = extranonce1 - - # Subscribe response - self.send_stratum_response(client, msg_id, [ - [["mining.set_difficulty", "subscription_id"], ["mining.notify", "subscription_id"]], - extranonce1, - 4 # extranonce2 size - ]) - - # Send difficulty - MUCH LOWER for testing - self.send_stratum_notification(client, "mining.set_difficulty", [0.00001]) - - # Send initial job - if self.current_job: - self.send_job_to_client(client, self.current_job) - else: - if self.get_block_template(): - self.send_job_to_client(client, self.current_job) - - elif method == "mining.authorize": - username = params[0] if params else "anonymous" - self.clients[addr]['username'] = username - self.send_stratum_response(client, msg_id, True) - timestamp = time.strftime("%Y-%m-%d %H:%M:%S") - print(f"[{timestamp}] ๐Ÿ” [{addr}] Authorized as {username}") - - elif method == "mining.extranonce.subscribe": - self.send_stratum_response(client, msg_id, True) - - elif method == "mining.submit": - if len(params) >= 5: - username = params[0] - job_id = params[1] - extranonce2 = params[2] - ntime = params[3] - nonce = params[4] - - print(f"[{addr}] Submit: {username} | job={job_id} | nonce={nonce}") - - # Always validate against current job - if self.current_job: - extranonce1 = self.clients[addr].get('extranonce1', '00000000') - - # Submit share - success, message = self.submit_share(self.current_job, extranonce1, extranonce2, ntime, nonce) - - # Always accept shares for debugging, even if they don't meet target - self.send_stratum_response(client, msg_id, True) - - if success and "Block found" in message: - # Get new job after block found - threading.Thread(target=self.update_job_after_block, daemon=True).start() - else: - self.send_stratum_response(client, msg_id, True) - else: - self.send_stratum_response(client, msg_id, False, "Invalid parameters") - - else: - print(f"[{addr}] Unknown method: {method}") - self.send_stratum_response(client, msg_id, None, "Unknown method") - - except json.JSONDecodeError: - print(f"[{addr}] Invalid JSON: {message}") - except Exception as e: - print(f"[{addr}] Message handling error: {e}") - - def send_job_to_client(self, client, job): - """Send mining job to specific client""" - try: - self.send_stratum_notification(client, "mining.notify", [ - job["job_id"], - job["prevhash"], - "", # coinb1 (empty for now - miner handles coinbase) - "", # coinb2 (empty for now - miner handles coinbase) - [], # merkle_branch (empty for now - we calculate merkle root) - f"{job['version']:08x}", - job["bits"], - job["ntime"], - True # clean_jobs - ]) - except Exception as e: - print(f"Failed to send job: {e}") - - def update_job_after_block(self): - """Update job after a block is found""" - time.sleep(2) # Brief delay to let network propagate - if self.get_block_template(): - self.broadcast_new_job() - - def broadcast_new_job(self): - """Broadcast new job to all connected clients""" - if not self.current_job: - return - - print(f"Broadcasting new job to {len(self.clients)} clients") - - for addr, client_data in list(self.clients.items()): - try: - if 'socket' in client_data: - self.send_job_to_client(client_data['socket'], self.current_job) - except Exception as e: - print(f"Failed to send job to {addr}: {e}") - - def handle_client(self, client, addr): - """Handle individual client connection""" - print(f"[{addr}] Connected") - if addr not in self.clients: - self.clients[addr] = {} - self.clients[addr]['socket'] = client - - try: - while self.running: - data = client.recv(4096) - if not data: - break - - # Handle multiple messages in one packet - messages = data.decode('utf-8').strip().split('\n') - for message in messages: - if message: - self.handle_stratum_message(client, addr, message) - - except Exception as e: - print(f"[{addr}] Client error: {e}") - finally: - client.close() - if addr in self.clients: - del self.clients[addr] - print(f"[{addr}] Disconnected") - - def job_updater(self): - """Periodically update mining jobs""" - balance_log_counter = 0 - while self.running: - try: - time.sleep(30) # Update every 30 seconds - - old_height = self.current_job['height'] if self.current_job else 0 - - if self.get_block_template(): - new_height = self.current_job['height'] - if new_height > old_height: - print(f"New block detected! Broadcasting new job...") - self.broadcast_new_job() - - # Log wallet balance every 10 minutes (20 cycles of 30 seconds) - balance_log_counter += 1 - if balance_log_counter >= 20: - self.log_wallet_balance() - balance_log_counter = 0 - - except Exception as e: - print(f"Job updater error: {e}") - - def start(self): - """Start the Stratum proxy server""" - try: - # Test RPC connection - blockchain_info = self.rpc_call("getblockchaininfo") - if not blockchain_info: - print("Failed to connect to RinCoin node!") - return - - print(f"Connected to RinCoin node") - print(f"Current height: {blockchain_info.get('blocks', 'unknown')}") - print(f"Chain: {blockchain_info.get('chain', 'unknown')}") - - # Log initial wallet balance - self.log_wallet_balance() - - # Get initial block template - if not self.get_block_template(): - print("Failed to get initial block template!") - return - - # Start job updater thread - job_thread = threading.Thread(target=self.job_updater, daemon=True) - job_thread.start() - - # Start Stratum server - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - server_socket.bind((self.stratum_host, self.stratum_port)) - server_socket.listen(10) - - timestamp = time.strftime("%Y-%m-%d %H:%M:%S") - print(f"[{timestamp}] ๐Ÿš€ Mining Stratum proxy ready!") - print(f" ๐Ÿ“ก Listening on {self.stratum_host}:{self.stratum_port}") - print(f" ๐Ÿ’ฐ Mining to: {self.target_address}") - print(f" ๐Ÿ“Š Current job: {self.current_job['job_id'] if self.current_job else 'None'}") - print(f" ๐Ÿ“ Mining log: {self.log_file}") - print("") - print(" ๐Ÿ”ง Miner command:") - print(f" ./cpuminer -a rinhash -o stratum+tcp://{self.stratum_host}:{self.stratum_port} -u worker1 -p x -t 4") - print("") - - while self.running: - try: - client, addr = server_socket.accept() - client_thread = threading.Thread( - target=self.handle_client, - args=(client, addr), - daemon=True - ) - client_thread.start() - except KeyboardInterrupt: - print("\nShutting down...") - self.running = False - break - except Exception as e: - print(f"Server error: {e}") - - except Exception as e: - print(f"Failed to start server: {e}") - finally: - print("Server stopped") - -if __name__ == "__main__": - proxy = RinCoinStratumProxy() - proxy.start() diff --git a/MINE/rin/stratum_proxy_explanation.sh b/MINE/rin/stratum_proxy_explanation.sh deleted file mode 100644 index 3f9ec4c..0000000 --- a/MINE/rin/stratum_proxy_explanation.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# RinCoin Stratum Proxy for cpuminer-opt-rin -# Bridges cpuminer's Stratum protocol to RinCoin's RPC mining - -echo "=== RinCoin Stratum Proxy ===" -echo "This script creates a bridge between cpuminer and RinCoin node" -echo "" - -# Configuration -RPC_HOST="127.0.0.1" -RPC_PORT="9556" -RPC_USER="rinrpc" -RPC_PASS="745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90" -STRATUM_PORT="3333" -TARGET_ADDRESS="rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q" - -# Function to call RPC -call_rpc() { - local method="$1" - local params="$2" - - curl -s --user "$RPC_USER:$RPC_PASS" \ - -H 'content-type: text/plain' \ - --data "{\"jsonrpc\":\"1.0\",\"id\":\"curl\",\"method\":\"$method\",\"params\":$params}" \ - "http://$RPC_HOST:$RPC_PORT/" -} - -echo "โš ๏ธ IMPORTANT: This is a simplified proxy demonstration." -echo "For production use, you would need a full Stratum server implementation." -echo "" - -echo "Current RinCoin mining options:" -echo "1. Built-in Core Mining (Recommended for solo):" -echo " bash MINE/rin/solo_mining_core.sh -t 28" -echo "" -echo "2. Pool Mining (Recommended for consistent rewards):" -echo " sudo docker exec -it amd-strix-halo-llama-rocm bash -c \"/mnt/dl/rinhash/cpuminer-opt-rin/cpuminer -a rinhash -o stratum+tcp://rinhash.mine.zergpool.com:7148 -u bc1qjn4m6rmrveuxhk02a5qhe4r6kdcsvvt3vhdn9j -p c=BTC,mc=RIN,ID=StrixHalo -t 28\"" -echo "" -echo "3. Direct RPC Mining (Advanced - requires custom miner):" -echo " Use getblocktemplate RPC calls directly" -echo "" - -echo "โŒ cpuminer-opt-rin cannot directly mine to RinCoin node because:" -echo " - cpuminer uses Stratum protocol" -echo " - RinCoin node uses RPC protocol" -echo " - No built-in protocol conversion" -echo "" - -echo "โœ… Recommended approach:" -echo " Use the built-in core mining script for solo mining" -echo " Use pool mining for consistent rewards" diff --git a/MINE/rin/test_address_validation.sh b/MINE/rin/test_address_validation.sh deleted file mode 100644 index 34ebd9c..0000000 --- a/MINE/rin/test_address_validation.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/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" diff --git a/MINE/rin/test_pool_connections.sh b/MINE/rin/test_pool_connections.sh deleted file mode 100644 index 8d22208..0000000 --- a/MINE/rin/test_pool_connections.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -# Test different mining pool connection methods - -echo "=== Testing Mining Pool Connection Methods ===" -echo "" - -# Kill any existing processes -./MINE/rin/kill_stratum_proxy.sh - -echo "๐Ÿš€ Starting mining pool..." -./MINE/rin/start_mining_pool.sh & -POOL_PID=$! - -echo "" -echo "โณ Waiting for pool to start..." -sleep 5 - -echo "" -echo "๐Ÿงช Testing different connection methods:" -echo "" - -echo "1๏ธโƒฃ Test 1: Address as username" -echo "Command: ./cpuminer -a rinhash -o stratum+tcp://127.0.0.1:3333 -u rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q -p x -t 2" -echo "Expected: Pool should recognize this as a RinCoin address" -echo "" - -echo "2๏ธโƒฃ Test 2: Address.workername format" -echo "Command: ./cpuminer -a rinhash -o stratum+tcp://127.0.0.1:3333 -u rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q.worker1 -p x -t 2" -echo "Expected: Pool should recognize address and worker separately" -echo "" - -echo "3๏ธโƒฃ Test 3: Traditional username" -echo "Command: ./cpuminer -a rinhash -o stratum+tcp://127.0.0.1:3333 -u user.worker -p x -t 2" -echo "Expected: Pool should use default pool address for rewards" -echo "" - -echo "๐Ÿ“Š Pool Status:" -echo "Web Dashboard: http://127.0.0.1:8080" -echo "Pool Address: rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q" -echo "" - -echo "Press Enter to run test 1..." -read - -echo "Running Test 1..." -timeout 10s ./cpuminer -a rinhash -o stratum+tcp://127.0.0.1:3333 -u rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q -p x -t 2 - -echo "" -echo "Press Enter to run test 2..." -read - -echo "Running Test 2..." -timeout 10s ./cpuminer -a rinhash -o stratum+tcp://127.0.0.1:3333 -u rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q.worker1 -p x -t 2 - -echo "" -echo "Press Enter to run test 3..." -read - -echo "Running Test 3..." -timeout 10s ./cpuminer -a rinhash -o stratum+tcp://127.0.0.1:3333 -u user.worker -p x -t 2 - -echo "" -echo "๐Ÿงน Cleaning up..." -kill $POOL_PID 2>/dev/null -./MINE/rin/kill_stratum_proxy.sh - -echo "" -echo "โœ… Test complete! Check the pool logs above to see how each connection was handled." diff --git a/MINE/rin/view_mining_log.sh b/MINE/rin/view_mining_log.sh deleted file mode 100644 index de4ec60..0000000 --- a/MINE/rin/view_mining_log.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# View RinCoin Mining Log -# Shows the latest mining activity and wallet balance - -LOG_FILE="mining_log.txt" - -if [ ! -f "$LOG_FILE" ]; then - echo "โŒ Mining log file '$LOG_FILE' not found!" - echo "Make sure the stratum proxy has been started at least once." - exit 1 -fi - -echo "=== RinCoin Mining Log Viewer ===" -echo "" - -# Show last 20 lines of the log -echo "๐Ÿ“Š Recent Activity (last 20 entries):" -echo "----------------------------------------" -tail -20 "$LOG_FILE" - -echo "" -echo "๐Ÿ’ฐ Current Wallet Balance:" -echo "----------------------------------------" -grep "Wallet Balance:" "$LOG_FILE" | tail -1 || echo "No balance logged yet" - -echo "" -echo "๐ŸŽ‰ Total Blocks Found:" -echo "----------------------------------------" -grep -c "HASH FOUND!" "$LOG_FILE" || echo "0" - -echo "" -echo "๐Ÿ“ˆ Total Mining Time:" -echo "----------------------------------------" -if grep -q "Started:" "$LOG_FILE"; then - START_TIME=$(grep "Started:" "$LOG_FILE" | head -1 | cut -d' ' -f2-3) - echo "Started: $START_TIME" - echo "Current: $(date '+%Y-%m-%d %H:%M:%S')" -else - echo "Start time not available" -fi - -echo "" -echo "๐Ÿ“ Full log available at: $LOG_FILE" -echo "๐Ÿ”„ To watch live updates: tail -f $LOG_FILE"