What changed, and why it matters
This commit is a straightforward internal code reorganization. It moves three read-only database lookup methods from the OpenChannel type to the ChannelStateDB type, and adds matching method declarations to an interface. The actual database queries, data read, and data format are unchanged. There is no user-facing behavior change and no security fix or vulnerability introduced.
No security action needed. Treat as normal refactoring during code review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors three view-only KV store accessors—RemoteCommitChainTip, UnsignedAckedUpdates, and RemoteUnsignedLocalUpdates—so that OpenChannel receivers delegate to ChannelStateDB. The interface OpenChannelCommitmentStore in chanstate/interface.go is extended with the three new methods. The transaction bodies are copied almost verbatim, replacing c.Db.backend with c.backend and c. with channel.. No persisted data format changes, no new inputs are processed, and no cryptographic or network logic is modified.
Changed components
channeldb/channel.gochanstate/interface.goInspect captured patch +45 / −6
diff --git a/channeldb/channel.go b/channeldb/channel.go
index 601fe47..c69ce94 100644
--- a/channeldb/channel.go
+++ b/channeldb/channel.go
@@ -3013,10 +3013,19 @@ func (c *ChannelStateDB) AppendRemoteCommitChain(channel *OpenChannel,
// this new pending commitment. Once they revoked their prior state, we'll swap
// these pointers, causing the tip and the tail to point to the same entry.
func (c *OpenChannel) RemoteCommitChainTip() (*CommitDiff, error) {
+ return c.Db.RemoteCommitChainTip(c)
+}
+
+// RemoteCommitChainTip returns the "tip" of the current remote commitment
+// chain.
+func (c *ChannelStateDB) RemoteCommitChainTip(channel *OpenChannel) (
+ *CommitDiff, error) {
+
var cd *CommitDiff
- err := kvdb.View(c.Db.backend, func(tx kvdb.RTx) error {
+ err := kvdb.View(c.backend, func(tx kvdb.RTx) error {
chanBucket, err := fetchChanBucket(
- tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
+ tx, channel.IdentityPub, &channel.FundingOutpoint,
+ channel.ChainHash,
)
switch err {
case nil:
@@ -3052,10 +3061,19 @@ func (c *OpenChannel) RemoteCommitChainTip() (*CommitDiff, error) {
// UnsignedAckedUpdates retrieves the persisted unsigned acked remote log
// updates that still need to be signed for.
func (c *OpenChannel) UnsignedAckedUpdates() ([]LogUpdate, error) {
+ return c.Db.UnsignedAckedUpdates(c)
+}
+
+// UnsignedAckedUpdates retrieves the persisted unsigned acked remote log
+// updates that still need to be signed for.
+func (c *ChannelStateDB) UnsignedAckedUpdates(channel *OpenChannel) (
+ []LogUpdate, error) {
+
var updates []LogUpdate
- err := kvdb.View(c.Db.backend, func(tx kvdb.RTx) error {
+ err := kvdb.View(c.backend, func(tx kvdb.RTx) error {
chanBucket, err := fetchChanBucket(
- tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
+ tx, channel.IdentityPub, &channel.FundingOutpoint,
+ channel.ChainHash,
)
switch err {
case nil:
@@ -3086,10 +3104,19 @@ func (c *OpenChannel) UnsignedAckedUpdates() ([]LogUpdate, error) {
// RemoteUnsignedLocalUpdates retrieves the persisted, unsigned local log
// updates that the remote still needs to sign for.
func (c *OpenChannel) RemoteUnsignedLocalUpdates() ([]LogUpdate, error) {
+ return c.Db.RemoteUnsignedLocalUpdates(c)
+}
+
+// RemoteUnsignedLocalUpdates retrieves the persisted, unsigned local log
+// updates that the remote still needs to sign for.
+func (c *ChannelStateDB) RemoteUnsignedLocalUpdates(channel *OpenChannel) (
+ []LogUpdate, error) {
+
var updates []LogUpdate
- err := kvdb.View(c.Db.backend, func(tx kvdb.RTx) error {
+ err := kvdb.View(c.backend, func(tx kvdb.RTx) error {
chanBucket, err := fetchChanBucket(
- tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
+ tx, channel.IdentityPub, &channel.FundingOutpoint,
+ channel.ChainHash,
)
switch err {
case nil:
diff --git a/chanstate/interface.go b/chanstate/interface.go
index 323aa9c..e43e8f0 100644
--- a/chanstate/interface.go
+++ b/chanstate/interface.go
@@ -237,6 +237,18 @@ type OpenChannelCommitmentStore[Channel any] interface {
// party's commitment chain. This is used after preparing a new remote
// commitment state, before transmitting it to the remote party.
AppendRemoteCommitChain(channel Channel, diff *CommitDiff) error
+
+ // RemoteCommitChainTip returns the "tip" of the current remote
+ // commitment chain.
+ RemoteCommitChainTip(channel Channel) (*CommitDiff, error)
+
+ // UnsignedAckedUpdates retrieves the persisted unsigned acked remote
+ // log updates that still need to be signed for.
+ UnsignedAckedUpdates(channel Channel) ([]LogUpdate, error)
+
+ // RemoteUnsignedLocalUpdates retrieves the persisted, unsigned local
+ // log updates that the remote still needs to sign for.
+ RemoteUnsignedLocalUpdates(channel Channel) ([]LogUpdate, error)
}
// ClosedChannelStore owns closed-channel summaries and lifecycle mutations.
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.