Giter Club home page Giter Club logo

regtest's Introduction

Bitcoin SV Node

Regtest (multi-node)

This repository allows you run a full bitcoin network in an isolated environment. It uses bitcoin SV's regtest capability to setup an isolated bitcoin network, and then uses docker to setup a network with 2 nodes.

This is useful because normally in regtest mode you would generate all coins in the same wallet as where you'd send the coins. With this setup, you can use one node to generate the coins and then send it to one of the other nodes, which can then again send it to another node to simulate more real-life bitcoin usage.

Simple run

docker-compose up

to start all the containers. This will start the bitcoin nodes, and expose RPC on all of them. The nodes will run on the following ports:

Node RPC port * P2P port * RPC Username RPC Password
node1 18332 18333 bitcoin bitcoin
node2 18502 18501 bitcoin bitcoin
node3 18602 18601 bitcoin bitcoin

* Port as exposed on the host running docker.

Connect nodes to each other

./connect.sh

or, manually:

./regtest1.sh addnode "node2:18333" add
./regtest1.sh addnode "node3:18333" add

Samples

Note these samples use curl to exercise the API, but this would usually be bitcoin-cli. We're using curl so we don't have a dependency on bitcoin in the host.

You can also use the b.sh script passing any parameters. b.sh makes a call to the bitcoin-cli on regtest_node1_1

eg ./b.sh getinfo

Initial block count

Checks that the initial block count is 0.

# docker-compose up -d
Creating regtest_node1_1 ... done
Creating regtest_node2_1 ... done
Creating regtest_node3_1 ... done
# curl -d '{"jsonrpc":"2.0","id":"1","method":"getblockcount"}' -u bitcoin:bitcoin localhost:18332
{"result":0,"error":null,"id":"1"}

Check connected nodes

Check the "miner" node is connected to other nodes.

# curl -d '{"jsonrpc":"2.0","id":"1","method":"getpeerinfo","params":[]}' -u bitcoin:bitcoin -s localhost:18332 | jq '.result[] | {addr, inbound} '
{
  "addr": "node2:18333",
  "inbound": false
}
{
  "addr": "172.20.0.2:48504",
  "inbound": true
}
{
  "addr": "node3:18333",
  "inbound": false
}
{
  "addr": "172.20.0.4:57912",
  "inbound": true
}

regtest's People

Contributors

icellan avatar liam 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.