← Back to the archive
Bitcoin.onl > Archive > Bitcoin Forum > Re: overflow bug SERIOUS
AuthorTopic: Re: overflow bug SERIOUS
satoshiFounderSr. Member★★★★
Re: overflow bug SERIOUS
« on: August 15, 2010, 08:59:09 PM UTC »

Here's the preliminary change.  Look right?  I have more changes to make, this isn't all of it.  Will SVN shortly.

Code:
    bool CheckTransaction() const
    {
        // Basic checks that don't depend on any context
        if (vin.empty() || vout.empty())
            return error("CTransaction::CheckTransaction() : vin or vout empty");

        // Check for negative and overflow values
        int64 nTotal = 0;
        foreach(const CTxOut& txout, vout)
        {
            if (txout.nValue < 0)
                return error("CTransaction::CheckTransaction() : txout.nValue negative");
            if (txout.nValue > 21000000 * COIN)
                return error("CTransaction::CheckTransaction() : txout.nValue too high");
            nTotal += txout.nValue;
            if (nTotal > 21000000 * COIN)
                return error("CTransaction::CheckTransaction() : txout total too high");
        }

        if (IsCoinBase())
        {
            if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100)
                return error("CTransaction::CheckTransaction() : coinbase script size");
        }
        else
        {
            foreach(const CTxIn& txin, vin)
                if (txin.prevout.IsNull())
                    return error("CTransaction::CheckTransaction() : prevout is null");
        }

        return true;
    }

Don't sticky the topic, nobody looks up there.  There'll be enough posts to bump.

Satoshi designed Bitcoin so you can hold it yourself. Start here →

KEEP THE ARCHIVE ONLINE

Tip in sats.

Bitcoin.onl is free to read. If the archive is useful to you, a tip helps keep it online. Thanks to readers who keep this online.

Lightning (preferred)faramber539@walletofsatoshi.com
On-chainbc1p7dk9n0uv9ryuv73a578zglgq6f2ml0sz9xgy9du9ms9z89evtuts7py4ak
© Bitcoin.onl · Home · Is quantum a threat? · Keep the archive online · Follow us on Bluesky and Nostr