chainrpc: return Unavailable while notifier starts

From v0.20.0-rc3 (commit c6f458e478) onward
the ChainNotifier sub-server may still be initialising when clients attempt
to subscribe, currently resulting in a gRPC Unknown error with a plain-text
message. Change the notifier RPC endpoints to return codes.Unavailable instead
so clients can reliably interpret the condition as "retry later" and handle
the startup lag without unstable string matching.
This commit is contained in:
Boris Nagaev committed 2025-11-06 21:58:46 -03:00
1 parent 096ab65b1d
commit 9520a390ed
1 file changed
+4 -2
+4 -2
View File
@@ -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.