From cbda810849336b79a02b76ea06d4c17e7f2d2b99 Mon Sep 17 00:00:00 2001 From: DanS Date: Fri, 30 Oct 2026 10:39:41 -0500 Subject: [PATCH] frontend: guard nil Block in GetTransaction (empty TxFilter crash) An empty TxFilter (Hash==nil, Block==nil) fell through to 'if txf.Block.Hash' which dereferenced a nil Block and panicked the server (grpc-go v1.24.0 has no handler recover) -- one unauthenticated request killed the process. Guard txf.Block before dereferencing and return InvalidArgument for a request that carries neither a txid nor a usable block filter. Co-Authored-By: Claude Opus 4.8 --- frontend/service.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/service.go b/frontend/service.go index 8747d76..cea4cdf 100644 --- a/frontend/service.go +++ b/frontend/service.go @@ -295,12 +295,15 @@ func (s *SqlStreamer) GetTransaction(ctx context.Context, txf *walletrpc.TxFilte return &walletrpc.RawTransaction{Data: txBytes, Height: uint64(txHeight)}, nil } - if txf.Block.Hash != nil { + // txf.Block may be nil (an empty TxFilter); guard it before dereferencing, or a single + // empty request panics the server (grpc-go v1.24.0 has no handler recover). + if txf.Block != nil && txf.Block.Hash != nil { s.log.Error("Can't GetTransaction with a blockhash+num. Please call GetTransaction with txid") - return nil, errors.New("Can't GetTransaction with a blockhash+num. Please call GetTransaction with txid") + return nil, status.Error(codes.InvalidArgument, "Can't GetTransaction with a blockhash+num. Please call GetTransaction with txid") } - return &walletrpc.RawTransaction{Data: txBytes, Height: uint64(txHeight)}, nil + // Neither a txid (Hash) nor a usable block filter was supplied. + return nil, status.Error(codes.InvalidArgument, "GetTransaction: a txid (Hash) is required") } // GetLightdInfo gets the LightWalletD (this server) info