Skip to content

Commit 4d95ae2

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 2e30033 commit 4d95ae2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tapchannel/aux_sweeper.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,13 +2463,22 @@ func (a *AuxSweeper) DeriveSweepAddr(inputs []input.Input,
24632463
func (a *AuxSweeper) ExtraBudgetForInputs(
24642464
inputs []input.Input) lfn.Result[btcutil.Amount] {
24652465

2466-
hasResolutionBlob := fn.Any(inputs, func(i input.Input) bool {
2466+
inputsWithBlobs := fn.Filter(inputs, func(i input.Input) bool {
24672467
return i.ResolutionBlob().IsSome()
24682468
})
24692469

24702470
var extraBudget btcutil.Amount
2471-
if hasResolutionBlob {
2472-
extraBudget = tapsend.DummyAmtSats
2471+
if len(inputsWithBlobs) != 0 {
2472+
// In this case, just 1k sats (tapsend.DummyAmtSats) may not be
2473+
// enough budget to pay for sweeping. So instead, we'll use a
2474+
// multiple of this to ensure that any time we care about an
2475+
// output, we're pretty much always able to sweep it.
2476+
//
2477+
// TODO(roasbeef): return the sats equiv budget of the asset
2478+
// amount
2479+
extraBudget = tapsend.DummyAmtSats * btcutil.Amount(
2480+
20*len(inputsWithBlobs),
2481+
)
24732482
}
24742483

24752484
return lfn.Ok(extraBudget)

0 commit comments

Comments
 (0)