chainrpc: return Unavailable while notifier starts
What changed, and why it matters
This commit changes the error code returned when LND's ChainNotifier sub-server is still starting up. Previously, clients received a generic 'Unknown' gRPC error with a text message; now they receive a standard 'Unavailable' code, which is the normal signal to retry later. It is a reliability improvement, not a security fix.
No security action required; treat as a normal reliability/usability improvement. Clients may optionally update retry logic to rely on codes.Unavailable.
Security signals we found
Error-code hygiene improvement
No privilege boundary change
No input validation change
No cryptographic change
Evidence from the diff
The patch converts ErrChainNotifierServerNotActive from a plain errors.New() into a gRPC status.Error with codes.Unavailable. This lets gRPC clients detect the transient startup condition programmatically instead of parsing an error string. No logic, authorization, or data-handling behavior changes.
Changed components
lnrpc/chainrpc/chain_server.goChainNotifier gRPC sub-serverInspect captured patch +4 / −2
diff --git a/lnrpc/chainrpc/chain_server.go b/lnrpc/chainrpc/chain_server.go
index da68e03..e42a684 100644
--- a/lnrpc/chainrpc/chain_server.go
+++ b/lnrpc/chainrpc/chain_server.go
@@ -18,6 +18,8 @@ import (
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/macaroons"
"google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/status"
"gopkg.in/macaroon-bakery.v2/bakery"
)
@@ -84,8 +86,8 @@ var (
// ErrChainNotifierServerNotActive indicates that the chain notifier hasn't
// finished the startup process.
- ErrChainNotifierServerNotActive = errors.New("chain notifier RPC is " +
- "still in the process of starting")
+ ErrChainNotifierServerNotActive = status.Error(codes.Unavailable,
+ "chain notifier RPC is still in the process of starting")
)
// ServerShell is a shell struct holding a reference to the actual sub-server.
Why this scored 22/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.