Bitcoins the Hard Way: Using the Raw Bitcoin Protocol

Ken Shirriff manually constructs, signs, serializes, broadcasts, and observes a legacy P2PKH Bitcoin transaction, exposing the byte-level machinery that wallet software normally hides.

article Bitcoins the Hard Way: Using the Raw Bitcoin Protocol Shirriff, Ken · 2014 original

Shirriff's walkthrough remains unusually effective at showing that a Bitcoin payment is not an account debit. It selects a previous output, serializes an input and a new output, constructs a legacy P2PKH unlocking script, computes a signature digest, inserts a DER-encoded ECDSA signature, opens a peer connection, and sends the resulting transaction bytes. The article's main pedagogical contribution is causal: every byte belongs either to the state transition, its authorization witness, or the network envelope that carries it.

What the walkthrough gets right #

  • A transaction consumes whole previous outputs and creates new outputs; change must be explicit.
  • An output contains a value and a locking program. A later input names that output by transaction identifier and output index, then supplies data that satisfies the program.
  • The signed message is a rule-defined serialization selected by the sighash mode, not simply the final transaction bytes.
  • Legacy Bitcoin mixes fixed-width little-endian integers, displayed hashes with reversed byte order, CompactSize lengths, Script pushes, SEC public-key encodings, and DER signatures.
  • Peer transport, transaction relay, mempool admission, block inclusion, and confirmation are separate stages.

Historical boundary #

The experiment describes an uncompressed-key, legacy P2PKH transaction and the version-1 plaintext P2P transport as they existed in early 2014. It predates Segregated Witness, txid/wtxid separation, version-0 witness sighashes, Bech32 addresses, Taproot, BIP340 Schnorr signatures, addrv2, wtxidrelay, compact block relay, and the deployed BIP324 version-2 encrypted transport. Its block subsidy, fee examples, peer seeds, protocol version, software names, and Python code are historical observations rather than current operating guidance.

The supplied PDF is itself incomplete: it contains 16 physical pages whose printed footers run from 1/34 through 16/34, then ends at the Notes and references heading. Every supplied page was inspected, and the complete original web article—including its notes—was read separately. The incomplete PDF is therefore fingerprinted in the source audit but is not archived as though it were a complete copy.

Durable takeaways #

Use the article to develop byte-level intuition, then derive current behavior from deployed BIPs and Bitcoin Core. In particular, do not reproduce its transaction on mainnet: the example exposes a private key, uses an intentionally unsafe random generator, assumes legacy script forms, and bypasses wallet safeguards. For experiments, use regtest or a controlled test network and compare the decoded transaction, computed sighash, and node rejection reason at each boundary.

Searches titles, aliases, headings, summaries, and full text.↑↓ move ↵ open esc close