Code Monkey home page Code Monkey logo

bitcoin-testnet-box's Introduction

bitcoin-testnet-box

docker pulls

Create your own private bitcoin testnet

You must have bitcoind and bitcoin-cli installed on your system and in the path unless running this within a Docker container (see below).

Large Git History

If you'd like to clone this git repository locally and disk space or bandwidth usage is of concern, it's suggested to do a shallow clone, excluding some earlier history of the repo, where some testnet data was included.

Regular clone: du -sh . 44M

Shallow clone: du -sh . 168K

Regular Clone

git clone [email protected]:freewil/bitcoin-testnet-box.git

Shallow Clone

git clone --shallow-since 2014-10-18 [email protected]:freewil/bitcoin-testnet-box.git

Starting the testnet-box

This will start up two nodes using the two datadirs 1 and 2. They will only connect to each other in order to remain an isolated private testnet. Two nodes are provided, as one is used to generate blocks and it's balance will be increased as this occurs (imitating a miner). You may want a second node where this behavior is not observed.

Node 1 will listen on port 19000, allowing node 2 to connect to it.

Node 1 will listen on port 19001 and node 2 will listen on port 19011 for the JSON-RPC server.

$ make start

Check the status of the nodes

$ make getinfo
bitcoin-cli -datadir=1  getinfo
{
    "version" : 90300,
    "protocolversion" : 70002,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 0,
    "timeoffset" : 0,
    "connections" : 1,
    "proxy" : "",
    "difficulty" : 0.00000000,
    "testnet" : false,
    "keypoololdest" : 1413617762,
    "keypoolsize" : 101,
    "paytxfee" : 0.00000000,
    "relayfee" : 0.00001000,
    "errors" : ""
}
bitcoin-cli -datadir=2  getinfo
{
    "version" : 90300,
    "protocolversion" : 70002,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 0,
    "timeoffset" : 0,
    "connections" : 1,
    "proxy" : "",
    "difficulty" : 0.00000000,
    "testnet" : false,
    "keypoololdest" : 1413617762,
    "keypoolsize" : 101,
    "paytxfee" : 0.00000000,
    "relayfee" : 0.00001000,
    "errors" : ""
}

Creating wallets

bitcoin-cli -datadir=1 createwallet wallet1
bitcoin-cli -datadir=2 createwallet wallet2

Generating blocks

Normally on the live, real, bitcoin network, blocks are generated, on average, every 10 minutes. Since this testnet-in-box uses Bitcoin Core's (bitcoind) regtest mode, we are able to generate a block on a private network instantly using a simple command.

To generate a block:

$ make generate

To generate more than 1 block:

$ make generate BLOCKS=10

Need to generate at least 100 blocks before there will be a balance in the first wallet

$ make generate BLOCKS=200

Verify that there is a balance on the first wallet

$ make getinfo

Generate a wallet address for the second wallet

$ make address2

Sending bitcoins

To send bitcoins that you've generated to the second wallet: (be sure to change the ADDRESS value below to wallet address generated in the prior command)

$ make sendfrom1 ADDRESS=mxwPtt399zVrR62ebkTWL4zbnV1ASdZBQr AMOUNT=10

Does the balance show up?

Run the getinfo command again. Does the balance show up? Why not?

$ make getinfo

Generate another block

$ make generate

Stopping the testnet-box

$ make stop

To clean up any files created while running the testnet and restore to the original state:

$ make clean

Using with docker

This testnet-box can be used with Docker to run it in an isolated container.

Building docker image

Pull the image

  • docker pull freewil/bitcoin-testnet-box

or build it yourself from this directory

  • docker build -t bitcoin-testnet-box .

Running docker container

The docker image will run two bitcoin nodes in the background and is meant to be attached to allow you to type in commands. The image also exposes the two JSON-RPC ports from the nodes if you want to be able to access them from outside the container.

$ docker run -t -i -p 19001:19001 -p 19011:19011 freewil/bitcoin-testnet-box

or if you built the docker image yourself:

$ docker run -t -i -p 19001:19001 -p 19011:19011 bitcoin-testnet-box

Running without docker

To run without docker, one should download the supported Bitcoin core version. To find the supported version, search for the BITCOIN_CORE_VERSION environment variable in the Dockerfile file.

bitcoin-testnet-box's People

Contributors

chungy avatar freewil avatar ivanvnucec avatar jrmrjnck avatar kocmo avatar mkinney avatar ramontayag avatar scholtz avatar tiero avatar valerianpereira 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bitcoin-testnet-box's Issues

password for user 'tester' ?

$sudo docker run -t -i -p 19001:19001 -p 19011:19011 freewil/bitcoin-testnet-box

when i run this ,
i come into this docker cmd,
so i want apt get install vim ,
but it tell me i need some root ?
so i use sudo ,but i dont know the tester user`s password.

Large git history

This is more of an FYI (Slowed down cloning):

shai ~/bitcoin-testnet-box [master] ± % du -sh .
 45M	.

shai ~/bitcoin-testnet-box [master] ± % du -sh .git/
 45M	.git/

shai ~/bitcoin-testnet-box [master] ± % du -sh **
 12K	1
 12K	2
4.0K	Dockerfile
4.0K	LICENSE
4.0K	Makefile
4.0K	README.md

shai ~/bitcoin-testnet-box [master] ± % du -sh .git/objects
 45M	.git/objects

RPC 请求

请问怎么在容器外进行 RPC 请求呢?
在容器内执行 bitcoind 之后报错:
Binding RPC on address ::1 port 8332 failed

端口不应该是 19001 吗?请问还需要改动哪些配置吗?

litecoind integration

I am trying to make this with litecoin.
prompt$ make start
make: 'start' is up to date.
prompt$ ~/litecoin-testnet-box$ make getinfo
litecoind -datadir=1 getinfo
Error: Command line contains unexpected token 'getinfo', see litecoind -h for a list of options.
Makefile:18: recipe for target 'getinfo' failed
make: *** [getinfo] Error 1
Thank you

how to determine the address of a node

Hi,

So I'm running this docker* container to create a local testnet for purposes of doing a bit of bitcoin development, actually what I want to do is run abe on the local testnet so I can explore transaction in a database.

anyway, when I run the command make send ADDRESS=mxwPtt399zVrR62ebkTWL4zbnV1ASdZBQr AMOUNT=10 the bitcoins just disappear... I even minded new blocks to see if maybe the transactions weren't processed but that isn't it either.

I conjecture that this is because that address isn't associated with my node 2, so then my question is:

how can I determine the actual addresses of my nodes?

*Well actually I'm running the one of c0achmcguirk/bitcoin-dev-box which is a fork of this- but he doesn't have an issues tab- what's up with that?

How to ues testnet instead of regtest

After pulling and running this docker image, I use make start.
Then I got two wallets that use regtest mode.
Can I start with testnet mode?

Thanks for your help!

make getinfo error

tester@37aa027ed53b:~/bitcoin-testnet-box$ make getinfo
bitcoin-cli -datadir=1 getinfo
error code: -32601
error message:
getinfo

thank you

latest master Generate Coins

test coins; hmm sounds stupid but how does one get some test coins;

I have been generating blocks for a while; no joy; my bitcoind version is 8.0; it would be cool if this test box came with a balance already to rock and roll; is it just a case of playing a waiting game until coins have been generated;

cheers

Testnet Coin Generation Time

How long will in normally take to generate some coins in the private test network?

Thanks for putting this together!

Confirming transactions in the box

Hi, I'm trying to send from 1 to 2 and back, but this doesn't seem to be possible as there are no confirmations for the transaction? Please let me know if I did something wrong.

If not, could you update node 2 to have a few coins, I want to write tests for listaddressgroupings and maybe a few more that would need this. Or could I just launch more nodes on port 19000, do this by myself, and contribute a patch?

Mining

Hello, in the Makefile one can assign one node to generate a certain number of blocks. Also, it seems one can initiate more than two nodes. My question is, instead to explicitly assign which node to generate a new block, is it possible to have two or more nodes compete on a new block? Thanks!

bitcoin-qt: not found

When running make start-gui I get this error /bin/sh: 1: bitcoin-qt: not found.

Previous steps taken:
docker pull freewil/bitcoin-testnet-box
docker run -t -i -p 19001:19001 -p 19011:19011 freewil/bitcoin-testnet-box
and then I try to run start-gui right away.

I have Bitcoin-Qt installed locally, version 0.14.1.

transaction confirmations

I installed and ran with generate-true and got some test coins. So far so good. Then I added an account 'test01' in the '1' instance. I used "sendfrom '' 3.0 1 'foo bar'" to send 3.0 from the account '' to the account 'test01'.

"listtransactions test01" shows the transaction and 'listaccounts' shows that the balance in the account '' fell by 3.0. But the transaction's 'confirmations' remains 0 and the balance of test01 remains 0.0.

Help?

Fee estimation failed.

When sendingfrom1, it shows:
error code: -6
error message:
Fee estimation failed. Fallbackfee is disabled. Wait a few blocks or enable -fallbackfee.

Docker: Could not find repository

Hi @freewil, I'm testing out the Docker capability of this to make my dev box a little cleaner. I'm getting the following error though:

~/s/i/testnet ❯❯❯ sudo docker pull freewil/bitcoin-testnet-box                                                                                                                              ⏎
Pulling repository freewil/bitcoin-testnet-box
0e8a6fc89c75: Error pulling image (latest) from freewil/bitcoin-testnet-box, Driver devicemapper failed to create image rootfs 1b12296cd1500bf3720682f52555ce9f65c3bc6056e5c40476d220ec3aedb51
9: hash 1b12296cd1500bf3720682f52555ce9f65c3bc6056e5c40476d220ec3aedb519 already exists 65c3bc6056e5c40476d220ec3aedb519 already exists
6170bb7b0ad1: Download complete
9cd978db300e: Download complete
b487e366b098: Download complete
71a819a5e457: Download complete
1b12296cd150: Error downloading dependent layers
2014/06/15 04:35:15 Could not find repository on any of the indexed registries.

Any ideas?

What's special about the 'easy-mining' branch in your fork of bitcoin and what should I consider if I wish to update the testnet-box to use bitcoin core v0.9.2?

Hi @freewil, great work with this project. I'm slowly getting my head around it.

I'd like to update the version of bitcoind that the Docker file loads and I note that you've created your own form of the Bitcoin project and created a custom 'easy-mining' branch. I've tried to look through the change logs to see what's special about it but nothing leaps out at me.

What should I look out for if trying to update my core to version 0.9.2 so my tests are as close as possible to being concurrent with my eventual production system? Or doesn't it matter?

Cheers

Dave

Cannot generate blocks

When I run make start and then make generate I get the following error:

$ make generate
bitcoin-cli -datadir=1  -generate 1
error code: -18
error message:
No wallet is loaded. Load a wallet using loadwallet or create a new one with createwallet. (Note: A default wallet is no longer automatically created)

I think the problem is with the 0.21.0 version of bitcoin-cli because that version hasn't got default wallet.
I think that is the issue with the #52.
Maybe downgrade the version to the correct one or update README and Dockerfile with the creation of the bitcoin wallet commands.

ENV BITCOIN_CORE_VERSION "0.21.0"

Not compatible with v.0.8.0

Hello, git clone followed by make start (bitcoin 0.8 installed) gives me:
Error: Error initializing database environment /home/default/Desktop/testnet/bitcoin-testnet-box/2/testnet3! To recover, BACKUP THAT DIRECTORY, then remove everything from it except for wallet.dat.

allow private networks by default

We should add rpcallowip commands to the 2 bitcoin.conf files so we can access the JSON-RPC servers from outside docker container.

Problems connecting to testnet from node-bitcoin

I've got your bitcoin-testnet-box running (nice one) and had to modify the bitcoin.conf files slightly to allow incoming RPC calls by adding rpcallowip=192.168.59.103 where 192.168.59.103 is the IP of my VM as seen from my Mac.

I'm trying a simple test from my Node.js app to check that I have the connections right etc,

var bitcoin = require('bitcoin'),
    client = new bitcoin.Client({
      host: "192.168.59.103",
      port: 49155,
      user: "admin1",
      pass: "123"
    });

describe("Core Wallet Functions", function() {

  it("can get the current bitcoin difficulty", function(done){
    client.getDifficulty(function(err, difficulty){
      console.log("got response", err, difficulty);
      expect(err).to.equal(null);
      expect(difficulty).to.equal(1);
      done();
    });
  });
});

but I get an error response { [Error: Invalid params, response status code: 403] code: -32602 }

I've written this up over at StackOverflow - see http://stackoverflow.com/questions/25116608/how-to-connect-to-a-bitcoin-testnet-running-in-a-docker-container/

I'm hoping you can assist.
Thanks
Dave

Mine on testnet/regtest

Is it possible to mine with cgminer on the testnet. Or is the block generation just simulated?

Simplify Dockerfile

I think the layers of the Docker image can be lessen.

Some steps can be merged in Dockerfile, and the user tester is unnecessary.

So, in this issue, I want

  • Remove unnecessary steps
  • Merge commands in one layer

What do you think?

password for user 'tester'

why does the docker file default to the user called "tester" how can you log in as root? what's the password for 'tester'?

Documentation on bootstraping a bitcoin network from scratch

This is possibly an issue for Bitcoin upstream itself, but it would be nice if there was instructions on being able to generate the generation block from scratch, without any existing files.

Also tied into #6, the difficulty is a bit high and it does take a while before you even end up with 50BTC to spend between these wallets; a from-scratch network basically wouldn't be any more work.

Command 'make generate' fails on Linux

Running the make generate command fails. After trying to debug the Makefile I found a hyphen (-) missing before the generate argument. Adding this hyphen fixes the issue. I've created a PR for this fix.

Docker container not reachable at localhost

After the last commits, I'm not able to reach the bitcoin daemons curling at http://admi1:123@localhost:19001/ anymore.
I'm running them with Docker and this happens both if I run a container using the image pulled from the hub or if I build it with the Dockerfile (using commands in the README).
If I checkout to the last merged PR it all works fine instead.

How to get bitcoin address?

I will to simulate payment by bitcoin.

I start bitcoin-testnet-box, but I don't find bitcoin address from server 1 or 2.

How do i simulate payment by bitcoin?

tks ~

Increase difficulty?

Is there a way to increase difficulty? Ideally i would like it to take somewhere between 30 seconds and 3 minutes when CPU mining on an average PC.

bitcoind -conf

In the Makefile, i expected the bitcoind command for each node to point to its custom bitcoin.conf file. However the original only points to the data directory.

Original (only points to the data file location):
$(BITCOIND) $(B1) -daemon
$(BITCOIND) $(B2) -daemon

Expected (points each node to .conf file):
$(BITCOIND) $(B1) -conf=1/bitcoin.conf -daemon
$(BITCOIND) $(B2) -conf=2/bitcoin.conf -daemon

How does the original command know where the .conf file is located? I am trying the -conf method and i will post the results. Not really an issue, because i am still analyzing this repo for use. My apologies if i am posting this in the wrong location, i will move it to a better place or delete it if requested.

Thank you for this resource!

(UPDATE)
my getinfo looks exactly like the presented example, so the only conclusion i come to is that the -datadir flag also point the bitcoind to the bitcoin.conf file for the respective node. If anyone agrees i will close this issue. Thanks again.

{
"version": 129900,
"protocolversion": 70013,
"walletversion": 60000,
"balance": 0.00000000,
"blocks": 0,
"timeoffset": 0,
"connections": 1,
"proxy": "",
"difficulty": 4.656542373906925e-10,
"testnet": false,
"keypoololdest": 1464793025,
"keypoolsize": 100,
"paytxfee": 0.00000000,
"relayfee": 0.00001000,
"errors": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
}
{
"version": 129900,
"protocolversion": 70013,
"walletversion": 60000,
"balance": 0.00000000,
"blocks": 0,
"timeoffset": 0,
"connections": 1,
"proxy": "",
"difficulty": 4.656542373906925e-10,
"testnet": false,
"keypoololdest": 1464793673,
"keypoolsize": 100,
"paytxfee": 0.00000000,
"relayfee": 0.00001000,
"errors": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
}

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.