mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2025-06-08 08:26:17 +00:00
edits
This commit is contained in:
parent
2087c63bc2
commit
35edf3c504
@ -1,14 +1,13 @@
|
|||||||
# 15.2: Mining the Regtest
|
# A3.2: 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.
|
> **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.
|
This document explains how to generate (i.e. mine) blocks using a Regtest (Regression Test) blockchain.
|
||||||
To generate blocks on a new blockchain requires very minimal proof-of-work and it will take less than a second, due to the low difficulty and that it follows the Testnet rules.
|
To generate blocks on a new blockchain requires very minimal proof-of-work and it will take less than a second, due to the low difficulty and because it follows the Testnet rules.
|
||||||
|
|
||||||
|
|
||||||
## Generating blocks
|
## Generating blocks
|
||||||
|
|
||||||
You can generate/mine new blocks using the RPC method `generate`. It only makes sense to use this method on regtest, due to the high difficulty it's very unlikely that it will yield to new blocks in the mainnet or testnet:
|
You can generate (mine) new blocks on a regtest chain using the RPC method `generate` with an argument of how many blocks to generate. It only makes sense to use this method on regtest; due to the high difficulty it's very unlikely that it will yield to new blocks in the mainnet or testnet:
|
||||||
```
|
```
|
||||||
$ bitcoin-cli -regtest generate 101
|
$ bitcoin-cli -regtest generate 101
|
||||||
[
|
[
|
||||||
@ -19,15 +18,9 @@ $ bitcoin-cli -regtest generate 101
|
|||||||
"20cb2e815c3d42d6a117a204a0b5e726ab641c826e441b5b3417aca33f2aba48"
|
"20cb2e815c3d42d6a117a204a0b5e726ab641c826e441b5b3417aca33f2aba48"
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
The output is the block hash of every block generated (in our example, 101 hashes).
|
Because a block must have 100 confirmations before that reward can be spent, we generate 101 blocks, providing access to the coinbase transaction from block #1. Because this is a new block chain using Bitcoin’s default rules, the first blocks pays a block reward of 50 bitcoins. Unlike mainnet, in regtest mode only the first 150 blocks pay a reward of 50 bitcoins. The reward halves after 150 blocks, so it pays 25, 12.5, and so on...
|
||||||
|
|
||||||
|
|
||||||
This command will generate 101 blocks using a special RPC to generate the blocks on your regtest network. Running this command only makes sense on the regtest, if you try to run on the mainnet or testnet, it is very unlikely that it will be able to yield any block. On regtest, 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. After that, the reward halves after 150 blocks, so it pays 25, 12.5, and so on...
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
|
The output is the block hash of every block generated.
|
||||||
|
|
||||||
## What's Next?
|
## What's Next?
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user