From b9d1869d95725be88018cf4b2391afb1dc81d6cc Mon Sep 17 00:00:00 2001 From: Pratik Patil Date: Tue, 21 Jun 2022 11:32:19 +0530 Subject: [PATCH] added getHeaderWithAuthor function to change the coinbase filed in header with actual miner address --- internal/ethapi/api.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 59b6feba52..2768b6fbf3 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -814,6 +814,18 @@ func (s *PublicBlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.H return nil } +// getHeaderWithAuthor: changes the miner (0x0, coinbase) with the original miner address +func (s *PublicBlockChainAPI) getHeaderWithAuthor(head *types.Header) error { + // get author using From: Backend -> Engine -> Author + author, err := s.b.Engine().Author(head) + if err != nil { + return err + } + // change the coinbase (0x0) with the miner address + head.Coinbase = author + return nil +} + // GetBlockByNumber returns the requested canonical block. // * When blockNr is -1 the chain head is returned. // * When blockNr is -2 the pending chain head is returned.