1. 程式人生 > >比特幣學習-Transaction的locktime屬性

比特幣學習-Transaction的locktime屬性

Locktime, also known as nLockTime from the variable name used in the reference client, defines the earliest time that a transaction is valid and can be relayed on the network or added to the block chain. It is set to zero in most transactions to indicate immediate propagation and execution. If locktime is nonzero and below 500 million, it is interpreted as a block height, meaning the transaction is not valid and is not relayed or included in the blockchain prior to the specified block height. If it is above 500 million, it is interpreted as a Unix Epoch timestamp (seconds since Jan-1-1970) and the transaction is not valid prior to the specified time. Transactions with locktime specifying a future block or time must be held by the originating system and transmitted to the bitcoin network only after they become valid. The use of locktime is equivalent to postdating a paper check. 

 

Locktime, 也被稱為nLockTime, 它定義了個最早時間,只有過了這個最早時間,這個transaction可以被髮送到比特幣網路。通常被設定為0,表示transaction一建立好就馬上傳送到比特幣網路。如果nLocktime的時間在1到5億之間,則表示該transaction只會被新增到區塊高度大於或等於nLocktime的區塊中去。如果nLocktime的值超過5億,則表示從1970年01月01日開始算,加上nLocktime 秒之後的一個時間點,如果transaction被建立的時間早於那個時間點,則該transaction不會被髮送到比特幣網路。帶locktime的transaction,指明瞭transactions在未來的一個區塊或者未來的一個時間點,才會被驗證併發送到比特幣網路上去。……