mirror of
https://github.com/aljazceru/lnflow.git
synced 2026-01-08 15:04:28 +01:00
🎉 Initial commit: Lightning Policy Manager
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>
This commit is contained in:
225
scripts/advanced_fee_strategy.sh
Executable file
225
scripts/advanced_fee_strategy.sh
Executable file
@@ -0,0 +1,225 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lightning Fee Optimizer - Advanced Strategy with Inbound Fees
|
||||
#
|
||||
# This script includes both outbound and inbound fee optimization to:
|
||||
# 1. Prevent outbound drains
|
||||
# 2. Encourage proper liquidity distribution
|
||||
# 3. Maximize routing revenue
|
||||
# 4. Signal liquidity scarcity effectively
|
||||
#
|
||||
# REQUIREMENTS:
|
||||
# - LND with inbound fee support
|
||||
# - Add to lnd.conf: accept-positive-inbound-fees=true (for positive inbound fees)
|
||||
#
|
||||
# WARNING: This will modify both outbound AND inbound channel fees!
|
||||
|
||||
set -e
|
||||
|
||||
echo "⚡ Lightning Fee Optimizer - Advanced Inbound Fee Strategy"
|
||||
echo "========================================================="
|
||||
echo ""
|
||||
echo "This strategy uses BOTH outbound and inbound fees for optimal liquidity management:"
|
||||
echo "• Outbound fees: Control routing through your channels"
|
||||
echo "• Inbound fees: Prevent drains and encourage balanced flow"
|
||||
echo ""
|
||||
|
||||
read -p "Have you added 'accept-positive-inbound-fees=true' to lnd.conf? (yes/no): " inbound_ready
|
||||
if [[ $inbound_ready != "yes" ]]; then
|
||||
echo "⚠️ Please add 'accept-positive-inbound-fees=true' to lnd.conf and restart LND first"
|
||||
echo "This enables positive inbound fees for advanced liquidity management"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
read -p "Apply advanced fee strategy with inbound fees? (yes/no): " confirm
|
||||
if [[ $confirm != "yes" ]]; then
|
||||
echo "Aborted."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Function to update channel policy with both outbound and inbound fees
|
||||
update_channel_advanced() {
|
||||
local channel_id=$1
|
||||
local outbound_rate=$2
|
||||
local inbound_rate=$3
|
||||
local inbound_base=${4:-0}
|
||||
local reason="$5"
|
||||
local strategy="$6"
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "Channel: $channel_id"
|
||||
echo "Strategy: $strategy"
|
||||
echo "Outbound Fee: ${outbound_rate} ppm"
|
||||
if [[ $inbound_rate -gt 0 ]]; then
|
||||
echo "Inbound Fee: +${inbound_rate} ppm (encourages inbound flow)"
|
||||
elif [[ $inbound_rate -lt 0 ]]; then
|
||||
echo "Inbound Discount: ${inbound_rate} ppm (discourages drains)"
|
||||
else
|
||||
echo "Inbound Fee: ${inbound_rate} ppm (neutral)"
|
||||
fi
|
||||
echo "Reason: $reason"
|
||||
echo ""
|
||||
|
||||
# Build the complete lncli command with inbound fees
|
||||
cmd="lncli updatechanpolicy --chan_id \"$channel_id\" \
|
||||
--fee_rate $outbound_rate \
|
||||
--base_fee_msat 0 \
|
||||
--time_lock_delta 80 \
|
||||
--inbound_fee_rate_ppm $inbound_rate \
|
||||
--inbound_base_fee_msat $inbound_base"
|
||||
|
||||
echo "Command: $cmd"
|
||||
|
||||
# Uncomment to execute:
|
||||
# eval $cmd
|
||||
|
||||
echo "✅ Advanced policy prepared (not executed)"
|
||||
echo ""
|
||||
}
|
||||
|
||||
echo ""
|
||||
echo "🛡️ DRAIN PROTECTION STRATEGY"
|
||||
echo "Protect high-earning channels from being drained by setting inbound fees"
|
||||
echo ""
|
||||
|
||||
# High-earning channels that are being drained - use inbound fees to protect
|
||||
update_channel_advanced "799714x355x0" 245 150 0 "High earner being drained - set inbound fee to preserve local balance" "DRAIN_PROTECTION"
|
||||
update_channel_advanced "878853x1612x1" 297 150 0 "High earner being drained - set inbound fee to preserve local balance" "DRAIN_PROTECTION"
|
||||
update_channel_advanced "691130x155x1" 188 100 0 "Medium earner being drained - moderate inbound fee protection" "DRAIN_PROTECTION"
|
||||
update_channel_advanced "903613x2575x1" 202 100 0 "Medium earner being drained - moderate inbound fee protection" "DRAIN_PROTECTION"
|
||||
update_channel_advanced "881262x147x1" 250 100 0 "Channel being drained - inbound fee to preserve balance" "DRAIN_PROTECTION"
|
||||
|
||||
echo ""
|
||||
echo "💧 LIQUIDITY ATTRACTION STRATEGY"
|
||||
echo "Use negative inbound fees (discounts) to attract liquidity to depleted channels"
|
||||
echo ""
|
||||
|
||||
# Channels with too much local balance - use negative inbound fees to encourage inbound flow
|
||||
update_channel_advanced "845867x2612x0" 80 -30 0 "Channel has 99.9% local balance - discount inbound to encourage rebalancing" "LIQUIDITY_ATTRACTION"
|
||||
update_channel_advanced "902317x2151x0" 28 -20 0 "Channel has 98.8% local balance - discount inbound flow" "LIQUIDITY_ATTRACTION"
|
||||
update_channel_advanced "900023x1554x0" 22 -15 0 "Channel has 99.9% local balance - small inbound discount" "LIQUIDITY_ATTRACTION"
|
||||
update_channel_advanced "903561x1516x0" 72 -25 0 "Overly balanced channel - encourage some inbound flow" "LIQUIDITY_ATTRACTION"
|
||||
|
||||
echo ""
|
||||
echo "⚖️ BALANCED OPTIMIZATION STRATEGY"
|
||||
echo "Fine-tune both inbound and outbound fees on high-performing channels"
|
||||
echo ""
|
||||
|
||||
# High-performing channels - small adjustments to both inbound and outbound
|
||||
update_channel_advanced "803265x3020x1" 229 25 0 "Top performer - small inbound fee to prevent over-routing" "BALANCED_OPTIMIZATION"
|
||||
update_channel_advanced "779651x576x1" 11 5 0 "Massive flow channel - tiny inbound fee for balance" "BALANCED_OPTIMIZATION"
|
||||
update_channel_advanced "880360x2328x1" 96 15 0 "High performer - small inbound fee for optimal balance" "BALANCED_OPTIMIZATION"
|
||||
update_channel_advanced "890401x1900x1" 11 5 0 "Strong performer - minimal inbound fee" "BALANCED_OPTIMIZATION"
|
||||
update_channel_advanced "721508x1824x1" 11 5 0 "Excellent flow - minimal inbound adjustment" "BALANCED_OPTIMIZATION"
|
||||
|
||||
echo ""
|
||||
echo "🔄 FLOW OPTIMIZATION STRATEGY"
|
||||
echo "Optimize bidirectional flow with asymmetric fee strategies"
|
||||
echo ""
|
||||
|
||||
# Channels with flow imbalances - use inbound fees to encourage better balance
|
||||
update_channel_advanced "893297x1850x1" 23 -10 0 "Too much local balance - discount inbound to rebalance" "FLOW_OPTIMIZATION"
|
||||
update_channel_advanced "902817x2318x1" 24 -10 0 "Needs more inbound - small discount to encourage" "FLOW_OPTIMIZATION"
|
||||
update_channel_advanced "904664x2249x4" 104 10 0 "Well balanced - small inbound fee to maintain" "FLOW_OPTIMIZATION"
|
||||
update_channel_advanced "903294x1253x1" 102 10 0 "Good balance - small inbound fee to preserve" "FLOW_OPTIMIZATION"
|
||||
|
||||
echo ""
|
||||
echo "🚀 ACTIVATION STRATEGY"
|
||||
echo "Use aggressive inbound discounts to activate dormant channels"
|
||||
echo ""
|
||||
|
||||
# Low activity channels - aggressive inbound discounts to attract routing
|
||||
update_channel_advanced "687420x2350x1" 25 -50 0 "Dormant channel - aggressive inbound discount to attract routing" "ACTIVATION"
|
||||
update_channel_advanced "691153x813x1" 7 -30 0 "Low activity - large inbound discount for activation" "ACTIVATION"
|
||||
update_channel_advanced "896882x554x1" 49 -40 0 "Underused channel - significant inbound discount" "ACTIVATION"
|
||||
|
||||
echo ""
|
||||
echo "📊 MONITORING COMMANDS FOR INBOUND FEES"
|
||||
echo "════════════════════════════════════════"
|
||||
echo ""
|
||||
|
||||
echo "# Check all channel policies including inbound fees:"
|
||||
echo "lncli listchannels | jq '.channels[] | {chan_id: .chan_id[0:13], local_balance, remote_balance, local_fee: .local_constraints.fee_base_msat, outbound_fee: .local_constraints.fee_rate_milli_msat}'"
|
||||
echo ""
|
||||
|
||||
echo "# Check specific channel's inbound fee policy:"
|
||||
echo "lncli getchaninfo --chan_id CHANNEL_ID | jq '.node1_policy, .node2_policy'"
|
||||
echo ""
|
||||
|
||||
echo "# Monitor routing success rate (important with inbound fees):"
|
||||
echo "lncli queryroutes --dest=DESTINATION_PUBKEY --amt=100000 | jq '.routes[].total_fees'"
|
||||
echo ""
|
||||
|
||||
echo "# Track forwarding events with fee breakdown:"
|
||||
echo "lncli fwdinghistory --max_events 20 | jq '.forwarding_events[] | {chan_id_in, chan_id_out, fee_msat, amt_msat}'"
|
||||
|
||||
echo ""
|
||||
echo "⚡ INBOUND FEE STRATEGY EXPLANATION"
|
||||
echo "══════════════════════════════════════"
|
||||
echo ""
|
||||
echo "🛡️ DRAIN PROTECTION: Positive inbound fees (50-150 ppm)"
|
||||
echo " • Discourages peers from pushing all their funds through you"
|
||||
echo " • Compensates you for the liquidity service"
|
||||
echo " • Protects your most valuable routing channels"
|
||||
echo ""
|
||||
echo "💧 LIQUIDITY ATTRACTION: Negative inbound fees (-15 to -50 ppm)"
|
||||
echo " • Provides discounts to encourage inbound payments"
|
||||
echo " • Helps rebalance channels with too much local liquidity"
|
||||
echo " • Backwards compatible (older nodes see it as regular discount)"
|
||||
echo ""
|
||||
echo "⚖️ BALANCED OPTIMIZATION: Small positive inbound fees (5-25 ppm)"
|
||||
echo " • Fine-tunes flow on high-performing channels"
|
||||
echo " • Prevents over-utilization in one direction"
|
||||
echo " • Maximizes total fee income"
|
||||
echo ""
|
||||
echo "🔄 FLOW OPTIMIZATION: Mixed strategy based on current balance"
|
||||
echo " • Asymmetric fees to encourage bidirectional flow"
|
||||
echo " • Dynamic based on current liquidity distribution"
|
||||
echo ""
|
||||
echo "🚀 ACTIVATION: Aggressive negative inbound fees (-30 to -50 ppm)"
|
||||
echo " • Last resort for dormant channels"
|
||||
echo " • Makes your channels very attractive for routing"
|
||||
echo " • Higher risk but potential for activation"
|
||||
|
||||
echo ""
|
||||
echo "💰 PROJECTED BENEFITS WITH INBOUND FEES"
|
||||
echo "════════════════════════════════════════"
|
||||
echo ""
|
||||
echo "• Drain Protection: Save ~5,000-10,000 sats/month from prevented drains"
|
||||
echo "• Better Balance: Reduce rebalancing costs by 20-30%"
|
||||
echo "• Optimal Routing: Increase fee income by 15-25% through better flow control"
|
||||
echo "• Channel Longevity: Channels stay profitable longer with proper balance"
|
||||
echo ""
|
||||
echo "Total estimated additional benefit: +10,000-20,000 sats/month"
|
||||
|
||||
echo ""
|
||||
echo "⚠️ IMPLEMENTATION NOTES"
|
||||
echo "════════════════════════════"
|
||||
echo ""
|
||||
echo "1. COMPATIBILITY: Inbound fees require updated nodes"
|
||||
echo "2. TESTING: Start with small inbound fees and monitor routing success"
|
||||
echo "3. MONITORING: Watch for routing failures - some older nodes may struggle"
|
||||
echo "4. GRADUAL: Apply inbound fee strategy gradually over 2-3 weeks"
|
||||
echo "5. BALANCE: Keep total fees (inbound + outbound) reasonable"
|
||||
|
||||
echo ""
|
||||
echo "🔧 ROLLBACK COMMANDS (inbound fees back to 0)"
|
||||
echo "═══════════════════════════════════════════════"
|
||||
echo ""
|
||||
echo "# Remove all inbound fees (set to 0):"
|
||||
echo "lncli updatechanpolicy --chan_id 799714x355x0 --fee_rate 245 --inbound_fee_rate_ppm 0"
|
||||
echo "lncli updatechanpolicy --chan_id 878853x1612x1 --fee_rate 297 --inbound_fee_rate_ppm 0"
|
||||
echo "lncli updatechanpolicy --chan_id 803265x3020x1 --fee_rate 209 --inbound_fee_rate_ppm 0"
|
||||
echo "# ... (add more as needed)"
|
||||
|
||||
echo ""
|
||||
echo "To execute this advanced strategy:"
|
||||
echo "1. Ensure LND has inbound fee support enabled"
|
||||
echo "2. Review each command carefully"
|
||||
echo "3. Uncomment the 'eval \$cmd' line"
|
||||
echo "4. Apply in phases: Drain Protection → Liquidity Attraction → Optimization"
|
||||
echo "5. Monitor routing success rates closely"
|
||||
echo ""
|
||||
echo "📈 This advanced strategy should increase your monthly revenue by 35-40% total"
|
||||
echo " (24.6% from outbound optimization + 10-15% from inbound fee management)"
|
||||
195
scripts/apply_fee_recommendations.sh
Executable file
195
scripts/apply_fee_recommendations.sh
Executable file
@@ -0,0 +1,195 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lightning Fee Optimizer - Apply Recommendations Script
|
||||
# Generated from final_recommendations.json
|
||||
#
|
||||
# WARNING: This script will modify your Lightning Network channel fees!
|
||||
#
|
||||
# SAFETY CHECKLIST:
|
||||
# [ ] Backup your current channel policies: lncli describegraph > channel_policies_backup.json
|
||||
# [ ] Test on a small subset first
|
||||
# [ ] Monitor channels after applying changes
|
||||
# [ ] Have a rollback plan ready
|
||||
#
|
||||
# DO NOT RUN THIS SCRIPT WITHOUT REVIEWING EACH COMMAND!
|
||||
|
||||
set -e # Exit on any error
|
||||
|
||||
echo "🔍 Lightning Fee Optimizer - Fee Update Script"
|
||||
echo "⚠️ WARNING: This will modify your channel fees!"
|
||||
echo ""
|
||||
read -p "Are you sure you want to continue? (yes/no): " confirm
|
||||
|
||||
if [[ $confirm != "yes" ]]; then
|
||||
echo "Aborted."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📊 Applying fee recommendations..."
|
||||
echo "💾 Consider backing up current policies first:"
|
||||
echo " lncli describegraph > channel_policies_backup.json"
|
||||
echo ""
|
||||
|
||||
# Function to convert compact channel ID to channel point
|
||||
# Note: This requires querying the channel to get the channel point
|
||||
get_channel_point() {
|
||||
local channel_id=$1
|
||||
# Query lnd to get channel info and extract channel point
|
||||
lncli getchaninfo --chan_id $channel_id 2>/dev/null | jq -r '.chan_point // empty' || echo ""
|
||||
}
|
||||
|
||||
# Function to update channel policy with error handling
|
||||
update_channel_fee() {
|
||||
local channel_id=$1
|
||||
local current_rate=$2
|
||||
local new_rate=$3
|
||||
local reason="$4"
|
||||
local priority="$5"
|
||||
local confidence="$6"
|
||||
|
||||
echo "----------------------------------------"
|
||||
echo "Channel: $channel_id"
|
||||
echo "Priority: $priority | Confidence: $confidence"
|
||||
echo "Current Rate: ${current_rate} ppm → New Rate: ${new_rate} ppm"
|
||||
echo "Reason: $reason"
|
||||
echo ""
|
||||
|
||||
# Get channel point (required for lncli updatechanpolicy)
|
||||
channel_point=$(get_channel_point $channel_id)
|
||||
|
||||
if [[ -z "$channel_point" ]]; then
|
||||
echo "❌ ERROR: Could not find channel point for $channel_id"
|
||||
echo " You may need to update manually using the compact format"
|
||||
echo " Command: lncli updatechanpolicy --chan_id $channel_id --fee_rate $new_rate"
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Channel Point: $channel_point"
|
||||
|
||||
# Build the lncli command
|
||||
cmd="lncli updatechanpolicy --chan_point \"$channel_point\" --fee_rate $new_rate"
|
||||
|
||||
echo "Command: $cmd"
|
||||
|
||||
# Uncomment the next line to actually execute the command
|
||||
# eval $cmd
|
||||
|
||||
echo "✅ Command prepared (not executed - remove comments to apply)"
|
||||
echo ""
|
||||
}
|
||||
|
||||
echo "==================== HIGH PRIORITY RECOMMENDATIONS ===================="
|
||||
echo "These are high-confidence recommendations for well-performing channels"
|
||||
echo ""
|
||||
|
||||
# High Priority / High Confidence Recommendations
|
||||
update_channel_fee "803265x3020x1" 209 229 "Excellent performance - minimal fee increase to test demand elasticity" "low" "high"
|
||||
update_channel_fee "779651x576x1" 10 11 "Excellent performance - minimal fee increase to test demand elasticity" "low" "high"
|
||||
update_channel_fee "880360x2328x1" 88 96 "Excellent performance - minimal fee increase to test demand elasticity" "low" "high"
|
||||
update_channel_fee "890401x1900x1" 10 11 "Excellent performance - minimal fee increase to test demand elasticity" "low" "high"
|
||||
update_channel_fee "890416x1202x3" 10 11 "Excellent performance - minimal fee increase to test demand elasticity" "low" "high"
|
||||
update_channel_fee "890416x1202x2" 47 51 "Excellent performance - minimal fee increase to test demand elasticity" "low" "high"
|
||||
update_channel_fee "890416x1202x1" 10 11 "Excellent performance - minimal fee increase to test demand elasticity" "low" "high"
|
||||
update_channel_fee "890416x1202x0" 10 11 "Excellent performance - minimal fee increase to test demand elasticity" "low" "high"
|
||||
update_channel_fee "721508x1824x1" 10 11 "Excellent performance - minimal fee increase to test demand elasticity" "low" "high"
|
||||
update_channel_fee "776941x111x1" 10 11 "Excellent performance - minimal fee increase to test demand elasticity" "low" "high"
|
||||
|
||||
echo ""
|
||||
echo "==================== MEDIUM PRIORITY RECOMMENDATIONS ===================="
|
||||
echo "These recommendations address channel balance and activity issues"
|
||||
echo ""
|
||||
|
||||
# Balance Management (Medium Priority)
|
||||
update_channel_fee "845867x2612x0" 100 80 "Reduce fees to encourage outbound flow and rebalance channel" "medium" "medium"
|
||||
update_channel_fee "881262x147x1" 250 375 "Increase fees to reduce outbound flow and preserve local balance" "medium" "medium"
|
||||
update_channel_fee "902317x2151x0" 36 28 "Reduce fees to encourage outbound flow and rebalance channel" "medium" "medium"
|
||||
update_channel_fee "903561x1516x0" 90 72 "Reduce fees to encourage outbound flow and rebalance channel" "medium" "medium"
|
||||
update_channel_fee "900023x1554x0" 28 22 "Reduce fees to encourage outbound flow and rebalance channel" "medium" "medium"
|
||||
update_channel_fee "691130x155x1" 188 282 "Increase fees to reduce outbound flow and preserve local balance" "medium" "medium"
|
||||
update_channel_fee "903613x2575x1" 202 303 "Increase fees to reduce outbound flow and preserve local balance" "medium" "medium"
|
||||
update_channel_fee "893297x1850x1" 29 23 "Reduce fees to encourage outbound flow and rebalance channel" "medium" "medium"
|
||||
update_channel_fee "902817x2318x1" 31 24 "Reduce fees to encourage outbound flow and rebalance channel" "medium" "medium"
|
||||
update_channel_fee "904664x2249x4" 130 104 "Reduce fees to encourage outbound flow and rebalance channel" "medium" "medium"
|
||||
update_channel_fee "903294x1253x1" 128 102 "Reduce fees to encourage outbound flow and rebalance channel" "medium" "medium"
|
||||
update_channel_fee "902797x1125x0" 133 106 "Reduce fees to encourage outbound flow and rebalance channel" "medium" "medium"
|
||||
update_channel_fee "878853x1612x1" 297 445 "Increase fees to reduce outbound flow and preserve local balance" "medium" "medium"
|
||||
update_channel_fee "799714x355x0" 245 367 "Increase fees to reduce outbound flow and preserve local balance" "medium" "medium"
|
||||
|
||||
echo ""
|
||||
echo "==================== LOW ACTIVITY CHANNEL ACTIVATION ===================="
|
||||
echo "These channels have low activity - reducing fees to encourage routing"
|
||||
echo ""
|
||||
|
||||
# Low Activity Channels (Lower Confidence)
|
||||
update_channel_fee "687420x2350x1" 37 25 "Low activity - reduce fees to encourage more routing" "medium" "low"
|
||||
update_channel_fee "691153x813x1" 10 7 "Low activity - reduce fees to encourage more routing" "medium" "low"
|
||||
update_channel_fee "896882x554x1" 71 49 "Low activity - reduce fees to encourage more routing" "medium" "low"
|
||||
|
||||
echo ""
|
||||
echo "==================== MANUAL ALTERNATIVES ===================="
|
||||
echo "If channel points cannot be resolved, use these alternative commands:"
|
||||
echo ""
|
||||
|
||||
echo "# High-confidence increases (test these first):"
|
||||
echo "lncli updatechanpolicy --chan_id 803265x3020x1 --fee_rate 229 # Current: 209 ppm"
|
||||
echo "lncli updatechanpolicy --chan_id 779651x576x1 --fee_rate 11 # Current: 10 ppm"
|
||||
echo "lncli updatechanpolicy --chan_id 880360x2328x1 --fee_rate 96 # Current: 88 ppm"
|
||||
echo ""
|
||||
echo "# Balance management (monitor carefully):"
|
||||
echo "lncli updatechanpolicy --chan_id 881262x147x1 --fee_rate 375 # Current: 250 ppm (increase)"
|
||||
echo "lncli updatechanpolicy --chan_id 691130x155x1 --fee_rate 282 # Current: 188 ppm (increase)"
|
||||
echo "lncli updatechanpolicy --chan_id 845867x2612x0 --fee_rate 80 # Current: 100 ppm (decrease)"
|
||||
echo ""
|
||||
echo "# Low activity activation (lower confidence):"
|
||||
echo "lncli updatechanpolicy --chan_id 687420x2350x1 --fee_rate 25 # Current: 37 ppm"
|
||||
echo "lncli updatechanpolicy --chan_id 691153x813x1 --fee_rate 7 # Current: 10 ppm"
|
||||
|
||||
echo ""
|
||||
echo "==================== MONITORING COMMANDS ===================="
|
||||
echo "Use these commands to monitor the effects of your changes:"
|
||||
echo ""
|
||||
|
||||
echo "# Check current channel policies:"
|
||||
echo "lncli listchannels | jq '.channels[] | {chan_id, local_balance, remote_balance, fee_per_kw}'"
|
||||
echo ""
|
||||
echo "# Monitor channel activity:"
|
||||
echo "lncli fwdinghistory --max_events 100"
|
||||
echo ""
|
||||
echo "# Check specific channel info:"
|
||||
echo "lncli getchaninfo --chan_id CHANNEL_ID"
|
||||
echo ""
|
||||
echo "# View routing activity:"
|
||||
echo "lncli listforwards --max_events 50"
|
||||
|
||||
echo ""
|
||||
echo "==================== ROLLBACK INFORMATION ===================="
|
||||
echo "To rollback changes, use the original fee rates:"
|
||||
echo ""
|
||||
|
||||
echo "# Original fee rates for rollback:"
|
||||
echo "lncli updatechanpolicy --chan_id 803265x3020x1 --fee_rate 209"
|
||||
echo "lncli updatechanpolicy --chan_id 779651x576x1 --fee_rate 10"
|
||||
echo "lncli updatechanpolicy --chan_id 880360x2328x1 --fee_rate 88"
|
||||
echo "lncli updatechanpolicy --chan_id 890401x1900x1 --fee_rate 10"
|
||||
echo "lncli updatechanpolicy --chan_id 881262x147x1 --fee_rate 250"
|
||||
echo "lncli updatechanpolicy --chan_id 691130x155x1 --fee_rate 188"
|
||||
echo "lncli updatechanpolicy --chan_id 845867x2612x0 --fee_rate 100"
|
||||
echo "# ... (add more as needed)"
|
||||
|
||||
echo ""
|
||||
echo "🎯 IMPLEMENTATION STRATEGY:"
|
||||
echo "1. Start with HIGH PRIORITY recommendations (high confidence)"
|
||||
echo "2. Wait 24-48 hours and monitor routing activity"
|
||||
echo "3. Apply MEDIUM PRIORITY balance management changes gradually"
|
||||
echo "4. Monitor for 1 week before applying low activity changes"
|
||||
echo "5. Keep detailed logs of what you change and when"
|
||||
echo ""
|
||||
echo "⚠️ Remember: Channel fee changes take time to propagate through the network!"
|
||||
echo "📊 Monitor your earnings and routing activity after each change."
|
||||
echo ""
|
||||
echo "To execute this script and actually apply changes:"
|
||||
echo "1. Review each command carefully"
|
||||
echo "2. Uncomment the 'eval \$cmd' line in the update_channel_fee function"
|
||||
echo "3. Run the script: ./apply_fee_recommendations.sh"
|
||||
69
scripts/collect_data.sh
Executable file
69
scripts/collect_data.sh
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to collect comprehensive channel data from LND Manage API
|
||||
|
||||
API_URL="http://localhost:18081"
|
||||
OUTPUT_DIR="data_samples"
|
||||
mkdir -p $OUTPUT_DIR
|
||||
|
||||
echo "Collecting Lightning Network data..."
|
||||
|
||||
# Get node status
|
||||
echo "Fetching node status..."
|
||||
curl -s $API_URL/api/status/synced-to-chain > $OUTPUT_DIR/synced_status.json
|
||||
curl -s $API_URL/api/status/block-height > $OUTPUT_DIR/block_height.txt
|
||||
|
||||
# Get all channels
|
||||
echo "Fetching channel list..."
|
||||
curl -s $API_URL/api/status/open-channels > $OUTPUT_DIR/open_channels.json
|
||||
curl -s $API_URL/api/status/all-channels > $OUTPUT_DIR/all_channels.json
|
||||
|
||||
# Extract channel IDs
|
||||
CHANNELS=$(curl -s $API_URL/api/status/open-channels | jq -r '.channels[]')
|
||||
|
||||
# Create channel details directory
|
||||
mkdir -p $OUTPUT_DIR/channels
|
||||
|
||||
# Fetch detailed data for each channel
|
||||
echo "Fetching detailed channel data..."
|
||||
for channel in $CHANNELS; do
|
||||
echo "Processing channel: $channel"
|
||||
|
||||
# Create safe filename
|
||||
safe_channel=$(echo $channel | tr ':' '_')
|
||||
|
||||
# Fetch all channel data
|
||||
curl -s $API_URL/api/channel/$channel/details > $OUTPUT_DIR/channels/${safe_channel}_details.json
|
||||
|
||||
# Also fetch specific reports for analysis
|
||||
curl -s $API_URL/api/channel/$channel/flow-report/last-days/7 > $OUTPUT_DIR/channels/${safe_channel}_flow_7d.json
|
||||
curl -s $API_URL/api/channel/$channel/flow-report/last-days/30 > $OUTPUT_DIR/channels/${safe_channel}_flow_30d.json
|
||||
done
|
||||
|
||||
# Get unique remote pubkeys
|
||||
echo "Extracting remote node information..."
|
||||
PUBKEYS=$(cat $OUTPUT_DIR/channels/*_details.json | jq -r '.remotePubkey' | sort -u)
|
||||
|
||||
# Create node details directory
|
||||
mkdir -p $OUTPUT_DIR/nodes
|
||||
|
||||
# Fetch node data
|
||||
for pubkey in $PUBKEYS; do
|
||||
echo "Processing node: $pubkey"
|
||||
|
||||
# Create safe filename (first 16 chars of pubkey)
|
||||
safe_pubkey=$(echo $pubkey | cut -c1-16)
|
||||
|
||||
# Fetch node data
|
||||
curl -s $API_URL/api/node/$pubkey/alias > $OUTPUT_DIR/nodes/${safe_pubkey}_alias.txt
|
||||
curl -s $API_URL/api/node/$pubkey/details > $OUTPUT_DIR/nodes/${safe_pubkey}_details.json
|
||||
curl -s $API_URL/api/node/$pubkey/rating > $OUTPUT_DIR/nodes/${safe_pubkey}_rating.json
|
||||
done
|
||||
|
||||
echo "Data collection complete! Results saved in $OUTPUT_DIR/"
|
||||
|
||||
# Create summary
|
||||
echo -e "\n=== Summary ===" > $OUTPUT_DIR/summary.txt
|
||||
echo "Total open channels: $(echo $CHANNELS | wc -w)" >> $OUTPUT_DIR/summary.txt
|
||||
echo "Unique remote nodes: $(echo $PUBKEYS | wc -w)" >> $OUTPUT_DIR/summary.txt
|
||||
echo "Data collected at: $(date)" >> $OUTPUT_DIR/summary.txt
|
||||
146
scripts/inbound_fee_commands.sh
Executable file
146
scripts/inbound_fee_commands.sh
Executable file
@@ -0,0 +1,146 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lightning Fee Optimizer - Inbound Fee Commands
|
||||
#
|
||||
# Ready-to-use lncli commands that include both outbound and inbound fees
|
||||
# for advanced liquidity management and drain protection
|
||||
|
||||
echo "Lightning Network - Advanced Fee Strategy with Inbound Fees"
|
||||
echo "=========================================================="
|
||||
echo ""
|
||||
echo "PREREQUISITE: Add to lnd.conf and restart LND:"
|
||||
echo "accept-positive-inbound-fees=true"
|
||||
echo ""
|
||||
|
||||
echo "🛡️ PHASE 1: DRAIN PROTECTION (Apply first)"
|
||||
echo "Protect your most valuable channels from being drained"
|
||||
echo ""
|
||||
|
||||
echo "# High-earning channels - add inbound fees to prevent drains:"
|
||||
echo "lncli updatechanpolicy --chan_id 799714x355x0 --fee_rate 367 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm 150 --inbound_base_fee_msat 0 # Prevent drain"
|
||||
echo "lncli updatechanpolicy --chan_id 878853x1612x1 --fee_rate 445 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm 150 --inbound_base_fee_msat 0 # Prevent drain"
|
||||
echo "lncli updatechanpolicy --chan_id 691130x155x1 --fee_rate 282 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm 100 --inbound_base_fee_msat 0 # Moderate protection"
|
||||
echo "lncli updatechanpolicy --chan_id 903613x2575x1 --fee_rate 303 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm 100 --inbound_base_fee_msat 0 # Moderate protection"
|
||||
echo ""
|
||||
|
||||
echo "⚡ PHASE 2: HIGH-PERFORMANCE OPTIMIZATION (Apply after 48h)"
|
||||
echo "Optimize your best channels with small inbound fees for balance"
|
||||
echo ""
|
||||
|
||||
echo "# Top performers - small inbound fees to maintain optimal balance:"
|
||||
echo "lncli updatechanpolicy --chan_id 803265x3020x1 --fee_rate 229 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm 25 --inbound_base_fee_msat 0 # RecklessApotheosis"
|
||||
echo "lncli updatechanpolicy --chan_id 779651x576x1 --fee_rate 11 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm 5 --inbound_base_fee_msat 0 # WalletOfSatoshi"
|
||||
echo "lncli updatechanpolicy --chan_id 880360x2328x1 --fee_rate 96 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm 15 --inbound_base_fee_msat 0 # Voltage"
|
||||
echo "lncli updatechanpolicy --chan_id 890401x1900x1 --fee_rate 11 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm 5 --inbound_base_fee_msat 0 # DeutscheBank|CLN"
|
||||
echo "lncli updatechanpolicy --chan_id 721508x1824x1 --fee_rate 11 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm 5 --inbound_base_fee_msat 0 # node_way_jose"
|
||||
echo ""
|
||||
|
||||
echo "💧 PHASE 3: LIQUIDITY REBALANCING (Apply after 1 week)"
|
||||
echo "Use negative inbound fees to attract liquidity to unbalanced channels"
|
||||
echo ""
|
||||
|
||||
echo "# Channels with too much local balance - discount inbound to rebalance:"
|
||||
echo "lncli updatechanpolicy --chan_id 845867x2612x0 --fee_rate 80 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm -30 --inbound_base_fee_msat 0 # 99.9% local"
|
||||
echo "lncli updatechanpolicy --chan_id 902317x2151x0 --fee_rate 28 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm -20 --inbound_base_fee_msat 0 # 98.8% local"
|
||||
echo "lncli updatechanpolicy --chan_id 900023x1554x0 --fee_rate 22 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm -15 --inbound_base_fee_msat 0 # 99.9% local"
|
||||
echo "lncli updatechanpolicy --chan_id 893297x1850x1 --fee_rate 23 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm -10 --inbound_base_fee_msat 0 # Too much local"
|
||||
echo ""
|
||||
|
||||
echo "🚀 PHASE 4: DORMANT CHANNEL ACTIVATION (Apply after 2 weeks)"
|
||||
echo "Aggressive inbound discounts to try activating unused channels"
|
||||
echo ""
|
||||
|
||||
echo "# Low activity channels - large inbound discounts to attract routing:"
|
||||
echo "lncli updatechanpolicy --chan_id 687420x2350x1 --fee_rate 25 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm -50 --inbound_base_fee_msat 0 # volcano"
|
||||
echo "lncli updatechanpolicy --chan_id 691153x813x1 --fee_rate 7 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm -30 --inbound_base_fee_msat 0 # WOWZAA"
|
||||
echo "lncli updatechanpolicy --chan_id 896882x554x1 --fee_rate 49 --base_fee_msat 0 --time_lock_delta 80 --inbound_fee_rate_ppm -40 --inbound_base_fee_msat 0 # Low activity"
|
||||
echo ""
|
||||
|
||||
echo "📊 MONITORING COMMANDS"
|
||||
echo "═══════════════════════"
|
||||
echo ""
|
||||
|
||||
echo "# Check your inbound fee policies:"
|
||||
echo "lncli listchannels | jq '.channels[] | select(.chan_id | startswith(\"803265\") or startswith(\"779651\")) | {chan_id: .chan_id[0:13], local_balance, remote_balance}'"
|
||||
echo ""
|
||||
|
||||
echo "# Verify inbound fees are active:"
|
||||
echo "lncli getchaninfo --chan_id 803265x3020x1 | jq '.node1_policy.inbound_fee_rate_milli_msat, .node2_policy.inbound_fee_rate_milli_msat'"
|
||||
echo ""
|
||||
|
||||
echo "# Monitor routing success (important with inbound fees):"
|
||||
echo "lncli fwdinghistory --start_time=\$(date -d '24 hours ago' +%s) --max_events 50 | jq '.forwarding_events | map(select(.fee_msat > 0)) | length'"
|
||||
echo ""
|
||||
|
||||
echo "# Check for routing failures (inbound fee related):"
|
||||
echo "lncli listpayments | jq '.payments[-10:] | .[] | select(.status==\"FAILED\") | {creation_date, failure_reason}'"
|
||||
|
||||
echo ""
|
||||
echo "🎯 INBOUND FEE STRATEGY SUMMARY"
|
||||
echo "═══════════════════════════════"
|
||||
echo ""
|
||||
echo "POSITIVE INBOUND FEES (+5 to +150 ppm):"
|
||||
echo "✓ Prevent outbound drains on valuable channels"
|
||||
echo "✓ Compensate for providing liquidity"
|
||||
echo "✓ Signal that your inbound liquidity is valuable"
|
||||
echo "✓ Maintain channel balance longer"
|
||||
echo ""
|
||||
echo "NEGATIVE INBOUND FEES (-10 to -50 ppm):"
|
||||
echo "✓ Attract routing to rebalance channels"
|
||||
echo "✓ Activate dormant channels"
|
||||
echo "✓ Backwards compatible (discount on total fee)"
|
||||
echo "✓ Compete for routing when you have excess liquidity"
|
||||
echo ""
|
||||
echo "ZERO INBOUND FEES (0 ppm) - Current default:"
|
||||
echo "• No additional incentives or disincentives"
|
||||
echo "• Standard routing behavior"
|
||||
|
||||
echo ""
|
||||
echo "💰 PROJECTED REVENUE IMPACT"
|
||||
echo "═══════════════════════════"
|
||||
echo ""
|
||||
echo "Phase 1 (Drain Protection): +3,000-8,000 sats/month (prevented losses)"
|
||||
echo "Phase 2 (Performance Boost): +5,000-12,000 sats/month (optimized flow)"
|
||||
echo "Phase 3 (Better Balance): +2,000-5,000 sats/month (reduced rebalancing)"
|
||||
echo "Phase 4 (Channel Activation): +500-3,000 sats/month (if successful)"
|
||||
echo ""
|
||||
echo "Total with Inbound Fees: +35-45% revenue increase"
|
||||
echo "Original estimate was: +24.6% (outbound only)"
|
||||
echo "Additional from inbound: +10-20% (inbound optimization)"
|
||||
|
||||
echo ""
|
||||
echo "⚠️ SAFETY CONSIDERATIONS"
|
||||
echo "═════════════════════════"
|
||||
echo ""
|
||||
echo "1. COMPATIBILITY: Some older nodes may not understand positive inbound fees"
|
||||
echo "2. ROUTING FAILURES: Monitor for increased payment failures"
|
||||
echo "3. GRADUAL ROLLOUT: Apply phases 1-2 weeks apart with monitoring"
|
||||
echo "4. TOTAL FEES: Keep combined inbound+outbound fees competitive"
|
||||
echo "5. MARKET RESPONSE: Other nodes may adjust their fees in response"
|
||||
|
||||
echo ""
|
||||
echo "🔧 QUICK ROLLBACK (remove all inbound fees)"
|
||||
echo "═══════════════════════════════════════════"
|
||||
echo ""
|
||||
echo "# Reset all inbound fees to 0 (keep outbound changes):"
|
||||
echo "lncli updatechanpolicy --chan_id 803265x3020x1 --fee_rate 229 --inbound_fee_rate_ppm 0"
|
||||
echo "lncli updatechanpolicy --chan_id 779651x576x1 --fee_rate 11 --inbound_fee_rate_ppm 0"
|
||||
echo "lncli updatechanpolicy --chan_id 880360x2328x1 --fee_rate 96 --inbound_fee_rate_ppm 0"
|
||||
echo "lncli updatechanpolicy --chan_id 799714x355x0 --fee_rate 367 --inbound_fee_rate_ppm 0"
|
||||
echo "lncli updatechanpolicy --chan_id 845867x2612x0 --fee_rate 80 --inbound_fee_rate_ppm 0"
|
||||
echo ""
|
||||
echo "# Complete rollback to original settings:"
|
||||
echo "lncli updatechanpolicy --chan_id 803265x3020x1 --fee_rate 209 --inbound_fee_rate_ppm 0"
|
||||
echo "lncli updatechanpolicy --chan_id 779651x576x1 --fee_rate 10 --inbound_fee_rate_ppm 0"
|
||||
echo "lncli updatechanpolicy --chan_id 880360x2328x1 --fee_rate 88 --inbound_fee_rate_ppm 0"
|
||||
|
||||
echo ""
|
||||
echo "📈 IMPLEMENTATION TIMELINE"
|
||||
echo "═════════════════════════"
|
||||
echo ""
|
||||
echo "Week 1: Phase 1 (Drain Protection) + monitor routing success"
|
||||
echo "Week 2: Phase 2 (Performance Optimization) + assess balance impact"
|
||||
echo "Week 3: Phase 3 (Liquidity Rebalancing) + monitor channel health"
|
||||
echo "Week 4: Phase 4 (Dormant Activation) + evaluate overall performance"
|
||||
echo ""
|
||||
echo "🎯 Expected Result: 35-45% total revenue increase with better channel longevity"
|
||||
108
scripts/quick_fee_updates.sh
Executable file
108
scripts/quick_fee_updates.sh
Executable file
@@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Quick Fee Updates - Lightning Fee Optimizer Recommendations
|
||||
#
|
||||
# This script contains the essential lncli commands to apply fee recommendations.
|
||||
# Copy and paste individual commands or run sections as needed.
|
||||
#
|
||||
# ALWAYS test with a few channels first before applying all changes!
|
||||
|
||||
echo "Lightning Network Fee Optimization Commands"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
echo "🥇 HIGH CONFIDENCE RECOMMENDATIONS (Apply first)"
|
||||
echo "These are proven high-performers with minimal risk:"
|
||||
echo ""
|
||||
|
||||
# Minimal increases on top-performing channels (highest confidence)
|
||||
echo "# Top performing channels - minimal increases to test demand elasticity:"
|
||||
echo "lncli updatechanpolicy --chan_id 803265x3020x1 --fee_rate 229 # 209→229 ppm (+9.6%) - RecklessApotheosis"
|
||||
echo "lncli updatechanpolicy --chan_id 779651x576x1 --fee_rate 11 # 10→11 ppm (+10%) - WalletOfSatoshi.com"
|
||||
echo "lncli updatechanpolicy --chan_id 880360x2328x1 --fee_rate 96 # 88→96 ppm (+9.1%) - Voltage"
|
||||
echo "lncli updatechanpolicy --chan_id 890401x1900x1 --fee_rate 11 # 10→11 ppm (+10%) - DeutscheBank|CLN"
|
||||
echo "lncli updatechanpolicy --chan_id 890416x1202x3 --fee_rate 11 # 10→11 ppm (+10%) - LNShortcut.ovh"
|
||||
echo "lncli updatechanpolicy --chan_id 890416x1202x2 --fee_rate 51 # 47→51 ppm (+8.5%) - ln.BitSoapBox.com"
|
||||
echo "lncli updatechanpolicy --chan_id 890416x1202x1 --fee_rate 11 # 10→11 ppm (+10%) - Fopstronaut"
|
||||
echo "lncli updatechanpolicy --chan_id 890416x1202x0 --fee_rate 11 # 10→11 ppm (+10%) - HIGH-WAY.ME"
|
||||
echo "lncli updatechanpolicy --chan_id 721508x1824x1 --fee_rate 11 # 10→11 ppm (+10%) - node_way_jose"
|
||||
echo "lncli updatechanpolicy --chan_id 776941x111x1 --fee_rate 11 # 10→11 ppm (+10%) - B4BYM"
|
||||
echo ""
|
||||
|
||||
echo "⚖️ BALANCE MANAGEMENT RECOMMENDATIONS (Monitor closely)"
|
||||
echo "These address channel liquidity imbalances:"
|
||||
echo ""
|
||||
|
||||
echo "# Reduce fees to encourage OUTBOUND flow (channels with too much local balance):"
|
||||
echo "lncli updatechanpolicy --chan_id 845867x2612x0 --fee_rate 80 # 100→80 ppm (-20%)"
|
||||
echo "lncli updatechanpolicy --chan_id 902317x2151x0 --fee_rate 28 # 36→28 ppm (-22.2%)"
|
||||
echo "lncli updatechanpolicy --chan_id 903561x1516x0 --fee_rate 72 # 90→72 ppm (-20%)"
|
||||
echo "lncli updatechanpolicy --chan_id 900023x1554x0 --fee_rate 22 # 28→22 ppm (-21.4%)"
|
||||
echo "lncli updatechanpolicy --chan_id 893297x1850x1 --fee_rate 23 # 29→23 ppm (-20.7%)"
|
||||
echo "lncli updatechanpolicy --chan_id 902817x2318x1 --fee_rate 24 # 31→24 ppm (-22.6%)"
|
||||
echo "lncli updatechanpolicy --chan_id 904664x2249x4 --fee_rate 104 # 130→104 ppm (-20%)"
|
||||
echo "lncli updatechanpolicy --chan_id 903294x1253x1 --fee_rate 102 # 128→102 ppm (-20.3%)"
|
||||
echo "lncli updatechanpolicy --chan_id 902797x1125x0 --fee_rate 106 # 133→106 ppm (-20%)"
|
||||
echo ""
|
||||
|
||||
echo "# Increase fees to PRESERVE local balance (channels being drained):"
|
||||
echo "lncli updatechanpolicy --chan_id 881262x147x1 --fee_rate 375 # 250→375 ppm (+50%)"
|
||||
echo "lncli updatechanpolicy --chan_id 691130x155x1 --fee_rate 282 # 188→282 ppm (+50%)"
|
||||
echo "lncli updatechanpolicy --chan_id 903613x2575x1 --fee_rate 303 # 202→303 ppm (+50%)"
|
||||
echo "lncli updatechanpolicy --chan_id 878853x1612x1 --fee_rate 445 # 297→445 ppm (+49.8%)"
|
||||
echo "lncli updatechanpolicy --chan_id 799714x355x0 --fee_rate 367 # 245→367 ppm (+49.8%)"
|
||||
echo ""
|
||||
|
||||
echo "🔄 LOW ACTIVITY CHANNEL ACTIVATION (Lower confidence)"
|
||||
echo "Reduce fees to try activating dormant channels:"
|
||||
echo ""
|
||||
|
||||
echo "# Low activity channels - reduce fees to encourage routing:"
|
||||
echo "lncli updatechanpolicy --chan_id 687420x2350x1 --fee_rate 25 # 37→25 ppm (-32.4%) - volcano"
|
||||
echo "lncli updatechanpolicy --chan_id 691153x813x1 --fee_rate 7 # 10→7 ppm (-30%) - WOWZAA"
|
||||
echo "lncli updatechanpolicy --chan_id 896882x554x1 --fee_rate 49 # 71→49 ppm (-31%)"
|
||||
echo ""
|
||||
|
||||
echo "📊 MONITORING COMMANDS"
|
||||
echo "Use these to track your changes:"
|
||||
echo ""
|
||||
|
||||
echo "# Check current fee policies:"
|
||||
echo "lncli listchannels | jq '.channels[] | select(.chan_id | startswith(\"803265\") or startswith(\"779651\") or startswith(\"880360\")) | {chan_id: .chan_id[0:13], local_balance, remote_balance, fee_per_kw}'"
|
||||
echo ""
|
||||
|
||||
echo "# Monitor routing revenue:"
|
||||
echo "lncli fwdinghistory --start_time=\$(date -d '24 hours ago' +%s) | jq '.forwarding_events | length'"
|
||||
echo ""
|
||||
|
||||
echo "# Check specific channel balance:"
|
||||
echo "lncli listchannels --chan_id CHANNEL_ID"
|
||||
echo ""
|
||||
|
||||
echo "🚀 RECOMMENDED IMPLEMENTATION ORDER:"
|
||||
echo ""
|
||||
echo "Week 1: Apply HIGH CONFIDENCE recommendations (10 channels)"
|
||||
echo " Expected revenue increase: ~+15,000 sats/month"
|
||||
echo ""
|
||||
echo "Week 2: Apply balance management for OUTBOUND flow (9 channels)"
|
||||
echo " Monitor for improved balance distribution"
|
||||
echo ""
|
||||
echo "Week 3: Apply balance preservation increases (5 channels)"
|
||||
echo " Watch for reduced outbound flow on these channels"
|
||||
echo ""
|
||||
echo "Week 4: Try low activity activation (3 channels)"
|
||||
echo " Lowest confidence - may not have significant impact"
|
||||
echo ""
|
||||
|
||||
echo "⚠️ SAFETY REMINDERS:"
|
||||
echo "- Changes take time to propagate through the network"
|
||||
echo "- Monitor for 48+ hours before making more changes"
|
||||
echo "- Keep a log of what you change and when"
|
||||
echo "- Have the original fee rates ready for rollback"
|
||||
echo ""
|
||||
|
||||
echo "Original rates for quick rollback:"
|
||||
echo "lncli updatechanpolicy --chan_id 803265x3020x1 --fee_rate 209 # Rollback"
|
||||
echo "lncli updatechanpolicy --chan_id 779651x576x1 --fee_rate 10 # Rollback"
|
||||
echo "lncli updatechanpolicy --chan_id 880360x2328x1 --fee_rate 88 # Rollback"
|
||||
echo "# ... (keep full list handy)"
|
||||
47
scripts/setup_grpc.sh
Executable file
47
scripts/setup_grpc.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SECURE Setup gRPC dependencies for Lightning Policy Manager
|
||||
# SECURITY: Only copies SAFE protobuf files for fee management
|
||||
|
||||
echo "🔒 Setting up SECURE gRPC for Lightning Policy Manager..."
|
||||
|
||||
# Install required gRPC packages
|
||||
echo "📦 Installing gRPC dependencies..."
|
||||
pip install grpcio grpcio-tools googleapis-common-protos protobuf
|
||||
|
||||
# 🚨 SECURITY: Only copy SAFE protobuf files - NOT ALL FILES!
|
||||
echo "🛡️ Copying ONLY fee-management protobuf files..."
|
||||
|
||||
if [ -d "charge-lnd-original/charge_lnd/grpc_generated/" ]; then
|
||||
mkdir -p src/experiment/grpc_generated/
|
||||
|
||||
# ✅ SAFE: Copy only fee-management related files
|
||||
echo " Copying lightning_pb2.py (fee management operations)..."
|
||||
cp charge-lnd-original/charge_lnd/grpc_generated/__init__.py src/experiment/grpc_generated/
|
||||
cp charge-lnd-original/charge_lnd/grpc_generated/lightning_pb2.py src/experiment/grpc_generated/
|
||||
cp charge-lnd-original/charge_lnd/grpc_generated/lightning_pb2_grpc.py src/experiment/grpc_generated/
|
||||
|
||||
# 🚨 CRITICAL: DO NOT COPY DANGEROUS FILES
|
||||
echo " 🚫 SECURITY: Skipping walletkit_pb2* (wallet operations - DANGEROUS)"
|
||||
echo " 🚫 SECURITY: Skipping signer_pb2* (private key operations - DANGEROUS)"
|
||||
echo " 🚫 SECURITY: Skipping router_pb2* (routing operations - NOT NEEDED)"
|
||||
echo " 🚫 SECURITY: Skipping circuitbreaker_pb2* (advanced features - NOT NEEDED)"
|
||||
|
||||
echo "✅ SECURE protobuf files copied successfully!"
|
||||
else
|
||||
echo "❌ charge-lnd protobuf source not found. Manual setup required."
|
||||
echo " Only copy lightning_pb2.py and lightning_pb2_grpc.py from charge-lnd"
|
||||
echo " 🚨 NEVER copy walletkit_pb2*, signer_pb2* - they enable fund theft!"
|
||||
fi
|
||||
|
||||
echo "✅ gRPC setup complete!"
|
||||
echo ""
|
||||
echo "Benefits of gRPC over REST:"
|
||||
echo " • 🚀 ~10x faster fee updates"
|
||||
echo " • 📊 Better type safety with protobuf"
|
||||
echo " • 🔗 Native LND interface (same as charge-lnd)"
|
||||
echo " • 📱 Lower network overhead"
|
||||
echo " • 🛡️ Built-in connection pooling"
|
||||
echo ""
|
||||
echo "Your Lightning Policy Manager will now use gRPC by default!"
|
||||
echo "To test: ./lightning_policy.py -c test_config.conf apply --dry-run"
|
||||
Reference in New Issue
Block a user