Giter Club home page Giter Club logo

blockchain-parser's Introduction

Blockchain parser

Author: Denis Leonov [email protected]

Simple script for parsing blkXXXXX.dat files of Bitcoin blockchain database.

This script also compatible with most of altcoins, after making some tiny tricks.

The one realisation of blockchain parser that allows you to explore the main database as close as possible.

blockchain parser

Don't worry to email me your questions or suggestions about this parser.

No dependencies, no third-parties modules or libs needed. Just install Python standart release and run.

Make sure you change the paths for blkXXXXX.dat files and for the parsing results to yours.

This script convert the full blockchain raw database that is stored in blkXXXXX.dat files to the simple txt view.

If this was helpfull for you, don't hesistate to make a donations!!!

Bitcoin (BTC): 1FvssyzXNnmgHbJg2DYwb7rkzTrtT8adcL

blockchain-parser's People

Contributors

ragestack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blockchain-parser's Issues

Need Tx Details

This parser works great, however the ouput does not have the transaction addresses and BTC quantity explicitly. How do I decode that information?

Appreciate your help.

This is what I see as output:

transactionVersionNumber = 00000001
Inputs count = 02
TX from hash = 4E94BFC9654465092E38279FE94FBB5249FC4D07F2544960BC8A31DD1469DB9E
N output = 00000002
Input script = 0047304402202C83593385F29E32FA7E18FFB26F49FABE1BC6533F958AB04B6206F07DB247FC0220240E687974432FB912AF0D4EBEF780E6A3FC627E272FD653C9EC6E3B999F860901473044022038B2DD1C910A775C170B90D7AB22926F3E8912E3FFDDBC8CFB67F04C4C1B911E0220553ABF9429655747ED902A0D99E12E8596AA80028AF95B1DCB32E4C237A65E49014C69522103F51E8076324E1E6AE665CCC645D1E0DD3998236DF5F6263140BFC40448C81FAB2102A03CD673CE078E6F6922793B4067B3EDA0BD79C4CA41C961099DA66AC7F1108E2102FD7D8158C3AF6E11EB0C13859FD0A963ED86D955BB89CF7D94EFD720226C7BA853AE
sequenceNumber = FFFFFFFF
TX from hash = 9263840FC4B9DA86A8A606AF82268F9EBC7D4D8375CD395895CFA3E26171C6E0
N output = 00000000
Input script = 00483045022100E48A1692D82C6245BE690FC5C038B8390DF6F0FDB3460FE9B2F7ECCC7EFAB3BC022037A8538B5D4710A3EE0EA87590AB7E97F113CB107DFF9B16B9E586A80E3CB3650147304402204DFF76D443C72554818962F3B19E24A4112CD8C0C38559B09A941160BDC06F0902202F5D86529E9965D767C182947934CFF78C5CB490D9CFF2E9C955C65B6ADF7F39014C6952210245D5CF280B76327A059158537DA5D596365130A234769CD2EE4F1B88A2BA24522102FD08476944A2B7B67CEB870249C435532080A4E34D5DB06420674E9E10F9653721034A06FE8F3129EC4CDB849B3BC52C6EA2F4C119FA1D0DAFA3DCAF478BA58EB9BB53AE
sequenceNumber = FFFFFFFF
Outputs count = 2
Value = 0000000000C5CE1F
Output script = A9142A25F5F255EB0F7DAF1A96464E63E7A46DF1A3EC87
Value = 0000000000000000
Output script = 6A146F6D6E69000000000000001F00000004A817C800
Lock time = 00000000
TX hash = E6B4E3A9925C6C2D099BB6DDFD4F2A65575F8ACE66E7E9E731FEEB19C9A85DC4

MemoryError after first block is parsed

Traceback (most recent call last):
File "D:\parser\blockchain-parser.py", line 167, in
tmpHex = read_bytes(f,scriptLength,'B')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\parser\blockchain-parser.py", line 33, in read_bytes
data = file.read(n)
^^^^^^^^^^^^
MemoryError

crashes on first block

