I am looking at Bolt 3 in the Lightning rfc. My question is about how to redeem an HTLC. Example HTLC script for reference:
# To remote node with revocation key OP_DUP OP_HASH160
OP_EQUAL OP_IF OP_CHECKSIG OP_ELSE OP_SWAP OP_SIZE 32 OP_EQUAL OP_NOTIF # To local node via HTLC-timeout transaction (timelocked). OP_DROP 2 OP_SWAP 2 OP_CHECKMULTISIG OP_ELSE # To remote node with preimage. OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG OP_ENDIF OP_ENDIF
I understand that it can be redeemed in two ways. The first form can be done if the revocation secret is known.
revocationpubkey will produce the correct hash, OP_EQUAL will return "1", the script will enter OP_IF and the revocation_sig will be valid for OP_CHECKSIG.
The second way involves
Can anyone explain how this satisfies the script? For example, what does OP_SWAP do or when would it go through OP_NOTIF / OP_ELSE?