diff --git a/ctxc/tracers/api.go b/ctxc/tracers/api.go index b3ed8418cc..42cc89aa99 100644 --- a/ctxc/tracers/api.go +++ b/ctxc/tracers/api.go @@ -63,6 +63,8 @@ const ( defaultTracechainMemLimit = common.StorageSize(500 * 1024 * 1024) ) +var errTxNotFound = errors.New("transaction not found") + // StateReleaseFunc is used to deallocate resources held by constructing a // historical state for tracing purposes. type StateReleaseFunc func() @@ -807,10 +809,15 @@ func containsTx(block *types.Block, hash common.Hash) bool { // TraceTransaction returns the structured logs created during the execution of CVM // and returns them as a JSON object. func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) { - _, blockHash, blockNumber, index, err := api.backend.GetTransaction(ctx, hash) + tx, blockHash, blockNumber, index, err := api.backend.GetTransaction(ctx, hash) if err != nil { return nil, err } + + // Only mined txes are supported + if tx == nil { + return nil, errTxNotFound + } // It shouldn't happen in practice. if blockNumber == 0 { return nil, errors.New("genesis is not traceable")