What changed, and why it matters
This commit is a straightforward internal code refactor. It moves the actual database-saving logic for storing a 'next revocation' key from the OpenChannel object to a new ChannelStateDB method, while keeping the same locking behavior and adding the method to an interface. There is no visible change to security behavior, data validation, or access control in the diff.
No security action required. Review as normal code-quality refactor if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors InsertNextRevocation in channeldb/channel.go. Previously OpenChannel.InsertNextRevocation set channel.RemoteNextRevocation and performed a kvdb.Update directly. Now it delegates to c.Db.InsertNextRevocation(c, revKey), and a new ChannelStateDB.InsertNextRevocation method performs the same kvdb.Update and putChanRevocationState call. The OpenChannel receiver retains its external locking. The chanstate/interface.go adds InsertNextRevocation to the OpenChannelCommitmentStore interface. Logic, serialization, and error paths are preserved.
Changed components
channeldb/channel.gochanstate/interface.goInspect captured patch +17 / −4
diff --git a/channeldb/channel.go b/channeldb/channel.go
index c69ce94..1c70f48 100644
--- a/channeldb/channel.go
+++ b/channeldb/channel.go
@@ -3156,17 +3156,26 @@ func (c *OpenChannel) InsertNextRevocation(revKey *btcec.PublicKey) error {
c.Lock()
defer c.Unlock()
- c.RemoteNextRevocation = revKey
+ return c.Db.InsertNextRevocation(c, revKey)
+}
- err := kvdb.Update(c.Db.backend, func(tx kvdb.RwTx) error {
+// InsertNextRevocation inserts the next commitment point into the persisted
+// channel state.
+func (c *ChannelStateDB) InsertNextRevocation(channel *OpenChannel,
+ revKey *btcec.PublicKey) error {
+
+ channel.RemoteNextRevocation = revKey
+
+ err := kvdb.Update(c.backend, func(tx kvdb.RwTx) error {
chanBucket, err := fetchChanBucketRw(
- tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
+ tx, channel.IdentityPub, &channel.FundingOutpoint,
+ channel.ChainHash,
)
if err != nil {
return err
}
- return putChanRevocationState(chanBucket, c)
+ return putChanRevocationState(chanBucket, channel)
}, func() {})
if err != nil {
return err
diff --git a/chanstate/interface.go b/chanstate/interface.go
index e43e8f0..7d89279 100644
--- a/chanstate/interface.go
+++ b/chanstate/interface.go
@@ -249,6 +249,10 @@ type OpenChannelCommitmentStore[Channel any] interface {
// RemoteUnsignedLocalUpdates retrieves the persisted, unsigned local
// log updates that the remote still needs to sign for.
RemoteUnsignedLocalUpdates(channel Channel) ([]LogUpdate, error)
+
+ // InsertNextRevocation inserts the next commitment point into the
+ // persisted channel state.
+ InsertNextRevocation(channel Channel, revKey *btcec.PublicKey) error
}
// ClosedChannelStore owns closed-channel summaries and lifecycle mutations.
Why this scored 12/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.