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 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 10:39:41 -05:00
co-authored by Claude Opus 4.8
parent 6f52ff0969
commit cbda810849
+6 -3
View File
@@ -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