From 3d762e5f856d9e45bf7c421f3e92e489fc887e48 Mon Sep 17 00:00:00 2001 From: Dmitry <46797839+dkeysil@users.noreply.github.com> Date: Fri, 10 Feb 2023 13:48:32 +0800 Subject: [PATCH] Check if block is nil to prevent panic (#736) --- internal/ethapi/api.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 7df46b1f33..0c2f5ba2cb 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -628,6 +628,10 @@ func (s *PublicBlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, return nil, err } + if block == nil { + return nil, errors.New("block not found") + } + receipts, err := s.b.GetReceipts(ctx, block.Hash()) if err != nil { return nil, err