RoadmapsProjects
Sign in./start

Learn

RoadmapsProjects

Contribute

DiscoverIssues

Account

Sign in./start-building

Become an Open Source Builder. Learn. Build. Contribute.

Learn

RoadmapsProjectsStart Building

Contribute

DiscoverIssues

Account

Sign inDashboardSettings

Legal

PrivacyTerms

© 2026 Pull // all rights reserved

PrivacyTerms

lesson // bitcoin

Transactions

Build, decode, sign, and broadcast transactions using regtest.

beginner5 days

Public lesson — sign in to track progress on this roadmap.

./sign-in

On this page

Learning objectives

  • Decode the fields of a Bitcoin transaction
  • Explain sighashes and what a signature commits to
  • Create and broadcast a simple regtest payment

study // plan

Lessons are primers. Depth comes from required reading, interactive labs, reflection, and a hands-on check with evidence — the BOSS study pattern.

Research on Bitcoin Search

Required reading

  • bookMastering Bitcoin

    Ch. 6: Transactions

Interactive lab // Decoding Bitcoin

Open these Bitcoin Dev Project modules and tools before (or alongside) the graded lab. Capture evidence from the interactive path — do not only skim Pull.

  • Decoding Bitcoin: Transaction lifecycle

    Interactive module — walk creation → confirmation before the lab.

  • Decoding Bitcoin: Transaction decoder

    Paste a raw hex or explorer tx and label vin/vout/fee fields.

  • Decoding Bitcoin: Transaction exercises

    Classroom-style exercises — complete at least one graded path.

Reflection prompts

  1. Explain Transactions to a teammate without jargon — what problem does it solve?
  2. What would break in production if you misunderstood Transactions?
  3. Which BIP, book chapter, or Core doc is authoritative here, and what did you verify?

Lab // Decode + regtest send

Use Decoding Bitcoin's transaction decoder on a regtest (or known sample) transaction, then create and broadcast a simple payment on local regtest.

evidence required

  • ·Screenshot or notes from the Decoding Bitcoin transaction decoder with labeled vin/vout/fee
  • ·getrawtransaction <txid> true JSON (or equivalent) from your regtest send
  • ·One sentence on what you observed vs expected
  • ·Link to the Decoding exercise or module section you completed

A Bitcoin transaction moves value by consuming UTXOs and creating new ones. Everything else, wallets, Lightning channels, exchanges, eventually serializes to this structure.

Why this matters

If you cannot read a raw transaction, debugging stuck payments, wrong fees, or bad scripts becomes guesswork.

Analogy

A transaction is a signed instruction: “Take these coins (inputs) and lock them under these new conditions (outputs).” Miners include the instruction in a block; nodes verify the signatures and rules.

Core fields

  • version
  • inputs: previous txid + vout, scriptSig/witness, sequence
  • outputs: value + scriptPubKey
  • locktime

SegWit moves signatures into the witness, changing fee measurement to weight/vbytes.

Loading diagram…

Build, sign, broadcast, then wait for confirmations.

Regtest practice

bitcoin-cli -regtest getnewaddress
bitcoin-cli -regtest generatetoaddress 101 "$(bitcoin-cli -regtest getnewaddress)"
bitcoin-cli -regtest sendtoaddress <addr> 1.5
bitcoin-cli -regtest getrawtransaction <txid> true

Decode the JSON and identify vin/vout, fees, and scripts.

type TxOut = { valueSats: number; scriptPubKey: string };
type BuiltTx = { inputs: { txid: string; vout: number }[]; outputs: TxOut[] };

Always compute fees explicitly

Fee = sum(inputs) − sum(outputs). If outputs exceed inputs, nodes reject the transaction. If you under-fund fees in a busy mempool, the tx may sit forever.

What signatures cover

A signature commits to a sighash, a digest of (parts of) the transaction. That is why you must finalize amounts and outputs before signing, and why PSBT workflows exist for multi-party construction.

Common mistakes

  • Changing outputs after signing (invalidates signatures)
  • Mixing mainnet txids into regtest experiments
  • Forgetting change outputs

Virtual size and fees

SegWit transactions are priced by weight / vbytes, not legacy serialized size alone. When estimating:

const feeSats = Math.ceil(feeRateSatPerVb * vsize);

Underpaying relative to the mempool means waiting; overpaying wastes money. Product UX should expose slow/medium/fast targets.

Sighash flags (builder intuition)

Most wallets use sighash types that commit to all inputs and outputs so the signed transaction cannot be altered meaningfully. Special flags exist for advanced contracts, avoid them until you can explain why you need them.

Decode practice

Use the Decoding Bitcoin transaction decoder on a sample or your own hex, then verify the same fields locally:

TXID=$(bitcoin-cli -regtest sendtoaddress "$(bitcoin-cli -regtest getnewaddress)" 0.5)
bitcoin-cli -regtest getrawtransaction "$TXID" true | jq '.vin,.vout,.fee'

Trace which UTXOs were consumed and which new locks were created. Classroom-style drills live in transaction exercises.

Worked mental model

Re-read the diagrams in this lesson once out loud in plain language. If you cannot explain the flow to a friend without jargon, pause and revisit Mastering Bitcoin / Mastering Lightning chapters linked in Resources. Chapter references are intentional, not decorative.

Hands-on habit

Every protocol idea should be paired with one local experiment:

  1. Reproduce the happy path on regtest (or Polar for Lightning)
  2. Break it on purpose (wrong fee, expired invoice, offline peer)
  3. Write down what error you saw and which layer produced it (wallet, node, mempool, peer)

That habit turns reading into builder instinct.

Glossary check

Pick three terms from this lesson and define them in one sentence each without opening notes. Weak definitions mean the lesson is not finished yet.

Resource order

Use Resources in order: narrative book chapter first, then BIP/BOLT for precision, then implementation docs for commands. Jumping straight to RPC flags without the mental model creates brittle knowledge.

Next steps

Study Bitcoin Script, the tiny language that defines how outputs can be unlocked.

further reading

  • docsBitcoin Core RPC, createrawtransaction
  • toolBitcoin Optech: Transaction sizes

progress // sign in

Reading is public. Sign in to mark lessons complete, sync across devices, and unlock your roadmap.

./sign-in-to-track
prevBlocks & ChainnextBitcoin Script

On this page

Press Shift + ? for keyboard shortcuts.

Press R to research on Bitcoin Search.