Skip to content

Instantly share code, notes, and snippets.

@onggunhao
Last active August 9, 2023 20:26
Show Gist options
  • Save onggunhao/fcce0aac94ba73c44b59b4ff0dd6b638 to your computer and use it in GitHub Desktop.
Save onggunhao/fcce0aac94ba73c44b59b4ff0dd6b638 to your computer and use it in GitHub Desktop.
Annotated version of Blockchain.info's Websocket Transaction

Annotated Blockchain.info Websocket API

This is an annotated version of Blockchain.info's Websocket API with explanations of message contents.

Multiple Inputs and Outputs

Bitcoin transactions (especially if large) may have multiple inputs and outputs in a single transaction. http://chimera.labs.oreilly.com/books/1234000001802/ch02.html explains this very concisely.

Sample Transaction

The JSON object below is the actual message received from the Blockchain.info Websockets API for the transaction 0857b9de1884eec314ecf67c040a2657b8e083e1f95e31d0b5ba3d328841fc7f. You can see the Blockchain.info transaction page for this transaction here.

Transaction Page: https://blockchain.info/tx/0857b9de1884eec314ecf67c040a2657b8e083e1f95e31d0b5ba3d328841fc7f

{
  "op" : "utx",
  "x" : {
    "lock_time" : 0,
    "ver" : 1,
    "size" : 520,
    "inputs" : [ {                  // Array consisting of multiple "inputs", which are debits against a bitcoin account
      "sequence" : 4294967295,
      "prev_out" : {                // Indicates source funds is from a previous 'out' transaction
        "spent" : true,
        "tx_index" : 301966400,
        "type" : 0,
        "addr" : "1Y1gGHcFHajh9oY6WzeS4qxhjZoptfHts",
        "value" : 55000000,
        "n" : 6,
        "script" : "76a91405dd75bcc1d3893e24031a81cb882d8ff586ce0888ac"
      },
      "script" : "483045022100d0fdb06b26cbe1dfccb32b44e2c2e81a5a51f98df4b6b5f7bf164597026a5f4b02201a7aaf6bf8bbcdf2c4d4b5df48ad5ff4f457fc0dd5f112bc0eceb643198d8c9e012103684b3d6c7709e242f91ff2e14dfa865b7580076416b8e1a9a487de7519136995"
    }, {
      "sequence" : 4294967295,
      "prev_out" : {
        "spent" : true,
        "tx_index" : 300795215,
        "type" : 0,
        "addr" : "15bvuNL41gjkRXcp33r695YoZZwkrikDGG",
        "value" : 55310,
        "n" : 0,
        "script" : "76a914327ba446b94cc0ca296658fc633e99dafc0e3ad788ac"
      },
      "script" : "4730440220074ff9df86e2dbd4f6c50de56638fe6b40d58b565e725907487144ac78dffbb502206b9af46cd6314fb85679a06cf1f71700e69adb67996fd13947c4ab8f1a7a2f6701210301ee3ca3e53caf1ef0cd63924e96269be821820cff02262799d9179d44e41cdb"
    }, {
      "sequence" : 4294967295,
      "prev_out" : {
        "spent" : true,
        "tx_index" : 301657981,
        "type" : 0,
        "addr" : "1362EzLHB7tsvWJ1KYzXzmPSwU7JpFnib7",
        "value" : 109709,
        "n" : 1,
        "script" : "76a91416e35e11ff0e6fe8c8f5334c0f40cc05908a651a88ac"
      },
      "script" : "47304402207e8654bfa5e88effeee009f4bc334297b7b03f64e5218a514483d35fb43b97bf022078f714aa2035566def5dd80a4b389d014bc6a8f61e63e35202600e4785b0ad81012102b6a2be4beeadf05eaba12b2f50fbb31a436f7d9a1b402d91f81b079c5c6c6fa5"
    } ],
    "time" : 1510912841,
    "tx_index" : 302021857,
    "vin_sz" : 3,                                                                    // Number of "inputs"
    "hash" : "fa8ef2dc2241b89e5e7f2189fc522568620e4a3aae08b39cf38771a1006f4055",     // This is the transaction hash
    "vout_sz" : 2,                                                                   // Number of "outputs"
    "relayed_by" : "0.0.0.0",
    "out" : [ { 			// Array consisting of multiple "outputs", which are credits to a bitcoin account
      "spent" : false,
      "tx_index" : 302021857,
      "type" : 0,
      "addr" : "154dXFjRPukDFqZpRU7GfBDMCrkmbZXNsH",      // This is the main transaction amount
      "value" : 55000000,        // Value in satoshis
      "n" : 0,
      "script" : "76a9142c903cdc224e8b75b3f573014ec8c1f743854c1f88ac"
    }, {
      "spent" : false,
      "tx_index" : 302021857,
      "type" : 0,
      "addr" : "1NT1YgyA8RfrhVNUBJx6kRkwF899z1c5NA",            // This is the fractional share
      "value" : 65269,
      "n" : 1,
      "script" : "76a914eb45e99cb640e616f0de08e6a1fc4bba063a115a88ac"
    } ]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment