All Projects → gcarq → Rusty Blockparser

gcarq / Rusty Blockparser

Licence: gpl-3.0
Bitcoin Blockchain Parser written in Rust language

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Rusty Blockparser

Ecdsa Private Key Recovery
A simple library to recover the private key of ECDSA and DSA signatures sharing the same nonce k and therefore having identical signature parameter r
Stars: ✭ 186 (-17.7%)
Mutual labels:  blockchain, bitcoin, litecoin
Cryptolights
Live visualisation of blockchain transactions for popular cryptocurrencies
Stars: ✭ 54 (-76.11%)
Mutual labels:  blockchain, bitcoin, litecoin
Golden Wallet React Native
Golden - Best Wallet Ever
Stars: ✭ 201 (-11.06%)
Mutual labels:  blockchain, bitcoin, litecoin
Blockchain Parser
The simpliest script for parsing Bitcoin blockchain. It made convertion of blk*****.dat files to the simple text.
Stars: ✭ 84 (-62.83%)
Mutual labels:  blockchain, bitcoin, parser
Simcoin
Blockchain simulation framework with Docker and Python.
Stars: ✭ 470 (+107.96%)
Mutual labels:  blockchain, bitcoin, litecoin
Stocklook
crypto currency library for trading & market making bots, account management, and data analysis
Stars: ✭ 119 (-47.35%)
Mutual labels:  blockchain, bitcoin, litecoin
Gitmoney
A platform designed to help people work from anywhere and get paid bitcoin.
Stars: ✭ 187 (-17.26%)
Mutual labels:  blockchain, bitcoin
Node
The core of Po.et
Stars: ✭ 192 (-15.04%)
Mutual labels:  blockchain, bitcoin
Go Quote
Yahoo finance/Google finance/Coinbase/Bittrex/Binance/Tiingo historical quote downloader library and cli written in golang
Stars: ✭ 198 (-12.39%)
Mutual labels:  bitcoin, litecoin
Adamant Im
ADAMANT Decentralized Messenger. Progressive Web Application (PWA)
Stars: ✭ 202 (-10.62%)
Mutual labels:  blockchain, bitcoin
Axentro
To be the go to platform for building dApps quickly and cheaply for business and gaming
Stars: ✭ 181 (-19.91%)
Mutual labels:  blockchain, bitcoin
Bitcoin On Nodejs
《Node.js区块链开发》,注:新版代码已开源!请star支持哦-^-:
Stars: ✭ 2,321 (+926.99%)
Mutual labels:  blockchain, bitcoin
Eclair Mobile
An Android wallet for the Lightning Network
Stars: ✭ 231 (+2.21%)
Mutual labels:  blockchain, bitcoin
Blockchainwallet Crypto
比特币、以太坊公私钥生成以及签名,长时间不维护可移步 https://github.com/QuincySx/ChainWallet
Stars: ✭ 183 (-19.03%)
Mutual labels:  blockchain, bitcoin
Factomd
Factom Daemon
Stars: ✭ 197 (-12.83%)
Mutual labels:  blockchain, bitcoin
Blockvotes
An e-voting system based on blockchain using ring signature
Stars: ✭ 182 (-19.47%)
Mutual labels:  blockchain, bitcoin
Stacks Blockchain
The Stacks 2.0 blockchain implementation
Stars: ✭ 2,549 (+1027.88%)
Mutual labels:  blockchain, bitcoin
Bitcoin S
Bitcoin Implementation in Scala
Stars: ✭ 206 (-8.85%)
Mutual labels:  blockchain, bitcoin
Lbrycrd
The blockchain that provides the digital content namespace for the LBRY protocol
Stars: ✭ 2,756 (+1119.47%)
Mutual labels:  blockchain, bitcoin
Blockchain Stuff
Blockchain and Crytocurrency Resources
Stars: ✭ 2,549 (+1027.88%)
Mutual labels:  blockchain, bitcoin

rusty-blockparser

Build Status Coverage Status Crates.io

rusty-blockparser is a Bitcoin Blockchain Parser written in Rust language.

It allows extraction of various data types (blocks, transactions, scripts, public keys/hashes, balances, ...) and UTXDO dumps from Bitcoin based blockchains.

Currently Supported Blockchains:

Bitcoin, Namecoin, Litecoin, Dogecoin, Myriadcoin and Unobtanium.

It assumes a local copy of the blockchain with intact block index, downloaded with Bitcoin Core 0.15.1+. If you are not sure whether your local copy is valid you can apply --verify to validate the chain and block merkle trees. If something doesn't match the parser exits.

