Skip to content

Commit 82758bc

Browse files
committed
tapchannel: properly use htlc keys when making htlc tap descs
1 parent 49b4502 commit 82758bc

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

tapchannel/aux_sweeper.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ type tapscriptSweepDescs struct {
580580
func commitNoDelaySweepDesc(keyRing *lnwallet.CommitmentKeyRing,
581581
csvDelay uint32) lfn.Result[tapscriptSweepDescs] {
582582

583-
type returnType = tapscriptSweepDesc
583+
type returnType = tapscriptSweepDescs
584584

585585
// We'll make the script tree for the to remote script (we're remote as
586586
// this is their commitment transaction). We don't have an auxLeaf here
@@ -599,6 +599,7 @@ func commitNoDelaySweepDesc(keyRing *lnwallet.CommitmentKeyRing,
599599
input.ScriptPathSuccess,
600600
)
601601
if err != nil {
602+
return lfn.Err[returnType](err)
602603
}
603604
ctrlBlockBytes, err := ctrlBlock.ToBytes()
604605
if err != nil {
@@ -621,7 +622,7 @@ func commitNoDelaySweepDesc(keyRing *lnwallet.CommitmentKeyRing,
621622
func commitDelaySweepDesc(keyRing *lnwallet.CommitmentKeyRing,
622623
csvDelay uint32) lfn.Result[tapscriptSweepDescs] {
623624

624-
type returnType = tapscriptSweepDesc
625+
type returnType = tapscriptSweepDescs
625626

626627
// We'll make the script tree for the to remote script (we're remote as
627628
// this is their commitment transaction). We don't have an auxLeaf here
@@ -640,6 +641,7 @@ func commitDelaySweepDesc(keyRing *lnwallet.CommitmentKeyRing,
640641
input.ScriptPathSuccess,
641642
)
642643
if err != nil {
644+
return lfn.Err[returnType](err)
643645
}
644646
ctrlBlockBytes, err := ctrlBlock.ToBytes()
645647
if err != nil {
@@ -661,7 +663,7 @@ func commitDelaySweepDesc(keyRing *lnwallet.CommitmentKeyRing,
661663
func commitRevokeSweepDesc(keyRing *lnwallet.CommitmentKeyRing,
662664
csvDelay uint32) lfn.Result[tapscriptSweepDescs] {
663665

664-
type returnType = tapscriptSweepDesc
666+
type returnType = tapscriptSweepDescs
665667

666668
// To sweep their revoked output, we'll make the script tree for the
667669
// local tree of their commitment transaction, which is actually their
@@ -704,8 +706,9 @@ func remoteHtlcTimeoutSweepDesc(keyRing *lnwallet.CommitmentKeyRing,
704706
// We're sweeping a timed out HTLC, which means that we'll need to
705707
// create the receiver's HTLC script tree (from the remote party's PoV).
706708
htlcScriptTree, err := input.ReceiverHTLCScriptTaproot(
707-
htlcExpiry, keyRing.ToLocalKey, keyRing.ToRemoteKey,
708-
keyRing.RevocationKey, payHash, false, input.NoneTapLeaf(),
709+
htlcExpiry, keyRing.LocalHtlcKey, keyRing.RemoteHtlcKey,
710+
keyRing.RevocationKey, payHash, lntypes.Remote,
711+
input.NoneTapLeaf(),
709712
)
710713
if err != nil {
711714
return lfn.Err[tapscriptSweepDescs](err)
@@ -738,15 +741,15 @@ func remoteHtlcTimeoutSweepDesc(keyRing *lnwallet.CommitmentKeyRing,
738741
// the remote party's commitment transaction that we can sweep with the
739742
// preimage.
740743
func remoteHtlcSuccessSweepDesc(keyRing *lnwallet.CommitmentKeyRing,
741-
payHash []byte, csvDelay uint32,
742-
auxSigs lfn.Option[lnwallet.AuxSigDesc]) lfn.Result[tapscriptSweepDescs] {
744+
payHash []byte, csvDelay uint32) lfn.Result[tapscriptSweepDescs] {
743745

744746
// We're planning on sweeping an HTLC that we know the preimage to,
745747
// which the remote party sent, so we'll construct the sender version of
746748
// the HTLC script tree (from their PoV, they're the sender).
747749
htlcScriptTree, err := input.SenderHTLCScriptTaproot(
748-
keyRing.ToLocalKey, keyRing.ToRemoteKey, keyRing.RevocationKey,
749-
payHash, false, input.NoneTapLeaf(),
750+
keyRing.RemoteHtlcKey, keyRing.LocalHtlcKey,
751+
keyRing.RevocationKey, payHash, lntypes.Remote,
752+
input.NoneTapLeaf(),
750753
)
751754
if err != nil {
752755
return lfn.Err[tapscriptSweepDescs](err)

0 commit comments

Comments
 (0)