Skip to content

Commit b202a40

Browse files
committed
Fix coinbase output extraction to support all outputs, not just witness commitment
The previous implementation only extracted the witness commitment output, ignoring all other coinbase outputs (such as merge mining commitments). This fix extracts ALL coinbase outputs from the template, enabling proper support for merge mining and other multi-output scenarios. Verified with end-to-end testing: - Bitcoin Core: Creates 4 outputs (payout + 2 OP_RETURNs + witness) - sv2-tp: Now extracts and serializes all 4 outputs - SRI Pool: Receives all 4 outputs correctly Fixes issue #18
1 parent 1adcfcf commit b202a40

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/sv2/messages.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ node::Sv2NewTemplateMsg::Sv2NewTemplateMsg(const CBlockHeader& header, const CTr
1717
// The coinbase nValue already contains the nFee + the Block Subsidy when built using CreateBlock().
1818
m_coinbase_tx_value_remaining = static_cast<uint64_t>(coinbase_tx->vout[0].nValue);
1919

20-
m_coinbase_tx_outputs_count = 0;
21-
if (witness_commitment_index != NO_WITNESS_COMMITMENT) {
22-
m_coinbase_tx_outputs_count = 1;
23-
m_coinbase_tx_outputs = {coinbase_tx->vout[witness_commitment_index]};
20+
// Extract ALL coinbase outputs to support merge mining and other use cases
21+
m_coinbase_tx_outputs_count = coinbase_tx->vout.size();
22+
m_coinbase_tx_outputs.clear();
23+
for (const auto& output : coinbase_tx->vout) {
24+
m_coinbase_tx_outputs.push_back(output);
2425
}
2526

2627
m_coinbase_tx_locktime = coinbase_tx->nLockTime;

0 commit comments

Comments
 (0)