What changed, and why it matters
This commit is a small internal code cleanup in LND's channel-fitness subsystem. It swaps one internal Go data type for another equivalent one (moving from channeldb to a newer chanstate package) in test and production code. There is no user-facing behavior change, no bug fix, and no security-relevant change visible in the diff.
No security action required. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch changes the chanfitness package to use chanstate.OpenChannel and chanstate.ChannelCloseSummary instead of channeldb.OpenChannel and channeldb.ChannelCloseSummary for event payloads. The persistence layer still uses channeldb.FlapCount. Imports and type signatures in chaneventstore.go and two test files are updated accordingly. No logic, validation, serialization, or access-control changes are present.
Changed components
chanfitness/chaneventstore.gochanfitness/chaneventstore_test.gochanfitness/chaneventstore_testctx_test.goInspect captured patch +9 / −6
diff --git a/chanfitness/chaneventstore.go b/chanfitness/chaneventstore.go
index 9fc4296..016f67d 100644
--- a/chanfitness/chaneventstore.go
+++ b/chanfitness/chaneventstore.go
@@ -20,6 +20,7 @@ import (
"github.com/btcsuite/btcd/wire/v2"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channelnotifier"
+ "github.com/lightningnetwork/lnd/chanstate"
"github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/peernotifier"
"github.com/lightningnetwork/lnd/routing/route"
@@ -84,7 +85,7 @@ type Config struct {
// GetOpenChannels provides a list of existing open channels which is
// used to populate the ChannelEventStore with a set of channels on
// startup.
- GetOpenChannels func() ([]*channeldb.OpenChannel, error)
+ GetOpenChannels func() ([]*chanstate.OpenChannel, error)
// IsPeerOnline returns whether the peer with the given pubkey is
// currently connected. It is used to seed the initial online state of a
diff --git a/chanfitness/chaneventstore_test.go b/chanfitness/chaneventstore_test.go
index 09dc1ce..eed1d12 100644
--- a/chanfitness/chaneventstore_test.go
+++ b/chanfitness/chaneventstore_test.go
@@ -8,6 +8,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire/v2"
"github.com/lightningnetwork/lnd/channeldb"
+ "github.com/lightningnetwork/lnd/chanstate"
"github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/routing/route"
"github.com/lightningnetwork/lnd/subscribe"
@@ -35,7 +36,7 @@ func TestStartStoreError(t *testing.T) {
name string
ChannelEvents func() (subscribe.Subscription, error)
PeerEvents func() (subscribe.Subscription, error)
- GetChannels func() ([]*channeldb.OpenChannel, error)
+ GetChannels func() ([]*chanstate.OpenChannel, error)
}{
{
name: "Channel events fail",
@@ -50,7 +51,7 @@ func TestStartStoreError(t *testing.T) {
name: "Get open channels fails",
ChannelEvents: okSubscribeFunc,
PeerEvents: okSubscribeFunc,
- GetChannels: func() ([]*channeldb.OpenChannel, error) {
+ GetChannels: func() ([]*chanstate.OpenChannel, error) {
return nil, errors.New("intentional test err")
},
},
diff --git a/chanfitness/chaneventstore_testctx_test.go b/chanfitness/chaneventstore_testctx_test.go
index dca7580..72a2530 100644
--- a/chanfitness/chaneventstore_testctx_test.go
+++ b/chanfitness/chaneventstore_testctx_test.go
@@ -9,6 +9,7 @@ import (
"github.com/btcsuite/btcd/wire/v2"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channelnotifier"
+ "github.com/lightningnetwork/lnd/chanstate"
"github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/peernotifier"
"github.com/lightningnetwork/lnd/routing/route"
@@ -83,7 +84,7 @@ func newChanEventStoreTestCtx(t *testing.T) *chanEventStoreTestCtx {
SubscribePeerEvents: func() (subscribe.Subscription, error) {
return testCtx.peerSubscription, nil
},
- GetOpenChannels: func() ([]*channeldb.OpenChannel, error) {
+ GetOpenChannels: func() ([]*chanstate.OpenChannel, error) {
return nil, nil
},
WriteFlapCount: func(updates map[route.Vertex]*channeldb.FlapCount) error {
@@ -192,7 +193,7 @@ func (c *chanEventStoreTestCtx) closeChannel(channel wire.OutPoint,
peer *btcec.PublicKey) {
update := channelnotifier.ClosedChannelEvent{
- CloseSummary: &channeldb.ChannelCloseSummary{
+ CloseSummary: &chanstate.ChannelCloseSummary{
ChanPoint: channel,
RemotePub: peer,
},
@@ -232,7 +233,7 @@ func (c *chanEventStoreTestCtx) sendChannelOpenedUpdate(pubkey *btcec.PublicKey,
channel wire.OutPoint) {
update := channelnotifier.OpenChannelEvent{
- Channel: &channeldb.OpenChannel{
+ Channel: &chanstate.OpenChannel{
FundingOutpoint: channel,
IdentityPub: pubkey,
},
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.