@@ -483,13 +483,20 @@ func (h *htlcTimeoutResolver) sweepSecondLevelTx() error {
483
483
h .broadcastHeight ,
484
484
))
485
485
}
486
+
486
487
_ , err := h .Sweeper .SweepInput (
487
488
inp ,
488
489
sweep.Params {
489
490
Fee : sweep.FeeEstimateInfo {
490
491
ConfTarget : secondLevelConfTarget ,
491
492
},
492
493
Force : true ,
494
+
495
+ // TODO(yy): make this a user-config option.
496
+ Budget : btcutil .Amount (inp .SignDesc ().Output .Value ),
497
+
498
+ // TODO(yy): specify a no-deadline here.
499
+ // DeadlineHeight:
493
500
},
494
501
)
495
502
if err != nil {
@@ -699,12 +706,38 @@ func (h *htlcTimeoutResolver) handleCommitSpend(
699
706
h .htlcResolution .CsvDelay , h .broadcastHeight ,
700
707
h .htlc .RHash ,
701
708
)
709
+ // Get the tx-level nLocktime for this HTLC.
710
+ nLocktime , required := inp .RequiredLockTime ()
711
+ if ! required {
712
+ log .Errorf ("%T(%x): second level tx not timelocked" , h ,
713
+ h .htlc .RHash [:])
714
+ }
715
+
702
716
_ , err = h .Sweeper .SweepInput (
703
717
inp ,
704
718
sweep.Params {
705
719
Fee : sweep.FeeEstimateInfo {
706
720
ConfTarget : sweepConfTarget ,
707
721
},
722
+
723
+ // TODO(yy): make this a user-config option.
724
+ Budget : btcutil .Amount (
725
+ inp .SignDesc ().Output .Value ,
726
+ ),
727
+
728
+ // For first level timeout tx, we'll use the
729
+ // nLocktime as the deadline, tho the actual
730
+ // deadline should be the CTLV inside this
731
+ // HTLC's corresponding incoming HTLC. It's ok
732
+ // if the tx is not cofnirmed by nLocktime, as
733
+ // if the remote decides to go with the
734
+ // preimage path, we will notice the preimage
735
+ // and settled the incoming HTLC anyway. We
736
+ // still need to set a deadline here, as it's
737
+ // required that when grouping
738
+ // SINGLE|ANYONECANPAY txes, the nLocktime of
739
+ // all inputs must be the same.
740
+ DeadlineHeight : int32 (nLocktime ),
708
741
},
709
742
)
710
743
if err != nil {
0 commit comments