mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 14:22:37 +01:00
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.
This commit is contained in:
parent
81987f050d
commit
e8a37e1414
2 changed files with 11 additions and 6 deletions
|
@ -1267,7 +1267,7 @@ func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) error {
|
|||
)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("wait for spend: %w", err)
|
||||
s.markInputFatal(pi, err)
|
||||
s.markInputFatal(pi, nil, err)
|
||||
|
||||
return err
|
||||
}
|
||||
|
@ -1482,12 +1482,17 @@ func (s *UtxoSweeper) markInputsSwept(tx *wire.MsgTx, isOurTx bool) {
|
|||
|
||||
// markInputFatal marks the given input as fatal and won't be retried. It
|
||||
// will also notify all the subscribers of this input.
|
||||
func (s *UtxoSweeper) markInputFatal(pi *SweeperInput, err error) {
|
||||
func (s *UtxoSweeper) markInputFatal(pi *SweeperInput, tx *wire.MsgTx,
|
||||
err error) {
|
||||
|
||||
log.Errorf("Failed to sweep input: %v, error: %v", pi, err)
|
||||
|
||||
pi.state = Fatal
|
||||
|
||||
s.signalResult(pi, Result{Err: err})
|
||||
s.signalResult(pi, Result{
|
||||
Tx: tx,
|
||||
Err: err,
|
||||
})
|
||||
}
|
||||
|
||||
// updateSweeperInputs updates the sweeper's internal state and returns a map
|
||||
|
@ -1819,7 +1824,7 @@ func (s *UtxoSweeper) markInputsFatal(set InputSet, err error) {
|
|||
continue
|
||||
}
|
||||
|
||||
s.markInputFatal(input, err)
|
||||
s.markInputFatal(input, nil, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1932,7 +1937,7 @@ func (s *UtxoSweeper) handleUnknownSpendTx(inp *SweeperInput, tx *wire.MsgTx) {
|
|||
|
||||
// Since the input is spent by others, we now mark it as fatal and won't
|
||||
// be retried.
|
||||
s.markInputFatal(inp, ErrRemoteSpend)
|
||||
s.markInputFatal(inp, tx, ErrRemoteSpend)
|
||||
|
||||
log.Debugf("Removing descendant txns invalidated by (txid=%v): %v",
|
||||
txid, lnutils.SpewLogClosure(tx))
|
||||
|
|
|
@ -596,7 +596,7 @@ func TestMarkInputFailed(t *testing.T) {
|
|||
}
|
||||
|
||||
// Call the method under test.
|
||||
s.markInputFatal(pi, errors.New("dummy error"))
|
||||
s.markInputFatal(pi, nil, errors.New("dummy error"))
|
||||
|
||||
// Assert the state is updated.
|
||||
require.Equal(t, Fatal, pi.state)
|
||||
|
|
Loading…
Add table
Reference in a new issue