diff --git a/pkg/rpc/response/result/tx_raw_output.go b/pkg/rpc/response/result/tx_raw_output.go index 326923c8a..59405c5a7 100644 --- a/pkg/rpc/response/result/tx_raw_output.go +++ b/pkg/rpc/response/result/tx_raw_output.go @@ -4,8 +4,6 @@ import ( "encoding/json" "errors" - "github.com/nspcc-dev/neo-go/pkg/core/block" - "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/util" ) @@ -25,25 +23,6 @@ type TransactionMetadata struct { VMState string `json:"vmstate,omitempty"` } -// NewTransactionOutputRaw returns a new ransactionOutputRaw object. -func NewTransactionOutputRaw(tx *transaction.Transaction, header *block.Header, appExecResult *state.AppExecResult, chain LedgerAux) TransactionOutputRaw { - result := TransactionOutputRaw{ - Transaction: *tx, - } - if header == nil { - return result - } - // confirmations formula - confirmations := int(chain.BlockHeight() - header.Index + 1) - result.TransactionMetadata = TransactionMetadata{ - Blockhash: header.Hash(), - Confirmations: confirmations, - Timestamp: header.Timestamp, - VMState: appExecResult.VMState.String(), - } - return result -} - // MarshalJSON implements the json.Marshaler interface. func (t TransactionOutputRaw) MarshalJSON() ([]byte, error) { output, err := json.Marshal(t.TransactionMetadata) diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index cd8460e48..0c2d7e9be 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -1542,8 +1542,11 @@ func (s *Server) getrawtransaction(reqParams params.Params) (interface{}, *respo return nil, response.ErrUnknownTransaction } if v, _ := reqParams.Value(1).GetBoolean(); v { - if height == math.MaxUint32 { - return result.NewTransactionOutputRaw(tx, nil, nil, s.chain), nil + res := result.TransactionOutputRaw{ + Transaction: *tx, + } + if height == math.MaxUint32 { // Mempooled transaction. + return res, nil } _header := s.chain.GetHeaderHash(int(height)) header, err := s.chain.GetHeader(_header) @@ -1557,7 +1560,13 @@ func (s *Server) getrawtransaction(reqParams params.Params) (interface{}, *respo if len(aers) == 0 { return nil, response.NewRPCError("Inconsistent application log", "application log for the transaction is empty") } - return result.NewTransactionOutputRaw(tx, header, &aers[0], s.chain), nil + res.TransactionMetadata = result.TransactionMetadata{ + Blockhash: header.Hash(), + Confirmations: int(s.chain.BlockHeight() - header.Index + 1), + Timestamp: header.Timestamp, + VMState: aers[0].VMState.String(), + } + return res, nil } return tx.Bytes(), nil }