Address

測試網公鑰雜湊地址的解碼腳本

  • May 5, 2020

這是地址資訊:

bitcoin-cli validateaddress n35oDVMPNkHRzBKy7q9RDB7r5e8qbVa9SW
{
 "isvalid": true,
 "address": "n35oDVMPNkHRzBKy7q9RDB7r5e8qbVa9SW",
 "scriptPubKey": "76a914ec90ca28c0ec302e991fb1c8171bf49c0d3d05be88ac",
 "isscript": false,
 "iswitness": false
}
bitcoin-cli decodescript 76a914ec90ca28c0ec302e991fb1c8171bf49c0d3d05be88ac
{
 "asm": "OP_DUP OP_HASH160 ec90ca28c0ec302e991fb1c8171bf49c0d3d05be OP_EQUALVERIFY OP_CHECKSIG",
 "reqSigs": 1,
 "type": "pubkeyhash",
 "addresses": [
   "n35oDVMPNkHRzBKy7q9RDB7r5e8qbVa9SW"
 ],
 "p2sh": "2NFyoZJJuWpvyiHFirFqsQnPXXna6mtf4Li",
 "segwit": {
   "asm": "0 ec90ca28c0ec302e991fb1c8171bf49c0d3d05be",
   "hex": "0014ec90ca28c0ec302e991fb1c8171bf49c0d3d05be",
   "reqSigs": 1,
   "type": "witness_v0_keyhash",
   "addresses": [
     "tb1qajgv52xqasczaxglk8ypwxl5nsxn6pd7307tfg"
   ],
   "p2sh-segwit": "2MwgL2byHmKdRvfGhufKpJkpAvtDLpo1REs"
 }
}

為什麼還顯示了 2 個 P2SH 地址?它們可以互換嗎?他們有什麼共同點?

什麼是“witness_v0_keyhash”地址?

來自bitcoin-cli help decodescript

{
 "asm":"asm",          (string) Script public key
 "type":"type",        (string) The output type (e.g. nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_scripthash, witness_v0_keyhash, witness_unknown)
 "reqSigs": n,         (numeric) The required signatures
 "addresses": [        (json array of string)
    "address"          (string) bitcoin address
    ,...
 ],
 "p2sh":"str"          (string) address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH).
 "segwit": {           (json object) Result of a witness script public key wrapping this redeem script (not returned if the script is a P2SH or witness).
   "asm":"str",        (string) String representation of the script public key
   "hex":"hexstr",     (string) Hex string of the script public key
   "type":"str",       (string) The type of the script public key (e.g. witness_v0_keyhash or witness_v0_scripthash)
   "reqSigs": n,       (numeric) The required signatures (always 1)
   "addresses": [      (json array of string) (always length 1)
     "address"         (string) segwit address
      ,...
   ],
   "p2sh-segwit":"str" (string) address of the P2SH script wrapping this witness redeem script.
}

使用您的範例進行附加說明:

n35oDVMPNkHRzBKy7q9RDB7r5e8qbVa9SW:這是一個“遺留”的付費公鑰雜湊地址。asm發送到該地址的硬幣被您在輸出中看到的腳本鎖定。可以使用scriptSig包含與雜湊匹配的公鑰,後跟與公鑰匹配的簽名來解鎖它們。

p2sh: 2NFyoZJJuWpvyiHFirFqsQnPXXna6mtf4Li: 這個有點亂。它仍然是一個“遺留”(不是 segwit)地址,它是一個付費腳本雜湊地址。發送到該地址的硬幣被鎖定在上面您在上面看到的整個腳本的雜湊值中asm。它們是通過將scriptSig整個序列化腳本(DUP/HASH/EQUAL/CHECKSIG)推送到公鑰和最後簽名來花費的。

segwit: tb1qajgv52xqasczaxglk8ypwxl5nsxn6pd7307tfg: 這是一個segwit地址。BIP141定義了一些 segwit 地址類型,如您所見,這是一個付費見證的 pubkey-hashwitness_v0_keyhash或 p2wpkh 地址。發送到此地址的硬幣僅使用公鑰的散列(以及表示隔離見證的特定字節)鎖定。它們通過推送 EMPTYscriptSig並提供witness具有公鑰和簽名的堆棧來花費。

p2sh-segwit: 2MwgL2byHmKdRvfGhufKpJkpAvtDLpo1REs: 另一個隔離見證地址。如您所見,這是一個 NESTED pay-to-witness-pubkey-hash 或 p2wpkh-p2sh 地址。發送到該地址的硬幣被鎖定在該部分的部分中看到的見證程序的雜湊值。它們通過在 a和 ALSO 中提供序列化的見證程序來使用,包括帶有公鑰和簽名的見證堆棧。asm``segwit``scriptSig

概括

如果你有一個私鑰,你可以花費發送到這四個地址中的任何一個的硬幣。

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