I have some experience in Ethereum-related development and it was very easy to set up a private net with Ethereum that simulate the public main net, I just create a custom genesis block json config, then I can use it to set up half a dozen nodes to connect to a single bootnode, and voila I have a completely up and working private net which can perfectly mimic how the public main net works where I can mine ether and send transactions and wait for them to be mined in around 15 seconds, which is perfect for development and testing.

However when it comes to bitcoin it seems there's no easy way to setup a private net in a closed environment? I have searched around and the best I can find is use the regtest mode to connect multiple nodes, but there seems to be no way to simulate the real mining process, or do I really need to download the Bitcoin source and change some hardcoded settings and recompile my own version of (alt) bitcoin to just setup a private net?

  • What do you mean by "no way to simulate the real mining process"? You can mine on regtest. – Andrew Chow Jun 13 '18 at 6:09
  • @Andrew Chow, well from what I got from google results, it seems you just generate new blocks instantly in regtest mode, not really doing PoW mining to get a new block? Also the block confirmation is 100 blocks which is not the same as the public network. So are those info I see online incorrect? – hellopeach Jun 13 '18 at 10:50
  • It is still PoW mining, just the difficulty is extremely low. The difficulty also does not change. Otherwise, everything is the same as the mainnet. There is no such thing as "block confirmation". However there is coinbase maturity which is the number of confirmations for a coinbase transaction to be spendable from, and that is 100 blocks. This is the same for mainnet. – Andrew Chow Jun 13 '18 at 17:42
  • @Andrew Chow, okay I guess the online tutorials that I looked up messed up on the concepts of block maturity and transaction maturity, but still the mining mechanism seems different from mainnet, since it seems I'm not able to mine the regtest nodes with an older version of cgminer that still supports cpu mining? – hellopeach Jun 14 '18 at 4:28
  • cgminer relies on getblocktemplate which is not available unless your node is connected to another node. This behavior is the same for mainnet, testnet, and regtest. cgminer should work on regtest if you can connect another node. Of course it is going to mine blocks extremely quickly as the difficulty is extremely low and does not change. – Andrew Chow Jun 14 '18 at 6:30

I would recommend using the testnet of your desired client (bitcoin/litecoin etc.) with it's own genesis block and thus it's own blockchain. Configure the testnet parameters in chainparams.cpp to fit your desired outcome, compile it on a couple of nodes on your LAN and configure them to connect to each other in your config file (your/data/dir/.yourcoin) by appending the line connect=IPADDRESS:PORT

You will also want to make sure that you have DNS seeding disabled. Once you have done this you will be able to mine coins on the testnet, grow the chain and eventually depending on how you've set your parameters the network will retarget difficulty and work as if it were on the main network but you will be shielded from the outside world.

  • 1
    yup, I'm aware that I can compile from source to set up my private net, I'm just wondering if there's some easier where I don't need to deal with the source code to do it. If there's no better option then I guess I'll just have to recompile from source. – hellopeach Jun 14 '18 at 4:33
  • Yeah unfortunately you'll have to play with the source to get the outcome you desire. Also, don't forget to comment out the hard-coded seed nodes in chainparamsseeds.h and change the "magic number" values in chainparams.cpp under pchMessageStart. Good luck! – apt-getschwifty Jul 31 '18 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.