在比特币测试网下的比特币核心守护程序v0.16.99.0-7c32b41版本
Ubuntu 14.04.5 LTS x64
锁定脚本:O(NlogN)
RIPEMD160<Hash256<2 PK1 PK2 PK3 3 OP_CHECKMULTISIG>>
root@ubuntu:~# bitcoin-cli -testnet getnewaddress
2Mv3bjnJv2XtDjAvjYfKjwXBHCmojCiu3mz
root@ubuntu:~# bitcoin-cli -testnet dumpprivkey 2Mv3bjnJv2XtDjAvjYfKjwXBHCmojCiu3mz
cPegPf2xaeaqYB9kqqM2gzVPPXnAmwCME2KjsAQG6gkVnbxZpTKo
root@ubuntu:~# bitcoin-cli -testnet getnewaddress
2MsJ1eKdVZrYLptCLGNrvuTvVjVQzR2FR5o
root@ubuntu:~# bitcoin-cli -testnet dumpprivkey 2MsJ1eKdVZrYLptCLGNrvuTvVjVQzR2FR5o
cQ8ZUeBy27NKafYioHp4f3isHFTFuAx65vPf6dgUgxdNSBegsW3W
root@ubuntu:~# bitcoin-cli -testnet getnewaddress
2N4fwyEsVN9Lowja9ab5ek4R3yck3PmasdN
root@ubuntu:~# bitcoin-cli -testnet dumpprivkey 2N4fwyEsVN9Lowja9ab5ek4R3yck3PmasdN
cVTFSWeeeB9uoKZgcCbCN7eovztbQzNySGsruAFrVSiiX8ogMqtJ
如果致电root@ubuntu:~# bitcoin-cli -testnet addmultisigaddress 2 "[\"2Mv3bjnJv2XtDjAvjYfKjwXBHCmojCiu3mz\",\"2MsJ1eKdVZrYLptCLGNrvuTvVjVQzR2FR5o\", \"2N4fwyEsVN9Lowja9ab5ek4R3yck3PmasdN\"]" "test account"
{
"address": "2MwgnLokB4WA9NLNd6yL36AvPHHVChDh5r3",
"redeemScript": "522102f396b11941706b0424499fbf679c3e5987a8d2bf5b47116ec60ceb4f71804d46210256c0ec8ee73ba5fff9b12910880c12be9ff7d15f1f1b5d64685c3bcbdeb6734d210269321ca40da82f1fb8da8932b25beb96b4a84e6af593e89ee64e4c3f867eb7b553ae"
}
,请获取此信息:
validateaddress
root@ubuntu:~# bitcoin-cli -testnet validateaddress 2MwgnLokB4WA9NLNd6yL36AvPHHVChDh5r3
{
"isvalid": true,
"address": "2MwgnLokB4WA9NLNd6yL36AvPHHVChDh5r3",
"scriptPubKey": "a91430b5e8e9151e46be789562580b0118911d875f3d87",
"isscript": true,
"iswitness": false
}
向sendtoaddress
发送0.527 BTC 2MwgnLokB4WA9NLNd6yL36AvPHHVChDh5r3
root@ubuntu:~# bitcoin-cli -testnet sendtoaddress 2MwgnLokB4WA9NLNd6yL36AvPHHVChDh5r3 0.527
5332ed1482e665c6f7146283991ad69c05af99cfebab344729d54b382f68a46c
当然,我们可以在blockchain browser 5中对其进行查询。解码交易
root@ubuntu:~# bitcoin-cli -testnet gettransaction 5332ed1482e665c6f7146283991ad69c05af99cfebab344729d54b382f68a46c
{
"amount": 0.00000000,
"fee": -0.00000646,
"confirmations": 566,
"blockhash": "00000000000002cfc4df802cec81a71db91226d891967461d13fd2efc4a1e12a",
"blockindex": 55,
"blocktime": 1539251947,
"txid": "5332ed1482e665c6f7146283991ad69c05af99cfebab344729d54b382f68a46c",
"walletconflicts": [
],
"time": 1539251710,
"timereceived": 1539251710,
"bip125-replaceable": "no",
"details": [
{
"address": "2MwgnLokB4WA9NLNd6yL36AvPHHVChDh5r3",
"category": "send",
"amount": -0.52700000,
"label": "test account",
"vout": 1,
"fee": -0.00000646,
"abandoned": false
},
{
"address": "2MwgnLokB4WA9NLNd6yL36AvPHHVChDh5r3",
"category": "receive",
"amount": 0.52700000,
"label": "test account",
"vout": 1
}
],
"hex": "02000000000102f0e767b811ce82089372d33c01e8d3414141ed1e81ddb428a4627fd4a08301750000000017160014635522cd6d36b45cf770940c78642f266b143ff2feffffff679ccf96d39fe90120bda2f05df3ed839b6d2fd2f2b4f318512a769565dfa46001000000171600149a39be1c75e23903eaa348816eb6052e0fa4d103feffffff022233d3020000000017a91474e740e17eab3f6afbc65b68e06607bafb71b50b87602324030000000017a91430b5e8e9151e46be789562580b0118911d875f3d8702483045022100fc4ed93bf11a84d3ebf3a32850b27df4e800f4d7cdcb079278685866d7d0196102206313c70b24dbbfb9ed014a7613997645b2fa5ffcb03856cb156be581428ea6f6012102838aa4c771101a3045692ff1e49a583dd1a7e537f855bbe30324eed283cc8b300247304402201f19da9f999249041880ecc4319f42890ffddb3502941cc2dd1daf929e77952e0220675603fc6608f4ad5aa09eb8e6dde071ed0354f259cd0c5906a489f3851d62e901210393822b1788b15dee5cd629ebd018a29d3a3d644415810d464b309fbcffa8f0654fe81500"
}
让我们关注代码段
root@ubuntu:~# bitcoin-cli -testnet decoderawtransaction 02000000000102f0e767b811ce82089372d33c01e8d3414141ed1e81ddb428a4627fd4a08301750000000017160014635522cd6d36b45cf770940c78642f266b143ff2feffffff679ccf96d39fe90120bda2f05df3ed839b6d2fd2f2b4f318512a769565dfa46001000000171600149a39be1c75e23903eaa348816eb6052e0fa4d103feffffff022233d3020000000017a91474e740e17eab3f6afbc65b68e06607bafb71b50b87602324030000000017a91430b5e8e9151e46be789562580b0118911d875f3d8702483045022100fc4ed93bf11a84d3ebf3a32850b27df4e800f4d7cdcb079278685866d7d0196102206313c70b24dbbfb9ed014a7613997645b2fa5ffcb03856cb156be581428ea6f6012102838aa4c771101a3045692ff1e49a583dd1a7e537f855bbe30324eed283cc8b300247304402201f19da9f999249041880ecc4319f42890ffddb3502941cc2dd1daf929e77952e0220675603fc6608f4ad5aa09eb8e6dde071ed0354f259cd0c5906a489f3851d62e901210393822b1788b15dee5cd629ebd018a29d3a3d644415810d464b309fbcffa8f0654fe81500
{
"txid": "5332ed1482e665c6f7146283991ad69c05af99cfebab344729d54b382f68a46c",
"hash": "4f388f0ec97318d91a0624468dbffbf3f2c6b4ce349ca5edd70b07e69ac9851c",
"version": 2,
"size": 419,
"vsize": 257,
"weight": 1025,
"locktime": 1435727,
"vin": [
{
"txid": "750183a0d47f62a428b4dd811eed414141d3e8013cd372930882ce11b867e7f0",
"vout": 0,
"scriptSig": {
"asm": "0014635522cd6d36b45cf770940c78642f266b143ff2",
"hex": "160014635522cd6d36b45cf770940c78642f266b143ff2"
},
"txinwitness": [
"3045022100fc4ed93bf11a84d3ebf3a32850b27df4e800f4d7cdcb079278685866d7d0196102206313c70b24dbbfb9ed014a7613997645b2fa5ffcb03856cb156be581428ea6f601",
"02838aa4c771101a3045692ff1e49a583dd1a7e537f855bbe30324eed283cc8b30"
],
"sequence": 4294967294
},
{
"txid": "60a4df6595762a5118f3b4f2d22f6d9b83edf35df0a2bd2001e99fd396cf9c67",
"vout": 1,
"scriptSig": {
"asm": "00149a39be1c75e23903eaa348816eb6052e0fa4d103",
"hex": "1600149a39be1c75e23903eaa348816eb6052e0fa4d103"
},
"txinwitness": [
"304402201f19da9f999249041880ecc4319f42890ffddb3502941cc2dd1daf929e77952e0220675603fc6608f4ad5aa09eb8e6dde071ed0354f259cd0c5906a489f3851d62e901",
"0393822b1788b15dee5cd629ebd018a29d3a3d644415810d464b309fbcffa8f065"
],
"sequence": 4294967294
}
],
"vout": [
{
"value": 0.47395618,
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 74e740e17eab3f6afbc65b68e06607bafb71b50b OP_EQUAL",
"hex": "a91474e740e17eab3f6afbc65b68e06607bafb71b50b87",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"2N3uMQJm7WgsyHsnmoQS8d8eDKBco1LHzWx"
]
}
},
{
"value": 0.52700000,
"n": 1,
"scriptPubKey": {
"asm": "OP_HASH160 30b5e8e9151e46be789562580b0118911d875f3d OP_EQUAL",
"hex": "a91430b5e8e9151e46be789562580b0118911d875f3d87",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"2MwgnLokB4WA9NLNd6yL36AvPHHVChDh5r3"
]
}
}
]
}
在"scriptPubKey": {
"asm": "OP_HASH160 30b5e8e9151e46be789562580b0118911d875f3d OP_EQUAL",
"hex": "a91430b5e8e9151e46be789562580b0118911d875f3d87",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"2MwgnLokB4WA9NLNd6yL36AvPHHVChDh5r3"
]
}
中,如何计算OP_HASH160 30b5e8e9151e46be789562580b0118911d875f3d OP_EQUAL
?
我认为30b5e8e9151e46be789562580b0118911d875f3d
是指2 PK1 PK2 PK3 3 OP_CHECKMULTISIG
522102f396b11941706b0424499fbf679c3e5987a8d2bf5b47116ec60ceb4f71804d46210256c0ec8ee73ba5fff9b12910880c12be9ff7d15f1f1b5d64685c3bcbdeb6734d210269321ca40da82f1fb8da8932b25beb96b4a84e6af593e89ee64e4c3f867eb7b553ae
是指Hash256<2 PK1 PK2 PK3 3 OP_CHECKMULTISIG>
fe2c7d8886d6dacaec530916a108ad2dd040fbf72c80ea3ddd6d4f220e7e8b3a
指的是RIPEMD160<Hash256<2 PK1 PK2 PK3 3 OP_CHECKMULTISIG>>
,它不等于89f4d9cdd2b3a68a1c93d8de4417eda6e4dfdbc9
此外,https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line/blob/master/08_2_Building_the_Structure_of_P2SH.md提供了线索,但无法释放我。
如果提供任何帮助,将不胜感激。