Features

  • Callbacks

    Callbacks are built on top of the core parser. They can be implemented to extract specific types of information.

    balances: dumps all addresses with a non-zero balance. The csv file is in the following format:

    balances.csv
    address ; balance
    

    unspentcsvdump: dumps all UTXOs along with the address balance. The csv file is in the following format:

    unspent.csv
    txid ; indexOut ; height ; value ; address
    

    NOTE: The total size of the csv dump is at least 8 GiB (height 635000).

    csvdump: dumps all parsed data as CSV files into the specified folder. See Usage for an example. I chose CSV dumps instead of an active db-connection because LOAD DATA INFILE is the most performant way for bulk inserts. The files are in the following format:

    blocks.csv
    block_hash ; height ; version ; blocksize ; hashPrev ; hashMerkleRoot ; nTime ; nBits ; nNonce
    
    transactions.csv
    txid ; hashBlock ; version ; lockTime
    
    tx_in.csv
    txid ; hashPrevOut ; indexPrevOut ; scriptSig ; sequence
    
    tx_out.csv
    txid ; indexOut ; height ; value ; scriptPubKey ; address
    

    If you want to insert the files into MySql see sql/schema.sql. It contains all table structures and SQL statements for bulk inserting. Also see sql/views.sql for some query examples. NOTE: The total size of the csv dump is at least to 731 GiB (height 635000).

    simplestats: prints some blockchain statistics like block count, transaction count, avg transactions per block, largest transaction, transaction types etc.

You can also define custom callbacks. A callback gets called at startup, on each block and at the end. See src/callbacks/mod.rs for more information.

  • Low memory usage

    The required memory usage depends on the used callback:

      * simplestats: ~100MB
      * csvdump: ~100M
      * unspentcsvdump: ~18GB
      * balances: ~18GB
    

    NOTE: Those values are taken from parsing to block height 639631 (17.07.2020).

  • Script evaluation

    Evaluates and detects P2PK, P2PKH, P2SH and some non-standard transactions.

  • Resume scans

    --start <height> and --end <height> can be passed to resume a scan. However this makes no sense for unspentcsvdump!

Installing

This tool runs on Windows, OS X and Linux. All you need is rust and cargo.

Latest Release

You can download the latest release from crates.io:

cargo install rusty-blockparser

Build from source

git clone https://github.com/gcarq/rusty-blockparser.git
cd rusty-blockparser
cargo build --release
cargo test --release
./target/release/rusty-blockparser --help

It is important to build with --release, otherwise you will get a horrible performance!

*Tested on Gentoo Linux with rust-stable 1.44.1

Usage

USAGE:
    rusty-blockparser [FLAGS] [OPTIONS] [SUBCOMMAND]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v               Increases verbosity level. Info=0, Debug=1, Trace=2 (default: 0)
        --verify     Verifies the leveldb index integrity and verifies merkle roots

OPTIONS:
    -d, --blockchain-dir <blockchain-dir>    Sets blockchain directory which contains blk.dat files (default:
                                             ~/.bitcoin/blocks)
    -c, --coin <NAME>                        Specify blockchain coin (default: bitcoin) [possible values: bitcoin,
                                             testnet3, namecoin, litecoin, dogecoin, myriadcoin, unobtanium]
    -e, --end <NUMBER>                       Specify last block for parsing (inclusive) (default: all known blocks)
    -s, --start <NUMBER>                     Specify starting block for parsing (inclusive)

SUBCOMMANDS:
    balances          Dumps all addresses with non-zero balance to CSV file
    csvdump           Dumps the whole blockchain into CSV files
    help              Prints this message or the help of the given subcommand(s)
    simplestats       Shows various Blockchain stats
    unspentcsvdump    Dumps the unspent outputs to CSV file

Example

To make a unspentcsvdump of the Bitcoin blockchain your command would look like this:

# ./blockparser unspentcsvdump /path/to/dump/
[6:02:53] INFO - main: Starting rusty-blockparser v0.7.0 ...
[6:02:53] INFO - index: Reading index from ~/.bitcoin/blocks/index ...
[6:02:54] INFO - index: Got longest chain with 639626 blocks ...
[6:02:54] INFO - blkfile: Reading files from ~/.bitcoin/blocks ...
[6:02:54] INFO - parser: Parsing Bitcoin blockchain (range=0..) ...
[6:02:54] INFO - callback: Using `unspentcsvdump` with dump folder: /path/to/dump ...
[6:03:04] INFO - parser: Status: 130885 Blocks processed. (left: 508741, avg: 13088 blocks/sec)
...
[10:28:47] INFO - parser: Status: 639163 Blocks processed. (left:    463, avg:    40 blocks/sec)
[10:28:57] INFO - parser: Status: 639311 Blocks processed. (left:    315, avg:    40 blocks/sec)
[10:29:07] INFO - parser: Status: 639452 Blocks processed. (left:    174, avg:    40 blocks/sec)
[10:29:17] INFO - parser: Status: 639596 Blocks processed. (left:     30, avg:    40 blocks/sec)
[10:29:19] INFO - parser: Done. Processed 639626 blocks in 266.43 minutes. (avg:    40 blocks/sec)
[10:32:01] INFO - callback: Done.
Dumped all 639626 blocks:
        -> transactions: 549390991
        -> inputs:       1347165535
        -> outputs:      1359449320
[10:32:01] INFO - main: Fin.

Contributing

Use the issue tracker to report problems, suggestions and questions. You may also contribute by submitting pull requests.

If you find this project helpful, please consider making a donation: 1LFidBTeg5joAqjw35ksebiNkVM8azFM1K

TODO

  • Implement correct SegWit handling
  • Implement Pay2MultiSig script evaluation
  • Handle BECH32 addresses
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].