Skip to content

Commit 15cdc5f

Browse files
committed
channeldb: add BalanceAboveDustForParty helper
We add this helper which will be used in a following commit. For the noop htlcs that we are going to add we need to know whether the "potential" receiver's balance is above dust, so we add this specific helper that helps us safely perform this check.
1 parent 93a6ab8 commit 15cdc5f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

channeldb/channel.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,6 +2127,27 @@ func (c *OpenChannel) clearChanStatus(status ChannelStatus) error {
21272127
return nil
21282128
}
21292129

2130+
// BalanceAboveDustForParty checks if the balance for the provided party is
2131+
// above the configured dust limit.
2132+
func (c *OpenChannel) BalanceAboveDustForParty(
2133+
party lntypes.ChannelParty) bool {
2134+
2135+
c.Lock()
2136+
defer c.Unlock()
2137+
2138+
dust := c.LocalChanCfg.DustLimit
2139+
2140+
switch {
2141+
case party.IsLocal():
2142+
return c.LocalCommitment.LocalBalance.ToSatoshis() > dust
2143+
2144+
case party.IsRemote():
2145+
return c.RemoteCommitment.RemoteBalance.ToSatoshis() > dust
2146+
}
2147+
2148+
return false
2149+
}
2150+
21302151
// putOpenChannel serializes, and stores the current state of the channel in its
21312152
// entirety.
21322153
func putOpenChannel(chanBucket kvdb.RwBucket, channel *OpenChannel) error {

0 commit comments

Comments
 (0)