Skip to content

DinosaurDerek/bitcoin-utxo-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bitcoin UTXO Demo

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)

Requirements

  • 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)

Setup

  1. Clone and install dependencies:
git clone <your-repo-url>
cd bitcoin-utxo-demo
yarn
  1. 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
  1. Start your node:
yarn btc:start:daemon
  1. Create and load a wallet:
yarn btc:wallet:create
yarn btc:wallet:load
  1. Fund your testnet wallet from a faucet.

  2. Copy .env.example to .env and set the recipient address:

TESTNET_RECIPIENT_ADDRESS=tb1qyourrecipientaddress...

Usage

# Explore UTXOs in your wallet
yarn explore

# Build & send a transaction (handles change automatically)
yarn build-tx

# Monitor node info
yarn monitor

Bitcoin Core helper scripts

yarn 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

Notes

  • 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published