MultiversX Tracker is Live!

Why does IsCoinBase() check if there is exactly one input?

Bitcoin Stack Exchange

Bitcoin News / Bitcoin Stack Exchange 101 Views

In the Bitcoin Core source code there is a function to check if a given transaction is a coinbase or not:

 bool IsCoinBase() const { return (vin.size() == 1 && vin[0].prevout.IsNull()); }

Does it really need to check if vin.size() is equal to 1? Isn't vin[0].prevout.IsNull() a sufficient condition for a transaction to be a coinbase? Is there any situation that the later condition is true but we have more than one input?

The only reason I can guess is to avoid run-time error when vin is empty (so there is no vin[0]).


Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments