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.
This commit is contained in:
Matt Hess
2026-02-10 23:35:17 +00:00
parent 6904ee60a4
commit 3a90f78ab9
2 changed files with 5 additions and 2 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
bun.lock
node_modules/
build/
build/*
!build/randomx.wasm
TODO
# Rust/WASM build artifacts
+3 -1
View File
@@ -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);
}