查找下 block 400000的coinbase的交易.
第一个 Transactions 就是coinbase a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5
.
使用rpc命令 getrawtransaction得到 rawtransaction
.
{
"result": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff3f03801a060004cc2acf560433c30f37085d4a39ad543b0c000a425720537570706f727420384d200a666973686572206a696e78696e092f425720506f6f6c2fffffffff012fd8ff96000000001976a914721afdf638d570285d02d3076d8be6a03ee0794d88ac00000000",
"error": null,
"id": null
}
在使用 decoderawtransaction 解析 上一步得到的 rawtransaction
,即 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff3f03801a060004cc2acf560433c30f37085d4a39ad543b0c000a425720537570706f727420384d200a666973686572206a696e78696e092f425720506f6f6c2fffffffff012fd8ff96000000001976a914721afdf638d570285d02d3076d8be6a03ee0794d88ac00000000
结果如下:
{
"result": {
"txid": "a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5",
"hash": "a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5",
"size": 148,
"vsize": 148,
"version": 1,
"locktime": 0,
"vin": [
{
"coinbase": "03801a060004cc2acf560433c30f37085d4a39ad543b0c000a425720537570706f727420384d200a666973686572206a696e78696e092f425720506f6f6c2f",
"sequence": 4294967295
}
],
"vout": [
{
"value": 25.33349423,
"n": 0,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 721afdf638d570285d02d3076d8be6a03ee0794d OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914721afdf638d570285d02d3076d8be6a03ee0794d88ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": [
"1BQLNJtMDKmMZ4PyqVFfRuBNvoGhjigBKF"
]
}
}
]
},
"error": null,
"id": null
}
coinbase tx手动分析下
01000000 version
01 var_int
0000000000000000000000000000000000000000000000000000000000000000 tx_id
ffffffff tx_index
3f03801a060004cc2acf560433c30f37085d4a39ad543b0c000a425720537570706f727420384d200a666973686572206a696e78696e092f425720506f6f6c2f #自定义内容
ffffffff tx_in_sequence
01 var_int
2fd8ff9600000000 amount 发币数量
19 没实际含义
76a914 OP_DUP OP_HASH160
721afdf638d570285d02d3076d8be6a03ee0794d addr_rmd160
88 ac OP_EQUALVERIFY OP_CHECKSIG
00000000 lock_time
tx结构不一样 https://btc.com/be5598cbc8881748220128c19afc6f989590d60e66bee8c0e35f3409cb281fe3
bip143
参考:
sipa的回答 https://bitcoin.stackexchange.com/a/20725
https://en.bitcoin.it/wiki/Transaction
https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer