| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-11-10 04:43:09 -05:00
										 |  |  |   BIP: 65 | 
					
						
							| 
									
										
										
										
											2016-11-30 09:45:33 +00:00
										 |  |  |   Layer: Consensus (soft fork) | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |   Title: OP_CHECKLOCKTIMEVERIFY | 
					
						
							|  |  |  |   Author: Peter Todd <pete@petertodd.org> | 
					
						
							| 
									
										
										
										
											2016-11-30 09:47:31 +00:00
										 |  |  |   Comments-Summary: No comments yet. | 
					
						
							|  |  |  |   Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0065 | 
					
						
							| 
									
										
										
											
												Promote Accepted->Final BIPs 11, 14, 21, 22, 23, 31, 32, 34, 35, 37, 65
											
										 
											2016-02-01 20:14:22 +00:00
										 |  |  |   Status: Final | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |   Type: Standards Track | 
					
						
							|  |  |  |   Created: 2014-10-01 | 
					
						
							| 
									
										
										
										
											2016-11-30 09:47:31 +00:00
										 |  |  |   License: PD | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ==Abstract== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This BIP describes a new opcode (OP_CHECKLOCKTIMEVERIFY) for the Bitcoin | 
					
						
							|  |  |  | scripting system that allows a transaction output to be made unspendable until | 
					
						
							|  |  |  | some point in the future. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ==Summary== | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-02 02:03:30 +08:00
										 |  |  | CHECKLOCKTIMEVERIFY redefines the existing NOP2 opcode. When executed, if | 
					
						
							|  |  |  | any of the following conditions are true, the script interpreter will terminate | 
					
						
							|  |  |  | with an error: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-06 23:52:42 +08:00
										 |  |  | * the stack is empty; or | 
					
						
							| 
									
										
										
										
											2015-12-02 02:03:30 +08:00
										 |  |  | * the top item on the stack is less than 0; or | 
					
						
							| 
									
										
										
										
											2015-12-06 23:52:42 +08:00
										 |  |  | * the lock-time type (height vs. timestamp) of the top stack item and the nLockTime field are not the same; or | 
					
						
							| 
									
										
										
										
											2015-12-02 02:03:30 +08:00
										 |  |  | * the top stack item is greater than the transaction's nLockTime field; or | 
					
						
							| 
									
										
										
										
											2015-12-09 00:37:25 +08:00
										 |  |  | * the nSequence field of the txin is 0xffffffff; | 
					
						
							| 
									
										
										
										
											2015-12-02 02:03:30 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | Otherwise, script execution will continue as if a NOP had been executed. | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | The nLockTime field in a transaction prevents the transaction from being mined | 
					
						
							|  |  |  | until either a certain block height, or block time, has been reached. By | 
					
						
							|  |  |  | comparing the argument to CHECKLOCKTIMEVERIFY against the nLockTime field, we | 
					
						
							|  |  |  | indirectly verify that the desired block height or block time has been reached; | 
					
						
							|  |  |  | until that block height or block time has been reached the transaction output | 
					
						
							|  |  |  | remains unspendable. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ==Motivation== | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-13 12:24:27 -05:00
										 |  |  | The nLockTime field in transactions can be used to prove that it is | 
					
						
							|  |  |  | ''possible'' to spend a transaction output in the future, by constructing a | 
					
						
							|  |  |  | valid transaction spending that output with the nLockTime field set. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | However, the nLockTime field can't prove that it is ''impossible'' to spend a | 
					
						
							|  |  |  | transaction output until some time in the future, as there is no way to know if | 
					
						
							|  |  |  | a valid signature for a different transaction spending that output has been | 
					
						
							|  |  |  | created. | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ===Escrow=== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | If Alice and Bob jointly operate a business they may want to | 
					
						
							|  |  |  | ensure that all funds are kept in 2-of-2 multisig transaction outputs that | 
					
						
							|  |  |  | require the co-operation of both parties to spend. However, they recognise that | 
					
						
							|  |  |  | in exceptional circumstances such as either party getting "hit by a bus" they | 
					
						
							|  |  |  | need a backup plan to retrieve the funds. So they appoint their lawyer, Lenny, | 
					
						
							|  |  |  | to act as a third-party. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | With a standard 2-of-3 CHECKMULTISIG at any time Lenny could conspire with | 
					
						
							|  |  |  | either Alice or Bob to steal the funds illegitimately. Equally Lenny may prefer | 
					
						
							|  |  |  | not to have immediate access to the funds to discourage bad actors from | 
					
						
							|  |  |  | attempting to get the secret keys from him by force. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-23 17:34:41 -04:00
										 |  |  | However, with CHECKLOCKTIMEVERIFY the funds can be stored in scriptPubKeys of | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | the form: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IF | 
					
						
							|  |  |  |         <now + 3 months> CHECKLOCKTIMEVERIFY DROP | 
					
						
							|  |  |  |         <Lenny's pubkey> CHECKSIGVERIFY | 
					
						
							|  |  |  |         1 | 
					
						
							|  |  |  |     ELSE | 
					
						
							|  |  |  |         2 | 
					
						
							|  |  |  |     ENDIF | 
					
						
							|  |  |  |     <Alice's pubkey> <Bob's pubkey> 2 CHECKMULTISIG | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | At any time the funds can be spent with the following scriptSig: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-29 17:33:05 +08:00
										 |  |  |     0 <Alice's signature> <Bob's signature> 0 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | After 3 months have passed Lenny and one of either Alice or Bob can spend the | 
					
						
							|  |  |  | funds with the following scriptSig: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-29 17:33:05 +08:00
										 |  |  |     0 <Alice/Bob's signature> <Lenny's signature> 1 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ===Non-interactive time-locked refunds=== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | There exist a number of protocols where a transaction output is created that | 
					
						
							| 
									
										
										
										
											2014-11-10 04:43:09 -05:00
										 |  |  | requires the co-operation of both parties to spend the output. To ensure the | 
					
						
							| 
									
										
										
										
											2015-06-23 17:34:41 -04:00
										 |  |  | failure of one party does not result in the funds becoming lost, refund | 
					
						
							| 
									
										
										
										
											2014-11-10 04:43:09 -05:00
										 |  |  | transactions are setup in advance using nLockTime. These refund transactions | 
					
						
							| 
									
										
										
										
											2017-08-24 23:50:20 +12:00
										 |  |  | need to be created interactively, and additionally, are currently vulnerable to | 
					
						
							| 
									
										
										
										
											2015-11-13 12:17:23 -05:00
										 |  |  | transaction malleability. CHECKLOCKTIMEVERIFY can be used in these protocols, | 
					
						
							| 
									
										
										
										
											2014-11-10 04:43:09 -05:00
										 |  |  | replacing the interactive setup with a non-interactive setup, and additionally, | 
					
						
							| 
									
										
										
										
											2015-11-13 12:17:23 -05:00
										 |  |  | making transaction malleability a non-issue. | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ====Two-factor wallets==== | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-05 17:57:04 +08:00
										 |  |  | Services like GreenAddress store bitcoins with 2-of-2 multisig scriptPubKey's | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | such that one keypair is controlled by the user, and the other keypair is | 
					
						
							|  |  |  | controlled by the service. To spend funds the user uses locally installed | 
					
						
							|  |  |  | wallet software that generates one of the required signatures, and then uses a | 
					
						
							|  |  |  | 2nd-factor authentication method to authorize the service to create the second | 
					
						
							|  |  |  | SIGHASH_NONE signature that is locked until some time in the future and sends | 
					
						
							|  |  |  | the user that signature for storage. If the user needs to spend their funds and | 
					
						
							|  |  |  | the service is not available, they wait until the nLockTime expires. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The problem is there exist numerous occasions the user will not have a valid | 
					
						
							|  |  |  | signature for some or all of their transaction outputs. With | 
					
						
							|  |  |  | CHECKLOCKTIMEVERIFY rather than creating refund signatures on demand | 
					
						
							|  |  |  | scriptPubKeys of the following form are used instead: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IF | 
					
						
							|  |  |  |         <service pubkey> CHECKSIGVERIFY | 
					
						
							|  |  |  |     ELSE | 
					
						
							|  |  |  |         <expiry time> CHECKLOCKTIMEVERIFY DROP | 
					
						
							|  |  |  |     ENDIF | 
					
						
							|  |  |  |     <user pubkey> CHECKSIG | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Now the user is always able to spend their funds without the co-operation of | 
					
						
							|  |  |  | the service by waiting for the expiry time to be reached. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-13 12:14:19 -05:00
										 |  |  | ====Payment Channels==== | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-13 12:14:19 -05:00
										 |  |  | Jeremy Spilman style payment channels first setup a deposit controlled by | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 2-of-2 multisig, tx1, and then adjust a second transaction, tx2, that spends | 
					
						
							|  |  |  | the output of tx1 to payor and payee. Prior to publishing tx1 a refund | 
					
						
							|  |  |  | transaction is created, tx3, to ensure that should the payee vanish the payor | 
					
						
							|  |  |  | can get their deposit back. The process by which the refund transaction is | 
					
						
							| 
									
										
										
										
											2015-11-13 12:17:23 -05:00
										 |  |  | created is currently vulnerable to transaction malleability attacks, and | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | additionally, requires the payor to store the refund. Using the same | 
					
						
							| 
									
										
										
										
											2018-01-26 14:58:11 +03:00
										 |  |  | scriptPubKey form as in the Two-factor wallets example solves both these issues. | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ===Trustless Payments for Publishing Data=== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The PayPub protocol makes it possible to pay for information in a trustless way | 
					
						
							|  |  |  | by first proving that an encrypted file contains the desired data, and secondly | 
					
						
							|  |  |  | crafting scriptPubKeys used for payment such that spending them reveals the | 
					
						
							|  |  |  | encryption keys to the data. However the existing implementation has a | 
					
						
							|  |  |  | significant flaw: the publisher can delay the release of the keys indefinitely. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This problem can be solved interactively with the refund transaction technique; | 
					
						
							|  |  |  | with CHECKLOCKTIMEVERIFY the problem can be non-interactively solved using | 
					
						
							|  |  |  | scriptPubKeys of the following form: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IF | 
					
						
							|  |  |  |         HASH160 <Hash160(encryption key)> EQUALVERIFY | 
					
						
							|  |  |  |         <publisher pubkey> CHECKSIG | 
					
						
							|  |  |  |     ELSE | 
					
						
							|  |  |  |         <expiry time> CHECKLOCKTIMEVERIFY DROP | 
					
						
							|  |  |  |         <buyer pubkey> CHECKSIG | 
					
						
							|  |  |  |     ENDIF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The buyer of the data is now making a secure offer with an expiry time. If the | 
					
						
							|  |  |  | publisher fails to accept the offer before the expiry time is reached the buyer | 
					
						
							|  |  |  | can cancel the offer by spending the output. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ===Proving sacrifice to miners' fees=== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Proving the sacrifice of some limited resource is a common technique in a | 
					
						
							|  |  |  | variety of cryptographic protocols. Proving sacrifices of coins to mining fees | 
					
						
							|  |  |  | has been proposed as a ''universal public good'' to which the sacrifice could | 
					
						
							|  |  |  | be directed, rather than simply destroying the coins. However doing so is | 
					
						
							| 
									
										
										
										
											2024-07-07 01:01:03 +00:00
										 |  |  | non-trivial, and even the best existing technique - announce-commit sacrifices | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | - could encourage mining centralization. CHECKLOCKTIMEVERIFY can be used to | 
					
						
							|  |  |  | create outputs that are provably spendable by anyone (thus to mining fees | 
					
						
							|  |  |  | assuming miners behave optimally and rationally) but only at a time | 
					
						
							| 
									
										
										
										
											2015-11-13 12:13:03 -05:00
										 |  |  | sufficiently far into the future that large miners can't profitably sell the | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | sacrifices at a discount. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-23 17:34:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-22 00:01:03 -04:00
										 |  |  | ===Freezing Funds=== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | In addition to using cold storage, hardware wallets, and P2SH multisig outputs | 
					
						
							|  |  |  | to control funds, now funds can be frozen in UTXOs directly on the blockchain. | 
					
						
							|  |  |  | With the following scriptPubKey, nobody will be able to spend the encumbered | 
					
						
							|  |  |  | output until the provided expiry time. This ability to freeze funds reliably may | 
					
						
							|  |  |  | be useful in scenarios where reducing duress or confiscation risk is desired. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <expiry time> CHECKLOCKTIMEVERIFY DROP DUP HASH160 <pubKeyHash> EQUALVERIFY CHECKSIG | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-23 17:34:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | ===Replacing the nLockTime field entirely=== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | As an aside, note how if the SignatureHash() algorithm could optionally cover | 
					
						
							|  |  |  | part of the scriptSig the signature could require that the scriptSig contain | 
					
						
							|  |  |  | CHECKLOCKTIMEVERIFY opcodes, and additionally, require that they be executed. | 
					
						
							|  |  |  | (the CODESEPARATOR opcode came very close to making this possible in v0.1 of | 
					
						
							|  |  |  | Bitcoin) This per-signature capability could replace the per-transaction | 
					
						
							|  |  |  | nLockTime field entirely as a valid signature would now be the proof that a | 
					
						
							|  |  |  | transaction output ''can'' be spent. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ==Detailed Specification== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Refer to the reference implementation, reproduced below, for the precise | 
					
						
							|  |  |  | semantics and detailed rationale for those semantics. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-25 18:35:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |     case OP_NOP2: | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // CHECKLOCKTIMEVERIFY | 
					
						
							|  |  |  |         // | 
					
						
							|  |  |  |         // (nLockTime -- nLockTime ) | 
					
						
							| 
									
										
										
										
											2024-07-25 18:35:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |         if (!(flags & SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)) | 
					
						
							|  |  |  |             break; // not enabled; treat as a NOP | 
					
						
							| 
									
										
										
										
											2024-07-25 18:35:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |         if (stack.size() < 1) | 
					
						
							|  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2024-07-25 18:35:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |         // Note that elsewhere numeric opcodes are limited to | 
					
						
							|  |  |  |         // operands in the range -2**31+1 to 2**31-1, however it is | 
					
						
							|  |  |  |         // legal for opcodes to produce results exceeding that | 
					
						
							|  |  |  |         // range. This limitation is implemented by CScriptNum's | 
					
						
							|  |  |  |         // default 4-byte limit. | 
					
						
							|  |  |  |         // | 
					
						
							|  |  |  |         // If we kept to that limit we'd have a year 2038 problem, | 
					
						
							|  |  |  |         // even though the nLockTime field in transactions | 
					
						
							|  |  |  |         // themselves is uint32 which only becomes meaningless | 
					
						
							|  |  |  |         // after the year 2106. | 
					
						
							|  |  |  |         // | 
					
						
							|  |  |  |         // Thus as a special case we tell CScriptNum to accept up | 
					
						
							|  |  |  |         // to 5-byte bignums, which are good until 2**32-1, the | 
					
						
							|  |  |  |         // same limit as the nLockTime field itself. | 
					
						
							|  |  |  |         const CScriptNum nLockTime(stacktop(-1), 5); | 
					
						
							| 
									
										
										
										
											2024-07-25 18:35:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |         // In the rare event that the argument may be < 0 due to | 
					
						
							|  |  |  |         // some arithmetic being done first, you can always use | 
					
						
							|  |  |  |         // 0 MAX CHECKLOCKTIMEVERIFY. | 
					
						
							|  |  |  |         if (nLockTime < 0) | 
					
						
							|  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2024-07-25 18:35:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-29 17:45:55 +08:00
										 |  |  |         // There are two types of nLockTime: lock-by-blockheight | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |         // and lock-by-blocktime, distinguished by whether | 
					
						
							|  |  |  |         // nLockTime < LOCKTIME_THRESHOLD. | 
					
						
							|  |  |  |         // | 
					
						
							|  |  |  |         // We want to compare apples to apples, so fail the script | 
					
						
							|  |  |  |         // unless the type of nLockTime being tested is the same as | 
					
						
							|  |  |  |         // the nLockTime in the transaction. | 
					
						
							|  |  |  |         if (!( | 
					
						
							|  |  |  |               (txTo.nLockTime <  LOCKTIME_THRESHOLD && nLockTime <  LOCKTIME_THRESHOLD) || | 
					
						
							|  |  |  |               (txTo.nLockTime >= LOCKTIME_THRESHOLD && nLockTime >= LOCKTIME_THRESHOLD) | 
					
						
							|  |  |  |              )) | 
					
						
							|  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2024-07-25 18:35:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |         // Now that we know we're comparing apples-to-apples, the | 
					
						
							|  |  |  |         // comparison is a simple numeric one. | 
					
						
							|  |  |  |         if (nLockTime > (int64_t)txTo.nLockTime) | 
					
						
							|  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2024-07-25 18:35:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |         // Finally the nLockTime feature can be disabled and thus | 
					
						
							|  |  |  |         // CHECKLOCKTIMEVERIFY bypassed if every txin has been | 
					
						
							|  |  |  |         // finalized by setting nSequence to maxint. The | 
					
						
							|  |  |  |         // transaction would be allowed into the blockchain, making | 
					
						
							|  |  |  |         // the opcode ineffective. | 
					
						
							|  |  |  |         // | 
					
						
							|  |  |  |         // Testing if this vin is not final is sufficient to | 
					
						
							|  |  |  |         // prevent this condition. Alternatively we could test all | 
					
						
							|  |  |  |         // inputs, but testing just this input minimizes the data | 
					
						
							|  |  |  |         // required to prove correct CHECKLOCKTIMEVERIFY execution. | 
					
						
							|  |  |  |         if (txTo.vin[nIn].IsFinal()) | 
					
						
							|  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2024-07-25 18:35:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2024-07-25 18:35:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | https://github.com/petertodd/bitcoin/commit/ab0f54f38e08ee1e50ff72f801680ee84d0f1bf4 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 13:11:59 +01:00
										 |  |  | ==Deployment== | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 18:14:05 +01:00
										 |  |  | We reuse the double-threshold IsSuperMajority() switchover mechanism used in | 
					
						
							| 
									
										
										
										
											2015-12-05 17:57:43 +08:00
										 |  |  | BIP66 with the same thresholds, but for nVersion = 4. The new rules are | 
					
						
							| 
									
										
										
										
											2015-10-23 13:11:59 +01:00
										 |  |  | in effect for every block (at height H) with nVersion = 4 and at least | 
					
						
							|  |  |  | 750 out of 1000 blocks preceding it (with heights H-1000..H-1) also | 
					
						
							| 
									
										
										
										
											2015-10-23 17:07:21 -04:00
										 |  |  | have nVersion >= 4. Furthermore, when 950 out of the 1000 blocks | 
					
						
							|  |  |  | preceding a block do have nVersion >= 4, nVersion < 4 blocks become | 
					
						
							| 
									
										
										
										
											2015-10-23 13:11:59 +01:00
										 |  |  | invalid, and all further blocks enforce the new rules. | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 18:14:05 +01:00
										 |  |  | It should be noted that BIP9 involves permanently setting a high-order bit to | 
					
						
							|  |  |  | 1 which results in nVersion >= all prior IsSuperMajority() soft-forks and thus | 
					
						
							|  |  |  | no bits in nVersion are permanently lost. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 17:16:22 -04:00
										 |  |  | ===SPV Clients=== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | While SPV clients are (currently) unable to validate blocks in general, | 
					
						
							|  |  |  | trusting miners to do validation for them, they are able to validate block | 
					
						
							|  |  |  | headers and thus can validate a subset of the deployment rules. SPV clients | 
					
						
							|  |  |  | should reject nVersion < 4 blocks if 950 out of 1000 preceding blocks have | 
					
						
							|  |  |  | nVersion >= 4 to prevent false confirmations from the remaining 5% of | 
					
						
							|  |  |  | non-upgraded miners when the 95% threshold has been reached. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | ==Credits== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Thanks goes to Gregory Maxwell for suggesting that the argument be compared | 
					
						
							|  |  |  | against the per-transaction nLockTime, rather than the current block height and | 
					
						
							|  |  |  | time. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-23 17:34:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | ==References== | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-06 09:59:19 +09:00
										 |  |  | PayPub | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | * https://github.com/unsystem/paypub | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-06 09:59:27 +09:00
										 |  |  | Jeremy Spilman Payment Channels | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | * https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2013-April/002433.html | 
					
						
							| 
									
										
										
										
											2015-06-22 00:01:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-23 17:34:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-22 00:01:03 -04:00
										 |  |  | ==Implementations== | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-22 00:01:03 -04:00
										 |  |  | Python / python-bitcoinlib | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-06 09:59:33 +09:00
										 |  |  | * https://github.com/petertodd/checklocktimeverify-demos | 
					
						
							| 
									
										
										
										
											2015-06-22 00:01:03 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | JavaScript / Node.js / bitcore | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-06 09:59:40 +09:00
										 |  |  | * https://github.com/mruddy/bip65-demos | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-23 17:34:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 08:59:26 -04:00
										 |  |  | ==Copyright== | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This document is placed in the public domain. | 
					
						
							| 
									
										
										
										
											2015-06-22 00:01:03 -04:00
										 |  |  | 
 |