Skip to content

Commit

Permalink
Merge pull request #9447 from yyforyongyu/yy-sweeper-fix
Browse files Browse the repository at this point in the history
sweep: start tracking input spending status in the fee bumper
  • Loading branch information
Roasbeef authored Feb 21, 2025
2 parents 09a4d7e + 9f7e2bf commit 553899b
Show file tree
Hide file tree
Showing 13 changed files with 2,205 additions and 502 deletions.
2 changes: 1 addition & 1 deletion chainntnfs/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (m *MempoolNotifier) findRelevantInputs(tx *btcutil.Tx) (inputsWithTx,

// If found, save it to watchedInputs to notify the
// subscriber later.
Log.Infof("Found input %s, spent in %s", op, txid)
Log.Debugf("Found input %s, spent in %s", op, txid)

// Construct the spend details.
details := &SpendDetail{
Expand Down
10 changes: 7 additions & 3 deletions contractcourt/anchor_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,21 @@ func (c *anchorResolver) Resolve() (ContractResolver, error) {

select {
case sweepRes := <-c.sweepResultChan:
switch sweepRes.Err {
err := sweepRes.Err

switch {
// Anchor was swept successfully.
case nil:
case err == nil:
sweepTxID := sweepRes.Tx.TxHash()

spendTx = &sweepTxID
outcome = channeldb.ResolverOutcomeClaimed

// Anchor was swept by someone else. This is possible after the
// 16 block csv lock.
case sweep.ErrRemoteSpend:
case errors.Is(err, sweep.ErrRemoteSpend),
errors.Is(err, sweep.ErrInputMissing):

c.log.Warnf("our anchor spent by someone else")
outcome = channeldb.ResolverOutcomeUnclaimed

Expand Down
5 changes: 5 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ The underlying functionality between those two options remain the same.
* A code refactor that [replaces min/max helpers with built-in min/max
functions](https://github.com/lightningnetwork/lnd/pull/9451).

* [Unified](https://github.com/lightningnetwork/lnd/pull/9447) the monitoring
inputs spending logic in the sweeper so it can properly handle missing inputs
and recover from restart.


## Tooling and Documentation

* [Improved `lncli create` command help text](https://github.com/lightningnetwork/lnd/pull/9077)
Expand Down
4 changes: 4 additions & 0 deletions itest/list_on_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ var allTestCases = []*lntest.TestCase{
Name: "invoice migration",
TestFunc: testInvoiceMigration,
},
{
Name: "fee replacement",
TestFunc: testFeeReplacement,
},
}

// appendPrefixed is used to add a prefix to each test name in the subtests
Expand Down
Loading

0 comments on commit 553899b

Please sign in to comment.