Skip to content

fix: tolerate non-numeric keys in get_fee_estimates (mempool.space deprecation warning)#212

Closed
Copexit wants to merge 1 commit into
bitcoindevkit:masterfrom
RaijuAI:fix/lenient-fee-estimates
Closed

fix: tolerate non-numeric keys in get_fee_estimates (mempool.space deprecation warning)#212
Copexit wants to merge 1 commit into
bitcoindevkit:masterfrom
RaijuAI:fix/lenient-fee-estimates

Conversation

@Copexit

@Copexit Copexit commented Jun 4, 2026

Copy link
Copy Markdown

mempool.space added a non-numeric "warning" key to its (deprecated) /fee-estimates response:

{"1":4.8, ... ,"1008":0.1,"warning":"This endpoint is deprecated ... use /api/v1/fees/precise"}

get_fee_estimates deserializes the body as HashMap<u16, f64>, so the "warning" key fails to parse and the whole call errors. Any client pointed at a mempool.space Esplora is affected.

The most severe downstream impact is ldk-node: it calls get_fee_estimates during Node::start(), so the failed parse makes the node refuse to start and crash-loop on restart. This is a real production failure mode (see #210).

Fix

Parse /fee-estimates leniently: deserialize into a permissive map and keep only entries whose key is a numeric confirmation target and whose value is a number; ignore anything else (such as the "warning" string). Behavior is unchanged for spec-compliant servers (e.g. Blockstream). Applied to both the async and blocking clients.

Changelog

  • Fixed: get_fee_estimates tolerates non-numeric entries in the /fee-estimates response (e.g. mempool.space deprecation warning), which previously broke fee estimation for mempool.space-backed clients and prevented ldk-node from starting.

Refs #210

mempool.space added a non-numeric "warning" key to its deprecated
/fee-estimates response. The strict HashMap<u16, f64> deserialization rejects
it, so get_fee_estimates fails for any client pointed at mempool.space - most
visibly ldk-node, whose Node::start() aborts on the failed fee-rate update.

Parse leniently: deserialize to a permissive map and keep only entries whose
key is a numeric confirmation target and whose value is a number. Applies to
both the async and blocking clients.

Refs #210
@luisschwab

Copy link
Copy Markdown
Member

NACK. This client is not responsible for conforming to server implementations that deviate from the specification (https://github.com/Blockstream/esplora/blob/master/API.md#get-fee-estimates).

Instead, Mempool should return 301 Moved Permanently/303 See Other/308 Permanent Redirect.

@Copexit

Copexit commented Jun 4, 2026

Copy link
Copy Markdown
Author

Thanks for the review, and fair point on spec purity.

The practical wrinkle: per #210, the mempool team has said they're keeping /fee-estimates (recommending /api/v1/fees/precise but not removing the old one), and they added the warning key rather than redirecting, so a 301/308 from mempool doesn't look like it's coming. In the meantime this breaks node.start() in ldk-node for anyone pointed at a mempool.space backend, which is a very common configuration.

This change is strictly more lenient, Blockstream/spec-compliant responses parse identically; it only drops non-numeric keys. So there's no spec regression for compliant servers. But I'm happy to defer to whatever direction you prefer: fold it into the EsploraMethods / MempoolSpaceMethods split discussed in #200, gate it behind a mempool feature, or close this if you'd rather solve it there. Mostly flagging that real users of downstream crates (ldk-node) are hitting node-startup failures today.

@junderw

junderw commented Jun 6, 2026

Copy link
Copy Markdown

#210 (comment)

As mentioned in this comment I made. We should be pushing a fix shortly.

However, most wallets will be converting "1" to something human readable like "fast" anyways, so it would be best if end users add a normal HTTP client to their apps (use the same version that bdk uses if you don't want to add a new dependency) and just pull Mempool's precise fee API values.

@Copexit

Copexit commented Jun 7, 2026

Copy link
Copy Markdown
Author

Closing as mempool/mempool#6546 has been merged.

@Copexit Copexit closed this Jun 7, 2026
@Copexit Copexit deleted the fix/lenient-fee-estimates branch June 7, 2026 02:38
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.

3 participants