Skip to content

Commit

Permalink
input: eliminate CSV trick for HTLC outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Roasbeef committed May 26, 2023
1 parent 51a4f79 commit 048e4c7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions input/script_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func SenderHTLCTapLeafTimeout(senderHtlcKey,
// OP_SIZE 32 OP_EQUALVERIFY OP_HASH160
// <RIPEMD160(payment_hash)> OP_EQUALVERIFY
// <remote_htlcpubkey> OP_CHECKSIG
// OP_CHECKSEQUENCEVERIFY
// 1 OP_CHECKSEQUENCEVERIFY OP_DROP
func SenderHTLCTapLeafSuccess(receiverHtlcKey *btcec.PublicKey,
paymentHash []byte) (txscript.TapLeaf, error) {

Expand All @@ -560,7 +560,9 @@ func SenderHTLCTapLeafSuccess(receiverHtlcKey *btcec.PublicKey,
// after confirmation to properly sweep.
builder.AddData(schnorr.SerializePubKey(receiverHtlcKey))
builder.AddOp(txscript.OP_CHECKSIG)
builder.AddOp(txscript.OP_1)
builder.AddOp(txscript.OP_CHECKSEQUENCEVERIFY)
builder.AddOp(txscript.OP_DROP)

successLeafScript, err := builder.Script()
if err != nil {
Expand Down Expand Up @@ -649,7 +651,7 @@ func senderHtlcTapScriptTree(senderHtlcKey, receiverHtlcKey,
// OP_SIZE 32 OP_EQUALVERIFY
// OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
// <remote_htlcpubkey> OP_CHECKSIG
// OP_CHECKSEQUENCEVERIFY
// 1 OP_CHECKSEQUENCEVERIFY OP_DROP
//
// The timeout path can be spent with a witness of (sender timeout):
//
Expand Down Expand Up @@ -1054,7 +1056,7 @@ func ReceiverHtlcSpendTimeout(signer Signer, signDesc *SignDescriptor,
// timeout the HTLC after expiry:
//
// <sender_htlcpubkey> OP_CHECKSIG
// OP_CHECKSEQUENCEVERIFY
// 1 OP_CHECKSEQUENCEVERIFY OP_DROP
// <cltv_expiry> OP_CHECKLOCKTIMEVERIFY OP_DROP
func ReceiverHtlcTapLeafTimeout(senderHtlcKey *btcec.PublicKey,
cltvExpiry uint32) (txscript.TapLeaf, error) {
Expand All @@ -1065,7 +1067,9 @@ func ReceiverHtlcTapLeafTimeout(senderHtlcKey *btcec.PublicKey,
// sender authorizing the spend (the timeout).
builder.AddData(schnorr.SerializePubKey(senderHtlcKey))
builder.AddOp(txscript.OP_CHECKSIG)
builder.AddOp(txscript.OP_1)
builder.AddOp(txscript.OP_CHECKSEQUENCEVERIFY)
builder.AddOp(txscript.OP_DROP)

// The second portion will ensure that the CLTV expiry on the spending
// transaction is correct.
Expand Down Expand Up @@ -1175,7 +1179,7 @@ func receiverHtlcTapScriptTree(senderHtlcKey, receiverHtlcKey,
//
// - The timeout path:
// <remote_htlcpubkey> OP_CHECKSIG
// OP_CHECKSEQUENCEVERIFY
// 1 OP_CHECKSEQUENCEVERIFY OP_DROP
// <cltv_expiry> OP_CHECKLOCKTIMEVERIFY OP_DROP
//
// - Success path:
Expand Down

0 comments on commit 048e4c7

Please sign in to comment.