Fix crash when stratum miners submit with stale templates

Added bounds check in get_hashing_blob_nolock() to handle empty
m_transactionHashes when old/stale template slots are accessed.
Returns 0 and logs at level 3 instead of vector out-of-bounds crash.

Primarily affects external stratum miners that may
hold onto old job IDs across template updates
This commit is contained in:
Matt Hess
2025-12-09 03:10:14 +00:00
parent 3316751f5e
commit 36d03d19fe
+6
View File
@@ -1576,8 +1576,14 @@ uint32_t BlockTemplate::get_hashing_blob_nolock(uint32_t extra_nonce, uint8_t* b
hash miner_tx_hash = calc_miner_tx_hash(extra_nonce);
const size_t num_hashes = m_transactionHashes.size() / HASH_SIZE;
if (num_hashes == 0) {
LOGERR(3, "get_hashing_blob_nolock: m_transactionHashes is empty");
return 0;
}
std::vector<hash> hashes(num_hashes);
hashes[0] = miner_tx_hash; // miner tx with current extra_nonce
for (size_t i = 1; i < num_hashes; ++i) {
memcpy(hashes[i].h, m_transactionHashes.data() + i * HASH_SIZE, HASH_SIZE);
}