Skip to content

Commit a4d8485

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 b7bf7a7 commit a4d8485

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
@@ -2368,13 +2368,22 @@ func (a *AuxSweeper) DeriveSweepAddr(inputs []input.Input,
23682368
func (a *AuxSweeper) ExtraBudgetForInputs(
23692369
inputs []input.Input) lfn.Result[btcutil.Amount] {
23702370

2371-
hasResolutionBlob := fn.Any(inputs, func(i input.Input) bool {
2371+
inputsWithBlobs := fn.Filter(inputs, func(i input.Input) bool {
23722372
return i.ResolutionBlob().IsSome()
23732373
})
23742374

23752375
var extraBudget btcutil.Amount
2376-
if hasResolutionBlob {
2377-
extraBudget = tapsend.DummyAmtSats
2376+
if len(inputsWithBlobs) != 0 {
2377+
// In this case, just 1k sats (tapsend.DummyAmtSats) may not be
2378+
// enough budget to pay for sweeping. So instead, we'll use a
2379+
// multiple of this to ensure that any time we care about an
2380+
// output, we're pretty much always able to sweep it.
2381+
//
2382+
// TODO(roasbeef): return the sats equiv budget of the asset
2383+
// amount
2384+
extraBudget = tapsend.DummyAmtSats * btcutil.Amount(
2385+
20*len(inputsWithBlobs),
2386+
)
23782387
}
23792388

23802389
return lfn.Ok(extraBudget)

0 commit comments

Comments
 (0)