{
  "schema_version": "1.0",
  "title": "Protocol state-transition sketch",
  "description": "Implementation-neutral pseudocode separates wallet construction, local policy, mining, consensus validation, and best-chain activation.",
  "type": "code",
  "language": "text",
  "code": "wallet:\n  inputs  = select_unspent_outputs(amount + target_fee)\n  outputs = [recipient(amount)]\n  remainder = sum(inputs) - amount - target_fee\n  if remainder_is_economic(remainder):\n      outputs.append(change(remainder))\n  tx = sign_transaction(inputs, outputs)\n\nreceiving_node:\n  require basic_consensus_checks(tx)\n  require scripts_and_inputs_valid(tx, current_utxo_view)\n  if local_mempool_policy_accepts(tx):\n      store_and_relay(tx)\n\nminer:\n  block.transactions = [coinbase(subsidy + fees), selected_transactions]\n  block.header.merkle_root = transaction_merkle_root(block)\n  while sha256d(block.header) > target:\n      mutate_candidate(block)\n  broadcast(block)\n\nfull_node:\n  require header_and_proof_valid(block)\n  require commitments_and_limits_valid(block)\n  require every_state_transition_valid(block, parent_utxo_view)\n  add_candidate_branch(block)\n  activate_valid_branch_with_greatest_chainwork()\n  confirmations(tx) = active_tip_height - containing_block_height + 1",
  "source_ids": [
    "mechanics-white-paper",
    "mechanics-transaction-code",
    "mechanics-tx-verification",
    "mechanics-validation-code",
    "mechanics-block-header",
    "mechanics-merkle-code",
    "mechanics-pow-code",
    "mechanics-policy-docs"
  ],
  "sources": [
    {
      "id": "mechanics-white-paper",
      "title": "Bitcoin: A Peer-to-Peer Electronic Cash System",
      "author": "Satoshi Nakamoto",
      "publisher": "Bitcoin.org",
      "type": "primary specification",
      "url": "https://bitcoin.org/bitcoin.pdf",
      "supports": "The original transaction-chain, timestamp-server, proof-of-work, network, incentive, Merkle-tree, and simplified-verification design."
    },
    {
      "id": "mechanics-transaction-code",
      "title": "Bitcoin transaction primitives",
      "publisher": "Bitcoin Core",
      "type": "primary source code",
      "url": "https://github.com/bitcoin/bitcoin/blob/128456b62d5e38abea031f97f823d5b28aef9357/src/primitives/transaction.h",
      "supports": "The serialized input, outpoint, output, witness, value, and transaction data structures."
    },
    {
      "id": "mechanics-tx-verification",
      "title": "Transaction consensus verification",
      "publisher": "Bitcoin Core",
      "type": "primary source code",
      "url": "https://github.com/bitcoin/bitcoin/blob/128456b62d5e38abea031f97f823d5b28aef9357/src/consensus/tx_verify.cpp",
      "supports": "Consensus checks for transaction structure, duplicate inputs, values, locks, and input availability."
    },
    {
      "id": "mechanics-validation-code",
      "title": "Bitcoin Core validation",
      "publisher": "Bitcoin Core",
      "type": "primary source code",
      "url": "https://github.com/bitcoin/bitcoin/blob/128456b62d5e38abea031f97f823d5b28aef9357/src/validation.cpp",
      "supports": "Mempool admission, block checking, connect and disconnect behavior, best-chain activation, and chainstate transitions."
    },
    {
      "id": "mechanics-block-header",
      "title": "Block-header primitives",
      "publisher": "Bitcoin Core",
      "type": "primary source code",
      "url": "https://github.com/bitcoin/bitcoin/blob/128456b62d5e38abea031f97f823d5b28aef9357/src/primitives/block.h",
      "supports": "The six serialized header fields, block structure, and header hash operation."
    },
    {
      "id": "mechanics-merkle-code",
      "title": "Merkle-root implementation",
      "publisher": "Bitcoin Core",
      "type": "primary source code",
      "url": "https://github.com/bitcoin/bitcoin/blob/128456b62d5e38abea031f97f823d5b28aef9357/src/consensus/merkle.cpp",
      "supports": "Construction of transaction and witness Merkle roots."
    },
    {
      "id": "mechanics-pow-code",
      "title": "Proof-of-work and difficulty adjustment",
      "publisher": "Bitcoin Core",
      "type": "primary source code",
      "url": "https://github.com/bitcoin/bitcoin/blob/128456b62d5e38abea031f97f823d5b28aef9357/src/pow.cpp",
      "supports": "Target calculation, retarget bounds, proof checking, and chainwork calculation."
    },
    {
      "id": "mechanics-policy-docs",
      "title": "Bitcoin Core transaction policy documentation",
      "publisher": "Bitcoin Core",
      "type": "primary software documentation",
      "url": "https://github.com/bitcoin/bitcoin/tree/master/doc/policy",
      "supports": "The project’s explicit separation and documentation of transaction relay and mempool policy."
    }
  ]
}
