What changed, and why it matters
This is a routine code cleanup in LND's RPC server. It changes several internal helper functions to accept a more specific 'chanstate.OpenChannel' type instead of the broader 'channeldb.OpenChannel' alias. The functions only read channel state, so this is purely a type-refactoring change with no visible behavior or security effect.
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 RPC helper functions (calcRemainingConfs, getClosingTx closure, isPrivate, encodeCustomChanData, createRPCOpenChannel) to take chanstate.OpenChannel rather than channeldb.OpenChannel. It adds the corresponding import and removes the channeldb alias where no longer needed. The diff shows only type signature changes; no logic, validation, or data-flow changes are present.
Changed components
rpcserver.goRPC channel formatting helpersInspect captured patch +6 / −5
diff --git a/rpcserver.go b/rpcserver.go
index 884dfa0..52b682f 100644
--- a/rpcserver.go
+++ b/rpcserver.go
@@ -43,6 +43,7 @@ import (
"github.com/lightningnetwork/lnd/chanfitness"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channelnotifier"
+ "github.com/lightningnetwork/lnd/chanstate"
"github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/discovery"
@@ -4010,7 +4011,7 @@ type (
// 1. The current blockchain height
// 2. The block height at which the funding transaction was first confirmed
// 3. The total number of confirmations required for the channel.
-func calcRemainingConfs(pendingChan *channeldb.OpenChannel,
+func calcRemainingConfs(pendingChan *chanstate.OpenChannel,
currentHeight uint32) uint32 {
// If the funding transaction hasn't been confirmed yet,
@@ -4315,7 +4316,7 @@ func (r *rpcServer) fetchWaitingCloseChannels(
// getClosingTx is a helper closure that tries to find the closing tx of
// a given waiting close channel. Notice that if the remote closes the
// channel, we may not have the closing tx.
- getClosingTx := func(c *channeldb.OpenChannel) (*wire.MsgTx, error) {
+ getClosingTx := func(c *chanstate.OpenChannel) (*wire.MsgTx, error) {
var (
tx *wire.MsgTx
err error
@@ -4955,7 +4956,7 @@ func createChannelConstraint(
// isPrivate evaluates the ChannelFlags of the db channel to determine if the
// channel is private or not.
-func isPrivate(dbChannel *channeldb.OpenChannel) bool {
+func isPrivate(dbChannel *chanstate.OpenChannel) bool {
if dbChannel == nil {
return false
}
@@ -4964,7 +4965,7 @@ func isPrivate(dbChannel *channeldb.OpenChannel) bool {
// encodeCustomChanData encodes the custom channel data for the open channel.
// It encodes that data as a pair of var bytes blobs.
-func encodeCustomChanData(lnChan *channeldb.OpenChannel) ([]byte, error) {
+func encodeCustomChanData(lnChan *chanstate.OpenChannel) ([]byte, error) {
customOpenChanData := lnChan.CustomBlob.UnwrapOr(nil)
customLocalCommitData := lnChan.LocalCommitment.CustomBlob.UnwrapOr(nil)
@@ -4995,7 +4996,7 @@ func encodeCustomChanData(lnChan *channeldb.OpenChannel) ([]byte, error) {
//
//nolint:funlen
func createRPCOpenChannel(ctx context.Context, r *rpcServer,
- dbChannel *channeldb.OpenChannel,
+ dbChannel *chanstate.OpenChannel,
isActive, peerAliasLookup bool) (*lnrpc.Channel, error) {
nodePub := dbChannel.IdentityPub
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.