Web Socket Kafka Producer为比特币数据返回的JSON架构是什么?

时间:2018-03-13 04:38:16

标签: json apache-kafka bitcoin

我使用Web Socket API作为Kafka生产者来查看来自比特币的交易管道。我不明白什么是返回。我看到JSON,但我正在寻找模式的解释。我试图分析来自生产者的比特币数据源的数据。你知道任何有助于此的资源吗?

  ------- 6003 --------
closing websocket
CloseReason[1000,Closing]
opening websocket
--Sending 6004 to topic: bitcoin --------
{
  "op" : "utx",
  "x" : {
    "lock_time" : 0,
    "ver" : 1,
    "size" : 422,
    "inputs" : [ {
      "sequence" : 4294967295,
      "prev_out" : {
        "spent" : true,
        "tx_index" : 327471315,
        "type" : 0,
        "addr" : "3K6GADZAGUY9wwpHNepYh4ftuxPiMHXAP3",
        "value" : 89940000,
        "n" : 1,
        "script" : "a914bedf96bef59527b35737b2773c49bc016de542a587"
      },
      "script" : "160014887473e9feda6f65b5de955e211a9bb488e4b071"
    }, {
      "sequence" : 4294967295,
      "prev_out" : {
        "spent" : true,
        "tx_index" : 327470386,
        "type" : 0,
        "addr" : "3LiPcUF3ZYNK8cEvPELFHdDBTwwyytUUbD",
        "value" : 110000000,
        "n" : 0,
        "script" : "a914d0ace910be659d76de99dd80ef40a921169a974087"
      },
      "script" : "160014e318aae7a934fb5dfbf4826c11b9c6109dc6f120"
    } ],
    "time" : 1520916510,
    "tx_index" : 336047432,
    "vin_sz" : 2,
    "hash" : "10b0db471e18cacc3c16215d5e6f3df0035c89ddff5a6bb18f095447b4f0a1e6",
    "vout_sz" : 2,
    "relayed_by" : "0.0.0.0",
    "out" : [ {
      "spent" : false,
      "tx_index" : 336047432,
      "type" : 0,
      "addr" : "18sfS476hFMkuofHZrk8DdXCywQw7mUk23",
      "value" : 100000000,
      "n" : 0,
      "script" : "76a914565dc28ca3096f16816adc010da34ec93939ca1588ac"
    }, {
      "spent" : false,
      "tx_index" : 336047432,
      "type" : 0,
      "addr" : "3LLDLeqhnJWXweGDtdWrP1ZbFSoEyPuoUM",
      "value" : 99934000,
      "n" : 1,
      "script" : "a914cc7b2f1c398a99e4602779273598bbad9d2bb10787"
    } ]
  }
}

1 个答案:

答案 0 :(得分:0)

使用此工具https://jsonschema.net/,我能够生成此

