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

2024-04-29 13:20:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我试过emcpow2的pyblockchain包。但这个包似乎只是返回标题信息。我真正需要的是事务脚本和地址。如图所示,没有事务脚本方法

是否有其他方法enter image description here来解析blkxxxxx.dat文件,或者我是否错误地使用了此包

提前谢谢


Tags: 文件方法image脚本信息标题here地址
2条回答

只需解析为:

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

不建议直接读取二进制文件,因为二进制格式应该有所更改

或者,请使用REST API

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

相关问题 更多 >