├── 1 ├── bitcoin.conf └── regtest │ ├── server.cert │ └── server.pem ├── 2 ├── bitcoin.conf └── regtest │ ├── server.cert │ └── server.pem ├── .bashrc ├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile └── README.md /.bashrc: -------------------------------------------------------------------------------- 1 | 2 | if [ "`id -u`" -ne 0 ]; then 3 | export PS1='\[\033[32;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]\$ ' 4 | else 5 | export PS1='\[\033[32;32m\]\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]\$ ' 6 | fi 7 | 8 | # enable color support of ls and also add handy aliases 9 | if [ "$TERM" != "dumb" ]; then 10 | eval "`dircolors -b`" 11 | alias ls='ls -a --color=auto' 12 | alias grep='grep --color=auto' 13 | alias egrep='egrep --color=auto' 14 | fi 15 | 16 | # some more ls aliases 17 | alias ll='ls -l' 18 | alias lh='ls -lh' 19 | alias la='ls -Al' 20 | 21 | alias b1='bitcoin-cli -datadir=1 ' 22 | alias b2='bitcoin-cli -datadir=2 ' 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | 3 | ?/blocks 4 | ?/regtest/* 5 | !?/regtest/server.pem 6 | !?/regtest/server.cert 7 | -------------------------------------------------------------------------------- /1/bitcoin.conf: -------------------------------------------------------------------------------- 1 | # testnet-box functionality 2 | regtest=1 3 | dnsseed=0 4 | upnp=0 5 | 6 | # always run a server, even with bitcoin-qt 7 | server=1 8 | 9 | [regtest] 10 | # listen on different ports than default testnet 11 | port=19000 12 | rpcport=19001 13 | 14 | # enable SSL for RPC server 15 | #rpcssl=1 16 | 17 | # enable to allow non-localhost RPC connections 18 | # recommended to change to a subnet, such as your LAN 19 | #rpcallowip=0.0.0.0/0 20 | #rpcallowip=::/0 21 | 22 | rpcuser=admin1 23 | rpcpassword=123 24 | -------------------------------------------------------------------------------- /1/regtest/server.cert: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 |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1N7rS31LCZOr07mOlW9pz2yRaL9 18 | nGRy9hxte1g8kb0W8W+ciHIDRs3+USz4shEQtIGqVpGK6SwY8IPXqn79I8xIkLuN 19 | WXngnmD5cpyGjMiSOus44QzGLj1e99pExMwIc/+GVjgEA999Ke8cGZHkrAuyVjyV 20 | ovAWeaBfh6IK7aSS19FBdrQ9NTIxd2payYOV7tYljE7gvD1RWWfMHd8= 21 | -----END CERTIFICATE----- 22 | -------------------------------------------------------------------------------- /1/regtest/server.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEAuZ4RZVnjh8kS32TZn7pMWJevf473pLqecObWMLmeB6FIzpvf 3 | kYi8RyLD9Q87QjmIhbrqFncyaBaw1iz5sx2sVM2+acwlocN4UHPBCxwvmtUeEn1t 4 | WMp29D4NetJNssvq7PxzcXY7bv7FQ7q7kJ5KpoBc+OBu/4vdQhM0gkR5QEL52KNj 5 | C8umfhc2aEeRn4et9lBqNlE4WjH3s5tOO3DqNt5kQ28hulcSaiPMaKPcjqmAYz8+ 6 | VLOY7fefGNBecr72MaA5St+oc0TDK6msHPoTtYe4b6r6AsyM9O+7f82idtWK9nu/ 7 | rjQZP2UeMQvqUtQj+Ar3WoM60SkEQ8Ckq6PQPwIDAQABAoIBAFUlZFd4r34HR8gA 8 | LDAwNnthQZkjDQicrredvF1nmE1pt8tHB3xsG+oJ0Zgln4pWeADYaC9cCFxlJENr 9 | KDP5Bad1JcbEZfLZhuRo5QHisRe2cXAL51AWuBB8MpTHyeqdzitd9tryYHsfFYBn 10 | NUk2w4mzUnK8CU7iauG3i5vCK1jFV9OvedeQGjmKcJ39U4R8qOQesTP1x0tc7C8Y 11 | SgSNaicZKXcHOlHntk6sGfpCekDX0bPKAOB2CMtbujeUNB/wgM/eEGLugdddXHfV 12 | GErnqqnSCUog3bhZLaEOdl4XOJZtBmKIzQcUecNH3myADgpSm+AethCYErRqmvIj 13 | FhXNfVkCgYEA7B2NjuOeaxoIgqPVN+DFVOVOv25AODLpgZDrfPZqr0E231LaexRn 14 | xtsuJpxQ/lGPgY6dOrhX6d5HEQ2JrFDiKyv+uP7V/s9Wp562UhSMRLzuXWg7phto 15 | yuia2bwj9k4Fwl9b3tQfJMxUulv2Bkq4+ZtuX0bFw8P4C3xwQMLQCgMCgYEAyT/S 16 | UFIFp2u/7tXce5qrT3Z/SMe3qa+1DeosmhdCNQdJhV0p7rARX0bl+UN1oeDg65Sb 17 | khzmTf+zpB0Nho63+W/CjlSdHBBFPTgSgjejkfiENfW63HBT18K0ya2LC4+fOuWg 18 | e35VBJjKZT4nUTjZ/rscdeKNve4SvSWl3dFPqhUCgYEAgqIbJroydKkTmkvQdLjs 19 | FHtF5U23RCCO5ntqflnLTqkzFb2+WShB/lhXoU8M1JgFYLWpsco6AY9UHFA0Il0h 20 | tKcDqBB+Dxthox2BW8o4jPNGofFARzeU8+ZbfinEb8pdD1w49QDBNlfCbNTiOjrv 21 | OlJPb3E1i4kJ3Dj91iayeUcCgYEAgS5qfgxofLN5nIHC6cS6umNCCSHKDy4udiQf 22 | RTow0YE//E91HzX9sL792CcpVyPWvOHDiuLqIp9EXNAZYooyJfdLV7mQr/bxuv5H 23 | Qzcb1BNGKqz1qZKg/xqImfzACEfE2jWT8jGBuVWqdZqT+lsX85+AAVvPyF8NwERu 24 | WBiHnpECgYA28LMcfOVplez7z7wxzoVZyq7I7yV50RCxZiJ6GepZPzTnqR2LAmb6 25 | 2qMOJkShHk/pydtF+49j9/MjWJexGWaCbsFaei/bnsZfskEF+/2MFmBp6fAN1FRP 26 | FLNEF+YTPz6yFCNWecZ2INEAokEi2D809XhDQwiJz0E2vEzhR93fDg== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /2/bitcoin.conf: -------------------------------------------------------------------------------- 1 | # testnet-box functionality 2 | regtest=1 3 | dnsseed=0 4 | upnp=0 5 | 6 | # always run a server, even with bitcoin-qt 7 | server=1 8 | 9 | [regtest] 10 | # don't listen on a port, just connect to node 1 11 | listen=0 12 | connect=127.0.0.1:19000 13 | 14 | # listen on different ports than default testnet 15 | port=19010 16 | rpcport=19011 17 | 18 | # enable SSL for RPC server 19 | #rpcssl=1 20 | 21 | # enable to allow non-localhost RPC connections 22 | # recommended to change to a subnet, such as your LAN 23 | #rpcallowip=0.0.0.0/0 24 | #rpcallowip=::/0 25 | 26 | rpcuser=admin2 27 | rpcpassword=123 28 | -------------------------------------------------------------------------------- /2/regtest/server.cert: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDhTCCAm2gAwIBAgIJALjCgEBIwDscMA0GCSqGSIb3DQEBBQUAMFkxCzAJBgNV 3 | BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX 4 | aWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0xMzAzMDgxMzQw 5 | MDJaFw0yMzAzMDYxMzQwMDJaMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21l 6 | LVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNV 7 | BAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOTL 8 | p47Qy1hovBC6VWi33CCpq5r5+QHnt5PLsjhOoZ0VjHI0KYNMPkT9yfwJZO8vHEsW 9 | dDoW+fRojp+VO6JOYcO1JAr0jBlnzfOlr+zBHKvaEWylku9DS5ZbxLnj4AQe5m5/ 10 | uqtlQt4ib4vXQr3yfW8B9Jy55OfWV8m9orfxubOzK1Ll0LeDwubKgUwuzB3auJKb 11 | VNsIlZQzrKDzMoTExtKF/7cSUC+5+1UHFy9rUh9VOtU2RkFJQgOPOyw9lmg7pCfl 12 | uurz4Q8wjSchhWvMnEc8YenqOaA+AcmlFiHwQq3z0aILCa5IEUOUzwER4bZM6eDe 13 | 8rZLG+uRAABhhfC/LfUCAwEAAaNQME4wHQYDVR0OBBYEFEhAKuSwT9BxLaHcxzmn 14 | CDZ7bxycMB8GA1UdIwQYMBaAFEhAKuSwT9BxLaHcxzmnCDZ7bxycMAwGA1UdEwQF 15 | MAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAIK1pI70uzMET8QAJ6o0rBsuYnat9WeL 16 | Y/27yKWg440BoWYxI6XJPP+nnncesGxcElnQCPkut8ODIGG037WKuQNRMr7dBQeU 17 | MIaIxKGZETGIj5biao6tqYuWwIS54NxOTIUVx4QomXnyLNyE0Mj4ftD8bKEIuVfV 18 | 2bDC6UjN02lPh2IsV+th5oOr3BShwafu+7CAKLSaidraUW/hGKSWpMgBSBHnA2tD 19 | W3mLidFxB2ufi6ufT87HliC6AJw6S9A5+iuAIEuRGV4zhc4BZpKTeeFRVWYPUBtp 20 | /SoNIeLQ4ORhIFQjTY2nEq2lGnCJ0JcTTt1gVNbsEitRtw0eAUtMTXs= 21 | -----END CERTIFICATE----- 22 | -------------------------------------------------------------------------------- /2/regtest/server.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEA5MunjtDLWGi8ELpVaLfcIKmrmvn5Aee3k8uyOE6hnRWMcjQp 3 | g0w+RP3J/Alk7y8cSxZ0Ohb59GiOn5U7ok5hw7UkCvSMGWfN86Wv7MEcq9oRbKWS 4 | 70NLllvEuePgBB7mbn+6q2VC3iJvi9dCvfJ9bwH0nLnk59ZXyb2it/G5s7MrUuXQ 5 | t4PC5sqBTC7MHdq4kptU2wiVlDOsoPMyhMTG0oX/txJQL7n7VQcXL2tSH1U61TZG 6 | QUlCA487LD2WaDukJ+W66vPhDzCNJyGFa8ycRzxh6eo5oD4ByaUWIfBCrfPRogsJ 7 | rkgRQ5TPARHhtkzp4N7ytksb65EAAGGF8L8t9QIDAQABAoIBACNjoNpFT36wTI6l 8 | 07or3j+rHuEM00hJKCsTMdDl0Le0cpHjoZ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u/bX4YfxXeZTSdsi7KeXHGgcDG9peVbvBGGFFHAILPox5 25 | JRItQ3+XQ/sG6OPtL4BxAuffLR3ZrmTotG1b19vFEdfwpzLEzBCfK55oshL37iiU 26 | f0VJuwlTT9jWFoUbwBceVPcON3mEwEYCZipv6GxknfUl3Fjn7WBc 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # bitcoin-testnet-box docker image 2 | 3 | FROM ubuntu 4 | LABEL maintainer="Sean Lavine " 5 | 6 | # install make 7 | RUN apt-get update && \ 8 | apt-get install --yes make wget 9 | 10 | # create a non-root user 11 | RUN adduser --disabled-login --gecos "" tester 12 | 13 | # run following commands from user's home directory 14 | WORKDIR /home/tester 15 | 16 | ENV BITCOIN_CORE_VERSION "0.21.0" 17 | 18 | # download and install bitcoin binaries 19 | RUN mkdir tmp \ 20 | && cd tmp \ 21 | && wget "https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_CORE_VERSION}/bitcoin-${BITCOIN_CORE_VERSION}-x86_64-linux-gnu.tar.gz" \ 22 | && tar xzf "bitcoin-${BITCOIN_CORE_VERSION}-x86_64-linux-gnu.tar.gz" \ 23 | && cd "bitcoin-${BITCOIN_CORE_VERSION}/bin" \ 24 | && install --mode 755 --target-directory /usr/local/bin * 25 | 26 | # clean up 27 | RUN rm -r tmp 28 | 29 | # copy the testnet-box files into the image 30 | ADD . /home/tester/bitcoin-testnet-box 31 | 32 | # make tester user own the bitcoin-testnet-box 33 | RUN chown -R tester:tester /home/tester/bitcoin-testnet-box 34 | 35 | # color PS1 36 | RUN mv /home/tester/bitcoin-testnet-box/.bashrc /home/tester/ && \ 37 | cat /home/tester/.bashrc >> /etc/bash.bashrc 38 | 39 | # use the tester user when running the image 40 | USER tester 41 | 42 | # run commands from inside the testnet-box directory 43 | WORKDIR /home/tester/bitcoin-testnet-box 44 | 45 | # expose two rpc ports for the nodes to allow outside container access 46 | EXPOSE 19001 19011 47 | CMD ["/bin/bash"] 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2012-2016 Sean Lavine 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | BITCOIND=bitcoind 2 | BITCOINGUI=bitcoin-qt 3 | BITCOINCLI=bitcoin-cli 4 | B1_FLAGS= 5 | B2_FLAGS= 6 | B1=-datadir=1 $(B1_FLAGS) 7 | B2=-datadir=2 $(B2_FLAGS) 8 | BLOCKS=1 9 | ADDRESS= 10 | AMOUNT= 11 | ACCOUNT= 12 | 13 | start: 14 | $(BITCOIND) $(B1) -daemon 15 | $(BITCOIND) $(B2) -daemon 16 | 17 | start-gui: 18 | $(BITCOINGUI) $(B1) & 19 | $(BITCOINGUI) $(B2) & 20 | 21 | generate: 22 | $(BITCOINCLI) $(B1) -generate $(BLOCKS) 23 | 24 | getinfo: 25 | $(BITCOINCLI) $(B1) -getinfo 26 | $(BITCOINCLI) $(B2) -getinfo 27 | 28 | sendfrom1: 29 | $(BITCOINCLI) $(B1) sendtoaddress $(ADDRESS) $(AMOUNT) 30 | 31 | sendfrom2: 32 | $(BITCOINCLI) $(B2) sendtoaddress $(ADDRESS) $(AMOUNT) 33 | 34 | address1: 35 | $(BITCOINCLI) $(B1) getnewaddress $(ACCOUNT) 36 | 37 | address2: 38 | $(BITCOINCLI) $(B2) getnewaddress $(ACCOUNT) 39 | 40 | stop: 41 | $(BITCOINCLI) $(B1) stop 42 | $(BITCOINCLI) $(B2) stop 43 | 44 | clean: 45 | find 1/regtest/* -not -name 'server.*' -delete 46 | find 2/regtest/* -not -name 'server.*' -delete 47 | 48 | docker-build: 49 | docker build --tag bitcoin-testnet-box . 50 | 51 | docker-run: 52 | docker run -ti bitcoin-testnet-box 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bitcoin-testnet-box 2 | [![docker pulls](https://img.shields.io/docker/pulls/freewil/bitcoin-testnet-box.svg?style=flat)](https://hub.docker.com/r/freewil/bitcoin-testnet-box/) 3 | 4 | Create your own private bitcoin testnet 5 | 6 | You must have `bitcoind` and `bitcoin-cli` installed on your system and in the 7 | path unless running this within a [Docker](https://www.docker.com) container 8 | (see [below](#using-with-docker)). 9 | 10 | ## Large Git History 11 | If you'd like to clone this git repository locally and disk space or bandwidth 12 | usage is of concern, it's suggested to do a shallow clone, excluding some 13 | earlier history of the repo, where some testnet data was included. 14 | 15 | > Regular clone: `du -sh .` 44M 16 | 17 | > Shallow clone: `du -sh .` 168K 18 | 19 | ### Regular Clone 20 | ``` 21 | git clone git@github.com:freewil/bitcoin-testnet-box.git 22 | ``` 23 | 24 | ### Shallow Clone 25 | ``` 26 | git clone --shallow-since 2014-10-18 git@github.com:freewil/bitcoin-testnet-box.git 27 | ``` 28 | 29 | ## Starting the testnet-box 30 | 31 | This will start up two nodes using the two datadirs `1` and `2`. They 32 | will only connect to each other in order to remain an isolated private testnet. 33 | Two nodes are provided, as one is used to generate blocks and it's balance 34 | will be increased as this occurs (imitating a miner). You may want a second node 35 | where this behavior is not observed. 36 | 37 | Node `1` will listen on port `19000`, allowing node `2` to connect to it. 38 | 39 | Node `1` will listen on port `19001` and node `2` will listen on port `19011` 40 | for the JSON-RPC server. 41 | 42 | 43 | ``` 44 | $ make start 45 | ``` 46 | 47 | ## Check the status of the nodes 48 | 49 | ``` 50 | $ make getinfo 51 | bitcoin-cli -datadir=1 getinfo 52 | { 53 | "version" : 90300, 54 | "protocolversion" : 70002, 55 | "walletversion" : 60000, 56 | "balance" : 0.00000000, 57 | "blocks" : 0, 58 | "timeoffset" : 0, 59 | "connections" : 1, 60 | "proxy" : "", 61 | "difficulty" : 0.00000000, 62 | "testnet" : false, 63 | "keypoololdest" : 1413617762, 64 | "keypoolsize" : 101, 65 | "paytxfee" : 0.00000000, 66 | "relayfee" : 0.00001000, 67 | "errors" : "" 68 | } 69 | bitcoin-cli -datadir=2 getinfo 70 | { 71 | "version" : 90300, 72 | "protocolversion" : 70002, 73 | "walletversion" : 60000, 74 | "balance" : 0.00000000, 75 | "blocks" : 0, 76 | "timeoffset" : 0, 77 | "connections" : 1, 78 | "proxy" : "", 79 | "difficulty" : 0.00000000, 80 | "testnet" : false, 81 | "keypoololdest" : 1413617762, 82 | "keypoolsize" : 101, 83 | "paytxfee" : 0.00000000, 84 | "relayfee" : 0.00001000, 85 | "errors" : "" 86 | } 87 | ``` 88 | ## Creating wallets 89 | 90 | ``` 91 | bitcoin-cli -datadir=1 createwallet wallet1 92 | ``` 93 | 94 | ``` 95 | bitcoin-cli -datadir=2 createwallet wallet2 96 | ``` 97 | 98 | ## Generating blocks 99 | 100 | Normally on the live, real, bitcoin network, blocks are generated, on average, 101 | every 10 minutes. Since this testnet-in-box uses Bitcoin Core's (bitcoind) 102 | regtest mode, we are able to generate a block on a private network 103 | instantly using a simple command. 104 | 105 | To generate a block: 106 | 107 | ``` 108 | $ make generate 109 | ``` 110 | 111 | To generate more than 1 block: 112 | 113 | ``` 114 | $ make generate BLOCKS=10 115 | ``` 116 | 117 | ## Need to generate at least 100 blocks before there will be a balance in the first wallet 118 | ``` 119 | $ make generate BLOCKS=200 120 | ``` 121 | 122 | ## Verify that there is a balance on the first wallet 123 | ``` 124 | $ make getinfo 125 | ``` 126 | 127 | ## Generate a wallet address for the second wallet 128 | ``` 129 | $ make address2 130 | ``` 131 | 132 | ## Sending bitcoins 133 | 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) 134 | 135 | ``` 136 | $ make sendfrom1 ADDRESS=mxwPtt399zVrR62ebkTWL4zbnV1ASdZBQr AMOUNT=10 137 | ``` 138 | 139 | ## Does the balance show up? 140 | Run the getinfo command again. Does the balance show up? Why not? 141 | ``` 142 | $ make getinfo 143 | ``` 144 | 145 | ## Generate another block 146 | ``` 147 | $ make generate 148 | ``` 149 | 150 | ## Stopping the testnet-box 151 | 152 | ``` 153 | $ make stop 154 | ``` 155 | 156 | To clean up any files created while running the testnet and restore to the 157 | original state: 158 | 159 | ``` 160 | $ make clean 161 | ``` 162 | 163 | ## Using with docker 164 | This testnet-box can be used with [Docker](https://www.docker.com/) to run it in 165 | an isolated container. 166 | 167 | ### Building docker image 168 | 169 | Pull the image 170 | * `docker pull freewil/bitcoin-testnet-box` 171 | 172 | or build it yourself from this directory 173 | * `docker build -t bitcoin-testnet-box .` 174 | 175 | ### Running docker container 176 | The docker image will run two bitcoin nodes in the background and is meant to be 177 | attached to allow you to type in commands. The image also exposes 178 | the two JSON-RPC ports from the nodes if you want to be able to access them 179 | from outside the container. 180 | 181 | `$ docker run -t -i -p 19001:19001 -p 19011:19011 freewil/bitcoin-testnet-box` 182 | 183 | or if you built the docker image yourself: 184 | 185 | `$ docker run -t -i -p 19001:19001 -p 19011:19011 bitcoin-testnet-box` 186 | 187 | ## Running without docker 188 | To run without docker, one should download the supported Bitcoin core version. 189 | To find the supported version, search for the `BITCOIN_CORE_VERSION` environment variable 190 | in the `Dockerfile` file. 191 | --------------------------------------------------------------------------------