Comment
Author: Admin | 2025-04-28
We're mapping the btc folder as a volume for .bitcoin, we can easily check the folder contents in the host machine. It's important to know the bitcoin directory. Here's its initial contents:btc└── regtest ├── banlist.json ├── bitcoind.pid ├── blocks │ ├── blk00000.dat │ └── index │ ├── 000003.log │ ├── CURRENT │ ├── LOCK │ └── MANIFEST-000002 ├── chainstate │ ├── 000003.log │ ├── CURRENT │ ├── LOCK │ └── MANIFEST-000002 ├── debug.log ├── peers.dat ├── settings.json └── walletsBefore going ahead, let's get attached to the container:docker-compose exec --user bitcoin bitcoin-core-regtest shCreating wallets and their addressesLet's create two wallets, one for Iago and another for Jafar. The commands with their corresponding results:$ bitcoin-cli -regtest createwallet "iago"{ "name": "iago", "warning": ""}$ bitcoin-cli -regtest createwallet "jafar"{ "name": "jafar", "warning": ""}If you list the addresses from Iago's wallet, you receive an empty array:$ bitcoin-cli -regtest -rpcwallet=iago listreceivedbyaddress 1 true[]Let's create one address for each wallet:$ bitcoin-cli -regtest -rpcwallet=iago getnewaddressbcrt1q7c6h8a4n6tvmkfcwhpe9gvpefgyfec2t75vwru$ bitcoin-cli -regtest -rpcwallet=jafar getnewaddressbcrt1qj28d8v3528ygqpjt2dp436sx3dhn7x5qwxnyc9Now let's see the addresses from Iago's wallet again:$ bitcoin-cli -regtest -rpcwallet=iago listreceivedbyaddress 1 true[ { "address": "bcrt1q7c6h8a4n6tvmkfcwhpe9gvpefgyfec2t75vwru", "amount": 0.00000000, "confirmations": 0, "label": "", "txids": [ ] }]By the way, how is our btc folder?btc└── regtest ├── banlist.json ├── bitcoind.pid ├── blocks │ ├── blk00000.dat │ └── index │ ├── 000003.log │ ├── CURRENT │ ├── LOCK │ └── MANIFEST-000002 ├── chainstate │ ├── 000003.log │ ├── CURRENT │ ├── LOCK │ └── MANIFEST-000002 ├── debug.log ├── peers.dat ├── settings.json └── wallets ├── iago │ ├── database │ │ ├── log.0000000003 │ │ └── log.0000000004 │ ├── db.log │ └── wallet.dat └── jafar ├── database │ ├── log.0000000003 │ └── log.0000000004 ├── db.log └── wallet.datNotice that bitcoind created two folders inside the wallets folder. By the way, I'm saying bitcoind instead of bitcoin-cli because it is just an interface to interact with the bitcoind.Receiving a block reward of 50 bitcoinsLet's use the command below to send 50 bitcoins to one address of Iago's wallet:$ bitcoin-cli -regtest generatetoaddress 101 bcrt1q7c6h8a4n6tvmkfcwhpe9gvpefgyfec2t75vwru[ "06fb898d3f32545bd098e41736595841d7dbf149a44a9f80b4c8eb7fdcd5669d", "4f98e6d2d322c0107470d4dfc5b779de766ef8e558fce666875afb9ecbac769b", ... "26374885c6f95a845763e91a65ec0dc9e033d7ae77259afd399265d03b7abc1e", "24188db36163964fe5addf6fd5a7d4d5862af19c492521c49ada5f476ae1aa88"]Why 101 blocks? I strongly recommend reading this explanation. Let's see Iago and Jafar's balance:$ bitcoin-cli -regtest -rpcwallet=iago getbalance50.00000000$ bitcoin-cli -regtest -rpcwallet=jafar getbalance0.00000000Verify that Iago now has 50 bitcoins available to spend.Sending coins from Iago to JafarLet's send 15 bitcoins to Jafar. We'll receive a transaction ID when the command executes with success.$ bitcoin-cli -regtest -rpcwallet=iago -named sendtoaddress \ address=bcrt1qj28d8v3528ygqpjt2dp436sx3dhn7x5qwxnyc9 \ amount=15 \ fee_rate=1000d153b10e8eb4b348ab384e1888984c73f7dfc47508a1953eab3b63da65094a76We can verify the transaction
Add Comment