Implement blockchain.scripthash.get_mempool Electrum RPC method#1294
Open
PeterXMR wants to merge 1 commit into
Open
Implement blockchain.scripthash.get_mempool Electrum RPC method#1294PeterXMR wants to merge 1 commit into
blockchain.scripthash.get_mempool Electrum RPC method#1294PeterXMR wants to merge 1 commit into
Conversation
This method is required by Electrum protocol v1.6 and was not
previously implemented in electrs.
The response is the same shape as `blockchain.scripthash.get_history`
but filtered to mempool entries only — `{tx_hash, height, fee}` per
entry, where `height` is `0` if all inputs are confirmed and `-1`
otherwise. Mempool ordering matches the existing scripthash status
hash calculation, satisfying the v1.6 requirement of a canonical
order.
Implemented as a filter over the existing status history rather than
a recomputation, so it is O(history) and shares its sort key with the
status hash by construction.
Spec: https://electrum-protocol.readthedocs.io/en/latest/protocol-methods.html#blockchain-scripthash-get-mempool
Refs romanz#1241
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 free
to 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.
Refs #1241 — checks off the
blockchain.scripthash.get_mempoolitem on the v1.6 protocol checklist.Summary
blockchain.scripthash.get_mempoolis required by Electrum protocol v1.6 and was not previously implemented in electrs.Response shape matches
blockchain.scripthash.get_historybut filtered to mempool entries only —{tx_hash, height, fee}per entry, whereheightis0if all inputs are confirmed and-1otherwise.v1.6 ordering requirement: the spec mandates that
get_mempoolresults "must be sorted ... same order as computing scripthash status". This implementation is a filter over the existing status history, so it shares the sort key with the status hash by construction — no separate ordering logic needed.Test plan
test_is_unconfirmed) instatus::testsplus dispatch reuses the existingHistoryEntryJSON shape covered bytest_txinfo_jsoncargo test --lib— 22/22 passcargo clippy --all-targets -- -D warnings— cleancargo fmt --check— cleansendtoaddressto a new address to produce a mempool entry:After mining one block to confirm the tx,
get_mempoolcorrectly filters it out whileget_historynow reports it as confirmed: