DEV Community

Aman Sachan
Aman Sachan

Posted on

BTCRouter: Real-Time Bitcoin Fee Estimation Without a Full Node

I built BTCRouter because most Bitcoin wallets estimate fees with a simple multiplier — "slow / medium / fast" — and it's often catastrophically wrong. When the mempool is empty, you overpay. When it's full, you underpay and wait 3 days.

The Problem with Current Fee Estimation

Full Bitcoin Core nodes solve this properly, but require:

  • 150GB+ storage
  • All-day initial sync
  • Constant upkeep

Too heavy for embedded devices, mobile apps, or quick scripting.

BTCRouter uses Blockstream's Electrum API instead — no node required, works from any machine.

What BTCRouter Does

A Python library for real-time Bitcoin intelligence:

  • Fee Estimation — 4 tiers (economy/normal/fast/instant) from live mempool data
  • Congestion Analysis — score 0–100 of on-chain demand with actionable recommendations
  • UTXO Optimization — greedy selection minimizing inputs + fees
  • RBF Simulation — model Replace-By-Fee scenarios
  • Privacy Scoring — grade your UTXO set based on address reuse and amount patterns

How Fee Estimation Works

Blockstream returns percentile fee data at different block targets:

Tier Block Target Typical Wait
Economy 24 blocks (~4 hrs) ~30 min
Normal 6 blocks (~1 hr) ~1 hour
Fast 3 blocks (~30 min) ~10 min
Instant 1 block next block

UTXO Selection Algorithm

Uses greedy selection by value — sort UTXOs descending, pick largest until total covers target + fee. Minimizes input count → smaller transaction → lower fees.

Privacy Scoring

Your UTXO set leaks privacy in subtle ways:

  • Address reuse — deduct 10pts per duplicate
  • Round amounts — many UTXOs at exact multiples of 100k sats (likely exchange batches)
  • One dominant UTXO — >90% of value in single UTXO (easy to correlate)

Quick Start

\

When to Use BTCRouter

  • Embedded Bitcoin projects (Raspberry Pi, microcontrollers)
  • Mobile wallets that can't run a full node
  • Trading bots needing accurate fee estimation for batching
  • Lightning node operators managing commitment transaction fees

Single File, Zero Dependencies

Drop btcrouter.py into any project. No node, no 150GB download. Just live Bitcoin intelligence.

GitHub: https://github.com/AmSach/btc-router

Top comments (0)