【问题标题】:How to parse bitcoin blockchain blkxxxxx.dat files, especially transaction parts如何解析比特币区块链 blkxxxxx.dat 文件,尤其是交易部分
【发布时间】:2021-06-02 15:23:17
【问题描述】:
我尝试过 emcpow2 的 pyblockchain 包。但是这个包似乎只是返回头信息。我真正需要的是交易脚本和地址。如图所示,没有交易脚本方法
有没有其他方法enter image description here来解析 blkxxxxx.dat 文件还是我错误地使用了这个包?
提前致谢
【问题讨论】:
标签:
python
parsing
blockchain
block
bitcoin
【解决方案1】:
只需解析为:
for transaction in block.transactions:
for output in transaction.outputs:
for addr in output.addresses:
print(addr.address)
【解决方案2】:
不建议直接读取二进制文件,因为二进制格式应该会有变化。
或者,请改用REST API。
$ curl http://localhost:8332/rest/blockhashbyheight/1.json
$ curl http://localhost:8332/rest/block/00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048.json