Skip to content

Commit f44cdd1

Browse files
committed
tapchannel: add an extra budget for each input w/ a blob
In this commit, we fix an issue that would cause lnd to not broadcast sweeps of HTLCs due to their small value. Before we didn't add enough budget to actually convince lnd to init the fee function and broadcast the sweep. In the future, we should do a more careful calculation here based on the current BTC value of the asset, to make an economical decision. For now, we just increase the amt based on the amt of inputs we have. This gives lnd a fee budget to use for bumping.
1 parent c072d3f commit f44cdd1

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

tapchannel/aux_sweeper.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ import (
3838
"golang.org/x/exp/maps"
3939
)
4040

41+
const (
42+
// sweeperBudgetMultiplier is the multiplier used to determine the
43+
// budget expressed in sats, report to lnd's sweeper. As we have small
44+
// outputs on chain, we'll need an increased budget (the amount we
45+
// should spend on fees) to make sure the outputs are always swept.
46+
sweeperBudgetMultiplier = 20
47+
)
48+
4149
// resolutionReq carries a request to resolve a contract output along with a
4250
// response channel of the result.
4351
type resolutionReq struct {
@@ -2445,13 +2453,22 @@ func (a *AuxSweeper) DeriveSweepAddr(inputs []input.Input,
24452453
func (a *AuxSweeper) ExtraBudgetForInputs(
24462454
inputs []input.Input) lfn.Result[btcutil.Amount] {
24472455

2448-
hasResolutionBlob := fn.Any(inputs, func(i input.Input) bool {
2456+
inputsWithBlobs := fn.Filter(inputs, func(i input.Input) bool {
24492457
return i.ResolutionBlob().IsSome()
24502458
})
24512459

24522460
var extraBudget btcutil.Amount
2453-
if hasResolutionBlob {
2454-
extraBudget = tapsend.DummyAmtSats
2461+
if len(inputsWithBlobs) != 0 {
2462+
// In this case, just 1k sats (tapsend.DummyAmtSats) may not be
2463+
// enough budget to pay for sweeping. So instead, we'll use a
2464+
// multiple of this to ensure that any time we care about an
2465+
// output, we're pretty much always able to sweep it.
2466+
//
2467+
// TODO(roasbeef): return the sats equiv budget of the asset
2468+
// amount
2469+
extraBudget = tapsend.DummyAmtSats * btcutil.Amount(
2470+
sweeperBudgetMultiplier*len(inputsWithBlobs),
2471+
)
24552472
}
24562473

24572474
return lfn.Ok(extraBudget)

0 commit comments

Comments
 (0)