Author

Topic: MoneyRange() allows zero? (Read 110 times)

legendary
Activity: 3472
Merit: 10611
April 13, 2022, 07:16:31 AM
#4
It's definitely possible if address2 actually refer to OP_RETURN output.
It is standard if the address2 is OP_RETURN output but it is still perfectly valid for it to be anything else.

is it possible for CAmount in a transaction be zero?
Basically the only thing that the consensus rules care about is that the sum of outputs is not bigger than sump of inputs. In simple terms: you don't spend more than you can.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
April 13, 2022, 06:56:20 AM
#3
I can see how fees can be zero, but is it possible for CAmount in a transaction (e.g. p2wh address1 --> address2) be zero?

It's definitely possible if address2 actually refer to OP_RETURN output.
newbie
Activity: 7
Merit: 27
April 13, 2022, 06:13:49 AM
#2
in tx_check.cpp

Code:
// Check for negative or overflow output values (see CVE-2010-5139)
CAmount nValueOut = 0;
for (const auto& txout : tx.vout)
{
     if (txout.nValue < 0)
          return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-vout-negative");
     if (txout.nValue > MAX_MONEY)
          return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-vout-toolarge");
     nValueOut += txout.nValue;
     if (!MoneyRange(nValueOut))
          return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-txouttotal-toolarge");
}

It looks like you can
newbie
Activity: 7
Merit: 27
April 13, 2022, 05:45:38 AM
#1
In MoneyRange():
Code:
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
Zero is valid.

I can see how fees can be zero, but is it possible for CAmount in a transaction (e.g. p2wh address1 --> address2) be zero?

Jump to: