[英]How to extract all Bitcoin Addresses from block files (revxxxxx.dat)
我正在運行一個完整的比特幣節點,並且可以訪問所有塊文件(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" )
如果你想要hash160s
,顯然 blockparser 是一個很好的工具。
https://github.com/znort987/blockparser
根據我的理解,您可能需要大量磁盤空間,最重要的是至少需要128GB RAM
,或者需要大量交換文件和大量時間。 它顯然有一個令人討厭的crashing/seg-faulting
習慣。
在第606
和729
行的util.cpp
,顯然解決失敗的方法是注釋掉// BN_CTX_init(ctx);
編輯:抱歉,更改為BN_CTX_free(ctx);
在606
和729
。
git 克隆https://github.com/znort987/blockparser.git
安裝 deps,並在目錄中運行./make
,它應該可以正常工作。
祝你好運! 不要忘記先檢查./parser
幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.