Skip to content

As-of confirmed wallet reads (Electrum / Esplora) - #202

Merged
reardencode merged 6 commits into
query/chain-viewfrom
query/asof
Aug 23, 2026
Merged

As-of confirmed wallet reads (Electrum / Esplora)#202
reardencode merged 6 commits into
query/chain-viewfrom
query/asof

Conversation

@rearden-grok

@rearden-grok rearden-grok Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Why

Thanks again to Yuval — the A-B-A / “bind confirmations to a chain”
work in #200 also
implies wallet state as of a still-live ancestor, not only the live
tip. Same threads:
mempool#6584,
electrum-protocol#2.

Spentness is annotation + spender confirmed-strong. Clamping that check
to height (H) is “UTXOs / balance as of (H)” on the current chain.
Not fork MVCC: we do not serve a disconnected hash.

Stacked on query/chain-view (#200).

API

Selector is block hash (display-order hex), not height.

Surface Param Stamp Mempool
Esplora ?asof=<64 hex> on /utxo, / stats, /txs, /txs/chain, /tx/:id/status, /outspend(s) Headers are the asof hash Off
Electrum Trailing "asof:<64-hex>" on get_balance / listunspent / get_history chain_tip is the asof block Off
Miss 404 / asof not on chain Do not retry onto another block at the same height

server.features.asof = true. Live (no asof) path unchanged.

Test plan

  • Query: buried pin survives tip extension; spend at h=1 invisible as of h=0.
  • Electrum: asof genesis vs spend block; unknown hash errors; stamp is asof hash.
  • Esplora: /utxo?asof= + /status?asof= + 404 unknown; headers are asof hash.

Do not merge unless asked.

rbitcoin-grok added 6 commits August 22, 2026 16:54
As-of reads need a snapshot of an ancestor, not only the live tip.
pin_chain_view_at uses height_of_hash; still_live stays true while that
height's confirmed header_fk is unchanged (tip extension is fine).
A spend at height N is invisible as of N-1 because spentness is
annotation plus spender confirmed-strong, not a mutated UTXO set.
has_confirmed_strong_spender_at and listunspent_in/balance_in take that
height clamp.
Confirmed rows are joined at that still-live ancestor; mempool is off.
Unknown hash is 'asof not on chain'. server.features.asof advertises it.
The stamped chain_tip is the asof block, not the live tip.
Wallet reads join at that still-live ancestor. Mempool is off. Response
headers are the asof hash, not the live tip. Unknown or disconnected
asof is 404 (no retry onto another block at the same height).
Thank Yuval again: as-of-hash is the buried-height half of binding
confirmations to a chain (mempool#6584 / electrum-protocol#2). Stamp
is the asof block; a disconnected asof is 404, not a different hash.
Trailing bare 64-hex collides with a later official string/hash arg.
Tag the extra positional as asof:<blockhash> and honor it only after
server.version negotiates 1.4.2-asof. protocol_max stays dotted-int
1.4.2 so Electrum parsers do not choke; features.asof_protocol
advertises the dialect. First version call wins.
@reardencode
reardencode merged commit c7569c1 into query/chain-view Aug 23, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant