From 3a90f78ab998404d0d48e4b3c0f596361ff76b92 Mon Sep 17 00:00:00 2001 From: Matt Hess Date: Tue, 10 Feb 2026 23:35:17 +0000 Subject: [PATCH] Fix CARROT main address outputs silently rejected during sync recoveredSpendPubkeyHex was block-scoped inside the subaddress else-if branch but referenced in the return statement, causing a ReferenceError for outputs sent to the main CARROT address (K_s). The exception was silently caught, making all main-address mining rewards invisible. --- .gitignore | 3 ++- src/carrot-scanning.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d580aa0..907077c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ bun.lock node_modules/ -build/ +build/* +!build/randomx.wasm TODO # Rust/WASM build artifacts diff --git a/src/carrot-scanning.js b/src/carrot-scanning.js index 5d823c3..1bed635 100644 --- a/src/carrot-scanning.js +++ b/src/carrot-scanning.js @@ -676,15 +676,17 @@ export function scanCarrotOutput(output, viewIncomingKey, accountSpendPubkey, in // 5. Check if this matches our account or any subaddress let subaddressIndex = null; let isMainAddress = false; + let recoveredSpendPubkeyHex = null; // Check main address first with direct binary comparison (no hex allocation) if (recoveredSpendPubkey.length === accountSpendPubkey.length && recoveredSpendPubkey.every((b, i) => b === accountSpendPubkey[i])) { isMainAddress = true; subaddressIndex = { major: 0, minor: 0 }; + recoveredSpendPubkeyHex = bytesToHex(recoveredSpendPubkey); } else if (subaddressMap) { // Subaddress map uses hex keys — only convert if main address didn't match - const recoveredSpendPubkeyHex = bytesToHex(recoveredSpendPubkey); + recoveredSpendPubkeyHex = bytesToHex(recoveredSpendPubkey); if (subaddressMap.has(recoveredSpendPubkeyHex)) { subaddressIndex = subaddressMap.get(recoveredSpendPubkeyHex); }