Bitcoind

隔離見證、比特幣 JSON-RPC 和(奇怪的?)地址

  • October 16, 2019

我正在嘗試分析此交易:

<https://blockchain.info/tx/a388d6f88373aacf2a5c170eeff4adf51f2c6744da26375d5890f42d653a2e6c>

我曾經能夠執行bitcoin-cli getrawtransaction txid 1並獲得合理的輸出,但是使用這個特定的事務 id 執行它,我得到了這個:

{
 "txid": "a388d6f88373aacf2a5c170eeff4adf51f2c6744da26375d5890f42d653a2e6c",
 "hash": "c856582f997dc4b6f1e009f2096c4e549aeaeeb3f20703dbd71476dc957f77ec",
 "version": 1,
 "size": 383,
 "vsize": 192,
 "locktime": 0,
 "vin": [
   {
     "txid": "37138d3df8e1d41bf6474ecdc21d53f78ab9907c500172de31bda4048556bd83",
     "vout": 1,
     "scriptSig": {
       "asm": "",
       "hex": ""
     },
     "txinwitness": [
       "",
       "304402205ed1d5ac8bee5f58da52cdf6fe6e64dccd9560c84ae933172ad26ae1fd7468eb02201e5db99e00d7fd3997b2b457c4b689c1cd8b2708afa128d030fc62055117d07401",
       "3045022100fa5054964962656890e466b35f111ab5b2f869eb41c39a6830bde9b7f00013b00220592d5369b295ec49e90504060748a67cc371519ab945fbcbb9e99b5b1d8040dc01",
       "52210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae"
     ],
     "sequence": 4294967295
   }
 ],
 "vout": [
   {
     "value": 0.08000000,
     "n": 0,
     "scriptPubKey": {
       "asm": "OP_DUP OP_HASH160 04645ed4e7b22362e4baf1aa396115450d99347c OP_EQUALVERIFY OP_CHECKSIG",
       "hex": "76a91404645ed4e7b22362e4baf1aa396115450d99347c88ac",
       "reqSigs": 1,
       "type": "pubkeyhash",
       "addresses": [
         "1QDwdPsF1cpf6Wvmo8QmFWZKUVGh1KzNh"
       ]
     }
   },
   {
     "value": 0.01043487,
     "n": 1,
     "scriptPubKey": {
       "asm": "0 701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d",
       "hex": "0020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d",
       "type": "witness_v0_scripthash"
     }
   }
 ],
 "hex": "0100000000010183bd568504a4bd31de7201507c90b98af7531dc2cd4e47f61bd4e1f83d8d13370100000000ffffffff0200127a00000000001976a91404645ed4e7b22362e4baf1aa396115450d99347c88ac1fec0f0000000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d040047304402205ed1d5ac8bee5f58da52cdf6fe6e64dccd9560c84ae933172ad26ae1fd7468eb02201e5db99e00d7fd3997b2b457c4b689c1cd8b2708afa128d030fc62055117d07401483045022100fa5054964962656890e466b35f111ab5b2f869eb41c39a6830bde9b7f00013b00220592d5369b295ec49e90504060748a67cc371519ab945fbcbb9e99b5b1d8040dc016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000",
 "blockhash": "000000000000000000e8b63e15371848d765904e3bcfee1d0b45a37247fca9c2",
 "confirmations": 7,
 "time": 1507561656,
 "blocktime": 1507561656
}

因此,第二個輸出中沒有地址。但是 blockchain.info 有這樣的說法:

bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej (0.09083487 BTC - Output) --&gt; 1QDwdPsF1cpf6Wvmo8QmFWZKUVGh1KzNh - (Unspent) 0.08 BTC, 
bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej - (Unspent) 0.01043487 BTC

我有多個問題:

  1. 在我提供的上述 blockchain.info 連結中,那些以“bc1 …”開頭的奇怪地址是什麼,以及
  2. 有沒有辦法從輸出中提取此類數據getrawtransaction
  3. 如果沒有,blockchain.info 是如何做到的?

在我提供的上述 blockchain.info 連結中,那些以“bc1 …”開頭的奇怪地址是什麼,以及

這些是 bech32 地址。這些在BIP 173中指定

有沒有辦法從 getrawtransaction 的輸出中提取這些數據?

不可以。最新版本的 Bitcoin Core 沒有將本地見證輸出轉換為 bech32 地址的功能。然而,blockchain.info 這樣做了,他們將這些輸出顯示為 bech32 地址。比特幣核心中的 Bech32 功能將與隔離見證錢包功能一起在比特幣核心 0.15.1 中發布。

如果沒有,blockchain.info 是如何做到的?

Blockchain.info 不使用比特幣核心。他們有自己的定制軟體,似乎他們已經實現了 bech32。

引用自:https://bitcoin.stackexchange.com/questions/60463