2

From what I can tell OP_DROP is a method of storing non validation data in a tx ( seperate from using data after OP_RETURN ).

However in this unlocking script described by bip199, the timeout block and timeout op are before the OP_DROP, meaning they would be dropped during validation? OP_DROP can't be describing what comes after because that should be the payment path validation - and because afaik bitcoin script is stack based.

What is the point of OP_DROP? How does it apply in the following script?

OP_IF
    [HASHOP] <digest> OP_EQUALVERIFY OP_DUP OP_HASH160 <seller pubkey hash>            
OP_ELSE
    <num> [TIMEOUTOP] OP_DROP OP_DUP OP_HASH160 <buyer pubkey hash>
OP_ENDIF
OP_EQUALVERIFY
OP_CHECKSIG
0

Both OP_CHECKSEQUENCEVERIFYand OP_CHECKLOCKTIMEVERIFY were OP_NOP opcodes that were redefined to their current definitions via a softfork. The presence of an OP_NOP opcode does nothing on the stack (it neither pops the item nor verifies anything.)

Softforks can only constrict the definition, not expand them. When OP_NOP opcodes were re-defined to meet the new conditions of the TIMEOUT, the constriction was to make a transaction invalid if the TIMEOUT conditions are not met.

However, the property of OP_NOP to do nothing on the stack could not be changed as that would mean expanding the scope of it's definition. Thus the number (blocks or seconds) that precedes the OP_CLTV or OP_CSV continues to remain on the stack even after the verification. This number has to be dropped manually to make the script execute the next items correctly (like ECDSA signature verification), which is why we use the OP_DROP opcode.

2

The TIMEOUTOP, which is one of OP_CHECKSEQUENCEVERIFY or OP_CHECKLOCKTIMEVERIFY, will either:

  1. Terminate the script with an error if the TIMEOUT conditions are not met
  2. Act as a NOP and leave the stack unchanged if the TIMEOUT conditions are met

2 occurs if the timeout has been met, and leaves the top of the stack with the timeout delay value. OP_DROP removes this value from the top of the stack, allowing the regular p2pkh script to continue execution by consuming the rest of the stack.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.