Update A3_0_Using_Bitcoin_Regtest for version 0.21

. It adds a " Generate Regtest Wallet" since Bitcoin Core v.021 does not automatically create new wallets on startup.
If the reader try to mine without a wallet, it will receive the erro: "No wallet is loaded. Load a wallet using loadwallet or create a new one with createwallet. (Note: A default wallet is no longer automatically created)" 

. The command "bitcoin-cli -regtest generate" throws the error: " generate has been replaced by the -generate cli option.". So it fixes the command.

. "bitcoin-cli -regtest sendtoaddress" throws the error: "Fee estimation failed. Fallbackfee is disabled. Wait a few blocks or enable -fallbackfee.", so the "fallbackfee." is added to the bitcoind startup.
This commit is contained in:
leonardojobim 2021-02-23 00:40:23 -03:00 committed by GitHub
parent 5ac748e82f
commit ad0a09329d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,9 +8,13 @@ The majority of this course presumes that you will either use the Mainnet or Tes
After [setting up your Bitcoin-Core VPS](02_0_Setting_Up_a_Bitcoin-Core_VPS.md) or [compiling from source](A2_0_Compiling_Bitcoin_from_Source.md), you are now able to use regtest. To start your `bitcoind` on regtest and create a private Blockchain, use the following command: After [setting up your Bitcoin-Core VPS](02_0_Setting_Up_a_Bitcoin-Core_VPS.md) or [compiling from source](A2_0_Compiling_Bitcoin_from_Source.md), you are now able to use regtest. To start your `bitcoind` on regtest and create a private Blockchain, use the following command:
``` ```
$ bitcoind -regtest -daemon $ bitcoind -regtest -daemon -fallbackfee=1.0 -maxtxfee=1.1
``` ```
The argments `-fallbackfee=1.0 -maxtxfee=1.1` will prevent the `Fee estimation failed. Fallbackfee is disabled` error.
On regtest, usually there are not enough transactions so bitcoind cannot give a reliable estimate and, without it, the wallet will not create transactions unless it is explicitly set the fee.
### Reset the Regtest Blockchain ### Reset the Regtest Blockchain
If you wish, you can later restart your Regtest with a new blockchain. If you wish, you can later restart your Regtest with a new blockchain.
@ -25,12 +29,20 @@ To start a brand new Blockchain using regtest, all you have to do is delete the
``` ```
$ rm -rf regtest $ rm -rf regtest
``` ```
## Generate Regtest Wallet
Before generating blocks, it is necessary to load a wallet using `loadwallet` or create a new one with `createwallet`. Since version 0.21, Bitcoin Core does not automatically create new wallets on startup.
The argument `descriptors=true` creates a native descriptor wallet, that stores scriptPubKey information using output descriptors. If it is `false`, it will create a legacy wallet, where keys are used to implicitly generate scriptPubKeys and addresses.
```
$ bitcoin-cli -regtest -named createwallet wallet_name="regtest_desc_wallet" descriptors=true
```
## Generate Blocks ## Generate Blocks
You can generate (mine) new blocks on a regtest chain using the RPC method `generate` with an argument for 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 on the mainnet or testnet: You can generate (mine) new blocks on a regtest chain using the RPC method `generate` with an argument for 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 on the mainnet or testnet:
``` ```
$ bitcoin-cli -regtest generate 101 $ bitcoin-cli -regtest -generate 101
[ [
"57f17afccf28b9296048b6370312678b6d8e48dc3a7b4ef7681d18ed3d91c122", "57f17afccf28b9296048b6370312678b6d8e48dc3a7b4ef7681d18ed3d91c122",
"631ff7b8135ce633c774828be3b8505726459eb65c339aab981b10363befe5a7", "631ff7b8135ce633c774828be3b8505726459eb65c339aab981b10363befe5a7",
@ -109,7 +121,7 @@ $ bitcoin-cli -regtest gettransaction e834a4ac6ef754164c8e3f0be4f34531b74b768199
However, you must now finalize it by creating blocks on the blockchain. However, you must now finalize it by creating blocks on the blockchain.
Most applications require a six-block confirmations to consider the transaction as irreversible. If that is your case, you can mine additional six blocks into your regtest chain: Most applications require a six-block confirmations to consider the transaction as irreversible. If that is your case, you can mine additional six blocks into your regtest chain:
``` ```
$ bitcoin-cli -regtest generate 6 $ bitcoin-cli -regtest -generate 6
[ [
"33549b2aa249f0a814db4a2ba102194881c14a2ac041c23dcc463b9e4e128e9f", "33549b2aa249f0a814db4a2ba102194881c14a2ac041c23dcc463b9e4e128e9f",
"2cc5c2012e2cacf118f9db4cdd79582735257f0ec564418867d6821edb55715e", "2cc5c2012e2cacf118f9db4cdd79582735257f0ec564418867d6821edb55715e",