Toying around with blockchain parsers I also tried yours ... to little success so far. I added just a print line before the crashing line and set my blockchain data folder.

$ python blockchainParser.py 
Start /home/leo/.bitcoin/blocks/blk00000.dat in 2019-03-21 22:22:55.012799
txCount is 1
txCount is 115231992590434559
Traceback (most recent call last):
  File "blockchainParser.py", line 146, in <module>
    for k in range(txCount):
MemoryError

Syntax error in file name, folder name, or volume label

Hello Denis, indicated the saving of the blockchain to disk D, indicated this path in the software -
dirA = 'D:\BTC\blocks' # Directory where blk*.dat files are stored
#dirA = sys.argv[1]
dirB = 'D:\Result' # Directory where to save parsing results
#dirA = sys.argv[2]

here is the error code -
D: \Result\blockchain-parser-master> py blockchain-parser.py
Traceback (most recent call last):
File "D:\Result\blockchain-parser-master\blockchain-parser.py", line 61, in
fList = os.listdir (dirA)
OSError: [WinError 123] Syntax error in file name, folder name or volume label: 'D: \ BTC \ x08locks'

tried to write another way
dirA = 'D:\BTC\blocks' # Directory where blk * .dat files are stored
#dirA = sys.argv [1]
dirB = 'D:\Result' # Directory where to save parsing results
#dirA = sys.argv [2]

then the mistake is
D:\Result\blockchain-parser-master> py blockchain-parser.py
File "D:\Result\ blockchain-parser-master \ blockchain-parser.py", line 56
dirA = 'D:\BTC\blocks' # Directory where blk * .dat files are stored
^
SyntaxError: EOL while scanning string literal

I tried to run from the root of the C drive and put the blk * file next to it and indicate the path, the error repeats

Tell me what I'm doing wrong, thanks in advance

Hitting crashes

Hello! Is this meant to be run under Python 2 or 3? Under Python 2, I get:

Start /var/bitcoin/data/blocks/blk00000.dat in 2020-02-26 11:04:09.093834
Traceback (most recent call last):
  File "./blockchain-parser.py", line 79, in <module>
    tmpHex = read_bytes(f,4)
  File "./blockchain-parser.py", line 38, in read_bytes
    data = data.hex().upper()
AttributeError: 'str' object has no attribute 'hex'

Under Python 3 I get:

Start /var/bitcoin/data/blocks/blk00000.dat in 2020-02-26 11:05:58.985973
Traceback (most recent call last):
  File "./blockchain-parser.py", line 169, in <module>
    tmpHex = read_bytes(f,scriptLength,'B')
  File "./blockchain-parser.py", line 35, in read_bytes
    data = file.read(n)
MemoryError

I'm using data files from bitcoin-core 0.19. Seems similar to issue #3

get list of all adresses on bitcoin block chain

how can i get all addresses on bitcoin blockchain i mean every address that comited a transaction on blockchain no matter it has balance or not?
for example get list of all addresses in text file
no balance or transaction or anything else just adresses
thank you

AttributeError: 'bytes' object has no attribute 'encode'

I get the following error as soon as i start the script:

Start /media/aman/BTC_Blockch/blocks/blk00000.dat in 2019-05-03 17:42:56.161722
Traceback (most recent call last):
File "blockchain-parser.py", line 64, in
b = b.encode('hex').upper()
AttributeError: 'bytes' object has no attribute 'encode'

Ideas?

TX

hi! would like to ask its possible to modify script to received rawtx? ScriptSig Size and ScriptPubKey Size must be calculated separately or its just didnt parse? thank for your work!

Enchancement Request for additional information.

Please allow it to output the source address for a transaction in either hex or address code (preferably both). Output the R and S values for each transaction (preferably in both hex or integer). Also, output the destination address in hex and normal address for each transaction.

maximum recursion depth exceeded

File "blockchain-parser.py", line 30, in merkle_root
return merkle_root([hash_pair(x,y) for x, y in zip(*[iter(lst)]*2)])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Previous line repeated 996 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object

using python 3.11.3

sys.setrecursionlimit(num) crashes windows before completing a block transformation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.