Skip to content

Commit 4ed07e0

Browse files
committed
Fix: don't compute double spenders for coinbase txs.
1 parent f53b876 commit 4ed07e0

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

include/bitcoin/database/impl/query/consensus.ipp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,13 @@ bool CLASS::push_spenders(tx_links& out, const point& point,
265265
TEMPLATE
266266
bool CLASS::get_double_spenders(tx_links& out, const block& block) const NOEXCEPT
267267
{
268-
for (const auto& tx: *block.transactions_ptr())
269-
for (const auto& in: *tx->inputs_ptr())
268+
// Empty or coinbase only implies no spends.
269+
const auto& txs = *block.transactions_ptr();
270+
if (txs.size() <= one)
271+
return true;
272+
273+
for (auto tx = std::next(txs.begin()); tx != txs.end(); ++tx)
274+
for (const auto& in: *(*tx)->inputs_ptr())
270275
if (!push_spenders(out, in->point(), in->metadata.link))
271276
return false;
272277

@@ -470,10 +475,6 @@ bool CLASS::set_unstrong(const header_link& link) NOEXCEPT
470475
TEMPLATE
471476
bool CLASS::set_prevouts(const header_link& link, const block& block) NOEXCEPT
472477
{
473-
// Empty or coinbase only implies no spends.
474-
if (block.transactions() <= one)
475-
return true;
476-
477478
tx_links spenders{};
478479
if (!get_double_spenders(spenders, block))
479480
return false;

0 commit comments

Comments
 (0)