Skip to content

Commit e9dd01b

Browse files
authored
Merge pull request #9274 from ziggie1984/remove-2x-value
The sweeper subsystem uses now also the configured budget values for HTLCs
2 parents b958667 + f36f7c1 commit e9dd01b

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

contractcourt/htlc_timeout_resolver.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,9 @@ func (h *htlcTimeoutResolver) sweepTimeoutTx() error {
465465
}
466466

467467
// Calculate the budget.
468-
//
469-
// TODO(yy): the budget is twice the output's value, which is needed as
470-
// we don't force sweep the output now. To prevent cascading force
471-
// closes, we use all its output value plus a wallet input as the
472-
// budget. This is a temporary solution until we can optionally cancel
473-
// the incoming HTLC, more details in,
474-
// - https://github.com/lightningnetwork/lnd/issues/7969
475468
budget := calculateBudget(
476-
btcutil.Amount(inp.SignDesc().Output.Value), 2, 0,
469+
btcutil.Amount(inp.SignDesc().Output.Value),
470+
h.Budget.DeadlineHTLCRatio, h.Budget.DeadlineHTLC,
477471
)
478472

479473
h.log.Infof("offering 2nd-level HTLC timeout tx to sweeper "+
@@ -535,15 +529,9 @@ func (h *htlcTimeoutResolver) sweepDirectHtlcOutput() error {
535529
)
536530

537531
// Calculate the budget.
538-
//
539-
// TODO(yy): the budget is twice the output's value, which is needed as
540-
// we don't force sweep the output now. To prevent cascading force
541-
// closes, we use all its output value plus a wallet input as the
542-
// budget. This is a temporary solution until we can optionally cancel
543-
// the incoming HTLC, more details in,
544-
// - https://github.com/lightningnetwork/lnd/issues/7969
545532
budget := calculateBudget(
546-
btcutil.Amount(sweepInput.SignDesc().Output.Value), 2, 0,
533+
btcutil.Amount(sweepInput.SignDesc().Output.Value),
534+
h.Budget.DeadlineHTLCRatio, h.Budget.DeadlineHTLC,
547535
)
548536

549537
log.Infof("%T(%x): offering offered remote timeout HTLC output to "+

docs/release-notes/release-notes-0.19.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@
135135
block. Check
136136
[here](https://github.com/lightningnetwork/lnd/blob/master/chainio/README.md)
137137
to learn more.
138+
139+
* [The sweeper](https://github.com/lightningnetwork/lnd/pull/9274) does now also
140+
use the configured budget values for HTLCs (first level sweep) in parcticular
141+
`--sweeper.budget.deadlinehtlcratio` and `--sweeper.budget.deadlinehtlc`.
138142

139143
## RPC Updates
140144

itest/lnd_sweep_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -928,12 +928,7 @@ func testSweepHTLCs(ht *lntest.HarnessTest) {
928928
require.Len(ht, outgoingSweep.TxOut, 2)
929929

930930
// Calculate the ending fee rate.
931-
//
932-
// TODO(yy): the budget we use to sweep the first-level outgoing HTLC
933-
// is twice its value. This is a temporary mitigation to prevent
934-
// cascading FCs and the test should be updated once it's properly
935-
// fixed.
936-
outgoingBudget := 2 * invoiceAmt
931+
outgoingBudget := invoiceAmt.MulF64(contractcourt.DefaultBudgetRatio)
937932
outgoingTxSize := ht.CalculateTxWeight(outgoingSweep)
938933
outgoingEndFeeRate := chainfee.NewSatPerKWeight(
939934
outgoingBudget, outgoingTxSize,

0 commit comments

Comments
 (0)