Small Node.js demo repo showing how to:
- List UTXOs from a Bitcoin testnet node (
listunspent) - Build, sign, and broadcast a transaction (
createrawtransaction,signrawtransactionwithwallet,sendrawtransaction) - Monitor node status (
getblockcount,getmempoolinfo)
- Bitcoin Core installed and available in your
PATH - A Bitcoin Core node running on testnet
- Node.js 18+
- Some testnet BTC in your wallet (grab from any available faucet)
- Clone and install dependencies:
git clone <your-repo-url>
cd bitcoin-utxo-demo
yarn- Configure Bitcoin Core:
- Create/edit
~/.bitcoin/bitcoin.conf(Linux) or~/Library/Application Support/Bitcoin/bitcoin.conf(Mac) or%APPDATA%\Bitcoin\bitcoin.conf(Windows). - Example minimal config:
testnet=1
server=1
[test]
rpcuser=user
rpcpassword=pass
rpcallowip=127.0.0.1
rpcport=18332- Start your node:
yarn btc:start:daemon- Create and load a wallet:
yarn btc:wallet:create
yarn btc:wallet:load-
Fund your testnet wallet from a faucet.
-
Copy
.env.exampleto.envand set the recipient address:
TESTNET_RECIPIENT_ADDRESS=tb1qyourrecipientaddress...# Explore UTXOs in your wallet
yarn explore
# Build & send a transaction (handles change automatically)
yarn build-tx
# Monitor node info
yarn monitoryarn btc:start:daemon # start node in background
yarn btc:start # start node in foreground
yarn btc:stop # stop node
yarn btc:wallet:create # create test wallet
yarn btc:wallet:load # load wallet
yarn btc:wallet:waitload # retry loading wallet until ready
yarn btc:addr:new # generate new address
yarn btc:balance # check wallet balance
yarn btc:utxos # list unspent outputs
yarn btc:status # get blockchain status- Fee and send amount are hardcoded in txBuilder.js (0.00001 BTC and 0.00004 BTC).
- Change outputs are automatically created, so your wallet balance is preserved after sending.
- This is a minimal demo — real wallets handle multiple UTXOs, dynamic fee estimation, and better change management.