Last active
February 19, 2022 13:31
-
-
Save jorijn/dc39f8b6340e4c6f73ad04c60a931708 to your computer and use it in GitHub Desktop.
Attempt at automatic rebalancing for LND with rebalance-lnd, although it could fit any script... π€·ββοΈ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
420183667455285923,rompert.comguy,20,20 | |
590034546445293500,otherpeeralias,20,20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
##### | |
# Attempt at automatic rebalancing for LND with rebalance-lnd, although it could | |
# fit any script... π€·ββοΈ The config file can't contain comments, format is | |
# <channel id>,<some label>,<trigger if funds on local side are less than N%>,<trigger if funds on remote side are less than N%> | |
# The script will order the rebalancing to stop if it's still going after 600 seconds | |
# and kill if it's not stopped 30 seconds after that. Oh, and spaces in the config breaks stuff. | |
##### | |
REBALANCE="/path/to/rebalance.py" | |
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | |
SOFT_TIMEOUT=600 | |
KILL_TIMEOUT=30 | |
cd $DIR | |
for line in $(cat ${DIR}/auto_rebalance.conf) | |
do | |
channel_id=$(echo $line|cut -d, -f1) | |
peer_alias=$(echo $line|cut -d, -f2) | |
local_threshold=$(echo $line|cut -d, -f3) | |
remote_threshold=$(echo $line|cut -d, -f4) | |
echo "βοΈ Checking ${peer_alias} (${channel_id}), will rebalance if less than ${local_threshold}% of funds are on the local side or less than ${remote_threshold}% are on the remote side." | |
if $REBALANCE -l -r "$local_threshold" -i |grep "$channel_id" &>/dev/null; then | |
echo "π€ Moving funds to ${peer_alias}.." | |
timeout -v -k $KILL_TIMEOUT $SOFT_TIMEOUT $REBALANCE -t "$channel_id" | |
fi | |
if $REBALANCE -l -r "$remote_threshold" -o |grep "$channel_id" &>/dev/null; then | |
echo "π€ Moving funds from ${peer_alias}.." | |
timeout -v -k $KILL_TIMEOUT $SOFT_TIMEOUT $REBALANCE -f "$channel_id" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I suggest to use
--econ-fee
, the default fee configuration most likely isn't successful. I also don't think rebalancing to 50/50 is the best idea, maybe just send 100k sats (repeatedly) until you've meet your threshold?