Bitcoin Forum
May 03, 2024, 11:53:22 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: MoneyRange() allows zero?  (Read 90 times)
dougEfish (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 27


View Profile
April 13, 2022, 10: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?

1714780402
Hero Member
*
Offline Offline

Posts: 1714780402

View Profile Personal Message (Offline)

Ignore
1714780402
Reply with quote  #2

1714780402
Report to moderator
1714780402
Hero Member
*
Offline Offline

Posts: 1714780402

View Profile Personal Message (Offline)

Ignore
1714780402
Reply with quote  #2

1714780402
Report to moderator
"Your bitcoin is secured in a way that is physically impossible for others to access, no matter for what reason, no matter how good the excuse, no matter a majority of miners, no matter what." -- Greg Maxwell
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
dougEfish (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 27


View Profile
April 13, 2022, 11: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
ABCbits
Legendary
*
Offline Offline

Activity: 2870
Merit: 7463


Crypto Swap Exchange


View Profile
April 13, 2022, 11:56:20 AM
Merited by pooya87 (1)
 #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.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10537



View Profile
April 13, 2022, 12:16:31 PM
Merited by Welsh (3), gmaxwell (2), ABCbits (2), BlackHatCoiner (1)
 #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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!