Merge dce6f3b29b into merged_master (Bitcoin PR #18383)

This commit is contained in:
Andrew Poelstra 2020-11-26 01:08:08 +00:00
commit ae4cac0cf4
2 changed files with 10 additions and 4 deletions

View file

@ -9,6 +9,8 @@
#include <tinyformat.h>
#include <util/strencodings.h>
#include <assert.h>
namespace Sidechain {
namespace Bitcoin {
@ -87,10 +89,11 @@ CAmount CTransaction::GetValueOut() const
{
CAmount nValueOut = 0;
for (const auto& tx_out : vout) {
nValueOut += tx_out.nValue;
if (!MoneyRange(tx_out.nValue) || !MoneyRange(nValueOut))
if (!MoneyRange(tx_out.nValue) || !MoneyRange(nValueOut + tx_out.nValue))
throw std::runtime_error(std::string(__func__) + ": value out of range");
nValueOut += tx_out.nValue;
}
assert(MoneyRange(nValueOut));
return nValueOut;
}

View file

@ -9,6 +9,8 @@
#include <tinyformat.h>
#include <util/strencodings.h>
#include <assert.h>
bool g_con_elementsmode = false;
std::string COutPoint::ToString() const
@ -128,11 +130,12 @@ CAmountMap CTransaction::GetValueOutMap() const {
if (tx_out.nValue.IsExplicit() && tx_out.nAsset.IsExplicit()) {
CAmountMap m;
m[tx_out.nAsset.GetAsset()] = tx_out.nValue.GetAmount();
values += m;
if (!MoneyRange(tx_out.nValue.GetAmount()) || !MoneyRange(values[tx_out.nAsset.GetAsset()]))
if (!MoneyRange(tx_out.nValue.GetAmount()) || !MoneyRange(values[tx_out.nAsset.GetAsset()] + tx_out.nValue.GetAmount()))
throw std::runtime_error(std::string(__func__) + ": value out of range");
values += m;
}
}
assert(MoneyRange(values));
return values;
}