2020-01-14 12:02:38 +00:00
|
|
|
package response
|
2018-03-05 08:53:09 +00:00
|
|
|
|
2019-02-19 11:47:25 +00:00
|
|
|
import (
|
2020-01-14 12:02:38 +00:00
|
|
|
"encoding/json"
|
|
|
|
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
2019-02-19 11:47:25 +00:00
|
|
|
)
|
2019-01-22 12:14:40 +00:00
|
|
|
|
2020-01-14 12:02:38 +00:00
|
|
|
// Header is a generic JSON-RPC 2.0 response header (ID and JSON-RPC version).
|
|
|
|
type Header struct {
|
|
|
|
ID json.RawMessage `json:"id"`
|
|
|
|
JSONRPC string `json:"jsonrpc"`
|
2018-03-05 08:53:09 +00:00
|
|
|
}
|
|
|
|
|
2020-01-14 12:02:38 +00:00
|
|
|
// HeaderAndError adds an Error (that can be empty) to the Header, it's used
|
|
|
|
// to construct type-specific responses.
|
|
|
|
type HeaderAndError struct {
|
|
|
|
Header
|
|
|
|
Error *Error `json:"error,omitempty"`
|
2018-03-05 08:53:09 +00:00
|
|
|
}
|
|
|
|
|
2020-01-14 12:02:38 +00:00
|
|
|
// Raw represents a standard raw JSON-RPC 2.0
|
|
|
|
// response: http://www.jsonrpc.org/specification#response_object.
|
|
|
|
type Raw struct {
|
|
|
|
HeaderAndError
|
2020-02-20 18:08:22 +00:00
|
|
|
Result json.RawMessage `json:"result,omitempty"`
|
2018-03-05 08:53:09 +00:00
|
|
|
}
|
2019-01-22 12:14:40 +00:00
|
|
|
|
2020-01-14 12:02:38 +00:00
|
|
|
// GetTxOut represents result of `gettxout` RPC call.
|
|
|
|
type GetTxOut struct {
|
|
|
|
HeaderAndError
|
|
|
|
Result *result.TransactionOutput
|
2019-01-22 12:14:40 +00:00
|
|
|
}
|
|
|
|
|
2020-01-14 12:02:38 +00:00
|
|
|
// GetRawTx represents verbose output of `getrawtransaction` RPC call.
|
|
|
|
type GetRawTx struct {
|
|
|
|
HeaderAndError
|
2020-02-20 16:29:21 +00:00
|
|
|
Result *result.TransactionOutputRaw `json:"result"`
|
2020-02-06 12:02:03 +00:00
|
|
|
}
|
2020-05-10 22:00:19 +00:00
|
|
|
|
|
|
|
// Notification is a type used to represent wire format of events, they're
|
|
|
|
// special in that they look like requests but they don't have IDs and their
|
|
|
|
// "method" is actually an event name.
|
|
|
|
type Notification struct {
|
|
|
|
JSONRPC string `json:"jsonrpc"`
|
|
|
|
Event EventID `json:"method"`
|
|
|
|
Payload []interface{} `json:"params"`
|
|
|
|
}
|