Author

Topic: some python tools + offline blockexplorer (Read 1831 times)

newbie
Activity: 55
Merit: 0
October 15, 2012, 08:36:42 PM
#2
If anyone is interested, now there's this too. Python script to read blocks from blk0001.dat, etc...

I've already seen a few people here say they made something like this, but noone posted the code, so...
newbie
Activity: 55
Merit: 0
October 14, 2012, 01:22:35 AM
#1
So... I started educating myself about Script and how raw blocks and transactions are stored recently, and I wrote a few python functions that I thought could be useful to me later (mostly reinventing the wheel to learn about wheels...)

Anyway, I ended up making this and I thought it could be useful to others, so I'm posting it here. It contains a dict of Script opcodes, a jsonrpcserver class, a pure python function similar to bitcoind's decoderawtransaction, and a few other things.

The last part is an HTTP server that uses these functions to mimic blockexplorer.

blockexplorer.com/rawtx/  --> localhost:8334/rawtx/
blockexplorer.com/rawblock/  --> localhost:8334/rawblock/
blockexplorer.com/q/getblockcount  --> localhost:8334/getblockcount
blockexplorer.com/q/getblockhash/  --> localhost:8334/getblockhash/

I tested bxgetblock against blocks 1->100000 and blocks 199000-> 203198 on blockexplorer to weed out any bugs, so it's a safe assumption that they have the same outputs.

(Don't forget to change the rpc password in line 311 to the one in your bitcoin.conf file before running.)

Wink
Jump to: