Skip to content

Commit 4bd1a34

Browse files
committed
sweep: signal tx in markInputFatal
This commit adds the failed tx to the result when marking the input as fatal, which is used in the commit resolver when handling revoked outputs.
1 parent b184afe commit 4bd1a34

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

sweep/sweeper.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) error {
12671267
)
12681268
if err != nil {
12691269
err := fmt.Errorf("wait for spend: %w", err)
1270-
s.markInputFatal(pi, err)
1270+
s.markInputFatal(pi, nil, err)
12711271

12721272
return err
12731273
}
@@ -1482,12 +1482,17 @@ func (s *UtxoSweeper) markInputsSwept(tx *wire.MsgTx, isOurTx bool) {
14821482

14831483
// markInputFatal marks the given input as fatal and won't be retried. It
14841484
// will also notify all the subscribers of this input.
1485-
func (s *UtxoSweeper) markInputFatal(pi *SweeperInput, err error) {
1485+
func (s *UtxoSweeper) markInputFatal(pi *SweeperInput, tx *wire.MsgTx,
1486+
err error) {
1487+
14861488
log.Errorf("Failed to sweep input: %v, error: %v", pi, err)
14871489

14881490
pi.state = Fatal
14891491

1490-
s.signalResult(pi, Result{Err: err})
1492+
s.signalResult(pi, Result{
1493+
Tx: tx,
1494+
Err: err,
1495+
})
14911496
}
14921497

14931498
// updateSweeperInputs updates the sweeper's internal state and returns a map
@@ -1819,7 +1824,7 @@ func (s *UtxoSweeper) markInputsFatal(set InputSet, err error) {
18191824
continue
18201825
}
18211826

1822-
s.markInputFatal(input, err)
1827+
s.markInputFatal(input, nil, err)
18231828
}
18241829
}
18251830

@@ -1932,7 +1937,7 @@ func (s *UtxoSweeper) handleUnknownSpendTx(inp *SweeperInput, tx *wire.MsgTx) {
19321937

19331938
// Since the input is spent by others, we now mark it as fatal and won't
19341939
// be retried.
1935-
s.markInputFatal(inp, ErrRemoteSpend)
1940+
s.markInputFatal(inp, tx, ErrRemoteSpend)
19361941

19371942
log.Debugf("Removing descendant txns invalidated by (txid=%v): %v",
19381943
txid, lnutils.SpewLogClosure(tx))

sweep/sweeper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ func TestMarkInputFailed(t *testing.T) {
596596
}
597597

598598
// Call the method under test.
599-
s.markInputFatal(pi, errors.New("dummy error"))
599+
s.markInputFatal(pi, nil, errors.New("dummy error"))
600600

601601
// Assert the state is updated.
602602
require.Equal(t, Fatal, pi.state)

0 commit comments

Comments
 (0)