/SpyCblock

:octocat: :hammer: A simple Bitcoin parser to parse the raw *.dat files, and decode them into differents format :microscope: :octocat:

Primary LanguageC++Apache License 2.0Apache-2.0

GitHub Matrix

🎓 SpyCBlock 🔬

SpyCBlock is an accademics software that analyses the blk file of Bitcoin blockchain Mainet. This is an explerimental version and it wants to demostrate that it is possible to work with only file blk.

SpyCBlock is a simple parser bitcoin blk file, with this parser it is possible to do some serialization, like:

  • Serialization Transaction Graph (:heavy_check_mark:);
  • Serialization complete Blockchain to JSON (:heavy_check_mark:);
  • Serialization Address Graph (:warning:).

To reduce the space of serialization Transaction graph, it is possible to use the library ZLib to compress the information; with this code it is possible to uncompress the data.

void decompressFileWithZLib()
{
    std::string filename = "YOUR_PATH/blkXXXXX.dat";
    gzFile inFileZ = gzopen(filename.c_str(), "rb");

    if(inFileZ == NULL){
        printf("Error: Failed to gzopen %s\n", filename.c_str());
        exit(0);
    }
    unsigned char unzipBuffer[8192];
    unsigned int unzippedBytes;
    std::vector<unsigned char> unzippedData;
    while (true)
    {
        unzippedBytes = gzread(inFileZ, unzipBuffer, 8192);
        if(unzippedBytes > 0) {
            unzippedData.insert(unzippedData.end(), unzipBuffer, unzipBuffer + unzippedBytes);
        }else{
            break;
        }
    }

    for(auto &character : unzippedData)
    {
        if(character == '.'){
            std::cout << "\n";
        }else{
            std::cout << character;
        }
    }
}

It Is possible to execute the parser with the library OpenMP for execution data with multi-core and this is a simple velocity benchmark.

PS: at the moment the parser uses all core of the CPU is the multicore propriety is enabled.

benchmark_image

The graph of transactions form is describe here and this is an example to visualise this with Web app, this is a simple demo.

The screenshot of transaction graph

transaction_graph

The screenshot of address graph subdivise to class (with luvain algorithm)

address_graph

⭐ JSON version Bitcoin Blockchain :octocat:

Having the version of Bitcoin blockchain to JSON is powerful because it is possible to work on the JSON format, With this is possible to create easy analysis on Bitcoin network.

An example: I created a simple analysis with AnalytcsPyBlock to get informations from type of script used in the Bitcoin blockchain; this is the result and here is avaible the web version.

analisis_script

💥 Build SpyCBlock :octocat:

Follow this guide

🏃 Configure SpyCBlock :octocat:

Follow this guide

💬 IRC channels :octocat:

  • IRC dev channel: #spycblock-dev :neckbeard:

PS: The IRC channel is deprecated in favor of the matrix channel.

Cite

You can use the research work in any way you want but please cite us!

@software{Palazzo_A_simple_Bitcoin_2021,
    author = {Palazzo, Vincenzo and Carlo, Sartiani},
    month = {12},
    title = {{A simple Bitcoin parser to parse the raw data files, and decode them into differents format}},
    url = {https://github.com/vincenzopalazzo/SpyCBlock},
    version = {1.0.0},
    year = {2021}
}

🍺 Buy me a beer 🍺

🍺 39juEyTGSNfD9JHCZdQKAjkzC3yiudce7b 🍺