Skip to content

Implement mempool.get_info Electrum RPC method#1292

Open
PeterXMR wants to merge 1 commit into
romanz:masterfrom
PeterXMR:implement-mempool-get-info-1241
Open

Implement mempool.get_info Electrum RPC method#1292
PeterXMR wants to merge 1 commit into
romanz:masterfrom
PeterXMR:implement-mempool-get-info-1241

Conversation

@PeterXMR
Copy link
Copy Markdown

Refs #1241 — checks off the mempool.get_info() item on the v1.6 protocol checklist.

Summary

Adds the new Electrum mempool.get_info method introduced in protocol v1.6. Returns the three fee-related fields the spec requires, in BTC/kvB:

Field Source (bitcoind getmempoolinfo) Notes
mempoolminfee mempoolminfee dynamic — max of minrelaytxfee and mempool minimum
minrelaytxfee minrelaytxfee operator-configured
incrementalrelayfee incrementalrelayfee omitted from response when bitcoind doesn't expose it (older Cores)

The JSON conversion is factored into a free function mempool_info_to_json so the spec mapping can be unit-tested without an RPC client.

Test plan

  • 3 new unit tests in electrum::tests covering the JSON shape: full response, omitted optional field, zero fees
  • cargo test --lib — 24/24 pass
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --check — clean
  • Live tested against Bitcoin Core v31.0.0 on regtest:
$ printf '{"id":0,"method":"server.version","params":["test","1.4"]}\n{"id":1,"method":"mempool.get_info","params":[]}\n' \
    | nc -w 2 127.0.0.1 60401
{"id":0,"jsonrpc":"2.0","result":["electrs/0.11.1","1.4"]}
{"id":1,"jsonrpc":"2.0","result":{"incrementalrelayfee":1e-6,"mempoolminfee":1e-6,"minrelaytxfee":1e-6}}

Matches bitcoind's reported values:

$ bitcoin-cli getmempoolinfo | jq '{mempoolminfee, minrelaytxfee, incrementalrelayfee}'
{
  "mempoolminfee": 0.00000100,
  "minrelaytxfee": 0.00000100,
  "incrementalrelayfee": 0.00000100
}

Adds support for the v1.6 `mempool.get_info` method introduced by the
Electrum protocol. Forwards bitcoind's `getmempoolinfo` and returns
the three fee-related fields the spec requires, in BTC/kvB:

  - mempoolminfee       (dynamic, max of minrelaytxfee and mempool min)
  - minrelaytxfee       (operator-configured)
  - incrementalrelayfee (optional; omitted when bitcoind does not expose it)

Spec: https://electrum-protocol.readthedocs.io/en/latest/protocol-methods.html#mempool-get-info

Refs romanz#1241
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