Skip to content

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

Merged
reardencode merged 7 commits into
masterfrom
query/asof-to-master
Aug 23, 2026
Merged

As-of confirmed wallet reads (Electrum / Esplora)#204
reardencode merged 7 commits into
masterfrom
query/asof-to-master

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.

#202 landed on
query/chain-view (stack), not master. This PR is that work plus the
Electrum 1.6/1.7 sequencing note, rebased onto current master.

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> after server.version dialect 1.4.2-asof 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 / asof_protocol = 1.4.2-asof. Live (no asof) path unchanged.

Electrum protocol versions

protocol_max stays 1.4.2. After P2P package relay (Q-48 / BIP331),
implement 1.6 (broadcast_package) then 1.7 and raise protocol_max in
the same work. Do not advertise a version we do not speak.

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; dialect handshake.
  • Esplora: /utxo?asof= + /status?asof= + 404 unknown; headers are asof hash.

Do not merge unless asked.

rbitcoin-grok 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.
Comment thread crates/rbitcoin-electrum/src/server.rs Dismissed
Comment thread crates/rbitcoin-esplora/src/server.rs Dismissed
Comment thread crates/rbitcoin-query/src/lib.rs Dismissed
@reardencode
reardencode merged commit a5ce3b1 into master Aug 23, 2026
12 checks passed
@rearden-grok
rearden-grok Bot deleted the query/asof-to-master branch August 23, 2026 01:36
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.

2 participants