From 7f7a1e041d70aebf585a769789f64f8e5165597f Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Sun, 15 Jan 2023 22:09:36 +0100 Subject: [PATCH] lnwallet: add log message for edge case also see discussion in #7108 --- docs/release-notes/release-notes-0.16.0.md | 4 ++++ lnwallet/channel.go | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/release-notes-0.16.0.md b/docs/release-notes/release-notes-0.16.0.md index c6f5f8170..6e6b3b74f 100644 --- a/docs/release-notes/release-notes-0.16.0.md +++ b/docs/release-notes/release-notes-0.16.0.md @@ -115,6 +115,9 @@ current gossip sync query status. * [Fix the issue of ghost UTXOs not being detected as spent if they were created with an external tool](https://github.com/lightningnetwork/lnd/pull/7243). +* [Add log message for edge + case](https://github.com/lightningnetwork/lnd/pull/7115). + ## Build [The project has updated to Go @@ -357,6 +360,7 @@ refactor the itest for code health and maintenance. * andreihod * Antoni Spaanderman * Carla Kirk-Cohen +* Carsten Otto * Conner Babinchak * cutiful * Daniel McNally diff --git a/lnwallet/channel.go b/lnwallet/channel.go index acdfdea05..dff44ac2e 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -7031,7 +7031,14 @@ func (lc *LightningChannel) availableCommitmentBalance(view *htlcView, // report our available balance just below the non-dust amount, to // avoid attempting HTLCs larger than this size. if theirBalance < htlcCommitFee && ourBalance >= nonDustHtlcAmt { - ourBalance = nonDustHtlcAmt - 1 + // see https://github.com/lightning/bolts/issues/728 + ourReportedBalance := nonDustHtlcAmt - 1 + lc.log.Infof("Reducing local balance (from %v to %v): "+ + "remote side does not have enough funds (%v < %v) to "+ + "pay for non-dust HTLC in case of unilateral close.", + ourBalance, ourReportedBalance, theirBalance, + htlcCommitFee) + ourBalance = ourReportedBalance } return ourBalance, commitWeight