Skip to content

Commit 35deaf5

Browse files
committed
Fix block.fees() (exclude coinbase).
1 parent 1d62a78 commit 35deaf5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/chain/block.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,13 +671,17 @@ static uint64_t block_subsidy(size_t height, uint64_t subsidy_interval,
671671

672672
uint64_t block::fees() const NOEXCEPT
673673
{
674+
if (txs_->empty())
675+
return {};
676+
674677
// Overflow returns max_uint64.
675678
const auto value = [](uint64_t total, const auto& tx) NOEXCEPT
676679
{
677680
return ceilinged_add(total, tx->fee());
678681
};
679682

680-
return std::accumulate(txs_->begin(), txs_->end(), uint64_t{}, value);
683+
return std::accumulate(std::next(txs_->begin()), txs_->end(),
684+
uint64_t{}, value);
681685
}
682686

683687
uint64_t block::claim() const NOEXCEPT

0 commit comments

Comments
 (0)