As-of confirmed wallet reads (Electrum / Esplora) - #204
Merged
Conversation
added 7 commits
August 22, 2026 18:29
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.
protocol_max stays 1.4.2 until BIP331 (Q-48). Then implement 1.6 (broadcast_package) and 1.7 and raise the advertised max in the same work — do not advertise a version we do not speak.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
#202 landed on
query/chain-view(stack), notmaster. This PR is that work plus theElectrum 1.6/1.7 sequencing note, rebased onto current
master.API
Selector is block hash (display-order hex), not height.
?asof=<64 hex>on/utxo,/stats,/txs,/txs/chain,/tx/:id/status,/outspend(s)asof:<64-hex>afterserver.versiondialect1.4.2-asofchain_tipis the asof blockasof not on chainserver.features.asof/asof_protocol = 1.4.2-asof. Live (no asof) path unchanged.Electrum protocol versions
protocol_maxstays 1.4.2. After P2P package relay (Q-48 / BIP331),implement 1.6 (
broadcast_package) then 1.7 and raiseprotocol_maxinthe same work. Do not advertise a version we do not speak.
Test plan
/utxo?asof=+/status?asof=+ 404 unknown; headers are asof hash.Do not merge unless asked.