From 0b59b7eb430fb843bbc37dced8f14625d91057f3 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Wed, 15 Nov 2023 16:18:05 +0100 Subject: [PATCH] Zephyr solo mining: handle multiple outputs --- src/base/tools/cryptonote/BlockTemplate.cpp | 40 ++++++++++++--------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/base/tools/cryptonote/BlockTemplate.cpp b/src/base/tools/cryptonote/BlockTemplate.cpp index bc5e2a93b..1a26a914d 100644 --- a/src/base/tools/cryptonote/BlockTemplate.cpp +++ b/src/base/tools/cryptonote/BlockTemplate.cpp @@ -225,8 +225,12 @@ bool xmrig::BlockTemplate::parse(bool hashes) ar(m_height); ar(m_numOutputs); - const uint64_t expected_outputs = (m_coin == Coin::ZEPHYR) ? 2 : 1; - if (m_numOutputs != expected_outputs) { + if (m_coin == Coin::ZEPHYR) { + if (m_numOutputs < 2) { + return false; + } + } + else if (m_numOutputs != 1) { return false; } @@ -252,23 +256,25 @@ bool xmrig::BlockTemplate::parse(bool hashes) ar.skip(asset_type_len); ar(m_viewTag); - uint64_t amount2; - ar(amount2); + for (uint64_t k = 1; k < m_numOutputs; ++k) { + uint64_t amount2; + ar(amount2); - uint8_t output_type2; - ar(output_type2); - if (output_type2 != 2) { - return false; + uint8_t output_type2; + ar(output_type2); + if (output_type2 != 2) { + return false; + } + + Span key2; + ar(key2, kKeySize); + + ar(asset_type_len); + ar.skip(asset_type_len); + + uint8_t view_tag2; + ar(view_tag2); } - - Span key2; - ar(key2, kKeySize); - - ar(asset_type_len); - ar.skip(asset_type_len); - - uint8_t view_tag2; - ar(view_tag2); } else if (m_outputType == 3) { ar(m_viewTag);