Enforce nLockTime in the blockchain #1820

issue gmaxwell opened this issue on September 12, 2012
  1. gmaxwell commented at 1:17 AM on September 12, 2012: contributor
        bool IsFinal(int nBlockHeight=0, int64 nBlockTime=0) const
        {
            // Time based nLockTime implemented in 0.1.6
            if (nLockTime == 0)
                return true;   
            if (nBlockHeight == 0)
                nBlockHeight = nBestHeight;
            if (nBlockTime == 0)
                nBlockTime = GetAdjustedTime();
            if ((int64)nLockTime < ((int64)nLockTime < LOCKTIME_THRESHOLD ? (int64)nBlockHeight : nBlockTime))
                return true;
            BOOST_FOREACH(const CTxIn& txin, vin)
                if (!txin.IsFinal())
                    return false;   
            return true;
        }
    

    IsFinal() can never return false. The final return true should be return false and the input check should come before the time check (or left where it is and had its sense reversed). Would be a trivial fix except its a soft-forking change. ... and will probably require bumping the transaction version number as well as updating the block enforcing rules.

    It's well known that replacement didn't work, but nLockTime not being enforced in the chain was a surprise to me

  2. gmaxwell commented at 6:02 AM on September 12, 2012: contributor

    13e100dd08b6da0a7426ea520b0bb3ae54cef79dd045e2e4f7116023df3a5c95 is an example of a violating transaction in the chain.

  3. sipa commented at 12:29 PM on September 12, 2012: member

    How do you mean IsFinal() can never return false? If you want a non-final transaction, at least one transaction input should have a non-maximum nSequence number.

  4. gmaxwell commented at 12:46 PM on September 12, 2012: contributor

    Doh. Missed that it was calling the ctxin IsFinal not itself.

  5. gmaxwell closed this on Sep 12, 2012

  6. DrahtBot locked this on Sep 8, 2021
Contributors
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-18 21:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me