What changed, and why it matters
This commit is a simple code reorganization: it moves a data structure called ChannelSnapshot from one package (channeldb) to another (chanstate), and leaves a compatibility alias so existing code keeps working. There are no functional changes, no bug fixes, and no security implications.
No security action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch relocates the ChannelSnapshot struct definition from channeldb/channel.go to a new file chanstate/snapshot.go. The original location is replaced with a type alias (type ChannelSnapshot = cstate.ChannelSnapshot). Field definitions, types, comments, and behavior are identical. No logic, serialization, access control, or API surface changes.
Changed components
channeldb/channel.gochanstate/snapshot.goInspect captured patch +46 / −34
diff --git a/channeldb/channel.go b/channeldb/channel.go
index 7ce0078..eae8f2f 100644
--- a/channeldb/channel.go
+++ b/channeldb/channel.go
@@ -4013,40 +4013,8 @@ func (c *ChannelStateDB) closeChannelTombstone(channel *OpenChannel,
}, func() {})
}
-// ChannelSnapshot is a frozen snapshot of the current channel state. A
-// snapshot is detached from the original channel that generated it, providing
-// read-only access to the current or prior state of an active channel.
-//
-// TODO(roasbeef): remove all together? pretty much just commitment
-type ChannelSnapshot struct {
- // RemoteIdentity is the identity public key of the remote node that we
- // are maintaining the open channel with.
- RemoteIdentity btcec.PublicKey
-
- // ChanPoint is the outpoint that created the channel. This output is
- // found within the funding transaction and uniquely identified the
- // channel on the resident chain.
- ChannelPoint wire.OutPoint
-
- // ChainHash is the genesis hash of the chain that the channel resides
- // within.
- ChainHash chainhash.Hash
-
- // Capacity is the total capacity of the channel.
- Capacity btcutil.Amount
-
- // TotalMSatSent is the total number of milli-satoshis we've sent
- // within this channel.
- TotalMSatSent lnwire.MilliSatoshi
-
- // TotalMSatReceived is the total number of milli-satoshis we've
- // received within this channel.
- TotalMSatReceived lnwire.MilliSatoshi
-
- // ChannelCommitment is the current up-to-date commitment for the
- // target channel.
- ChannelCommitment
-}
+// ChannelSnapshot is a frozen snapshot of the current channel state.
+type ChannelSnapshot = cstate.ChannelSnapshot
// Snapshot returns a read-only snapshot of the current channel state. This
// snapshot includes information concerning the current settled balance within
diff --git a/chanstate/snapshot.go b/chanstate/snapshot.go
new file mode 100644
index 0000000..2bae2ed
--- /dev/null
+++ b/chanstate/snapshot.go
@@ -0,0 +1,44 @@
+package chanstate
+
+import (
+ "github.com/btcsuite/btcd/btcec/v2"
+ "github.com/btcsuite/btcd/btcutil/v2"
+ "github.com/btcsuite/btcd/chainhash/v2"
+ "github.com/btcsuite/btcd/wire/v2"
+ "github.com/lightningnetwork/lnd/lnwire"
+)
+
+// ChannelSnapshot is a frozen snapshot of the current channel state. A
+// snapshot is detached from the original channel that generated it, providing
+// read-only access to the current or prior state of an active channel.
+//
+// TODO(roasbeef): remove all together? pretty much just commitment.
+type ChannelSnapshot struct {
+ // RemoteIdentity is the identity public key of the remote node that we
+ // are maintaining the open channel with.
+ RemoteIdentity btcec.PublicKey
+
+ // ChanPoint is the outpoint that created the channel. This output is
+ // found within the funding transaction and uniquely identified the
+ // channel on the resident chain.
+ ChannelPoint wire.OutPoint
+
+ // ChainHash is the genesis hash of the chain that the channel resides
+ // within.
+ ChainHash chainhash.Hash
+
+ // Capacity is the total capacity of the channel.
+ Capacity btcutil.Amount
+
+ // TotalMSatSent is the total number of milli-satoshis we've sent
+ // within this channel.
+ TotalMSatSent lnwire.MilliSatoshi
+
+ // TotalMSatReceived is the total number of milli-satoshis we've
+ // received within this channel.
+ TotalMSatReceived lnwire.MilliSatoshi
+
+ // ChannelCommitment is the current up-to-date commitment for the
+ // target channel.
+ ChannelCommitment
+}
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.