What changed, and why it matters
This commit is a simple code reorganization: it moves error message definitions from one internal package to another and keeps the old names as aliases so existing code keeps working. The actual error text and behavior are unchanged. There is no security fix or vulnerability here.
No security action needed. Treat as ordinary code maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch creates a new file chanstate/errors.go containing the same exported error variables previously defined in channeldb/channel.go, then replaces the original definitions in channeldb with aliases pointing to the new chanstate variables. This is a pure refactor preserving API compatibility; no logic, error strings, or control flow changed.
Changed components
channeldb/channel.gochanstate/errors.goInspect captured patch +66 / −12
diff --git a/channeldb/channel.go b/channeldb/channel.go
index 161aef4..605edab 100644
--- a/channeldb/channel.go
+++ b/channeldb/channel.go
@@ -176,50 +176,49 @@ var (
var (
// ErrNoCommitmentsFound is returned when a channel has not set
// commitment states.
- ErrNoCommitmentsFound = fmt.Errorf("no commitments found")
+ ErrNoCommitmentsFound = cstate.ErrNoCommitmentsFound
// ErrNoChanInfoFound is returned when a particular channel does not
// have any channels state.
- ErrNoChanInfoFound = fmt.Errorf("no chan info found")
+ ErrNoChanInfoFound = cstate.ErrNoChanInfoFound
// ErrNoRevocationsFound is returned when revocation state for a
// particular channel cannot be found.
- ErrNoRevocationsFound = fmt.Errorf("no revocations found")
+ ErrNoRevocationsFound = cstate.ErrNoRevocationsFound
// ErrNoPendingCommit is returned when there is not a pending
// commitment for a remote party. A new commitment is written to disk
// each time we write a new state in order to be properly fault
// tolerant.
- ErrNoPendingCommit = fmt.Errorf("no pending commits found")
+ ErrNoPendingCommit = cstate.ErrNoPendingCommit
// ErrNoCommitPoint is returned when no data loss commit point is found
// in the database.
- ErrNoCommitPoint = fmt.Errorf("no commit point found")
+ ErrNoCommitPoint = cstate.ErrNoCommitPoint
// ErrNoCloseTx is returned when no closing tx is found for a channel
// in the state CommitBroadcasted.
- ErrNoCloseTx = fmt.Errorf("no closing tx found")
+ ErrNoCloseTx = cstate.ErrNoCloseTx
// ErrNoShutdownInfo is returned when no shutdown info has been
// persisted for a channel.
- ErrNoShutdownInfo = errors.New("no shutdown info")
+ ErrNoShutdownInfo = cstate.ErrNoShutdownInfo
// ErrNoRestoredChannelMutation is returned when a caller attempts to
// mutate a channel that's been recovered.
- ErrNoRestoredChannelMutation = fmt.Errorf("cannot mutate restored " +
- "channel state")
+ ErrNoRestoredChannelMutation = cstate.ErrNoRestoredChannelMutation
// ErrChanBorked is returned when a caller attempts to mutate a borked
// channel.
- ErrChanBorked = fmt.Errorf("cannot mutate borked channel")
+ ErrChanBorked = cstate.ErrChanBorked
// ErrMissingIndexEntry is returned when a caller attempts to close a
// channel and the outpoint is missing from the index.
- ErrMissingIndexEntry = fmt.Errorf("missing outpoint from index")
+ ErrMissingIndexEntry = cstate.ErrMissingIndexEntry
// ErrOnionBlobLength is returned is an onion blob with incorrect
// length is read from disk.
- ErrOnionBlobLength = errors.New("onion blob < 1366 bytes")
+ ErrOnionBlobLength = cstate.ErrOnionBlobLength
)
const (
diff --git a/chanstate/errors.go b/chanstate/errors.go
new file mode 100644
index 0000000..4e8415c
--- /dev/null
+++ b/chanstate/errors.go
@@ -0,0 +1,55 @@
+package chanstate
+
+import (
+ "errors"
+ "fmt"
+)
+
+var (
+ // ErrNoCommitmentsFound is returned when a channel has not set
+ // commitment states.
+ ErrNoCommitmentsFound = fmt.Errorf("no commitments found")
+
+ // ErrNoChanInfoFound is returned when a particular channel does not
+ // have any channels state.
+ ErrNoChanInfoFound = fmt.Errorf("no chan info found")
+
+ // ErrNoRevocationsFound is returned when revocation state for a
+ // particular channel cannot be found.
+ ErrNoRevocationsFound = fmt.Errorf("no revocations found")
+
+ // ErrNoPendingCommit is returned when there is not a pending
+ // commitment for a remote party. A new commitment is written to disk
+ // each time we write a new state in order to be properly fault
+ // tolerant.
+ ErrNoPendingCommit = fmt.Errorf("no pending commits found")
+
+ // ErrNoCommitPoint is returned when no data loss commit point is found
+ // in the database.
+ ErrNoCommitPoint = fmt.Errorf("no commit point found")
+
+ // ErrNoCloseTx is returned when no closing tx is found for a channel
+ // in the state CommitBroadcasted.
+ ErrNoCloseTx = fmt.Errorf("no closing tx found")
+
+ // ErrNoShutdownInfo is returned when no shutdown info has been
+ // persisted for a channel.
+ ErrNoShutdownInfo = errors.New("no shutdown info")
+
+ // ErrNoRestoredChannelMutation is returned when a caller attempts to
+ // mutate a channel that's been recovered.
+ ErrNoRestoredChannelMutation = fmt.Errorf("cannot mutate restored " +
+ "channel state")
+
+ // ErrChanBorked is returned when a caller attempts to mutate a borked
+ // channel.
+ ErrChanBorked = fmt.Errorf("cannot mutate borked channel")
+
+ // ErrMissingIndexEntry is returned when a caller attempts to close a
+ // channel and the outpoint is missing from the index.
+ ErrMissingIndexEntry = fmt.Errorf("missing outpoint from index")
+
+ // ErrOnionBlobLength is returned is an onion blob with incorrect
+ // length is read from disk.
+ ErrOnionBlobLength = errors.New("onion blob < 1366 bytes")
+)
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.