Expand description
Spam Filtering for UTXO Commitments
Implements spam detection and filtering for Bitcoin transactions:
- Ordinals/Inscriptions detection
- Dust output filtering
- BRC-20 pattern detection
- Adaptive witness size thresholds based on script type
This filter enables 40-60% bandwidth savings by skipping spam transactions during ongoing sync while maintaining consensus correctness.
Critical Design Note: Spam filtering applies to OUTPUTS only, not entire transactions. When a spam transaction is processed:
- Its spent INPUTS are still removed from the UTXO tree (maintains consistency)
- Its OUTPUTS are filtered out (bandwidth savings)
This ensures the UTXO tree remains consistent even when spam transactions spend
non-spam inputs. The process_filtered_block function in initial_sync.rs implements
this correctly by processing all transactions but only adding non-spam outputs.
Structs§
- Spam
Breakdown - Breakdown of spam by category
- Spam
Filter - Spam filter implementation
- Spam
Filter Config - Spam filter configuration
- Spam
Filter Config Serializable - Serializable spam filter configuration (for config files)
- Spam
Filter Result - Spam filter result
- Spam
Summary - Summary of filtered spam
- Witness
Element Analysis - Witness element analysis result
- Witness
Size Thresholds - Adaptive witness size thresholds based on script type
- Witness
Size Thresholds Serializable - Serializable adaptive thresholds
Enums§
- Script
Type - Script type classification
- Spam
Filter Preset - Spam filter preset configurations
- Spam
Type - Spam classification for a transaction
Constants§
- DEFAULT_
DUST_ THRESHOLD - Default dust threshold (546 satoshis = 0.00000546 BTC)
- DEFAULT_
MAX_ SIZE_ VALUE_ RATIO - Default maximum transaction size to value ratio Non-monetary transactions often have very large size relative to value transferred
- DEFAULT_
MAX_ WITNESS_ SIZE - Default maximum witness size (bytes) - larger witness stacks suggest data embedding
- DEFAULT_
MIN_ FEE_ RATE - Default minimum fee rate threshold (satoshis per vbyte) Transactions with fee rate below this are suspicious
Functions§
- detect_
input_ script_ type - Detect script type from input script (scriptSig)