Docker bitcoin regtest

Web resources

Version 1. License MIT. Unpacked Size 7. Total Files Homepage github. Repository Git github. Last publish 2 months ago. Try on RunKit. Learn more. If nothing happens, download GitHub Desktop and try again. If nothing happens, download Xcode and try again. If nothing happens, download the GitHub extension for Visual Studio and try again. The newest images Debian-based, 0. Running docker pull on any of the supported platforms will automatically choose the right image for you as all of the manifests and artifacts are pushed to the Docker registry.

Bitcoin Core is a reference client that implements the Bitcoin protocol for remote procedure call RPC use. It is also the second Bitcoin client in the network's history. This image contains the main binaries from the Bitcoin Core project - bitcoind , bitcoin-cli and bitcoin-tx. It behaves like a binary, so you can pass any arguments to the image and they will be forwarded to the bitcoind binary:. Note: learn more about how -rpcauth works for remote authentication.

Crypto mining on Docker

The directory will be automatically created with the correct permissions for the bitcoin user and bitcoin-core automatically configured to use it. The first one is using a cookie-based local authentication.

It doesn't require any special authentication information as running a process locally under the same user that was used to launch the Bitcoin Core daemon allows it to read the cookie file previously generated by the daemon for clients. The downside of this method is that it requires local machine access. The second option is making a remote procedure call using a username and password combination. This has the advantage of not requiring local machine access, but in order to keep your credentials safe you should use the newer rpcauth authentication mechanism.

Then, inside the running bitcoin-server container, locally execute the query to the daemon using bitcoin-cli :.

Introduction

In production, the path would not contain the regtest part. Before setting up remote authentication, you will need to generate the rpcauth line that will hold the credentials for the Bitcoind Core daemon. Note: This is a Python 3 script. So its docker file is very short. Next we write the docker file that performs the actual build. This is again not difficult but here it comes in handy that we can run a container from the image that we have just generated and play around with the configuration to arrive at the final set of options below.

Once the daemon has started, we can verify that it is up and running and ready to accept commands. We can for instance — from within the container — run bitcoin-cli -regtest getinfo and should see some status information. So let us now move on to write the docker file that will create the run time environment for our daemon. There is still a couple of things we need to think about.


  • site brasileiro que aceita bitcoin!
  • Latest commit.
  • Project description.
  • What is Bitcoin?.

Second, we need a configuration file. We could generate this on the fly, but the easiest approach is to place this in the build context and copy it when we run the daemon. Finally, we have to think about the RPC authorization mechanism. Typically, the bitcoin server writes a cookie file into the configuration directory which is then picked up the by client, but this does not work if the server is running inside the container and the client locally on our host system. Probably the safest way would be to use the option to provide a hashed password to the server and keep the actual password secure.

We will use a different approach which is of course not recommended for production use as it could allow the world access to your wallet — we specify the username and password in the configuration file. Our full configuration file is.

Subscribe to RSS

Note that this opens the RPC port to the world and is probably not secure, but for use in a test setup this will do. Our docker file for the last stage is now. Then, in a second terminal, let us connect. We assume that you have an installation of the bitcoin-cli client on the host machine as well. You should now see the usual output of the getinfo command similar to the test that we have done before directly in the container. That is nice, but there is a serious issue.

If you look at the image that we have just created using docker images , you will most likely be shocked — our container is more than Mb in size. This is a problem. The reason is that our image contains everything that we have left behind during the build process — the development environment, header files, the source code, object files and so on. It would be much nicer if we could build a clean image that only contains the executables and libraries needed at runtime.

blockchain - Simulate private bitcoin network with random peer discovery - Stack Overflow

Fortunately, current versions of Docker offer a feature called multi-stage build which is exactly what we need. Let us take a look at the following docker file to explain this. We see that this docker file has two FROM statements. When it is executed, it starts with the image specified by the first FROM statement. In our case, this is the bin image that did already contain the executable binaries. In this stage, we do nothing in our simple example but simply print a message. However — and this is the magic — we still have access to the files from the first image, and we can copy them to our new image using the --from specifier.

This is what we do here — we copy the executable into our new container. Then we add only the runtime libraries that we really need and the configuration file.