Could I mine a non-final transaction?

4

I know that non-final transactions (locktime in future and sequence number < MAX_UINT) are not "accepted by miners". However, I could not figure out the exact behavior.

If I mined my own block with a non-final transaction, would that block be considered valid, i.e., would clients add it to their copy of the chain and would other miners build on top of that block? (I suppose the answer is "no" because otherwise attacks on contracts could be possible.)

real-or-random

Posted 2013-12-18T11:05:41.750

Reputation: 120

This may be possible, assuming that other miners will accept your block and not orphan it. However, you still need to sign the inputs of the transaction with the appropriate keys, so I'm not sure why you think that would allow an attack on a contract.rdb 2014-02-17T20:40:52.730

Answers

4

No. In the reference client, main.cpp runs this check during "AcceptBlock":

    // Check that all transactions are finalized
    BOOST_FOREACH(const CTransaction& tx, block.vtx)
        if (!IsFinalTx(tx, nHeight, block.GetBlockTime()))
            return state.DoS(10, error("AcceptBlock() : contains a non-final transaction"),
                             REJECT_INVALID, "bad-txns-nonfinal");

which rejects your block if it contain a non-final transaction. A client that accepts a block containing a transaction with a locktime in the future and sequence number less than std::numeric_limits<unsigned int>::max() would be on the losing side of a fork.

Joe Amenta

Posted 2013-12-18T11:05:41.750

Reputation: 381