Add optional mode argument to blockchain.estimatefee#1293
Open
PeterXMR wants to merge 1 commit into
Open
Conversation
Electrum protocol v1.6 adds an optional second `mode` argument to `blockchain.estimatefee` that is forwarded to bitcoind's `estimatesmartfee` as `estimate_mode`. Accepted values (case-insensitive): `UNSET`, `ECONOMICAL`, `CONSERVATIVE`. Parsing uses an `#[serde(untagged)]` enum that accepts both the legacy 1-argument form `[nblocks]` and the v1.6 2-argument form `[nblocks, mode]`, so existing clients keep working. Invalid mode strings produce a JSON-RPC error rather than being silently forwarded to bitcoind. Spec: https://electrum-protocol.readthedocs.io/en/latest/protocol-methods.html#blockchain-estimatefee 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.estimatefeemode item on the v1.6 protocol checklist.Summary
Electrum protocol v1.6 adds an optional second
modeargument toblockchain.estimatefeethat is forwarded to bitcoind'sestimatesmartfeeasestimate_mode.UNSET,ECONOMICAL,CONSERVATIVE[nblocks]keep working — handled via an#[serde(untagged)]enum that accepts either form (same pattern asBroadcastArgs).The string→enum parsing (
parse_estimate_mode) is a free function so it can be unit-tested without an RPC client.Test plan
electrum::tests: known values, case-insensitivity, invalid value rejection, 1-arg deserialization, 2-arg deserializationcargo test --lib— 26/26 passcargo clippy --all-targets -- -D warnings— cleancargo fmt --check— cleanThe
-1return values are the expectedUNKNOWN_FEEbecause regtest has no fee history — the point of the demo is showing that all four dispatch paths (1-arg, 2-arg with each mode, invalid mode) behave correctly.