feat: Add hybrid fee estimation using mempool.space oracle for RBF#235
Merged
feat: Add hybrid fee estimation using mempool.space oracle for RBF#235
Conversation
Use Math.max(localEstimate, oracleEstimate) so estimateSmartFee with a thin mempool doesn't produce an under-fee that stalls transactions. Oracle URL is configurable via ARCHON_SAT_FEE_ORACLE_URL (defaults to mempool.space for mainnet, empty/disabled for testnet/signet). Closes #234 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously getHybridFeeRateSatPerVb() was only used in RBF bumps. The initial walletAnchor call used conf_target which falls back to Bitcoin Core's thin-mempool estimateSmartFee, producing too-low fees. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
>= caused RBF to wait 2 blocks instead of feeConf blocks. Change to > so it fires after exactly feeConf missed blocks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a hybrid fee estimation strategy to the Satoshi mediator to improve anchoring and RBF bump behavior when local estimatesmartfee underestimates fees (e.g., thin mempool), with optional integration to a mempool.space-style fee oracle.
Changes:
- Introduces
getHybridFeeRateSatPerVb()(max of localestimateSmartFeeand external oracle recommendation) and uses it for both anchoring and RBF bumping. - Fixes the RBF timing off-by-one by changing the bump trigger condition from
>=to>. - Adds
ARCHON_SAT_FEE_ORACLE_URLwiring/documentation and propagates the env var through sample env + docker-compose files.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| services/mediators/satoshi/src/satoshi-mediator.ts | Use hybrid fee rate for anchor + RBF bump; fix RBF block trigger condition; plumb feeRate into wallet API calls. |
| services/mediators/satoshi/src/config.ts | Add feeOracleUrl config field sourced from ARCHON_SAT_FEE_ORACLE_URL. |
| services/mediators/satoshi/README.md | Document new fee oracle env var. |
| sample.env | Add per-network *_FEE_ORACLE_URL defaults (mainnet set, testnet4/signet empty). |
| docker-compose.btc-testnet4.yml | Pass fee oracle env var through to satoshi mediator container. |
| docker-compose.btc-signet.yml | Pass fee oracle env var through to satoshi mediator container. |
| docker-compose.btc-mainnet.yml | Pass fee oracle env var through to satoshi mediator container. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Re-queues a dropped operation by CID directly into the gatekeeper DB, allowing the mediator to re-anchor it on-chain and restore the confirmation chain for affected DID versions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Wrap estimateSmartFee in try/catch, fall back to feeFallback on error - Default feeOracleUrl to mempool.space only on BTC:mainnet; empty for testnet4/signet to avoid mainnet fee rates on test networks Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Defaults to empty (disabled). Set ARCHON_SAT_FEE_ORACLE_URL explicitly in .env to enable (sample.env provides the mempool.space URL). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
getHybridFeeRateSatPerVb()in satoshi-mediator: takesMath.max(localEstimate, oracleEstimate)so a thin-mempoolestimateSmartFeecan't produce a stalling under-feeARCHON_SAT_FEE_ORACLE_URL; defaults tohttps://mempool.space/api/v1/fees/recommendedfor mainnet, empty (disabled) for testnet4/signetwalletBumpFee, so Bitcoin Core's internal estimate isn't used a second time for the bump amountfeeConfblock target maps tofastestFee(≤1),halfHourFee(≤3), orhourFee(>3) from the oracle responseTest plan
ARCHON_SAT_FEE_ORACLE_URLis emptyCloses #234
🤖 Generated with Claude Code