{
    {
          "definitions": {},
          "$schema": "http://json-schema.org/draft-07/schema#",
          "$id": "http://example.com/root.json",
          "type": "object",
          "title": "The Root Schema",
          "required": [
            "op",
            "x"
          ],
          "properties": {
            "op": {
              "$id": "#/properties/op",
              "type": "string",
              "title": "The Op Schema",
              "default": "",
              "examples": [
                "utx"
              ],
              "pattern": "^(.*)$"
            },
            "x": {
              "$id": "#/properties/x",
              "type": "object",
              "title": "The X Schema",
              "required": [
                "lock_time",
                "ver",
                "size",
                "inputs",
                "time",
                "tx_index",
                "vin_sz",
                "hash",
                "vout_sz",
                "relayed_by",
                "out"
              ],
              "properties": {
                "lock_time": {
                  "$id": "#/properties/x/properties/lock_time",
                  "type": "integer",
                  "title": "The Lock_time Schema",
                  "default": 0,
                  "examples": [
                    589167
                  ]
                },
                "ver": {
                  "$id": "#/properties/x/properties/ver",
                  "type": "integer",
                  "title": "The Ver Schema",
                  "default": 0,
                  "examples": [
                    2
                  ]
                },
                "size": {
                  "$id": "#/properties/x/properties/size",
                  "type": "integer",
                  "title": "The Size Schema",
                  "default": 0,
                  "examples": [
                    223
                  ]
                },
                "inputs": {
                  "$id": "#/properties/x/properties/inputs",
                  "type": "array",
                  "title": "The Inputs Schema",
                  "items": {
                    "$id": "#/properties/x/properties/inputs/items",
                    "type": "object",
                    "title": "The Items Schema",
                    "required": [
                      "sequence",
                      "prev_out",
                      "script"
                    ],
                    "properties": {
                      "sequence": {
                        "$id": "#/properties/x/properties/inputs/items/properties/sequence",
                        "type": "integer",
                        "title": "The Sequence Schema",
                        "default": 0,
                        "examples": [
                          4294967293
                        ]
                      },
                      "prev_out": {
                        "$id": "#/properties/x/properties/inputs/items/properties/prev_out",
                        "type": "object",
                        "title": "The Prev_out Schema",
                        "required": [
                          "spent",
                          "tx_index",
                          "type",
                          "addr",
                          "value",
                          "n",
                          "script"
                        ],
                        "properties": {
                          "spent": {
                            "$id": "#/properties/x/properties/inputs/items/properties/prev_out/properties/spent",
                            "type": "boolean",
                            "title": "The Spent Schema",
                            "default": false,
                            "examples": [
                              true
                            ]
                          },
                          "tx_index": {
                            "$id": "#/properties/x/properties/inputs/items/properties/prev_out/properties/tx_index",
                            "type": "integer",
                            "title": "The Tx_index Schema",
                            "default": 0,
                            "examples": [
                              467815293
                            ]
                          },
                          "type": {
                            "$id": "#/properties/x/properties/inputs/items/properties/prev_out/properties/type",
                            "type": "integer",
                            "title": "The Type Schema",
                            "default": 0,
                            "examples": [
                              0
                            ]
                          },
                          "addr": {
                            "$id": "#/properties/x/properties/inputs/items/properties/prev_out/properties/addr",
                            "type": "string",
                            "title": "The Addr Schema",
                            "default": "",
                            "examples": [
                              "1LYfghSB5nXDA3rCJkUspvWadvr8PpX3QC"
                            ],
                            "pattern": "^(.*)$"
                          },
                          "value": {
                            "$id": "#/properties/x/properties/inputs/items/properties/prev_out/properties/value",
                            "type": "integer",
                            "title": "The Value Schema",
                            "default": 0,
                            "examples": [
                              12719590
                            ]
                          },
                          "n": {
                            "$id": "#/properties/x/properties/inputs/items/properties/prev_out/properties/n",
                            "type": "integer",
                            "title": "The N Schema",
                            "default": 0,
                            "examples": [
                              1
                            ]
                          },
                          "script": {
                            "$id": "#/properties/x/properties/inputs/items/properties/prev_out/properties/script",
                            "type": "string",
                            "title": "The Script Schema",
                            "default": "",
                            "examples": [
                              "76a914d66793ac2ea5aa6f0a0623bcaf61b5a41e4b418e88ac"
                            ],
                            "pattern": "^(.*)$"
                          }
                        }
                      },
                      "script": {
                        "$id": "#/properties/x/properties/inputs/items/properties/script",
                        "type": "string",
                        "title": "The Script Schema",
                        "default": "",
                        "examples": [
                          "473044022030c401f7929a3638ea26817d1c5ad1fd998b67ab137456a9064718b8a636865c022072205ac922f8bef2db39ca3564aebf69a5c49593e4e4169a01b8ebc9945ef9d60121037da4017cc13e85493c2bd1896430b20673d2db475c94f8bedd09c32c87019f95"
                        ],
                        "pattern": "^(.*)$"
                      }
                    }
                  }
                },
                "time": {
                  "$id": "#/properties/x/properties/time",
                  "type": "integer",
                  "title": "The Time Schema",
                  "default": 0,
                  "examples": [
                    1565261134
                  ]
                },
                "tx_index": {
                  "$id": "#/properties/x/properties/tx_index",
                  "type": "integer",
                  "title": "The Tx_index Schema",
                  "default": 0,
                  "examples": [
                    477827083
                  ]
                },
                "vin_sz": {
                  "$id": "#/properties/x/properties/vin_sz",
                  "type": "integer",
                  "title": "The Vin_sz Schema",
                  "default": 0,
                  "examples": [
                    1
                  ]
                },
                "hash": {
                  "$id": "#/properties/x/properties/hash",
                  "type": "string",
                  "title": "The Hash Schema",
                  "default": "",
                  "examples": [
                    "508aa1360e4188d281a592000876b03406b0d63585b24057c5c9f2a607a70175"
                  ],
                  "pattern": "^(.*)$"
                },
                "vout_sz": {
                  "$id": "#/properties/x/properties/vout_sz",
                  "type": "integer",
                  "title": "The Vout_sz Schema",
                  "default": 0,
                  "examples": [
                    2
                  ]
                },
                "relayed_by": {
                  "$id": "#/properties/x/properties/relayed_by",
                  "type": "string",
                  "title": "The Relayed_by Schema",
                  "default": "",
                  "examples": [
                    "0.0.0.0"
                  ],
                  "pattern": "^(.*)$"
                },
                "out": {
                  "$id": "#/properties/x/properties/out",
                  "type": "array",
                  "title": "The Out Schema",
                  "items": {
                    "$id": "#/properties/x/properties/out/items",
                    "type": "object",
                    "title": "The Items Schema",
                    "required": [
                      "spent",
                      "tx_index",
                      "type",
                      "addr",
                      "value",
                      "n",
                      "script"
                    ],
                    "properties": {
                      "spent": {
                        "$id": "#/properties/x/properties/out/items/properties/spent",
                        "type": "boolean",
                        "title": "The Spent Schema",
                        "default": false,
                        "examples": [
                          false
                        ]
                      },
                      "tx_index": {
                        "$id": "#/properties/x/properties/out/items/properties/tx_index",
                        "type": "integer",
                        "title": "The Tx_index Schema",
                        "default": 0,
                        "examples": [
                          477827083
                        ]
                      },
                      "type": {
                        "$id": "#/properties/x/properties/out/items/properties/type",
                        "type": "integer",
                        "title": "The Type Schema",
                        "default": 0,
                        "examples": [
                          0
                        ]
                      },
                      "addr": {
                        "$id": "#/properties/x/properties/out/items/properties/addr",
                        "type": "string",
                        "title": "The Addr Schema",
                        "default": "",
                        "examples": [
                          "37EMZLwcux8zxrJpqGuV8ZPmR2rmFmwAN6"
                        ],
                        "pattern": "^(.*)$"
                      },
                      "value": {
                        "$id": "#/properties/x/properties/out/items/properties/value",
                        "type": "integer",
                        "title": "The Value Schema",
                        "default": 0,
                        "examples": [
                          764825
                        ]
                      },
                      "n": {
                        "$id": "#/properties/x/properties/out/items/properties/n",
                        "type": "integer",
                        "title": "The N Schema",
                        "default": 0,
                        "examples": [
                          0
                        ]
                      },
                      "script": {
                        "$id": "#/properties/x/properties/out/items/properties/script",
                        "type": "string",
                        "title": "The Script Schema",
                        "default": "",
                        "examples": [
                          "a9143cc5e9ee0122b15b9e91fba427dc5433390d828187"
                        ],
                        "pattern": "^(.*)$"
                      }
                    }
                  }
                }
              }
            }
          }
        }