user101040: 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]).

user48884: A coinbase transaction is not allowed to have any other inputs, hence this check. Furthermore, because this check is part of consensus code, it is the definition for a coinbase transaction, so this ends up being a bit circular - the function says that a coinbase transaction must only have one input, and it checks that.

101040: <p>In the Bitcoin Core source code there is a <a href="https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h#L335" rel="nofollow noreferrer">function</a> to check if a given transaction is a coinbase or not:</p>
<pre><code>    bool IsCoinBase() const
    {
        return (vin.size() == 1 &amp;&amp; vin[0].prevout.IsNull());
    }
</code></pre>
<p>Does it really need to check if <code>vin.size()</code> is equal to 1? Isn't <code>vin[0].prevout.IsNull()</code> 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?</p>
<p>The only reason I can guess is to avoid run-time error when <code>vin</code> is empty (so there is no <code>vin[0]</code>).</p>
 48884: <p>A coinbase transaction is not allowed to have any other inputs, hence this check. Furthermore, because this check is part of consensus code, it is the definition for a coinbase transaction, so this ends up being a bit circular - the function says that a coinbase transaction must only have one input, and it checks that.</p>
