7

I used the command line bitcoin-cli decoderawtransaction <hex-value> and got back a JSON output (see below). However, I noticed there are hex and asm fields that are themselves hex values (at times). I am thinking these are metadata that can further be decoded. Is that right?

Is there any more documentation on the structure and meaning of the JSON passed back for these 2 fields (or more)?

I read this SO post which referred to this out-dated article.

Also, I checked the transaction on bitcoin block explorer. They seem to have a few metadata that I don't see in the JSON (e.g. received time, confirmations, relayed ip, etc...). Where are these values coming from?

{
  "txid": "2514161c059ac18bf2eff1e05c4628e322d846e930fd6dd4b24805ea59dc4913",
  "hash": "2514161c059ac18bf2eff1e05c4628e322d846e930fd6dd4b24805ea59dc4913",
  "size": 259,
  "vsize": 259,
  "version": 1,
  "locktime": 0,
  "vin": [
    {
      "txid": "4f40655c4ab1a029bc41bc547f79556a0dc48d22df7202778fad592791c77fcd",
      "vout": 0,
      "scriptSig": {
        "asm": "3046022100cd6795ebcd1b6b87833a4ad812733d3804065d34bafee24da181a770892272b902210088cd2484952ad2572f9bfb2874643dbb4b3c492b749e79d8177a14eb4a3bc61a[ALL] 04bbf2b84900b6f898548687aefba86cc06da6f4656a71e45fa55128b501455b5486cb09705cfa23c1899fe46d4355c9058bb2de4f1a7f1a01ff27e00b306f7356",
        "hex": "493046022100cd6795ebcd1b6b87833a4ad812733d3804065d34bafee24da181a770892272b902210088cd2484952ad2572f9bfb2874643dbb4b3c492b749e79d8177a14eb4a3bc61a014104bbf2b84900b6f898548687aefba86cc06da6f4656a71e45fa55128b501455b5486cb09705cfa23c1899fe46d4355c9058bb2de4f1a7f1a01ff27e00b306f7356"
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 889.94500000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 f9d49c5cf3e120ad1be60b67d868603a8fc945d2 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914f9d49c5cf3e120ad1be60b67d868603a8fc945d288ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1PmyxDv5VvGoSAKMr1DQcWB6sHPx1ZbgWe"
        ]
      }
    }, 
    {
      "value": 10.00000000,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 088465c1f0c8b3b3da06f7073a921d6b95b22f49 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914088465c1f0c8b3b3da06f7073a921d6b95b22f4988ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1n31g4rKiEeXnZEZR6VZwm3LggLicEqEC"
        ]
      }
    }
  ]
}

Furthermore, I decoded the raw transaction using https://blockchain.info/decode-tx and got something different.

{
   "lock_time":0,
   "size":259,
   "inputs":[
      {
         "prev_out":{
            "index":0,
            "hash":"4f40655c4ab1a029bc41bc547f79556a0dc48d22df7202778fad592791c77fcd"
         },
         "script":"493046022100cd6795ebcd1b6b87833a4ad812733d3804065d34bafee24da181a770892272b902210088cd2484952ad2572f9bfb2874643dbb4b3c492b749e79d8177a14eb4a3bc61a014104bbf2b84900b6f898548687aefba86cc06da6f4656a71e45fa55128b501455b5486cb09705cfa23c1899fe46d4355c9058bb2de4f1a7f1a01ff27e00b306f7356"
      }
   ],
   "version":1,
   "vin_sz":1,
   "hash":"2514161c059ac18bf2eff1e05c4628e322d846e930fd6dd4b24805ea59dc4913",
   "vout_sz":2,
   "out":[
      {
         "script_string":"OP_DUP OP_HASH160 f9d49c5cf3e120ad1be60b67d868603a8fc945d2 OP_EQUALVERIFY OP_CHECKSIG",
         "address":"1PmyxDv5VvGoSAKMr1DQcWB6sHPx1ZbgWe",
         "value":88994500000,
         "script":"76a914f9d49c5cf3e120ad1be60b67d868603a8fc945d288ac"
      },
      {
         "script_string":"OP_DUP OP_HASH160 088465c1f0c8b3b3da06f7073a921d6b95b22f49 OP_EQUALVERIFY OP_CHECKSIG",
         "address":"1n31g4rKiEeXnZEZR6VZwm3LggLicEqEC",
         "value":1000000000,
         "script":"76a914088465c1f0c8b3b3da06f7073a921d6b95b22f4988ac"
      }
   ]
}

1 Answer 1

8

asm refers to the de-serialised form of the script, with well-known tokens parsed as script tokens.

hex is just the serialised form of the script in hex encoding.

If you compare them carefully, they are essentially equivalent.

For example:

OP_DUP OP_HASH160 f9d49c5cf3e120ad1be60b67d868603a8fc945d2 OP_EQUALVERIFY OP_CHECKSIG

76 a9 14 f9d49c5cf3e120ad1be60b67d868603a8fc945d2 88 ac

76 is OP_DUP

14 is the number of bytes to be pushed onto the stack.

and etc...

2
  • What is "asm" stand for? Is it an acronym?
    – JDOaktown
    Commented Mar 11, 2021 at 17:52
  • 1
    i think its an abbreviation for assembly.
    – rny
    Commented Mar 12, 2021 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.