Autopilot by a Noob - attempt not working need some helpSee original GitHub issue
I’m a complete noob to CLI. I have managed to install rebalance-lnd and also managed to do a 10k sats rebalance! (which I’m super proud of!) but as you can appreciate, it would take forever doing that manually with 3 mil sats. So wanted to automate it so as to rebalance each of my 8 chosen channels every 10 minutes. Also I wasn’t sure how to set it up so that it keeps trying until it actually successfully rebalances. Here is my code, I would be most grateful for your feedback and help! being that I am a total noob. I am sure there are many in my situation who have hit a snag like this and have simply given up. But I believe that the more we make essential tools like this accessible to noobs the more adoption we will get!
umbrel@umbrel:/mnt/data/upgrades/rebalance-lnd/rebalance-lnd $ crontab -e GNU nano 3.2 /tmp/crontab.n8PNjy/crontab 10*/1*** python3 rebalance.py -t 804...929 -a 11000 --min-remote 10000$ 20*/1*** python3 rebalance.py -t 804...153 -a 11000 --min-remote 100000 30*/1*** python3 rebalance.py -t 804...449 -a 11000 --min-remote 100000 40*/1*** python3 rebalance.py -t 8041...353 -a 11000 --min-remote 100000 50*/1*** python3 rebalance.py -t 804...209 -a 11000 --min-remote 100000 55*/1*** python3 rebalance.py -t 804...352 -a 11000 --min-remote 100000 05*/1*** python3 rebalance.py -t 803...185 -a 11000 --min-remote 100000 15*/1*** python3 rebalance.py -t 8039...872 -a 11000 --min-remote 100000 [ Read 19 lines ] ^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^J Justify ^C Cur Pos ^X Exit ^R Read File ^\ Replace ^U Uncut Text^T To Spell ^_ Go To Line
Also I tried to reduce my --fee-factor to 0.9 but this is all I keep getting and I don’t know where I have gone wrong. I am guessing that I should be adding this into crontab? If so, what would the argument look like? Here is what I have done, so again any help and feedback on my attempt would be really appreciated:
umbrel@umbrel:/mnt/data/upgrades/rebalance-lnd/rebalance-lnd $ python3 rebalance.py --fee-factor 0.9 usage: rebalance.py [-h] [--lnddir LNDDIR] [--network NETWORK] [--grpc GRPC] [-l] [--show-all | --show-only CHANNEL | -c] [-o | -i] [-f CHANNEL] [-t CHANNEL] [-A] [-a AMOUNT | -p PERCENTAGE] [--min-amount MIN_AMOUNT] [--min-local MIN_LOCAL] [--min-remote MIN_REMOTE] [-e EXCLUDE] [--reckless] [--fee-factor FEE_FACTOR] [--fee-limit FEE_LIMIT | --fee-ppm-limit FEE_PPM_LIMIT] optional arguments: -h, --help show this help message and exit --lnddir LNDDIR (default ~/.lnd) lnd directory --network NETWORK (default mainnet) lnd network (mainnet, testnet, simnet, ...) --grpc GRPC (default localhost:10009) lnd gRPC endpoint list candidates: Show the unbalanced channels. -l, --list-candidates list candidate channels for rebalance --show-all also show channels with zero rebalance amount --show-only CHANNEL only show information about the given channel -c, --compact Shows a compact list of all channels, one per line including ID, inbound/outbound liquidity, and alias -o, --outgoing lists channels with less than 1,000,000 (--min-remote) satoshis inbound liquidity -i, --incoming (default) lists channels with less than 1,000,000 (--min-local) satoshis outbound liquidity rebalance: Rebalance a channel. You need to specify at least the 'from' channel (-f) or the 'to' channel (-t). -f CHANNEL, --from CHANNEL Channel ID of the outgoing channel (funds will be taken from this channel). You may also specify the ID using the colon notation (12345:12:1), or the x notation (12345x12x1). You may also use -1 to choose a random candidate. -t CHANNEL, --to CHANNEL Channel ID of the incoming channel (funds will be sent to this channel). You may also specify the ID using the colon notation (12345:12:1), or the x notation (12345x12x1). You may also use -1 to choose a random candidate. -A, --adjust-amount-to-limits If set, adjust the amount to the limits (--min-local and --min-remote). The script will exit if the adjusted amount is below the --min-amount threshold. As such, this switch can be used if you do NOT want to rebalance if the channel is within the limits. -a AMOUNT, --amount AMOUNT Amount of the rebalance, in satoshis. If not specified, the amount computed for a perfect rebalance will be used (up to the maximum of 4,294,967 satoshis) -p PERCENTAGE, --percentage PERCENTAGE Set the amount to a percentage of the computed amount. As an example, if this is set to 50, half of the computed amount will be used. See --amount. --min-amount MIN_AMOUNT (Default: 10,000) If the given or computed rebalance amount is below this limit, nothing is done. --min-local MIN_LOCAL (Default: 1,000,000) Ensure that the channels have at least this amount as outbound liquidity. --min-remote MIN_REMOTE (Default: 1,000,000) Ensure that the channels have at least this amount as inbound liquidity. -e EXCLUDE, --exclude EXCLUDE Exclude the given channel. Can be used multiple times. --reckless Allow rebalance transactions that are not economically viable. You might also want to set --min-local 0 and --min-remote 0. If set, you also need to set --amount and either --fee-limit or --fee-ppm-limit, and you must not enable --adjust-amount-to-limits (-A). --fee-factor FEE_FACTOR (default: 1.0) Compare the costs against the expected income, scaled by this factor. As an example, with --fee-factor 1.5, routes that cost at most 150% of the expected earnings are tried. Use values smaller than 1.0 to restrict routes to only consider those earning more/costing less. This factor is ignored with --reckless. --fee-limit FEE_LIMIT If set, only consider rebalance transactions that cost up to the given number of satoshis. --fee-ppm-limit FEE_PPM_LIMIT If set, only consider rebalance transactions that cost up to the given number of satoshis per 1M satoshis sent. umbrel@umbrel:/mnt/data/upgrades/rebalance-lnd/rebalance-lnd $
On a separate note, for those noobs who have not gotten as far as I have, here is what has helped me for my own setup. I run an umbrel from a raspberrypi4 and simply ssh from a command line terminal (I use the terminal of mac OS). Also ssh isn’t complicated and it took me a while to figure this out. It is just the word “ssh” followed by the username for your umbrel. For most people their umbrel’s username is “email@example.com”. Simply enter the first line of the code below into the terminal and you’re away! So if you have the same set up as me try this out by simply copying each line and pasting it followed by enter. Don’t do more than one line! Be patient! It has worked several times for me and I hope it does for you too:
- Installation of rebalance-lnd:
ssh firstname.lastname@example.org sudo mkdir -p /mnt/data/upgrades/rebalance-lnd cd /mnt/data/upgrades/rebalance-lnd && git clone https://github.com/C-Otto/rebalance-lnd.git ls cd rebalance-lnd ls pip3 install -r requirements.txt python3 rebalance.py -c
You should now have it installed and should see a list of all your channels and the corresponding balance in each channel, this is what mine looks like! I have used made up numbers in the below examples here so don’t attempt to use it! The initial installation process set out above does take time so be patient and remain on the page until it concludes. When you enter the ssh above it will ask you for your password as you are effectively logging into your umbrel!
804...929 | 2,968,826 | 0 | Node A 804...153 | 1,979,056 | 0 | Node B 804...449 | 1,968,824 | 0 | Node C 804...353 | 1,908,672 | 49,240 | Node E 804...209 | 1,582,349 | 33,496 | Node F 804...352 | 1,543,479 | 71,433 | Node G 803...872 | 494,056 | 0 | Node H 803...185 | 481,690 | 5,745 | Node I 804...848 | 1,022,647 | 936,409 | Node J 804...680 | 0 | 1,977,589 | Node K 804...616 | 10,326 | 2,928,499 | Node L
- To do a manual rebalance use this:
python3 rebalance.py -t [enter number on left] -a [enter amount]
this is what it should look like:
python3 rebalance.py -t 803...872 -a 100000
this means you’re transferring 100000 sats into the channel: 803…872.
3 Returning to Rebalance-lnd: If you want to re-enter rebalance-lnd after closing it down then these 5 steps should get you there:
ssh email@example.com cd /mnt/data/upgrades/rebalance-lnd ls cd rebalance-lnd python3 rebalance.py -c
I’d like to also take this opportunity to say what a fantastic job by Carsten! Thanks for your invaluable contribution to the network!
- Created a year ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Many thanks Carsten!
I was able to successfully set up my node using this simple formula below:
2,12,22,32,,42,52 * * * * python3 /mnt/data/upgrades/rebalance-lnd/rebalance-lnd/rebalance.py --fee-factor 1.0 -t 804...929 -a 10000
But first, some context, it was a bit counter intuitive for me initially but now that I’ve figured it out it actually works!
My initial instinct was to use “-f” to indicate pull inbound liquidity “from” my channel with excessive inbound liquidity, but in fact, that was simply pushing out outbound liquidity “from” that channel that had the excessive inbound liquidity which had the effect of adding in more inbound liquidity and draining my other channels that had insufficient inbound liquidity of their remaining inbound liquidity.
So instead what I decided to use was “-t” which actually helped with pulling outbound liquidity “to” the channel with excessive inbound liquidity, thereby distributing the excessive inbound liquidity to my other channels with insufficient inbound liquidity.
I set up 5 of these codes from the same single channel that has excess inbound liquidity on the remote side. Each code rebalances the same channel every 10 mins by removing the excess liquidity and distributing it to the rest of my channels that need that inbound liquidity.
This first code above rebalances on the second minute of every 10 minutes.
The second code that I set up rebalances on the 4th minute of every 10 minutes and so on…
I then set up each of the 5 codes to rebalance at different amounts ranging from 10k sats for the first code to 50k sats for the 5th code.
Once this has fully rebalanced then I can pause the code (or I think it should stop working once the channel with excessive inbound liquidity drops down to 1 million sats of inbound liquidity. If it doesn’t stop automatically then I can turn the code off.
I will then see how much routing fees I’m generating and compare that to the cost of the rebalancing and adjust accordingly.
But I must say, this automated rebalancing is absolutely brilliant. I can see it show up on my umbrel every 2 mins! Brilliant job and saved me a whole load of time with rebalancing at your preferred price!
My personal approach is:
- identify peers for which I want to rebalance (basically those where I already earned some sats)
- identify channels that need more liquidity (using lnd-manageJ, for all channels I have with a peer I sum up the sats on my side)
- compute the amount I want to rebalance (target - available)
- in a loop: rebalance until the target is reached, using different amounts and fee ratios
My script uses (simple) locking so that I don’t rebalance the same peer more than once, and it makes sure to wait a couple of minutes between rebalance attempts to the same peer.