Skip to content

Invalid JsonRPC API response method "create-tx" #14

@Rodion7777

Description

@Rodion7777

According to JsonRPC 2.0 specification https://www.jsonrpc.org/specification#conventions
every successful API response has to contain "result" field.

Steps to reproduce:

  1. call api:

curl -s -X POST --data '{
"id": 1,
"version": "1.0.0",
"method": "create-tx",
"params": {
"address": "0x0072ddeaa4a2268bcff495da42b901664cec77f1652f43dd79",
"to": "0x08319f04ece1975e486c867cee48a2a70658022c53249ffbab",
"value": 0,
"nonce": 11,
"data": ""
}
}' 127.0.0.1:9999

  1. fetch response:
    {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "mhc_send",
    "params": {
    "transaction": "08319f04ece1975e486c867cee48a2a70658022c53249ffbab00390b397b226d6574686f64223a2272756e222c2266756e6374696f6e223a226164644461746132222c22706172616d73223a5b227177653132225d7d",
    "to": "0x08319f04ece1975e486c867cee48a2a70658022c53249ffbab",
    "value": "0",
    "fee": "57",
    "nonce": "11",
    "data": "7b226d6574686f64223a2272756e222c2266756e6374696f6e223a226164644461746132222c22706172616d73223a5b227177653132225d7d",
    "pubkey": "3056301006072a8648ce3d020106052b8104000a0342000420bacbc997e6aaa8fe77c3892eb2926658a7210b4b70eab5335c114f63ea02be02f2fd4d6761fcb081371b06a499b65ab780ac2f3ed10224a22945d620882d2a",
    "sign": "3045022100a7ff185c3fd88a0fa1954840532f761ab5e6c856e64b7faecacff2b8eb77a56002201fc381090573e301e424138e6b13e22b3c1e7107f4a5c371efe3c0cdf566e2f3"
    }
    }

  2. validate result with JsonRPC response schema:

{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "A JSON RPC 2.0 response", "oneOf": [ { "$ref": "#/definitions/success" }, { "$ref": "#/definitions/error" }, { "type": "array", "items": { "oneOf": [ { "$ref": "#/definitions/success" }, { "$ref": "#/definitions/error" } ] } } ], "definitions": { "common": { "required": [ "id", "jsonrpc" ], "not": { "description": "cannot have result and error at the same time", "required": [ "result", "error" ] }, "type": "object", "properties": { "id": { "type": [ "string", "integer", "null" ], "note": [ "spec says a number which should not contain a fractional part", "We choose integer here, but this is unenforceable with some languages" ] }, "jsonrpc": { "enum": [ "2.0" ] } } }, "success": { "description": "A success. The result member is then required and can be anything.", "allOf": [ { "$ref": "#/definitions/common" }, { "required": [ "result" ] } ] }, "error": { "allOf": [ { "$ref": "#/definitions/common" }, { "required": [ "error" ], "properties": { "error": { "type": "object", "required": [ "code", "message" ], "properties": { "code": { "type": "integer", "note": [ "unenforceable in some languages" ] }, "message": { "type": "string" }, "data": { "description": "optional, can be anything" } } } } } ] } } }

expected result: obtained response passes validation.
actual result: result fails validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions