2 # Code for parsing the addr.dat file
3 # NOTE: I think you have to shutdown the Bitcoin client to
4 # successfully read addr.dat...
9 from operator import itemgetter
13 from BCDataStream import *
14 from base58 import public_key_to_bc_address
15 from util import short_hex
16 from deserialize import *
18 def dump_addresses(db_env):
21 r = db.open("addr.dat", "main", DB_BTREE, DB_THREAD|DB_RDONLY)
26 logging.error("Couldn't open addr.dat/main. Try quitting Bitcoin and running this again.")
32 for (key, value) in db.items():
33 kds.clear(); kds.write(key)
34 vds.clear(); vds.write(value)
36 type = kds.read_string()
39 d = parse_CAddress(vds)
40 print(deserialize_CAddress(d))