bitcoin-heuristics
Pattern detection heuristics for Bitcoin on-chain analytics.
Detects consolidations, distributions, CoinJoin, fee spikes, dormant supply reactivation, and more — from pre-extracted TxFeatures. No blockchain node required for most heuristics.
Features
- 8 bundled heuristics — consolidation, distribution, CoinJoin detection, urgent execution (fee spike), address reuse, round value, HFT consolidation, long-term supply activation
- 6 analyzer modules — topology, UTXO age classification, change detection, fee percentile, Lightning detection, BTC price encoding
- 20 classification enums — FeeRateTier, StructuralPattern, ScriptType, CoinJoinScore, LightningIndicator, and more
- Zero async runtime — synchronous design,
ureqfor optional RPC calls - No database dependencies — pure computation on
TxFeatures, works standalone - Extensible — implement the
Heuristictrait to add custom detectors
Quick Start
[]
= "0.1"
use ;
let features = TxFeatures ;
let registry = default_registry; // coinjoin threshold
let matches = registry.evaluate_all;
for m in &matches
Custom Heuristic
use ;
use EvidenceChain;
use json;
;
Long-Term Supply Activation (RPC)
The LongTermSupplyActivationHeuristic requires Bitcoin RPC access to fetch UTXO ages:
use ;
let rpc = new;
// Second param: minimum UTXO age in blocks (~3 years = 157_680 blocks)
let h = new;
Heuristics Reference
| ID | Trigger | Description |
|---|---|---|
institutional-consolidation-v1 |
tx | ≥10 inputs → ≤3 outputs, >$100k USD, homogeneous scripts |
institutional-distribution-v1 |
tx | ≤3 inputs → ≥20 outputs, >$50k USD, homogeneous outputs |
coinjoin-detection-v1 |
tx | CoinJoin score ≥ threshold, ≥5 inputs/outputs, equal outputs |
urgent-execution-v1 |
tx | Fee rate spike above configured threshold |
address-reuse-detection-v1 |
tx | ≥60% address reuse ratio, ≥2 reused, ≥3 outputs |
round-value-v1 |
tx | Round output values, possible OTC / P2P trade signal |
hft-consolidation-v1 |
block | ≥100 fresh inputs (≤7 days), ≤3 outputs |
long-term-supply-activation-v1 |
tx | Dormant UTXOs (≥3 years) spent, >$50k USD (requires RPC) |
License
MIT — see LICENSE.