如何从阻止文件(revxxxxx.dat)中提取所有比特币地址

时间:2018-10-07 07:35:48

标签: python database blockchain bitcoin bitcoind

我正在运行一个完整的比特币节点,并且可以访问所有阻止文件(150GB) (我的服务器具有32GB RAM和400GB SSD)

有什么想法如何从阻止文件(revxxxxx.dat)中提取比特币地址或hash160?

我只需要找到到目前为止所有使用过的比特币地址(找到重复的地址就可以了)

这是我执行此操作的代码,但是它非常慢且无用

from bitcoin.rpc import RawProxy

for blockheight in xrange(0, 543624):
    # Create a connection to local Bitcoin Core node
    p = RawProxy()

    # Get the block hash of block with height blockheight
    blockhash = p.getblockhash(blockheight)

    # Retrieve the block by its hash
    block = p.getblock(blockhash)

    # Element tx contains the list of all transaction IDs in the block
    transactions = block['tx']

    for txid in transactions:
        # Retrieve the raw transaction by ID
        try:
            raw_tx = p.getrawtransaction(txid)
        except:
            with open("error.txt", "a") as f: 
                f.write(str(blockheight) + "," + str(txid) + ",\n" )
            continue

        # Decode the transaction
        decoded_tx = p.decoderawtransaction(raw_tx)

        # Iterate through each output in the transaction
        for output in decoded_tx['vout']:
            try:
                with open('hash160.txt', 'a') as file:
                    file.write(output['scriptPubKey']['asm'].split('OP_HASH160 ')[1].split(' ')[0] + "," + output['scriptPubKey']['addresses'][0] + ",\n")
            except: 
                with open("error.txt", "a") as f: 
                    f.write(str(blockheight) + "," + str(txid) + "," + str(decoded_tx) + ",\n" )

1 个答案:

答案 0 :(得分:1)

如果您想使用hash160s,显然blockparser是一个很棒的工具。

https://github.com/znort987/blockparser

根据我的理解,您可能会需要大量的磁盘空间,并且至关重要的是至少128GB RAM,或者大的交换文件和大量的时间。它显然具有crashing/seg-faulting的讨厌习惯。

util.cpp606行的729中,显然失败的解决方案是注释掉// BN_CTX_init(ctx);

编辑:抱歉,在行BN_CTX_free(ctx);606上更改为729

git clone https://github.com/znort987/blockparser.git

安装deps,然后在目录中运行./make,它应该可以正常工作。

祝你好运!不要忘记先检查./parser帮助。