Bitcoin CLI Commands: A Comprehensive Guide

ยท

This guide provides a detailed overview of essential Bitcoin CLI commands for wallet management, transaction processing, and node operations. Whether you're running a full node or working with test networks, these commands will help streamline your Bitcoin operations.


Wallet Management Commands

View Wallet Information

Retrieve wallet version, balance, transaction count, and other metadata.

bitcoin-cli getwalletinfo

List Wallet Addresses

Display all wallet addresses along with their account names.

bitcoin-cli listreceivedbyaddress 1 true

Check Balance

Get the sum of available balances across all wallet addresses (excluding addresses without local private keys).

bitcoin-cli getbalance

Generate New Address

Create a new wallet address with an optional account label.

bitcoin-cli getnewaddress "test"

Check Received Amount

Query the total received amount for a specific address.

bitcoin-cli getreceivedbyaddress 2MtmeZ7W17zJzigtRhzKMP6MSc2DSyL5LYU

Security Commands

Encrypt Wallet

Protect your wallet with a password.

bitcoin-cli encryptwallet mypassword

Unlock Wallet

Temporarily unlock wallet for signing transactions (30-second duration example).

bitcoin-cli walletpassphrase mypassword 30

Lock Wallet

Immediately lock a previously unlocked wallet.

bitcoin-cli walletlock

Transaction Commands

Send Funds

Transfer BTC from default account to target address.

bitcoin-cli sendtoaddress "mxHFNt2RXkshzT3CuXb5Dx215BdeNDQRCu" 10

Generate Blocks

Mine new blocks (essential for testnet/regtest confirmation).

bitcoin-cli generate 1

List Transactions

View recent transactions (adjust parameters as needed).

bitcoin-cli listtransactions "*" 1 0 true

Query Transaction Details

Get detailed information about a specific transaction.

bitcoin-cli gettransaction 47b30a7c5b1cd10183e60676fc0f4a059b96c2f10f16a2828aeb6270f4467500

Advanced Operations

Create Raw Transaction

Generate unsigned transaction hex.

bitcoin-cli createrawtransaction '[{"txid":"7fff82f7b28bc12b349e6e4c7482d563e7af6119ca49126bfc04435ce909abbc","vout":0}]' '{"2MuJfZRJi7S7nqaxHrbTRMSTb6GygDD4SFz":1}'

Sign Transaction

Sign raw transaction with private keys.

bitcoin-cli signrawtransactionwithkey 020000000161dc79011198f3e042f68b6e8a1ae16d9cdab96ada6c8b5a9905adb54c6e92430000000000ffffffff0200e1f5050000000017a9141696d866051fb5ff771acc87f47fb1d4c6bb26778728d5a4350000000017a9141696d866051fb5ff771acc87f47fb1d4c6bb26778700000000 '["92oH6gkrUHwmts4jNgv71x87RsYe8hnFKJmGDAzg3FQBisKfTo1"]'

Broadcast Transaction

Submit signed transaction to the network.

bitcoin-cli sendrawtransaction 020000000161dc79011198f3e042f68b6e8a1ae16d9cdab96ada6c8b5a9905adb54c6e9243000000008a47304402201f60fa7cfc8a03cd2be9da0a4c78b00d9e3663748db173c3b778f7946b871e0c022021836426e0800125fe98d9fc8a44fe79a1b775d7e9ea723ee35f21881fb5d385014104ee9fa9f58e21a6d82565cb11391c4673831ae19319b01637ddd7f14fafbcf776608e63e6f0ba39663fd3060ad73d655e31da919e71c7574293b7b2bad1173885ffffffff02c062002d0000000017a9141696d866051fb5ff771acc87f47fb1d4c6bb26778740539a0e000000001976a914b7e29340f24ac2d7b8ac576fab843248298a65dd88ac00000000

FAQ Section

Why can't I see my wallet balance after generating blocks?

Testnet/regtest networks typically require over 100 block confirmations before balances appear. Keep mining blocks until your balance becomes visible.

How do I import an existing wallet?

๐Ÿ‘‰ Learn how to securely import wallets using the importwallet command after unlocking your node.

What does "Invalid or non-wallet transaction id" mean?

This error occurs when querying transactions not associated with your node's wallet addresses. Ensure you're checking transactions from addresses imported to your node.

Why is my transaction unconfirmed?

Transactions require miner confirmation. In test environments, manually generate blocks using the generate command.

How can I improve transaction privacy?

Consider using ๐Ÿ‘‰ advanced Bitcoin privacy techniques like CoinJoin or confidential transactions.


Key Takeaways

For more Bitcoin CLI insights, explore additional resources and practice commands in safe environments before live implementation.