I've been working on a few Python scripts to help automate and improve some Lightning node management tasks and wanted to share them with the community. I've bundled them into a GitHub repository called
Lightning-Python-ToolsLightning-Python-Tools
You can find it here: https://github.com/TrezorHannes/Lightning-Python-Tools
Here's a quick rundown of a few scripts inside:
fee_adjuster.py: This script pulls data from your LNDg database and public fee market data from Amboss. It allows you to build your own custom heuristics for managing your outbound and inbound channel fees automatically.
pocketmoney.py: Leveraging your LNBits instance, this tool can trigger regular, scheduled payments. It's perfect for things like sending pocket money to your children's wallets.
peerswap-lndg_push.py: For those using Peerswap, this script makes your Peerswap-enabled channels visible in your LNDg dashboard and conveniently enters your past swap history as a note.
boltz_swap-out.py: This is a command-line interface (CLI) tool for performing submarine swaps with Boltz. It intelligently suggests swaps based on your most outbound-heavy channels, again by feeding data from LNDg.
Disclaimer & Call for Contributions This is an open-source project. Please use it at your own risk. I welcome everyone to fork the repository, create pull requests to make the scripts more robust and versatile, or open issues with suggestions.
I'm also very keen to get your feedback. What other tools could be built to make a node runner's life easier? Let me know your thoughts!
Love to see it interact with LNDg. That was one of my favorite tools at the time. Is it still a time-consuming endeavour to run a routing node? Or have things become easier over the last 3-4 years?
Well, hard to say. I would say certainly more laid back into hammock maintenance possible, but some runners might take the extra mile to make the extra buck. It probably depends on
If both of the above is not a personal preference, todays tools like Autofees and Auto-Rebalancer in LNDg offer a hands-off "hammock" approach.
Certainly less fire-drilling compared to 2-4 years ago. Totally concur on your love for LNDg. I'm a big fan and also contributing to their code wherever I feel I can add value.
I've been loving the new LND autopilot features. It seems to do a much better job than I ever did at managing our node. Routing is slow but steady.
dang cool! Hey I have a few that we've worked on that may be handy too if you want some more: https://github.com/Velas-Commerce/lnurl-invoice-generator https://github.com/Velas-Commerce/liquifier https://github.com/Velas-Commerce/lightning-address-invoice-generator
One thing to add about a script I find particuarly useful to dig into when trying to answer the most pressing question a node-runner has: How much should I charge for my new channel to X?
The script
fee_adjuster.pycan be run with--debug, resulting in no write changes, but just giving a terminal output onfeeConfig.jsonThis is just an excerpt of what the script can do, eg fee-bands, group discounts, stuck adjustments etc. To see that in practice, below is the terminal output for my channel to Kraken 🐙⚡
.venv/bin/python ~/tools/Lightning-Python-Tools/Other/fee_adjuster.py --debug -------------------------------------------------------------------------------- --- Stuck Check Debug for Peer 02f1a8c876... --- Configured stuck_time_period: 3 days Configured min_local_balance_for_stuck_discount: 25.0% API Check Window: 12 days Last outbound forward timestamp found: 2025-06-12 03:26:38 Calculated days since last forward: 3 Aggregate Outbound Ratio for Peer: 63.1% Calculated stuck bands down (after checks): 1 Final Peer Status determination for stuck logic: Active (Recent Outbound Forward) --- End Stuck Check Debug --- -------------------------------------------------------------------------------- Alias: Kraken 🐙⚡ Pubkey: 02f1a8c87607f415c8f22c00593002775941dea48869ce23096af27b0cfdcc0b69 Channel ID: 837308890980417537 Capacity: 10,000,000 Local Balance: 6,311,206 | (Outbound: 63.1%) Old Fee Rate (LNDg): 786 --- Fee Calculation Waterfall --- Start Fee (Amboss WEIGHTED_CORRECTED): 1,503.4 ppm +/- Base Adj (+0.0%): 1,503.4 ppm +/- Group Adj (-5.0%): 1,428.3 ppm +/- Trend Adj (+0.0%): 1,428.3 ppm * Fee Band Adj (-45.0%): 785.5 ppm Max Cap (3500 ppm): Not Applied Calculated Rate (Rounded): 786 ppm --------------------------------- --- Context & Settings --- Group: Low Discount | Stuck ✅ | Weighted-Corrected Fee Base Used: weighted_corrected Trend Factor Used: 0.00 (Sensitivity: 0.60) Fee Bands: Enabled - Discount: -45.0%, Premium: 20.0% - Initial Band (Liquidity 63.1%): High Discount (60-80%) - Stuck Adjustment Applied: -1 bands - Final Band Used for Calc: Max Discount (80-100%) - Resulting Adjustment: -45.0% Stuck Adjustment: Enabled - Period: 3 days - Min Local Balance for Discount: 25.0% - Days Stuck: 3 days - Peer Status: Active (Recent Outbound Forward) - Adjustment Applied: 1 bands down --- Inbound Auto Fee Adjustment --- Inbound Auto Fee Global Setting: Disabled --- Amboss Peer Fee Data (Remote Perspective) --- +-----------+---------+--------+--------+----------+-------------+ | Time | Max | Mean | Median | Weighted | W.Corrected | +-----------+---------+--------+--------+----------+-------------+ | TODAY | 5000000 | 6475.7 | 500 | 4066.3 | 1503.4 | | ONE_DAY | 5000000 | 6479.9 | 500 | 4061.5 | 1498.3 | | ONE_WEEK | 5000000 | 6527.8 | 500 | 3990.7 | 1409.4 | | ONE_MONTH | 1500000 | 3450.8 | 500 | 3557.8 | 1650.2 | +-----------+---------+--------+--------+----------+-------------+