GithubHelp home page GithubHelp logo

isabella232 / testchain-generator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from citp/testchain-generator

0.0 0.0 0.0 47 KB

Generate synthetic blockchains

License: GNU General Public License v3.0

Python 99.56% Shell 0.44%

testchain-generator's Introduction

Testchain Generator

Build Status

This tools deterministically generates a synthetic blockchain using Bitcoin's regtest mode. It was written to provide a lean blockchain to run functional and regression against and is used to test BlockSci.

Requirements

  • Requires Python >=3.6
  • Install Bitcoin Core (bitcoind)
  • Install secp256k1
  • Install Python3 requirements
    • pip3 install -r requirements.txt

Running

The generate_chain.py script takes three arguments:

  • --output-dir= specifies where the output should be stored (default: ../files/)
  • --chain= specifies whether a Bitcoin or a Bitcoin Cash chain should be generated (options: btc or bch, default: btc)
  • --exec= expects a path to the node daemon (default: bitcoind)

If you are using this as a submodule for BlockSci and want to update the Bitcoin (BTC) chain, you would run

python3 generate_chain.py

It will automatically update the BlockSci/test/files/btc/ directory with the new block and json files.

To update the Bitcoin Cash output, you'll need to select bch and provide a path to the Bitcoin ABC daemon executable.

python3 generate_chain.py --chain=bch --exec=<path/to/bitcoincashdaemon>

If you're using this as a standalone tool, you'll probably want to change the output directory for the generated files, e.g.

python3 generate_chain.py --output-dir=.output

Extending the blockchain

New motifs can be created by adding a new class in blockgen/motifs/ that inherits from Generator. Then, add this new class to generate_chain.py. The Generator class provides a number of utility functions, such as:

  • next_address(): returns a new Address
  • current_address(): returns the current address (the one returned by the last next_address() call)
  • fund_address(addr, value): sends value BTC to the address addr
  • create_transaction([sources], [recipients]): creates a new transaction using a list of addresses as inputs ([sources]) and another list of addresses as outputs ([recipients])
  • generate_block(): creates a new block that includes all transactions created since it was last called

testchain-generator's People

Contributors

maltemoeser avatar

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.