Skip to content

Instantly share code, notes, and snippets.

@maraoz
Last active October 5, 2016 13:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maraoz/d781393c0bd5b9f70c1f to your computer and use it in GitHub Desktop.
Save maraoz/d781393c0bd5b9f70c1f to your computer and use it in GitHub Desktop.
Hashed Timelock Contract (HTLC) as proposed in lightning.network paper
OP_DEPTH 3 OP_EQUAL
OP_IF
OP_HASH160 <hash160(R)> OP_EQUALVERIFY
OP_0 2 <AlicePubkey1> <BobPubkey1> 2 OP_CHECKMULTISIG
OP_ELSE
OP_0 2 <AlicePubkey2> <BobPubkey2> 2 OP_CHECKMULTISIG
OP_END
OP_IF
OP_HASH160 <hash160(R)> OP_EQUALVERIFY
OP_0 2 <AlicePubkey1> <BobPubkey1>
OP_ELSE
OP_0 2 <AlicePubkey2> <BobPubkey2>
OP_END
2 OP_CHECKMULTISIG
@maraoz
Copy link
Author

maraoz commented Jul 9, 2015

  • OP_DEPTH 3 OP_EQUAL is not needed as party spending the script can include a 0 or 1 in the scriptSig to choose to enter through if or else branch.
  • 2 OP_CHECKMULTISIG was factored out of the OP_IF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment