Giter Site home page Giter Site logo

perfectly-balanced's Introduction

Perfectly Balanced ⚖️

image

Script to make your LND node pefectly balanced as all things should be. Inspired by Igniter, rebalance-lnd and Balance Of Satoshi

Requirements:

Almost all included by default in most linux distros:

  • bash
  • python3
  • pip
  • bc
  • wget
  • unzip

Make sure your LND path is located or linked to $HOME/.lnd

Usage

Not need to edit anything, just run it! 🚀

Usage: ./perfectlybalanced.sh {-v|-h|-m=VALUE|-t=VALUE|list|rebalance}

Optional:
        -v, --version
                Shows the version for this script

        -h, --help
                Shows this help

        -i=CHANNEL_ID, --ignore=CHANNEL_ID
                Ignores a specific channel id useful only if passed before 'list' or 'rebalance'
                It can be used many times and should match a number of 18 digits

        -m=MAX_FEE, --max-fee=MAX_FEE
                (Default: 50) Changes max fees useful only if passed before 'list' or 'rebalance'

        -t=TOLERANCE, --tolerance=TOLERANCE
                (Default: 0.95) Changes tolerance useful only if passed before 'rebalance'

list:
        Shows a list of all channels in compacted mode using 'rebalance.py -c -l'
        for example to: './perfectlybalanced.sh --tolerance=0.99 list'

rebalance:
        Tries to rebalance unbalanced channels with default max fee of 50 and tolerance 0.95
        for example to: './perfectlybalanced.sh --max-fee=10 --tolerance=0.98 rebalance'

Examples

List all channels within tolerance 0.92:

./perfectlybalanced.sh --tolerance=0.92 list

or

./perfectlybalanced.sh -t=0.92 list

Default list within tolerance 0.95:

./perfectlybalanced.sh list

Unbalanced channels being rebalanced max fee 10 sats and tolerance 0.97:

./perfectlybalanced.sh --max-fee=10 --tolerance=0.97 rebalance

or

./perfectlybalanced.sh -m=10 -t=0.97 rebalance

Default max fee 50 sats and tolerance 0.95:

./perfectlybalanced.sh rebalance

Rebalance with max fee 10 sats and tolerance 0.98, ignoring channel id '761128128258703361':

./perfectlybalanced.sh --ignore=761128128258703361 -t=0.98 -m=10 rebalance

image

Contribute

Feel free to collaborate with code or donate a few Satoshi using your LND node ⚡ 😄

lncli sendpayment --keysend 03e7299ced214b19b87ed87979462d9aee3ec07a42fe6e2211854bfa4cb32b0bb8 100 # sats

perfectly-balanced's People

Contributors

cuaritas avatar ibz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

perfectly-balanced's Issues

De-balancing already balanced channels

Hey, this is an awesome variant of Otto's script as i've been looking for something that targets all channels.

One issue i'm having however is that it keeps re-balancing and pulling liquidity from already balanced channels causing a loop of infinite balancing attempts wasting satoshis. Any reason for this? i'd assume it'd ignore channels that are already balanced and not attempt pulling liquidity out of them to feed other channels.

Here's an example - note the repeated back and forth balancing of the same channels:

BOS Lightning Node, [11/07/2022 3:47 AM]
☯️ Rebalanced 0.00173464 out Alfholanda → ChronicCoins. Fee: 0.00000003 0.00% (17)

BOS Lightning Node, [11/07/2022 4:21 AM]
☯️ Rebalanced 0.00000184 out Alfholanda → ChronicCoins. Fee: 0.00000001 0.54% (5440)

BOS Lightning Node, [11/07/2022 6:35 AM]
☯️ Rebalanced 0.00281043 out ChronicCoins → Alfholanda. Fee: 0.00000007 0.00% (24)

BOS Lightning Node, [11/07/2022 10:09 AM]
☯️ Rebalanced 0.00280724 out Alfholanda → ChronicCoins. Fee: 0.00000004 0.00% (15)

BOS Lightning Node, [11/07/2022 12:44 PM]
☯️ Rebalanced 0.00280728 out ChronicCoins → Alfholanda. Fee: 0.00000007 0.00% (24)

BOS Lightning Node, [11/07/2022 3:49 PM]
☯️ Rebalanced 0.00280578 out Alfholanda → ChronicCoins. Fee: 0.00000004 0.00% (15)

BOS Lightning Node, [11/07/2022 7:05 PM]
☯️ Rebalanced 0.00281706 out ChronicCoins → Alfholanda. Fee: 0.00000007 0.00% (24)

Introduce -p and --fee-factor eventually to allow chunks of balances, instead of sending 50% in one go

This is both excellent and a fun exercise for some of the channels, kudos Cuaritas!
What do you think about this little idea, apparently missing from Carsten's script and adopting a little from BOS would be an iterative approach of amount to be send.

Steps like:

  1. 500,000 sats to balance out > temporary channel failure 1, temporary channel failure 2, .... > Could not find any suitable route
    resulting for the same channel into
  2. 2 x 250,000 sats to balance out > temporary channel failure 1, temporary channel failure 2, .... > Could not find any suitable route
  3. 4 x 125,000 ...
    etc.

This obviously collides with your max-fee setting and should rather leverage rebalance-lnd --fee-factor, since you'll have many more single transactions. But it would be more economically feasible, since bigger chunks on boths sides in our network are (yet) so rare to see.

So with --fee-factor, you can divide the max-fee by the number of parts in each iterative step, and keep the spend sats economically limited.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.