mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2025-06-07 16:06:26 +00:00
Improve Chapter 15 - Regtest
This commit is contained in:
parent
c5cc9d7bf5
commit
ecc3a6edb8
@ -10,9 +10,9 @@ After working through this chapter, a developer will be able to:
|
||||
* Create your own Blockchain from scratch
|
||||
* Create the Genesis block and more blocks on top of it
|
||||
* Get balance and interact with Bitcoind in a private way
|
||||
|
||||
|
||||
## Table of Contents
|
||||
|
||||
* [Section One: Building the Regtest](15_1_Building_the_Regtest.md)
|
||||
* [Section Two: Testing with Regtest](15_2_Testing_with_Regtest.md)
|
||||
* [Section Three: Mining with Regtest](15_3_Mining_with_Regtest.md)
|
||||
* [Section Two: Mining with Regtest](15_2_Mining_with_Regtest.md)
|
||||
* [Section Three: Testing with Regtest](15_3_Testing_with_Regtest.md)
|
||||
|
@ -27,6 +27,5 @@ $ rm -rf regtest
|
||||
|
||||
## What's Next?
|
||||
|
||||
After starting your bitcoind in the Regtest mode, you can now use Regtest-specific RPC commands to [generate/mine blocks in your private chain](15_3_Mining_with_Regtest.md).
|
||||
This will allow you to get balance in your wallet and [test the Regtest blockchain](15_2_Testing_with_Regtest.md).
|
||||
|
||||
After starting your bitcoind in the Regtest mode, you can now use Regtest-specific RPC commands to [generate/mine blocks in your private chain](15_2_Mining_with_Regtest.md).
|
||||
This will allow you to get balance in your wallet and [test the Regtest blockchain](15_3_Testing_with_Regtest.md).
|
||||
|
@ -1,28 +0,0 @@
|
||||
# 15.2: Testing with Regtest
|
||||
|
||||
> **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning.
|
||||
|
||||
This document explains how to test a Regtest (Regression Test).
|
||||
|
||||
|
||||
## Verifying balance
|
||||
|
||||
After [mining blocks](15_3_Mining_with_Regtest.md) and getting the rewards, you can verify the balance on your wallet:
|
||||
```
|
||||
$ bitcoin-cli -regtest getbalance
|
||||
```
|
||||
|
||||
## Testing the Regtest
|
||||
Now you should be able to use this balance for any type of interaction with the private Blockchain, such as sending Bitcoin transactions according to [Chapter 4]((04_0_Sending_Bitcoin_Transactions.md)) in this guide. The only difference is that you need to use the flag `-regtest` when running the `bitcoin-cli` in order for the request to be sent to the Regtest Bitcoin daemon.
|
||||
|
||||
It is important to note that for your transactions to complete, you will have to generate/mine new blocks so that the transactions can be included into them.
|
||||
|
||||
For example, to create a transaction and include into a block:
|
||||
```
|
||||
$ bitcoin-cli -regtest sendtoaddress [address] 10.0
|
||||
```
|
||||
|
||||
And after it, if your application requires 6 confirmations, you can mine additional 6 blocks into your Regtest chain:
|
||||
```
|
||||
$ bitcoin-cli -regtest generate 6
|
||||
```
|
@ -1,29 +0,0 @@
|
||||
# 15.3: Mining the Regtest
|
||||
|
||||
> **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning.
|
||||
|
||||
This document explains how to generate (i.e. mine) blocks using a Regtest (Regression Test) blockchain.
|
||||
To generate the Genesis block and the next blocks on a new blockchain requires very minimal proof-of-work, due to the low difficulty and that it follows the Testnet rules.
|
||||
|
||||
|
||||
## Generating blocks
|
||||
|
||||
You can generate/mine new blocks using the RPC method `generate`. This method is only available in the Regtest mode, using the following command:
|
||||
```
|
||||
$ bitcoin-cli -regtest generate 101
|
||||
[
|
||||
"57f17afccf28b9296048b6370312678b6d8e48dc3a7b4ef7681d18ed3d91c122",
|
||||
"631ff7b8135ce633c774828be3b8505726459eb65c339aab981b10363befe5a7",
|
||||
...
|
||||
"1162dbfe025c7da94ee1128dc26d518a94508f532c19edc0de6bc673a909d02c",
|
||||
"20cb2e815c3d42d6a117a204a0b5e726ab641c826e441b5b3417aca33f2aba48"
|
||||
]
|
||||
```
|
||||
The output is the block hash of every block generated (in our example, 101 hashes).
|
||||
|
||||
|
||||
This command will generate 101 blocks using a special RPC which is only available in regtest mode. This takes less than a second on a generic PC.
|
||||
Because this is a new block chain using Bitcoin’s default rules, the first blocks pay a block reward of 50 bitcoins.
|
||||
Unlike mainnet, in regtest mode only the first 150 blocks pay a reward of 50 bitcoins.
|
||||
However, a block must have 100 confirmations before that reward can be spent, so we generate 101 blocks to get access to the coinbase transaction from block #1.
|
||||
|
@ -106,8 +106,8 @@ Add: HOW TO DO A REFUND (short answer: ask!)
|
||||
|
||||
* [15.0: Setting Up a Bitcoin Regtest](15_0_Setting_Up_a_Bitcoin_Regtest.md)
|
||||
* [15.1: Building the Regtest](15_1_Building_the_Regtest.md)
|
||||
* [15.2: Testing with Regtest](15_2_Testing_with_Regtest.md)
|
||||
* [15.3: Mining with Regtest](15_3_Mining_with_Regtest.md)
|
||||
* [15.2: Mining with Regtest](15_2_Mining_with_Regtest.md)
|
||||
* [15.3: Testing with Regtest](15_3_Testing_with_Regtest.md)
|
||||
|
||||
** APPENDICES **
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user