Bitcoind
從原始事務解碼的 JSON 中的 hex 和 asm 欄位值是什麼?
我使用命令行
bitcoin-cli decoderawtransaction <hex-value>
並返回了 JSON 輸出(見下文)。hex
但是,我注意到有些asm
欄位本身就是十六進制值(有時)。我認為這些是可以進一步解碼的元數據。那正確嗎?是否有更多關於為這 2 個欄位(或更多)傳回的 JSON 的結構和含義的文件?
另外,我在比特幣區塊瀏覽器上檢查了交易。他們似乎有一些我在 JSON 中看不到的元數據(例如接收時間、確認、中繼 ip 等……)。這些價值觀從何而來?
{ "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" ] } } ] }
此外,我使用https://blockchain.info/decode-tx解碼了原始交易並得到了一些不同的東西。
{ "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" } ] }
asm
指腳本的反序列化形式,將眾所周知的標記解析為腳本標記。
hex
只是十六進制編碼中腳本的序列化形式。如果你仔細比較它們,它們本質上是等價的。
例如:
OP_DUP OP_HASH160 f9d49c5cf3e120ad1be60b67d868603a8fc945d2 OP_EQUALVERIFY OP_CHECKSIG
76 a9 14 f9d49c5cf3e120ad1be60b67d868603a8fc945d2 88 ac
76
是OP_DUP
14
是要壓入堆棧的字節數。等等…