Learning objectives
- Understand the UTXO model and inspect your spendable outputs
- Build and sign a raw transaction from scratch
- Broadcast a transaction to the regtest network
- Decode and analyze a transaction using Bitcoin Core tools
What is the UTXO model?
Bitcoin doesn’t use account balances like banks or Ethereum. Instead, it tracks unspent transaction outputs (UTXOs):- Each output is discrete and must be fully spent
- Change goes back to you as a new UTXO
- Wallets typically manage this automatically
Funding transactions manually
To build a transaction manually:- Choose an input UTXO (txid and vout)
- Specify your outputs (recipient address + amount, and change)
- Create, sign, and send the transaction
Creating a raw transaction
Step 1: Define the input Use bitcoin-cli -regtest listunspent. Assume: TXID: abc123… VOUT: 0 Address to send to: bcrt1qrecipient… Step 2: Create the transactionSigning the raw transaction
- The signed hex
- A boolean complete: true if fully signed
Broadcasting the transaction
Send it to the networkDecoding transactions
To analyze a raw transaction (replace <tx_hex> with any transaction hex):- vin (inputs): where the funds came from
- vout (outputs): destination addresses and values
- Script types (e.g. witness_v0_keyhash)
- Debugging transaction construction
- Verifying output order and structure
- Teaching UTXO mechanics
Activity
Build and broadcast a full transaction manually:- Mine 101 blocks to have spendable BTC
- Use the listunspent command to find UTXO
- Create a raw transaction sending 0.5 BTC to another address
- Sign it with your wallet
- Broadcast and mine 1 block
- Decode the transaction with decoderawtransaction