v23.0rc3

this document assumed you have a bitcoin full node, if you don’t, please refer to Bitcoin Full Node installation page

create new wallet:

#bitcoin-cli createwallet "mehdi1" 

#bitcoin-cli -stdin encryptwallet
secretpassword<ENTER>
<CTRL-D>
wallet encrypted; Bitcoin server stopping, restart to run with encrypted wallet. The keypool has been flushed and a new HD seed was generated (if you are using HD). You need to make a new backup.

show wallet:

#bitcoin-cli getwalletinfo
{
  "walletname": "mehdi1",
  "walletversion": 169900,
  "format": "sqlite",
  "balance": 0.00000000,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 0.00000000,
  "txcount": 0,
  "keypoolsize": 4000,
  "keypoolsize_hd_internal": 4000,
  "unlocked_until": 0,
  "paytxfee": 0.00000000,
  "private_keys_enabled": true,
  "avoid_reuse": false,
  "scanning": false,
  "descriptors": true,
  "external_signer": false
}

note: if the wallet didn’t loaded use the below command:

#bitcoin-cli loadwallet "mehdi.dat"
OR
#bitcoin-cli loadwallet "mehdi1"

Backup the wallet:

#mkdir /backup
#bitcoin-cli backupwallet /backup/mehdi1

receive BITCOIN:

below command creates a bech32 p2wpkh address for you

#bitcoin-cli -named getnewaddress address_type=bech32

bc1qzpahkdzh53vzkfte59ymqypxumfayyhcsdxk3k

The above command creates a bech32 p2wpkh address for you. If you prefer another type of address, you can change bech32 to legacy to get a p2pkh address or p2sh-segwit to get a p2wpkh nested in p2sh address.

SEND some bitcoins to your ADDRESS

WARNING: DONT SEND ANY Bitcoin to address of this document!

Check Wallet Balance:

#bitcoin-cli getunconfirmedbalance

0.00071293

This shows that you have a pending incoming payment of 0.00071293 BTC. We now have to wait until it’s confirmed in the blockchain. Meanwhile, we can dig into the transaction by running thelisttransactions command:

#bitcoin-cli listtransactions
[
  {
    "address": "bc1qzpahkdzh53vzkfte59ymqypxumfayyhcsdxk3k",
    "category": "receive",
    "amount": 0.00071293,
    "label": "",
    "vout": 5,
    "confirmations": 0,
    "trusted": false,
    "txid": "126b60578f4d0fb63dba9c0e4d97c878202f7b8dee489a858976fd76eecb0f51",
    "walletconflicts": [
    ],
    "time": 1648975360,
    "timereceived": 1648975360,
    "bip125-replaceable": "no"
  }
]

the confirmed balance can be shown using the below command:

#bitcoin-cli getbalance
0.00000000

after some time (1hour approx) you can get confirmed balance:

bitcoin-cli getbalance
0.00071293

Send BTC:

Prepare wallet private key and passphrase:

#bitcoin-cli -stdin walletpassphrase
secretpassword<ENTER>
300<ENTER>
<CTRL-D>

The last argument, 300, is the number of seconds to keep the wallet unlocked. After 300 seconds, the wallet will be automatically locked again in case we forget to lock it manually.

I will send the bitcoins to address bc1q4ewzpyky52ndfu7s5x0qxunprnzyt978lnkkvu , hoping it confirms within 20 blocks.

#bitcoin-cli -named sendtoaddress address="bc1q4ewzpyky52ndfu7s5x0qxunprnzyt978lnkkvu"  amount=0.00071 conf_target=20 estimate_mode=ECONOMICAL

4c02a4dc1fdaeaa653f64c4a30bf8c8c18c1d9dbe2f2139af470883368d5a79a

The command output a txid for the newly created transaction. This means that it went well. We can now lock the wallet again using the walletlockcommand:

#bitcoin-cli walletlock

By: Mehdi Sadighian
Contact: mehdi.sadighian@hotmail.com
TAG: Bitcoin, BTC, bitcoin wallet, bitcoin-cli