Post
Topic
Board Development & Technical Discussion
Merits 1 from 1 user
Re: Complete chainstate export from 2018-10-15 as torrent.
by
hackbyte
on 15/10/2018, 17:35:19 UTC
⭐ Merited by ETFbitcoin (1)
So, how do we use the parsed chainstate? Do we use https://github.com/mycroft/chainstate and follow the instruction on "How to Run" section?

Well, i don't know how you want or can use it at all. For me, i just wrote some bits python down to write every address i find in the original csv in to a database table..

Code:
#!/usr/bin/python
import sys, time, psycopg2

# chainstate output
sourcefile = "chainstate.output"

# oeffne chainstate export
filehandle = open(sourcefile, 'r')

# open database connection
dbcon = psycopg2.connect('host=** dbname=** user=** password=**')
dbcur = dbcon.cursor()

counter=1
tablename="btc_address"
fieldname="address"

for line in filehandle:

# read data from csv line
txid, dunno, address, value = line.strip().split(';')

# put it into the db, don't ask, just try and skip if it fails
try:
dbcur.execute("INSERT INTO " + tablename + " (" + fieldname + ") VALUES ('"+str(address)+"')")
dbcon.commit()
print("\033[K %08d written %s\n" % (counter,address), end='', flush=True)
counter += 1
continue
except:
print("\033[K %08d skipped %s\r" % (counter,address), end='', flush=True)
counter += 1
continue

print("\n")


So, whatever you want to do, just have fun. I'm just playing around for educational reasons. Wink

Oh btw, the format of the chainstate.output file is as follows (first 5 lines):

Code:
questron|hackbyte|18:01:48|~| 0> head -n 5 chainstate.output
033e83e3204b0cc28724e147f6fd140529b2537249f9c61c9de9972750030000;0;1KaPHfvVWNZADup3Yc26SfVdkTDvvHySVX;65279
4aa1defd46f10c27ff4d6c2565e1e0e611429cd673b0f7342f30820690030000;0;3PPqDTQgndCHiDxqeB3zayJxXB6UeKAiod;996900
b58cf0f52c86022b046838472fc308cb55c9756071399840ad38de8166040000;0;1NXznFqccAinm9RLEf9eTtppZG9tWJQp8M;259531
e1c9467a885a156e56a29d9c854e65674d581ad75611b02290454b4862060000;1;1LpCmEejWLNfZigApMPwUY9nZTS8NTJCNS;9466355
a1f28c43f1f3d4821d0db42707737ea90616613099234f905dfc6ae2b4060000;1;1FuphZ7xVPGrxthQT1S8X7nNQNByYxAT3V;339500

Have fun Wink

Hacky