From 7686d10075c98628dd9d232f8b8efe822b3ea013 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 24 May 2023 12:59:00 -0700 Subject: [PATCH] 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. --- contractcourt/htlc_timeout_resolver.go | 1 + contractcourt/utxonursery.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/contractcourt/htlc_timeout_resolver.go b/contractcourt/htlc_timeout_resolver.go index 095e538e4..0b3e8688d 100644 --- a/contractcourt/htlc_timeout_resolver.go +++ b/contractcourt/htlc_timeout_resolver.go @@ -327,6 +327,7 @@ func (h *htlcTimeoutResolver) sweepSecondLevelTx() error { Fee: sweep.FeePreference{ ConfTarget: secondLevelConfTarget, }, + Force: true, }, ) diff --git a/contractcourt/utxonursery.go b/contractcourt/utxonursery.go index 08b4a32be..3776a3546 100644 --- a/contractcourt/utxonursery.go +++ b/contractcourt/utxonursery.go @@ -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 }