contractcourt: force the sweeper to always resolve outgoing HTLCs

In this commit, we attempt to fix an issue that may lead to force closes due
to small value HTLCs. The sweeper has built in a "negative yield" heuristic
where it won't sweep something that'll result in paying more fees than the
HTLC amount. However for HTLCs, we want to always sweep them, as we don't
cancel back the HTLCs before the outgoing contract is fully resolved.

In the future, we'll start to make more uneconomical decisions about if we
should go to chain at all for small value HTLCs, and also do things like
cancel back early if the HTLC is small and we think we might be contested by
chain fees.
This commit is contained in:
Olaoluwa Osuntokun 2023-05-24 12:59:00 -07:00
parent bbbf7d33fb
commit 7686d10075
2 changed files with 5 additions and 3 deletions

View file

@ -327,6 +327,7 @@ func (h *htlcTimeoutResolver) sweepSecondLevelTx() error {
Fee: sweep.FeePreference{
ConfTarget: secondLevelConfTarget,
},
Force: true,
},
)

View file

@ -781,9 +781,10 @@ func (u *UtxoNursery) sweepMatureOutputs(classHeight uint32,
// passed in with disastrous consequences.
local := output
resultChan, err := u.cfg.SweepInput(
&local, sweep.Params{Fee: feePref},
)
resultChan, err := u.cfg.SweepInput(&local, sweep.Params{
Fee: feePref,
Force: true,
})
if err != nil {
return err
}