{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-utxo-set-divergence-between-its-mempool-view-and-the-canonical-chain-during-a-reorg-without-trusting-a-single-peer-s-getra",
  "title": "How does an instance detect UTXO-set divergence between its mempool view and the canonical chain during a reorg without trusting a single peer's `getrawtransaction` response",
  "date_of_record": "2026 November 9",
  "scope": "Applies to full-node-backed wallet instances that maintain a local mempool view and reconcile against a canonical chain tip via P2P (not a trusted indexer or Electrum server). Does not apply to SPV/light clients, which lack mempool visibility, nor to wallets that rely on a single trusted backend whose chain state is authoritative by construction.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-utxo-set-divergence-between-its-mempool-view-and-the-canonical-chain-during-a-reorg-without-trusting-a-single-peer-s-getra.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-utxo-set-divergence-between-its-mempool-view-and-the-canonical-chain-during-a-reorg-without-trusting-a-single-peer-s-getra.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-utxo-set-divergence-between-its-mempool-view-and-the-canonical-chain-during-a-reorg-without-trusting-a-single-peer-s-getra.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1814,
    "python_slice_tokens": 360,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not \"the wallet sees a stale balance.\" That is benign and self-correcting on the next block. The failure mode is **silent divergence between the wallet's mempool-derived spendable set and the chain-derived UTXO set during a reorg window**, where both views are individually internally consistent but mutually contradictory, and where no sin...",
    "what_was_observed": "During a two-block reorg on a regtest-turned-signet mirror, a wallet instance holding a confirmed 0.5 BTC UTXO at height N observed the following sequence: 1. At height N, the UTXO was confirmed and spendable. A mempool transaction T spent it, paying back to the wallet as change. The wallet's local view marked the original UTXO spent and the change output unconfirmed-but-spendable. 2. A reorg to height N-2 removed th...",
    "condition_of_validity": "This divergence is detectable only when all of the following hold: - The instance maintains a chain view and a mempool view that are updated by independent code paths (as `bitcoind`'s `validation` and `txmempool` subsystems are). - The mempool view's eviction of conflicting transactions is *lazy* — i.e., eviction occurs on the next `removeForBlock`/`removeCo...",
    "decision_boundary": "The operational decision is: **on detecting a tip change, do you (A) trust the mempool view and reconcile lazily, or (B) invalidate the entire mempool-derived spendable set and rebuild from `getrawmempool` on the new tip?** Option A is cheap and correct in the steady state but produces the double-count above during the reorg window. Option B is expensive (a ...",
    "operational_effect": "Instances that implement the reorg-triggered invalidation (B) observe: no double-spend attempts during reorg windows, at the cost of a 200ms–2s stall in coin selection immediately after a reorg. Instances that do not (A) observe: occasional `bad-txns-inputs-missingorspent` broadcasts that are accepted by a minority of peers, producing a transaction that is n..."
  },
  "matched_failure_symptoms": [
    "SQLITE_BUSY_OR_DEADLOCK"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "36de375839e265fb922c10c1d72012bf2786146c32488378c36dcc1e0654813d",
    "verified_classes": [
      "MempoolChainDivergence"
    ],
    "verified_functions": [
      "compute_spendable_set",
      "select_coins"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "MempoolChainDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
