From 8ba606747cf2bc46cf0f80ebc3e0568a01ec60cf Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Fri, 3 Apr 2026 08:55:22 +0200 Subject: [PATCH] Handle current Monero daemon templates --- src/base/tools/cryptonote/BlockTemplate.cpp | 50 ++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/base/tools/cryptonote/BlockTemplate.cpp b/src/base/tools/cryptonote/BlockTemplate.cpp index 54ecd666..8d5d5eab 100644 --- a/src/base/tools/cryptonote/BlockTemplate.cpp +++ b/src/base/tools/cryptonote/BlockTemplate.cpp @@ -264,7 +264,12 @@ bool xmrig::BlockTemplate::parse(bool hashes) ar(m_height); ar(m_numOutputs); - if (m_coin == Coin::ZEPHYR) { + if (m_coin == Coin::MONERO) { + if (m_numOutputs < 1) { + return false; + } + } + else if (m_coin == Coin::ZEPHYR) { if (m_numOutputs < 1) { return false; } @@ -343,6 +348,28 @@ bool xmrig::BlockTemplate::parse(bool hashes) ar(m_viewTag); } + if (m_coin == Coin::MONERO && m_numOutputs > 1) { + for (uint64_t k = 1; k < m_numOutputs; ++k) { + uint64_t amount2; + ar(amount2); + + uint8_t output_type2; + ar(output_type2); + + if ((output_type2 != kTxOutToKey) && (output_type2 != kTxOutToTaggedKey)) { + return false; + } + + Span key2; + ar(key2, kKeySize); + + if (output_type2 == kTxOutToTaggedKey) { + uint8_t view_tag2; + ar(view_tag2); + } + } + } + if (m_coin == Coin::SALVIUM && m_numOutputs > 1) { for (uint64_t k = 1; k < m_numOutputs; ++k) { uint64_t amount2; @@ -477,6 +504,27 @@ bool xmrig::BlockTemplate::parse(bool hashes) return false; } + // Some current parent daemon templates omit an explicit trailing tx_hashes_count=0 + // when there are no non-coinbase transactions in the block template. + if (ar.remaining() == 0) { + m_numHashes = 0; + + if (hashes) { + const uint64_t base_count = baseTransactionCount(); + m_hashes.resize(base_count * kHashSize); + + calculateMinerTxHash(blob(MINER_TX_PREFIX_OFFSET), blob(MINER_TX_PREFIX_END_OFFSET), m_hashes.data()); + + if (m_hasProtocolTx) { + calculateMinerTxHash(blob(PROTOCOL_TX_PREFIX_OFFSET), blob(PROTOCOL_TX_PREFIX_END_OFFSET), m_hashes.data() + kHashSize); + } + + calculateMerkleTreeHash(); + } + + return true; + } + if (m_hasProtocolTx) { // Protocol transaction begin