Bitcoin-Core
從 pubkey scriptPubKey 獲取地址
鑑於這
address
是一個“方便”欄位,因此在許多事務中預設不提供它是有道理的。但是,似乎可以從中提取address``hex
. 我想知道我是否可以從bitcoin
客戶端應用程序(例如,bitcoin-qt
)中獲取此地址,最好是通過 REST API。我正在查看的一個範例塊是高度為 100 的塊:
{ "hash": "000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a", "confirmations": 715831, "height": 100, "version": 1, "versionHex": "00000001", "merkleroot": "2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866", "time": 1231660825, "mediantime": 1231656204, "nonce": 1573057331, "bits": "1d00ffff", "difficulty": 1, "chainwork": "0000000000000000000000000000000000000000000000000000006500650065", "nTx": 1, "previousblockhash": "00000000cd9b12643e6854cb25939b39cd7a1ad0af31a9bd8b2efe67854b1995", "nextblockhash": "00000000b69bd8e4dc60580117617a466d5c76ada85fb7b87e9baea01f9d9984", "strippedsize": 215, "size": 215, "weight": 860, "tx": [ { "txid": "2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866", "hash": "2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866", "version": 1, "size": 134, "vsize": 134, "weight": 536, "locktime": 0, "vin": [ { "coinbase": "04ffff001d014d", "sequence": 4294967295 } ], "vout": [ { "value": 50.00000000, "n": 0, "scriptPubKey": { "asm": "04e70a02f5af48a1989bf630d92523c9d14c45c75f7d1b998e962bff6ff9995fc5bdb44f1793b37495d80324acba7c8f537caaf8432b8d47987313060cc82d8a93 OP_CHECKSIG", "hex": "4104e70a02f5af48a1989bf630d92523c9d14c45c75f7d1b998e962bff6ff9995fc5bdb44f1793b37495d80324acba7c8f537caaf8432b8d47987313060cc82d8a93ac", "type": "pubkey" } } ], "hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d014dffffffff0100f2052a01000000434104e70a02f5af48a1989bf630d92523c9d14c45c75f7d1b998e962bff6ff9995fc5bdb44f1793b37495d80324acba7c8f537caaf8432b8d47987313060cc82d8a93ac00000000" } ] }
並非所有 scriptPubKeys 都對應一個地址。該
address
欄位是為那些這樣做的人提供的,而對於那些不這樣做的人則省略。您的範例包含一個沒有相應地址的 P2PK scriptPubKey。一些區塊鏈瀏覽器可能會從 P2PK 輸出中提取公鑰併計算相應的地址,但這在技術上是不正確的。這樣的地址將產生 P2PKH scriptPubKey,而不是 P2PK。