Skip to content

Commit a2c40ad

Browse files
authored
Merge pull request #1765 from evoskuil/master
Fix block.fees() (exclude coinbase).
2 parents 27a971b + 35deaf5 commit a2c40ad

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

include/bitcoin/system/impl/stream/streamers/hex_writer.ipp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ template <typename OStream>
5252
void hex_writer<OStream>::do_write_bytes(const uint8_t* data,
5353
size_t size) NOEXCEPT
5454
{
55-
BC_ASSERT(!is_null(data));
5655
BC_ASSERT(!is_multiply_overflow(size, octet_width));
5756

5857
char chars[octet_width]{};

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

src/chain/header.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ DEFINE_JSON_FROM_TAG(header)
386386
{
387387
value =
388388
{
389-
// hash is meta property
389+
// hash is computed property
390390
{ "hash", encode_hash(instance.hash()) },
391391
{ "version", instance.version() },
392392
{ "previous", encode_hash(instance.previous_block_hash()) },

src/chain/transaction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ DEFINE_JSON_FROM_TAG(transaction)
969969
{
970970
value =
971971
{
972-
// hash is meta property
972+
// hash is computed property
973973
{ "hash", encode_hash(instance.hash(false)) },
974974
{ "version", instance.version() },
975975
{ "inputs", value_from(*instance.inputs_ptr()) },

0 commit comments

Comments
 (0)