@@ -1758,9 +1758,10 @@ namespace cryptonote
17581758 return m_mempool.check_for_key_images (key_im, spent);
17591759 }
17601760 // -----------------------------------------------------------------------------------------------
1761- std::optional<std::tuple<int64_t , int64_t , int64_t >> core::get_coinbase_tx_sum (uint64_t start_offset, size_t count)
1761+ std::optional<std::tuple<unsigned long long , unsigned long long , unsigned long long >>
1762+ core::get_coinbase_tx_sum (uint64_t start_offset, size_t count)
17621763 {
1763- std::optional<std::tuple<int64_t , int64_t , int64_t >> result{{0 , 0 , 0 }};
1764+ std::optional<std::tuple<unsigned long long , unsigned long long , unsigned long long >> result{{0ULL , 0ULL , 0ULL }};
17641765 if (count == 0 )
17651766 return result;
17661767
@@ -1787,6 +1788,8 @@ namespace cryptonote
17871788 {
17881789 std::shared_lock lock{m_coinbase_cache.mutex };
17891790 if (count >= m_coinbase_cache.height ) {
1791+ // NOTE: if m_coinbase_cache.emissions/fees/burnt are signed types, they will be implicitly
1792+ // converted to unsigned here. If they are signed, consider static_cast<unsigned long long>.
17901793 emission_amount = m_coinbase_cache.emissions ;
17911794 total_fee_amount = m_coinbase_cache.fees ;
17921795 burnt_beldex = m_coinbase_cache.burnt ;
@@ -1837,20 +1840,24 @@ namespace cryptonote
18371840 [this , &cache_to, &result, &cache_build_started](uint64_t height, const crypto::hash& hash, const block& b){
18381841 auto & [emission_amount, total_fee_amount, burnt_beldex] = *result;
18391842 std::vector<transaction> txs;
1840- auto coinbase_amount = static_cast <int64_t >(get_outs_money_amount (b.miner_tx ));
1843+
1844+ // Convert amounts into unsigned accumulators
1845+ const unsigned long long coinbase_amount = static_cast <unsigned long long >(get_outs_money_amount (b.miner_tx ));
18411846 get_transactions (b.tx_hashes , txs);
1842- int64_t tx_fee_amount = 0 ;
1843- for (const auto & tx: txs)
1847+
1848+ unsigned long long tx_fee_amount = 0ULL ;
1849+ for (const auto & tx: txs)
18441850 {
1845- tx_fee_amount += static_cast <int64_t >(get_tx_miner_fee (tx, b.major_version >= feature::FEE_BURNING ));
1846- if (b.major_version >= feature::FEE_BURNING )
1851+ tx_fee_amount += static_cast <unsigned long long >(get_tx_miner_fee (tx, b.major_version >= feature::FEE_BURNING ));
1852+ if (b.major_version >= feature::FEE_BURNING )
18471853 {
1848- burnt_beldex += static_cast <int64_t >(get_burned_amount_from_tx_extra (tx.extra ));
1854+ burnt_beldex += static_cast <unsigned long long >(get_burned_amount_from_tx_extra (tx.extra ));
18491855 }
18501856 }
18511857
18521858 emission_amount += coinbase_amount - tx_fee_amount;
18531859 total_fee_amount += tx_fee_amount;
1860+
18541861 if (cache_to && cache_to == height)
18551862 {
18561863 std::unique_lock lock{m_coinbase_cache.mutex };
0 commit comments