简体   繁体   English

如何解析比特币区块链 blkxxxxx.dat 文件,尤其是交易部分

[英]How to parse bitcoin blockchain blkxxxxx.dat files, especially transaction parts

I have tried pyblockchain package from emcpow2.我已经尝试过来自 emcpow2 的 pyblockchain package。 But this package seems just return header information.但是这个 package 似乎只是返回 header 信息。 What I really need is the transaction scripts and address.我真正需要的是交易脚本和地址。 As in the picture shows, there is no transaction scripts method如图所示,没有交易脚本方法

Is there any other way enter image description here to parse blkxxxxx.dat files or am I using this package incorrectly?有没有其他方法在这里输入图像描述来解析 blkxxxxx.dat 文件,或者我是否错误地使用了这个 package?

Thanks in advance提前致谢

Just parse as:只需解析为:

      for transaction in block.transactions:
          for output in transaction.outputs:
              for addr in output.addresses:
                  print(addr.address)

It is not recommended to read binary files directly, because there should be a change in the binary format.不建议直接读取二进制文件,因为二进制格式应该会有变化。

Alternatively, please use REST API instead.或者,请改用REST API

$ curl http://localhost:8332/rest/blockhashbyheight/1.json 
$ curl http://localhost:8332/rest/block/00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048.json 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM