From bc50e52cdb0dbe4bd64a85a1e773699efc3a4515 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Tue, 23 Sep 2025 11:34:13 +0300 Subject: [PATCH] stratum - fix miner info --- MINE/rin/mining_log.txt | 4 +- MINE/rin/stratum_proxy.py | 78 +++++++++++++++++++++++++++++++++++---- 2 files changed, 72 insertions(+), 10 deletions(-) diff --git a/MINE/rin/mining_log.txt b/MINE/rin/mining_log.txt index 5a399b5..22b4fca 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:28:19 +Started: 2025-09-23 11:31:27 Target Address: rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q Stratum: 0.0.0.0:3334 RPC: 127.0.0.1:9556 ================================================================================ -[2025-09-23 11:28:19] 💰 Wallet Balance: 25.00000000 RIN +[2025-09-23 11:31:27] 💰 Wallet Balance: 25.00000000 RIN diff --git a/MINE/rin/stratum_proxy.py b/MINE/rin/stratum_proxy.py index 4378ad9..e775691 100644 --- a/MINE/rin/stratum_proxy.py +++ b/MINE/rin/stratum_proxy.py @@ -222,25 +222,66 @@ class RinCoinStratumProxy: hashes = [coinbase_txid] for tx in transactions: hashes.append(bytes.fromhex(tx['hash'])[::-1]) # Reverse for little-endian - + # Build merkle tree while len(hashes) > 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 calculate_merkle_branches(self, tx_hashes, tx_index): + """Calculate merkle branches for a specific transaction index""" + try: + if not tx_hashes or tx_index >= len(tx_hashes): + return [] + + branches = [] + current_index = tx_index + + # Start with the full list of transaction hashes + hashes = tx_hashes[:] + + while len(hashes) > 1: + if len(hashes) % 2 == 1: + hashes.append(hashes[-1]) # Duplicate last hash if odd + + # Find the partner for current_index + partner_index = current_index ^ 1 # Flip the least significant bit + + if partner_index < len(hashes): + # Add the partner hash to branches (in big-endian for stratum) + branches.append(hashes[partner_index][::-1].hex()) + else: + # This shouldn't happen, but add the duplicate if it does + branches.append(hashes[current_index][::-1].hex()) + + # Move to next level + 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 + current_index //= 2 + + return branches + + except Exception as e: + print(f"Merkle branches calculation error: {e}") + return [] + def bits_to_target(self, bits_hex): """Convert bits to target - FIXED VERSION""" try: @@ -574,12 +615,33 @@ class RinCoinStratumProxy: def send_job_to_client(self, client, job): """Send mining job to specific client""" try: + # Build coinbase components for stratum + height = job.get('height', 0) + height_bytes = struct.pack('