ethapi: GetTransactionReceipt panic fix, nonexistent tx/receipt errors

This commit is contained in:
Anton Elmanov 2017-12-14 14:17:57 +03:00
parent a721ab20d8
commit a377e5fe51

View file

@ -1003,11 +1003,11 @@ func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context,
func (s *PublicTransactionPoolAPI) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error) { func (s *PublicTransactionPoolAPI) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error) {
tx, blockHash, blockNumber, index := core.GetTransaction(s.b.ChainDb(), hash) tx, blockHash, blockNumber, index := core.GetTransaction(s.b.ChainDb(), hash)
if tx == nil { if tx == nil {
return nil, nil return nil, errors.New("unknown transaction")
} }
receipt, _, _, _ := core.GetReceipt(s.b.ChainDb(), hash) // Old receipts don't have the lookup data available receipt, _, _, _ := core.GetReceipt(s.b.ChainDb(), hash) // Old receipts don't have the lookup data available
if receipt == nil { if receipt == nil {
return nil, nil return nil, errors.New("unknown receipt")
} }
var signer types.Signer = types.FrontierSigner{} var signer types.Signer = types.FrontierSigner{}