NLockTime分析

tx

tx describes a bitcoin transaction, in reply to getdata

NLockTime

nLockTime is a parameter that can be attached to a transaction, that mandates a minimal time (specified in either unix time or block height), that before this time, the transaction cannot be accepted into a block.

lock_time

The block number or timestamp at which this transaction is locked:

  • 0 Not locked
  • < 500000000 Block number at which this transaction is locked
  • >= 500000000 UNIX timestamp at which this transaction is locked

sequence

Transaction version as defined by the sender. Intended for "replacement" of transactions when information is updated before inclusion into a block.

If all TxIn inputs have final (0xffffffff) sequence numbers then lock_time is irrelevant. Otherwise, the transaction may not be added to a block until after lock_time (see NLockTime).

bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime) { AssertLockHeld(cs_main); // Time based nLockTime implemented in 0.1.6 if (tx.nLockTime == 0) return true; if (nBlockHeight == 0) nBlockHeight = chainActive.Height(); if (nBlockTime == 0) nBlockTime = GetAdjustedTime(); if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) return true; BOOST_FOREACH(const CTxIn& txin, tx.vin) if (!txin.IsFinal()) return false; return true; }

http://bitcoin.stackexchange.com/questions/861/why-isnt-transaction-replacement-supported
http://bbs.btcman.com/thread-17881-1-1.html
http://bitcoin.stackexchange.com/questions/5783/transactions-with-a-wait-time-using-nlocktime
https://brainwallet.github.io/#tx
https://en.bitcoin.it/wiki/Contracts

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容