GetTransactionReceipt returns the transaction receipt for the given transaction hash.
(ctx context.Context, hash common.Hash)
| 1285 | |
| 1286 | // GetTransactionReceipt returns the transaction receipt for the given transaction hash. |
| 1287 | func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) { |
| 1288 | tx, blockHash, blockNumber, index := rawdb.ReadTransaction(s.b.ChainDb(), hash) |
| 1289 | if tx == nil { |
| 1290 | return nil, nil |
| 1291 | } |
| 1292 | |
| 1293 | var receipt *types.Receipt |
| 1294 | if tx.IsPrivate() { |
| 1295 | receipt, _ = s.b.GetPrivateReceipt(ctx, tx.Hash()) |
| 1296 | if receipt == nil { |
| 1297 | return nil, nil |
| 1298 | } |
| 1299 | } else { |
| 1300 | receipts, err := s.b.GetReceipts(ctx, blockHash) |
| 1301 | if err != nil { |
| 1302 | return nil, err |
| 1303 | } |
| 1304 | if len(receipts) <= int(index) { |
| 1305 | return nil, nil |
| 1306 | } |
| 1307 | receipt = receipts[index] |
| 1308 | } |
| 1309 | |
| 1310 | var signer types.Signer = types.FrontierSigner{} |
| 1311 | if tx.Protected() { |
| 1312 | signer = types.NewCep1Signer(tx.ChainId()) |
| 1313 | } |
| 1314 | from, _ := types.Sender(signer, tx) |
| 1315 | |
| 1316 | fields := map[string]interface{}{ |
| 1317 | "blockHash": blockHash, |
| 1318 | "blockNumber": hexutil.Uint64(blockNumber), |
| 1319 | "transactionHash": hash, |
| 1320 | "transactionIndex": hexutil.Uint64(index), |
| 1321 | "from": from, |
| 1322 | "to": tx.To(), |
| 1323 | "gasUsed": hexutil.Uint64(receipt.GasUsed), |
| 1324 | "cumulativeGasUsed": hexutil.Uint64(receipt.CumulativeGasUsed), |
| 1325 | "contractAddress": nil, |
| 1326 | "logs": receipt.Logs, |
| 1327 | "logsBloom": receipt.Bloom, |
| 1328 | } |
| 1329 | |
| 1330 | // Assign receipt status or post state. |
| 1331 | if len(receipt.PostState) > 0 { |
| 1332 | fields["root"] = hexutil.Bytes(receipt.PostState) |
| 1333 | } else { |
| 1334 | fields["status"] = hexutil.Uint(receipt.Status) |
| 1335 | } |
| 1336 | if receipt.Logs == nil { |
| 1337 | fields["logs"] = [][]*types.Log{} |
| 1338 | } |
| 1339 | // If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation |
| 1340 | if receipt.ContractAddress != (common.Address{}) { |
| 1341 | fields["contractAddress"] = receipt.ContractAddress |
| 1342 | } |
| 1343 | return fields, nil |
| 1344 | } |
nothing calls this directly
no test coverage detected