The Indepth Anatomy of an HTLC

  • Revocation transactions in a Lightning Network channel
  • Cross chain atomic swaps to send the value of some Bitcoin to another crypto network
  • Submarine swaps to send the value of some Bitcoin from Layer1 to a Layer2 address

How do HTLCs work?

Let’s Talk Timeouts

The BIP199 HTLC script

HTLC defined by BIP 199
  • [HASHOP]: Some hashing algorthm, we’ll use OP_SHA256
  • <digest>: the hashed key ( preimage ) Alice gave bob
  • OP_EQUALVERIFY: Checks if the last 2 items in the stack are equal
scriptSig for nontimeout redemption

The Bolt 3 HTLCs

channel timeline explained w/ toast and cheese

The to_local HTLC

The offered and received HTLC

commitment tx output spending paths
Offered HTLC locking script
Received HTLC locking script

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store