@@ -191,10 +191,18 @@ func runChannelForceClosureTest(ht *lntest.HarnessTest,
191
191
// expect Alice's anchor sweeping tx being published.
192
192
ht .MineBlocksAndAssertNumTxes (1 , 1 )
193
193
194
- // Assert Alice's has one pending anchor output - because she doesn't
195
- // have incoming HTLCs, her outgoing HTLC won't have a deadline, thus
196
- // she won't use the anchor to perform CPFP.
197
- aliceAnchor := ht .AssertNumPendingSweeps (alice , 1 )[0 ]
194
+ // Assert Alice's has one pending anchor output and the commit output
195
+ // sweep - because she doesn't have incoming HTLCs, her outgoing HTLC
196
+ // won't have a deadline, thus she won't use the anchor to perform CPFP.
197
+ sweeps := ht .AssertNumPendingSweeps (alice , 2 )
198
+
199
+ // Find the anchor sweep - assume it's the first one, and change to the
200
+ // second one if the first one has a larger value.
201
+ aliceAnchor := sweeps [0 ]
202
+ if aliceAnchor .AmountSat > sweeps [1 ].AmountSat {
203
+ aliceAnchor = sweeps [1 ]
204
+ }
205
+
198
206
require .Equal (ht , aliceAnchor .Outpoint .TxidStr ,
199
207
waitingClose .Commitments .LocalTxid )
200
208
@@ -250,8 +258,9 @@ func runChannelForceClosureTest(ht *lntest.HarnessTest,
250
258
// commit and anchor outputs.
251
259
ht .MineBlocksAndAssertNumTxes (1 , 1 )
252
260
253
- // Alice should still have the anchor sweeping request.
254
- ht .AssertNumPendingSweeps (alice , 1 )
261
+ // Alice should still have the anchor and commit output sweeping
262
+ // requests.
263
+ ht .AssertNumPendingSweeps (alice , 2 )
255
264
256
265
// Alice should see the channel in her set of pending force closed
257
266
// channels with her funds still in limbo.
@@ -282,8 +291,8 @@ func runChannelForceClosureTest(ht *lntest.HarnessTest,
282
291
283
292
// At this point, the CSV will expire in the next block, meaning that
284
293
// the output should be offered to the sweeper.
285
- sweeps := ht .AssertNumPendingSweeps (alice , 2 )
286
- commitSweep , anchorSweep := sweeps [0 ], sweeps [1 ]
294
+ aliceSweeps := ht .AssertNumPendingSweeps (alice , 2 )
295
+ commitSweep , anchorSweep := aliceSweeps [0 ], aliceSweeps [1 ]
287
296
if commitSweep .AmountSat < anchorSweep .AmountSat {
288
297
commitSweep = anchorSweep
289
298
}
@@ -790,10 +799,18 @@ func runChannelForceClosureTestRestart(ht *lntest.HarnessTest,
790
799
// expect Alice's anchor sweeping tx being published.
791
800
ht .MineBlocksAndAssertNumTxes (1 , 1 )
792
801
793
- // Assert Alice's has one pending anchor output - because she doesn't
794
- // have incoming HTLCs, her outgoing HTLC won't have a deadline, thus
795
- // she won't use the anchor to perform CPFP.
796
- aliceAnchor := ht .AssertNumPendingSweeps (alice , 1 )[0 ]
802
+ // Assert Alice's has one pending anchor output and the commit output
803
+ // sweep - because she doesn't have incoming HTLCs, her outgoing HTLC
804
+ // won't have a deadline, thus she won't use the anchor to perform CPFP.
805
+ sweeps := ht .AssertNumPendingSweeps (alice , 2 )
806
+
807
+ // Find the anchor sweep - assume it's the first one, and change to the
808
+ // second one if the first one has a larger value.
809
+ aliceAnchor := sweeps [0 ]
810
+ if aliceAnchor .AmountSat > sweeps [1 ].AmountSat {
811
+ aliceAnchor = sweeps [1 ]
812
+ }
813
+
797
814
require .Equal (ht , aliceAnchor .Outpoint .TxidStr ,
798
815
waitingClose .Commitments .LocalTxid )
799
816
@@ -860,8 +877,9 @@ func runChannelForceClosureTestRestart(ht *lntest.HarnessTest,
860
877
// commit and anchor outputs.
861
878
ht .MineBlocksAndAssertNumTxes (1 , 1 )
862
879
863
- // Alice should still have the anchor sweeping request.
864
- ht .AssertNumPendingSweeps (alice , 1 )
880
+ // Alice should still have the anchor and commit output sweeping
881
+ // requests.
882
+ ht .AssertNumPendingSweeps (alice , 2 )
865
883
866
884
// The following restart checks to ensure that outputs in the contract
867
885
// court are persisted while waiting for the required number of
@@ -918,7 +936,7 @@ func runChannelForceClosureTestRestart(ht *lntest.HarnessTest,
918
936
919
937
// At this point, the CSV will expire in the next block, meaning that
920
938
// the output should be offered to the sweeper.
921
- sweeps : = ht .AssertNumPendingSweeps (alice , 2 )
939
+ sweeps = ht .AssertNumPendingSweeps (alice , 2 )
922
940
commitSweep , anchorSweep := sweeps [0 ], sweeps [1 ]
923
941
if commitSweep .AmountSat < anchorSweep .AmountSat {
924
942
commitSweep , anchorSweep = anchorSweep , commitSweep
0 commit comments