Skip to content

Instantly share code, notes, and snippets.

@RomanovRoman
Created August 23, 2018 08:22
Show Gist options
  • Save RomanovRoman/9b70e8786e3a5c31fd9acde71e4df977 to your computer and use it in GitHub Desktop.
Save RomanovRoman/9b70e8786e3a5c31fd9acde71e4df977 to your computer and use it in GitHub Desktop.
OP_IF // Normal redeem path
// Require initiator's secret to be a known length that the redeeming
// party can audit. This is used to prevent fraud attacks between two
// currencies that have different maximum data sizes.
OP_SIZE
secretSize
OP_EQUALVERIFY
// Require initiator's secret to be known to redeem the output.
OP_SHA256
secretHash
OP_EQUALVERIFY
// Verify their signature is being used to redeem the output. This
// would normally end with OP_EQUALVERIFY OP_CHECKSIG but this has been
// moved outside of the branch to save a couple bytes.
OP_DUP
OP_HASH160
addrTo
OP_ELSE // Refund path
// Verify locktime and drop it off the stack (which is not done by
// CLTV).
locktime
OP_CHECKLOCKTIMEVERIFY
OP_DROP
// Verify our signature is being used to redeem the output. This would
// normally end with OP_EQUALVERIFY OP_CHECKSIG but this has been moved
// outside of the branch to save a couple bytes.
OP_DUP
OP_HASH160
addrFrom
OP_ENDIF
// Complete the signature check.
OP_EQUALVERIFY
OP_CHECKSIG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment