1
0
mirror of https://github.com/bitcoin/bips.git synced 2024-11-19 09:50:06 +01:00

More clearly define script execution failure pathway

This commit is contained in:
BtcDrak 2015-11-24 13:08:54 +00:00
parent 4048f45316
commit d30f1c6d0b

View File

@ -20,16 +20,16 @@ being spent.
==Summary== ==Summary==
CHECKSEQUENCEVERIFY redefines the existing NOP3 opcode. CHECKSEQUENCEVERIFY redefines the existing NOP3 opcode.
When executed, the script interpreter continues as if a NOP was executed When executed, if any of the following conditions are true, the script interpreter will terminate with an error:
so long as:
* the top item on the stack is greater than or equal to 0; and * the top item on the stack is less than 0; or
* the top item on the stack does not have disable flag (1 << 31) set; and * the top item on the stack has the disable flag (1 << 31) unset; and
* the transaction version is 2 or above; and ** the transaction version is less than 2; or
* the transaction input's sequence number does not have the disable flag (1 << 31) set; and ** the transaction input sequence number disable flag (1 << 31) is set; and
* the top item on the stack and the transaction input's sequence number are both relative lock-times of the same type, and sequence number is greater than or equal to the top item on the stack. ** the relative lock-time type is not the same; or
** the top stack item is greater than the transaction sequence (when masked according to the BIP68);
Otherwise, script execution terminates with an error. Otherwise, script execution will continue as if a NOP had been executed.
BIP 68 prevents a non-final transaction from being selected for inclusion in a block until the corresponding input has reached the specified age, as measured in block-height or block-time. By comparing the argument to CHECKSEQUENCEVERIFY against the nSequence field, we indirectly verify a desired minimum age of the BIP 68 prevents a non-final transaction from being selected for inclusion in a block until the corresponding input has reached the specified age, as measured in block-height or block-time. By comparing the argument to CHECKSEQUENCEVERIFY against the nSequence field, we indirectly verify a desired minimum age of the
the output being spent; until that relative age has been reached any script execution pathway including the CHECKSEQUENCEVERIFY will fail to validate, causing the transaction not to be selected for inclusion in a block. the output being spent; until that relative age has been reached any script execution pathway including the CHECKSEQUENCEVERIFY will fail to validate, causing the transaction not to be selected for inclusion in a block.
@ -196,9 +196,9 @@ and correspondingly in Bob's commitment transaction:
ELSE ELSE
<R hash> EQUAL <R hash> EQUAL
IF IF
"24h" CHECKSEQUENCEVERIFY DROP
DUP HASH160 <Alice key hash> CHECKSIGVERIFY DUP HASH160 <Alice key hash> CHECKSIGVERIFY
ELSE ELSE
"24h" CHECKSEQUENCEVERIFY DROP
"2015/10/20 10:33" CHECKLOCKTIMEVERIFY DROP "2015/10/20 10:33" CHECKLOCKTIMEVERIFY DROP
DUP HASH160 <Bob key hash> CHECKSIGVERIFY DUP HASH160 <Bob key hash> CHECKSIGVERIFY
ENDIF ENDIF
@ -298,13 +298,13 @@ semantics and detailed rationale for those semantics.
return false; return false;
// Sequence numbers with their most significant bit set are not // Sequence numbers with their most significant bit set are not
// consensus constrained. Testing that the transaction's sequence // defined by BIP68. Testing that the transaction's sequence
// number do not have this bit set prevents using this property // number do not have this bit set prevents using this property
// to get around a CHECKSEQUENCEVERIFY check. // to get around a CHECKSEQUENCEVERIFY check.
if (txToSequence & CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG) if (txToSequence & CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG)
return false; return false;
// Mask off any bits that do not have consensus-enforced meaning // Mask off any bits that do not have BIP68 consensus-enforced meaning
// before doing the integer comparisons of ::VerifySequence. // before doing the integer comparisons of ::VerifySequence.
const uint32_t nLockTimeMask = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG const uint32_t nLockTimeMask = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG
| CTxIn::SEQUENCE_LOCKTIME_MASK; | CTxIn::SEQUENCE_LOCKTIME_MASK;
@ -365,7 +365,7 @@ related proposals for improving Bitcoin's lock-time capabilities, including:
OP_CHECKLOCKTIMEVERIFY, OP_CHECKLOCKTIMEVERIFY,
[https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki BIP 68]: [https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki BIP 68]:
Consensus-enforced transaction replacement signalled via sequence numbers, Relative lock-time through consensus-enforced sequence numbers,
and [https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki BIP 113]: and [https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki BIP 113]:
Median-Past-Time-Lock. Median-Past-Time-Lock.
@ -386,7 +386,7 @@ Thanks to Eric Lombrozo and Anthony Towns for contributing example use cases.
==References== ==References==
[https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki BIP 68] Consensus-enforced transaction replacement signalled via sequence numbers [https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki BIP 68] Relative lock-time through consensus-enforced sequence numbers
[https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki BIP 65] OP_CHECKLOCKTIMEVERIFY [https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki BIP 65] OP_CHECKLOCKTIMEVERIFY