Managing a Bitcoin node via the command line offers unparalleled control and insight into wallet operations, transaction handling, and blockchain interaction. Whether you're running a full node on mainnet, testnet, or a private network, mastering bitcoin-cli commands is essential for developers, node operators, and advanced users. This guide compiles the most commonly used Bitcoin CLI commands—organized by function—with clear explanations and usage notes to help you navigate your Bitcoin environment efficiently.
Specifying Configuration Files
When managing multiple nodes or custom setups, you may need to point bitcoin-cli to a specific configuration file.
bitcoin-cli -conf=/root/.bitcoin/bitcoin.conf getblockchaininfoThis syntax ensures that the command uses the specified bitcoin.conf, particularly useful when running non-default configurations or multiple instances.
Wallet Management Commands
Effective wallet management is crucial for securing funds and monitoring activity.
Get Wallet Information
Retrieve comprehensive details such as version, balance, transaction count, and key pool status.
bitcoin-cli getwalletinfo👉 Discover how to secure your Bitcoin wallet with advanced CLI tools.
List Received Addresses
View all addresses that have received funds, including associated account names (if used).
bitcoin-cli listreceivedbyaddress 1 trueThe first parameter sets minimum confirmations; the second enables inclusion of empty accounts.
Check Wallet Balance
Display the total confirmed balance across all addresses in the wallet.
bitcoin-cli getbalanceNote: Only includes balances from addresses whose private keys are stored locally. Watch-only or external addresses are excluded.
Generate a New Address
Create a new receiving address under an optional account label.
bitcoin-cli getnewaddress "test"Replace "test" with your preferred account name or leave empty for default.
Query Received Amount by Address
See how much BTC has been received at a specific address.
bitcoin-cli getreceivedbyaddress 2MtmeZ7W17zJzigtRhzKMP6MSc2DSyL5LYUAccepts an optional confirmation threshold as a second argument.
Encrypt Your Wallet
Secure your wallet with encryption to protect private keys.
bitcoin-cli encryptwallet mypasswordOnce encrypted, you must unlock the wallet before performing sensitive operations.
Unlock Wallet Temporarily
Unlock the wallet for signing or spending operations.
bitcoin-cli walletpassphrase mypassword 30Time is in seconds—here, 30 seconds of access granted.
Lock Wallet
Manually lock the wallet after operations are complete.
bitcoin-cli walletlockRecommended after sending transactions or exporting keys.
Backup Wallet
Safely create a backup of your wallet data.
bitcoin-cli backupwallet wallet.backEnsure backups are stored securely offline.
Restore from Backup
Import a previously backed-up wallet file.
bitcoin-cli importwallet wallet.backRequires wallet to be unlocked first.
Change Wallet Password
Update your encryption passphrase.
bitcoin-cli walletpassphrasechange mypassword 123456Provide old and new passwords as arguments.
Export All Keys
Dump all private keys into a text file (unlocks required).
bitcoin-cli dumpwallet wallet.txtUse extreme caution—this exposes all keys.
Import Private Key
Import a single private key (WIF format) into the wallet.
bitcoin-cli importprivkey 92dC2MM4dN4ei6qGarVkL48aiUcPjg2uvPdzpFY6QVjBAPQPGWy "test" trueThird parameter triggers blockchain rescan for associated transactions.
Import Watch-Only Address
Add an address without private key for monitoring purposes.
bitcoin-cli importaddress muhtvdmsnbQEPFuEmxcChX58fGvXaaUoVt "watch-only test" falseIdeal for auditing or multi-signature setups.
Import Public Key
Import a public key to track associated address activity.
bitcoin-cli importpubkey "04aefb3a2b6e0eef583216283b72279cdc1f79a0b99499a0ac9769598278a581ed7734f6b203fcd75fc4836296a4f662dea768671feea454d19b5abdc7a113b081" "transfer test" falseRescan (true) takes time but recovers historical transactions.
List Address Groupings
View grouped addresses with their balances.
bitcoin-cli listaddressgroupingsShows only addresses managed by this node (with imported keys).
Transaction Handling Commands
Precise transaction control enables advanced use cases like raw transaction building and offline signing.
Send BTC to an Address
Transfer funds from the default account.
bitcoin-cli sendtoaddress "mxHFNt2RXkshzT3CuXb5Dx215BdeNDQRCu" 10Amount is in BTC. Transaction requires confirmation via mining.
Send from Specific Account
Debit from a labeled account (deprecated in newer versions).
bitcoin-cli sendfrom "test" "n3BMgZMA26TcHnVa5iNJeB3PMqkF3cEWBE" 0.01👉 Learn how to build and sign transactions securely using command-line tools.
Mine Blocks (Regtest Only)
Generate blocks locally—for testing only (e.g., regtest mode).
bitcoin-cli generate 1Useful for testing confirmations and coinbase rewards.
List Recent Transactions
Fetch recent transaction records.
bitcoin-cli listtransactions "*" 1 0 trueParameters: account (* = all), limit, skip count, include watch-only.
Requirestxindex=1inbitcoin.conf.
Get Transaction Details
Inspect a specific transaction by ID.
bitcoin-cli gettransaction 47b30a7c5b1cd10183e60676fc0f4a059b96c2f10f16a2828aeb6270f4467500Only works for transactions involving this wallet.
List Unspent Outputs (UTXOs)
View spendable outputs for building transactions.
bitcoin-cli listunspentFilter by confirmation count and specific addresses:
bitcoin-cli listunspent 0 99999999 '["mi7efAUg86n8LZAFD4hdMTfoKYkj8YYbdA"]'Also requires txindex=1 for full visibility.
Create Raw Transaction
Build an unsigned transaction manually.
bitcoin-cli createrawtransaction '[{"txid":"7fff82f7b28bc12b349e6e4c7482d563e7af6119ca49126bfc04435ce909abbc","vout":0}]' '{"2MuJfZRJi7S7nqaxHrbTRMSTb6GygDD4SFz":1}'Specify input(s) and output(s) precisely.
Fund Raw Transaction
Automatically add inputs and change address to a raw transaction.
bitcoin-cli fundrawtransaction 02000000... '{"changeAddress": "2MuJfZRJi7S7nqaxHrbTRMSTb6GygDD4SFz", "includeWatching": true}'Enhances flexibility in transaction construction.
Sign Raw Transaction
Sign with private keys (offline signing supported).
bitcoin-cli signrawtransactionwithkey 02000000... '["your-private-key"]'Use signrawtransaction in older versions (deprecated).
Broadcast Signed Transaction
Submit the final transaction to the network.
bitcoin-cli sendrawtransaction 02000000...Returns the transaction ID if successful.
Utility and Help Commands
Explore available functionality and debug issues.
List All Available Commands
bitcoin-cli helpUse help [command] for detailed syntax (e.g., help getblockchaininfo).
Frequently Asked Questions
Q: Can I manage Bitcoin wallets without exposing private keys?
A: Yes—use watch-only addresses via importaddress. These allow balance monitoring without risk of theft from server compromise.
Q: Why does gettransaction return incomplete data?
A: If the wallet lacks private keys for an address, input/output details may be missing. Use getrawtransaction with txindex=1 for full data.
Q: How do I recover funds after restoring a wallet backup?
A: Rescan the blockchain using rescanblockchain or set importprivkey’s rescan flag to true. This can take time on large chains.
Q: What does “txindex=1” do?
A: Enables full transaction indexing, allowing queries for any transaction—not just those tied to your wallet. Required for advanced analysis and UTXO tracking.
Q: Is it safe to use dumpwallet?
A: Only in secure environments. The output contains all private keys in plain text. Never run this on internet-connected or untrusted systems.
Q: Can I run these commands on mainnet safely?
A: Yes—but double-check every address and amount. Mistakes in raw transactions are irreversible. Test first on testnet or regtest.
👉 Access powerful crypto tools and explore blockchain development resources today.
Core Keywords: Bitcoin CLI commands, bitcoin-cli wallet management, listunspent, signrawtransactionwithkey, gettransaction, sendrawtransaction, Bitcoin node operations, blockchain command line