What changed, and why it matters
This commit is a routine internal code cleanup in the LND lightning node software. It changes the peer package to use a new dedicated channel-state type (chanstate.OpenChannel) instead of an older alias from the channeldb package. There are no user-facing changes, no bug fixes, and no security-related behavior changes visible in the diff.
No security action required. Treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors the peer package to reference chanstate.OpenChannel directly rather than channeldb.OpenChannel. The diff shows only type renames and import updates across peer/brontide.go, peer/brontide_test.go, and peer/test_utils.go. The commit message explicitly frames this as a structural boundary cleanup: removing the OpenChannel alias from the public channel-state boundary while keeping channeldb for store-level errors and helpers. No functional logic changes are present.
Changed components
peer/brontide.gopeer/brontide_test.gopeer/test_utils.goInspect captured patch +22 / −19
diff --git a/peer/brontide.go b/peer/brontide.go
index 0a22005..193f20d 100644
--- a/peer/brontide.go
+++ b/peer/brontide.go
@@ -123,7 +123,7 @@ type outgoingMsg struct {
errChan chan error // MUST be buffered.
}
-// newChannelMsg packages a channeldb.OpenChannel with a channel that allows
+// newChannelMsg packages a chanstate.OpenChannel with a channel that allows
// the receiver of the request to report when the channel creation process has
// completed.
type newChannelMsg struct {
@@ -1142,7 +1142,9 @@ func (p *Brontide) addrWithInternalKey(
// channels returned by the database. It returns a slice of channel reestablish
// messages that should be sent to the peer immediately, in case we have borked
// channels that haven't been closed yet.
-func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
+//
+//nolint:funlen
+func (p *Brontide) loadActiveChannels(chans []*chanstate.OpenChannel) (
[]lnwire.Message, error) {
// Return a slice of messages to send to the peers in case the channel
@@ -1592,7 +1594,7 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint,
// maybeSendNodeAnn sends our node announcement to the remote peer if at least
// one confirmed public channel exists with them.
-func (p *Brontide) maybeSendNodeAnn(channels []*channeldb.OpenChannel) {
+func (p *Brontide) maybeSendNodeAnn(channels []*chanstate.OpenChannel) {
defer p.cg.WgDone()
hasConfirmedPublicChan := false
@@ -5496,7 +5498,7 @@ func (p *Brontide) attachChannelEventSubscription() error {
// updateNextRevocation updates the existing channel's next revocation if it's
// nil.
-func (p *Brontide) updateNextRevocation(c *channeldb.OpenChannel) error {
+func (p *Brontide) updateNextRevocation(c *chanstate.OpenChannel) error {
chanPoint := c.FundingOutpoint
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
@@ -5538,7 +5540,7 @@ func (p *Brontide) updateNextRevocation(c *channeldb.OpenChannel) error {
}
// addActiveChannel adds a new active channel to the `activeChannels` map. It
-// takes a `channeldb.OpenChannel`, creates a `lnwallet.LightningChannel` from
+// takes a `chanstate.OpenChannel`, creates a `lnwallet.LightningChannel` from
// it and assembles it with a channel link.
func (p *Brontide) addActiveChannel(c *lnpeer.NewChannel) error {
chanPoint := c.FundingOutpoint
@@ -5797,7 +5799,7 @@ func (p *Brontide) scaleTimeout(timeout time.Duration) time.Duration {
// bandwidth against the traffic shaper.
type auxHtlcValidator struct {
peer *Brontide
- dbChan *channeldb.OpenChannel
+ dbChan *chanstate.OpenChannel
ts htlcswitch.AuxTrafficShaper
}
@@ -5873,7 +5875,7 @@ func (v *auxHtlcValidator) ValidateHtlc(amount,
// createHtlcValidator creates an HTLC validator that performs final aux balance
// validation before HTLCs are added to the channel state.
-func (p *Brontide) createHtlcValidator(dbChan *channeldb.OpenChannel,
+func (p *Brontide) createHtlcValidator(dbChan *chanstate.OpenChannel,
ts htlcswitch.AuxTrafficShaper) lnwallet.AuxHtlcValidator {
return &auxHtlcValidator{
diff --git a/peer/brontide_test.go b/peer/brontide_test.go
index db2f35e..ee6efbb 100644
--- a/peer/brontide_test.go
+++ b/peer/brontide_test.go
@@ -13,7 +13,7 @@ import (
"github.com/btcsuite/btcd/txscript/v2"
"github.com/btcsuite/btcd/wire/v2"
"github.com/lightningnetwork/lnd/chainntnfs"
- "github.com/lightningnetwork/lnd/channeldb"
+ "github.com/lightningnetwork/lnd/chanstate"
"github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/htlcswitch"
@@ -765,7 +765,7 @@ func TestCustomShutdownScript(t *testing.T) {
// setShutdown is a function which sets the upfront shutdown address for
// the local channel.
- setShutdown := func(a, b *channeldb.OpenChannel) {
+ setShutdown := func(a, b *chanstate.OpenChannel) {
a.LocalShutdownScript = script
b.RemoteShutdownScript = script
}
@@ -775,7 +775,7 @@ func TestCustomShutdownScript(t *testing.T) {
// update is a function used to set values on the channel set up for the
// test. It is used to set values for upfront shutdown addresses.
- update func(a, b *channeldb.OpenChannel)
+ update func(a, b *chanstate.OpenChannel)
// userCloseScript is the address specified by the user.
userCloseScript lnwire.DeliveryAddress
@@ -1222,8 +1222,8 @@ func assertMsgSent(t *testing.T, conn *mockMessageConn,
func TestAlwaysSendChannelUpdate(t *testing.T) {
require := require.New(t)
- var channel *channeldb.OpenChannel
- channelIntercept := func(a, b *channeldb.OpenChannel) {
+ var channel *chanstate.OpenChannel
+ channelIntercept := func(a, b *chanstate.OpenChannel) {
channel = a
}
@@ -1432,8 +1432,8 @@ func TestStartupWriteMessageRace(t *testing.T) {
// createTestPeerWithChannel, so we can mark it borked below.
// We can't mark it borked within the callback, since the channel hasn't
// been saved to the DB yet when the callback executes.
- var channel *channeldb.OpenChannel
- getChannels := func(a, b *channeldb.OpenChannel) {
+ var channel *chanstate.OpenChannel
+ getChannels := func(a, b *chanstate.OpenChannel) {
channel = a
}
@@ -1633,7 +1633,7 @@ func TestCreateHtlcValidator(t *testing.T) {
}
// Create a mock channel with minimal required fields.
- dbChan := &channeldb.OpenChannel{
+ dbChan := &chanstate.OpenChannel{
ShortChannelID: lnwire.NewShortChanIDFromInt(123),
}
diff --git a/peer/test_utils.go b/peer/test_utils.go
index f2c0097..10af396 100644
--- a/peer/test_utils.go
+++ b/peer/test_utils.go
@@ -18,6 +18,7 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channelnotifier"
+ "github.com/lightningnetwork/lnd/chanstate"
"github.com/lightningnetwork/lnd/fn/v2"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/htlcswitch"
@@ -55,7 +56,7 @@ var (
// noUpdate is a function which can be used as a parameter in
// createTestPeerWithChannel to call the setup code with no custom values on
// the channels set up.
-var noUpdate = func(a, b *channeldb.OpenChannel) {}
+var noUpdate = func(a, b *chanstate.OpenChannel) {}
type peerTestCtx struct {
peer *Brontide
@@ -75,7 +76,7 @@ type peerTestCtx struct {
// It takes an updateChan function which can be used to modify the default
// values on the channel states for each peer.
func createTestPeerWithChannel(t *testing.T, updateChan func(a,
- b *channeldb.OpenChannel)) (*peerTestCtx, error) {
+ b *chanstate.OpenChannel)) (*peerTestCtx, error) {
params := createTestPeer(t)
@@ -238,7 +239,7 @@ func createTestPeerWithChannel(t *testing.T, updateChan func(a,
binary.BigEndian.Uint64(chanIDBytes[:]),
)
- aliceChannelState := &channeldb.OpenChannel{
+ aliceChannelState := &chanstate.OpenChannel{
LocalChanCfg: aliceCfg,
RemoteChanCfg: bobCfg,
IdentityPub: aliceKeyPub,
@@ -255,7 +256,7 @@ func createTestPeerWithChannel(t *testing.T, updateChan func(a,
Db: dbAlice.ChannelStateDB(),
FundingTxn: channels.TestFundingTx,
}
- bobChannelState := &channeldb.OpenChannel{
+ bobChannelState := &chanstate.OpenChannel{
LocalChanCfg: bobCfg,
RemoteChanCfg: aliceCfg,
IdentityPub: bobKeyPub,
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.