You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
714 B

  1. package rpctypes
  2. type RPCRequest struct {
  3. JSONRPC string `json:"jsonrpc"`
  4. ID string `json:"id"`
  5. Method string `json:"method"`
  6. Params []interface{} `json:"params"`
  7. }
  8. func NewRPCRequest(id string, method string, params []interface{}) RPCRequest {
  9. return RPCRequest{
  10. JSONRPC: "2.0",
  11. ID: id,
  12. Method: method,
  13. Params: params,
  14. }
  15. }
  16. type RPCResponse struct {
  17. JSONRPC string `json:"jsonrpc"`
  18. ID string `json:"id"`
  19. Result interface{} `json:"result"`
  20. Error string `json:"error"`
  21. }
  22. func NewRPCResponse(id string, res interface{}, err string) RPCResponse {
  23. return RPCResponse{
  24. JSONRPC: "2.0",
  25. ID: id,
  26. Result: res,
  27. Error: err,
  28. }
  29. }