Module 5: Transactions and UTXO Control

Learning Objectives

By the end of this module, you will:

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


1.

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

Check your wallet’s UTXOs:

List unspent transaction outputs

Example output:

Command Line

2.

Funding Transactions Manually

To build a transaction manually:

1.

Choose an input UTXO (txid and vout)

2.

Specify your outputs (recipient address + amount, and change)

3.

Create, sign, and send the transaction


3.

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 transaction

Create a raw transaction

This outputs a hex-encoded raw transaction.


4.

Signing the Raw Transaction

Sign the raw transaction

It will return:

The signed hex

A boolean complete: true if fully signed


5.

Broadcasting the Transaction

Send it to the network

Send the raw transaction

To confirm it:

Confirm the transaction by mining

Check status


Get transaction details
6.

Decoding Transactions

To analyze a raw transaction (replace <tx_hex> with any transaction hex):

Decode a raw transaction

You’ll see:

vin (inputs): where the funds came from

vout (outputs): destination addresses and values

Script types (e.g. witness_v0_keyhash)

This is useful for:

Debugging transaction construction

Verifying output order and structure

Teaching UTXO mechanics


Activity

Build and broadcast a full transaction manually:

1.

Mine 101 blocks to have spendable BTC

2.

Use the listunspent command to find UTXO

3.

Create a raw transaction sending 0.5 BTC to another address

4.

Sign it with your wallet

5.

Broadcast and mine 1 block

6.

Decode the transaction with decoderawtransaction