Quantcast
Viewing all articles
Browse latest Browse all 3

Can someone explain how an HTLC is redeemed?

I'm looking at Bolt 3 in the Lightning rfc. My question is about how a HTLC is redeemed. Example HTLC script for reference:

# To remote node with revocation keyOP_DUP OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUALOP_IF    OP_CHECKSIGOP_ELSE<remote_htlcpubkey> OP_SWAP OP_SIZE 32 OP_EQUAL    OP_NOTIF        # To local node via HTLC-timeout transaction (timelocked).        OP_DROP 2 OP_SWAP <local_htlcpubkey> 2 OP_CHECKMULTISIG    OP_ELSE        # To remote node with preimage.        OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY        OP_CHECKSIG    OP_ENDIFOP_ENDIF

My understanding is that it can be redeemed in two ways. The first way can be done if the revocation secret is known.

<revocation_sig> <revocationpubkey>

revocationpubkey will produce the correct hash, OP_EQUAL will return "1", the script goes into OP_IF, and the revocation_sig will be valid for OP_CHECKSIG.

The second way involves

<remotehtlcsig> <payment_preimage>

Can someone explain how this satisfies the script? For example, what OP_SWAP does or when it would go through OP_NOTIF/OP_ELSE?


Viewing all articles
Browse latest Browse all 3

Trending Articles