What changed, and why it matters
This commit is a small internal code cleanup in LND's channel database code. It adds a new public helper method that lets store/serialization code check a channel's status without grabbing a lock, and switches a few internal serialization functions to use it. There is no direct security fix or vulnerability being patched here; it appears to be preparation for a larger code reorganization.
No security action required. Treat as routine refactoring/migration work. If reviewing the broader migration, verify that callers of HasChanStatusForStore already hold appropriate synchronization or that the status bit is not mutated concurrently during store operations.
Security signals we found
No security-relevant behavioral change: the predicate logic is unchanged.
No bounds checks, input validation, cryptographic operations, or resource limits are modified.
No race condition or synchronization bug is introduced or fixed; the new method is explicitly documented as non-locking and for internal store callers only.
Commit message and diff do not mention a vulnerability, CVE, bug, or security issue.
Evidence from the diff
The change introduces OpenChannel.HasChanStatusForStore(status ChannelStatus) bool, a non-locking wrapper around the existing hasChanStatus helper. The commit message describes it as a ‘transitional migration hook’ for KV-backed store code while OpenChannel is being moved toward chanstate. Three existing call sites in fundingTxPresent, putChanCommitments, and fetchChanCommitments are switched from the unexported hasChanStatus to the new exported HasChanStatusForStore. The behavior is identical; the only difference is that the new method does not take the channel mutex (and the old helper also did not lock, per the existing hasChanStatus implementation).
Changed components
channeldb/channel.goOpenChannel status predicate helpersKV serialization helpers: fundingTxPresent, putChanCommitments, fetchChanCommitmentsInspect captured patch +14 / −3
diff --git a/channeldb/channel.go b/channeldb/channel.go
index 8985b70..729e313 100644
--- a/channeldb/channel.go
+++ b/channeldb/channel.go
@@ -962,6 +962,17 @@ func (c *OpenChannel) hasChanStatus(status ChannelStatus) bool {
return c.chanStatus&status == status
}
+// HasChanStatusForStore returns true if the internal bitfield channel status
+// has the specified status bit set, without taking the channel mutex.
+//
+// NOTE: This is a preliminary migration hook for KV-backed store code that
+// still lives in channeldb while OpenChannel moves toward chanstate. Callers
+// are responsible for synchronization. Normal callers should use
+// HasChanStatus.
+func (c *OpenChannel) HasChanStatusForStore(status ChannelStatus) bool {
+ return c.hasChanStatus(status)
+}
+
// ConfirmedScidForStore returns the in-memory confirmed SCID without taking
// the channel mutex.
//
@@ -4389,7 +4400,7 @@ func fundingTxPresent(channel *OpenChannel) bool {
return chanType.IsSingleFunder() && chanType.HasFundingTx() &&
channel.IsInitiator &&
- !channel.hasChanStatus(ChanStatusRestored)
+ !channel.HasChanStatusForStore(ChanStatusRestored)
}
func putChanInfo(chanBucket kvdb.RwBucket, channel *OpenChannel) error {
@@ -4521,7 +4532,7 @@ func putChanCommitment(chanBucket kvdb.RwBucket, c *ChannelCommitment,
func putChanCommitments(chanBucket kvdb.RwBucket, channel *OpenChannel) error {
// If this is a restored channel, then we don't have any commitments to
// write.
- if channel.hasChanStatus(ChanStatusRestored) {
+ if channel.HasChanStatusForStore(ChanStatusRestored) {
return nil
}
@@ -4700,7 +4711,7 @@ func fetchChanCommitments(chanBucket kvdb.RBucket, channel *OpenChannel) error {
// If this is a restored channel, then we don't have any commitments to
// read.
- if channel.hasChanStatus(ChanStatusRestored) {
+ if channel.HasChanStatusForStore(ChanStatusRestored) {
return nil
}
Why this scored 11/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.