mirror of
https://github.com/aljazceru/lnflow.git
synced 2026-01-22 05:24:25 +01:00
Advanced Lightning Network channel fee optimization system with: ✅ Intelligent inbound fee strategies (beyond charge-lnd) ✅ Automatic rollback protection for safety ✅ Machine learning optimization from historical data ✅ High-performance gRPC + REST API support ✅ Enterprise-grade security with method whitelisting ✅ Complete charge-lnd compatibility Features: - Policy-based fee management with advanced strategies - Balance-based and flow-based optimization algorithms - Revenue maximization focus vs simple rule-based approaches - Comprehensive security analysis and hardening - Professional repository structure with proper documentation - Full test coverage and example configurations Architecture: - Modern Python project structure with pyproject.toml - Secure gRPC integration with REST API fallback - Modular design: API clients, policy engine, strategies - SQLite database for experiment tracking - Shell script automation for common tasks Security: - Method whitelisting for LND operations - Runtime validation of all gRPC calls - No fund movement capabilities - fee management only - Comprehensive security audit completed - Production-ready with enterprise standards 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
140 lines
3.3 KiB
Plaintext
140 lines
3.3 KiB
Plaintext
# Advanced Policy Configuration - Showcasing improvements over charge-lnd
|
|
# This configuration uses all the advanced features including machine learning
|
|
|
|
[default]
|
|
final = false
|
|
base_fee_msat = 1000
|
|
fee_ppm = 1000
|
|
time_lock_delta = 80
|
|
enable_auto_rollback = true
|
|
rollback_threshold = 0.25
|
|
learning_enabled = true
|
|
|
|
[revenue-maximization]
|
|
# High-value channels with learning enabled
|
|
chan.min_capacity = 10000000
|
|
activity.level = high, medium
|
|
strategy = revenue_max
|
|
learning_enabled = true
|
|
enable_auto_rollback = true
|
|
rollback_threshold = 0.2
|
|
priority = 5
|
|
|
|
[competitive-pricing]
|
|
# Channels where we compete with many alternatives - use inbound discounts
|
|
network.min_alternatives = 5
|
|
peer.fee_ratio.min = 0.7
|
|
peer.fee_ratio.max = 1.3
|
|
strategy = inbound_discount
|
|
fee_ppm = 1200
|
|
inbound_fee_ppm = -75
|
|
inbound_base_fee_msat = -300
|
|
priority = 10
|
|
|
|
[premium-peers]
|
|
# Special rates for known high-value peers (replace with actual pubkeys)
|
|
node.id = 033d8656219478701227199cbd6f670335c8d408a92ae88b962c49d4dc0e83e025, 03cde60a6323f7122d5178255766e38114b4722ede08f7c9e0c5df9b912cc201d6
|
|
strategy = static
|
|
fee_ppm = 750
|
|
inbound_fee_ppm = -50
|
|
inbound_base_fee_msat = -250
|
|
enable_auto_rollback = false
|
|
priority = 5
|
|
|
|
[flow-based-optimization]
|
|
# Channels with good flow patterns - optimize based on activity
|
|
flow.7d.min = 5000000
|
|
strategy = flow_based
|
|
learning_enabled = true
|
|
enable_auto_rollback = true
|
|
rollback_threshold = 0.3
|
|
priority = 15
|
|
|
|
[balance-extreme-drain]
|
|
# Very unbalanced channels (>90% local) - aggressive rebalancing
|
|
chan.min_ratio = 0.9
|
|
strategy = balance_based
|
|
fee_ppm = 100
|
|
inbound_fee_ppm = -200
|
|
inbound_base_fee_msat = -1000
|
|
max_fee_ppm = 300
|
|
priority = 8
|
|
|
|
[balance-extreme-preserve]
|
|
# Very low balance channels (<10% local) - aggressive preservation
|
|
chan.max_ratio = 0.1
|
|
strategy = balance_based
|
|
fee_ppm = 3000
|
|
inbound_fee_ppm = 100
|
|
inbound_base_fee_msat = 500
|
|
min_fee_ppm = 2000
|
|
priority = 8
|
|
|
|
[small-channel-activation]
|
|
# Small channels that are inactive - make them competitive
|
|
chan.max_capacity = 1000000
|
|
activity.level = inactive, low
|
|
strategy = static
|
|
fee_ppm = 150
|
|
inbound_fee_ppm = -100
|
|
max_fee_ppm = 400
|
|
priority = 25
|
|
|
|
[large-inactive-penalty]
|
|
# Large but inactive channels - higher fees to encourage closure or activation
|
|
chan.min_capacity = 5000000
|
|
activity.level = inactive
|
|
strategy = static
|
|
fee_ppm = 2500
|
|
inbound_fee_ppm = 50
|
|
min_fee_ppm = 2000
|
|
priority = 20
|
|
|
|
[medium-flow-optimization]
|
|
# Medium activity channels - gradual optimization
|
|
activity.level = medium
|
|
flow.7d.min = 1000000
|
|
flow.7d.max = 10000000
|
|
strategy = proportional
|
|
fee_ppm = 1200
|
|
inbound_fee_ppm = -25
|
|
learning_enabled = true
|
|
priority = 30
|
|
|
|
[old-channels]
|
|
# Channels older than 90 days - conservative management
|
|
chan.min_age_days = 90
|
|
strategy = static
|
|
fee_ppm = 800
|
|
inbound_fee_ppm = -10
|
|
enable_auto_rollback = false
|
|
priority = 35
|
|
|
|
[new-channels]
|
|
# Channels younger than 7 days - give time to establish flow
|
|
chan.max_age_days = 7
|
|
strategy = static
|
|
fee_ppm = 500
|
|
inbound_fee_ppm = -50
|
|
max_fee_ppm = 1000
|
|
priority = 12
|
|
|
|
[discourage-routing]
|
|
# Channels we want to discourage (e.g., poorly connected peers)
|
|
chan.max_ratio = 0.05
|
|
chan.min_capacity = 1000000
|
|
strategy = static
|
|
fee_ppm = 5000
|
|
inbound_fee_ppm = 200
|
|
min_fee_ppm = 4000
|
|
priority = 90
|
|
|
|
[catch-all]
|
|
# Final policy with learning enabled
|
|
strategy = revenue_max
|
|
fee_ppm = 1000
|
|
inbound_fee_ppm = 0
|
|
learning_enabled = true
|
|
enable_auto_rollback = true
|
|
rollback_threshold = 0.3
|
|
priority = 100 |