add the option to exclude channels by channelage

pull/52/head
ziggie 1 year ago
parent f7b9ca5689
commit bfe17d0ce1
No known key found for this signature in database
GPG Key ID: 1AFF9C4DCED6D666

@ -24,7 +24,7 @@ rebalance-lnd](https://github.com/accumulator/rebalance-lnd).
- timeouts can be customized
- JSON/TOML config file to set some defaults you prefer
- optional route probing using binary search to rebalance a smaller amount
- optional rapid rebalancing using the same route for further rebalances
- optional rapid rebalancing using the same route for further rebalances
unitl route is depleted in case a rebalance succeeds
- data caching to speed up alias resolution, quickly skip failing channel pairs
etc.
@ -62,8 +62,8 @@ in `~/go/bin/linux_arm`.
```
Config:
-f, --config config file path
-f, --config config file path
Node Connection:
-c, --connect connect to lnd using host:port
-t, --tlscert path to tls.cert to connect
@ -88,6 +88,7 @@ Common:
-e, --exclude-channel (DEPRECATED) don't use this channel at all (can be specified multiple times)
-d, --exclude-node (DEPRECATED) don't use this node for routing (can be specified multiple times)
--exclude don't use this node or your channel for routing (can be specified multiple times)
--exclude-channel-age channels with a lower channel age (in blocks) relative to the current blockheight are excluded when rebalancing
--to try only this channel or node as target (should satisfy other constraints too; can be specified multiple times)
--from try only this channel or node as source (should satisfy other constraints too; can be specified multiple times)
--fail-tolerance a payment that differs from the prior attempt by this ppm will be cancelled
@ -198,9 +199,8 @@ continues.
# Docker Setup
In general its recommanded to run regolancer in a normal environment because it is
so easy to install as mentioned above. However if you want to run it in a docker
we also provide the Dockerfile and a docker-compose.yml so that you can easily
get started.
so easy to install as mentioned above. However if you want to run it in a docker
we also provide the Dockerfile so that you can easily get started.
Build the container or pull it:
@ -224,7 +224,6 @@ alias regolancer="docker run --rm --network=umbrel_main_network -it -v /home/umb
For older versions of Umbrel please use `/home/umbrel/umbrel/lnd` instead of `/home/umbrel/umbrel/app-data/lightning/data/lnd`
# What's wrong with the other rebalancers
While I liked probing in `bos`, it has many downsides: gives up quickly on
@ -288,6 +287,7 @@ during route construction. You can also disable them (it only happens on your
end so you'll be able to receive liquidity but not send it) but it hurts your
score on various sites so better not to do it. Increase fees or lower max_htlc and
you'll be good. You can set multiple brackets with multiple limits like:
- 20% local balance => set max_htlc to 0.1 of channel capacity (so it can
process ≈2 payments max or more smaller payments)
- 10% local balance => set max_htlc to 0.01 of channel capacity (small payments
@ -306,6 +306,7 @@ accept contributions and suggestions though! For now I implemented almost
everything I needed, maybe except a couple of timeouts being configurable. But I
don't see much need for that as of now. The main goals and motivation for this
project were:
- make it reliable and robust so I don't have to babysit it (stop/restart if it
hangs, crashes or gives up early)
- make it fast and lightweight, don't stress `lnd` too much as it all should run
@ -318,4 +319,4 @@ project were:
# Feedback and contact
We have a Matrix room to discuss this program and solve issues, feel free to
join [#regolancer:matrix.org](https://matrix.to/#/#regolancer:matrix.org)!
join [#regolancer:matrix.org](https://matrix.to/#/#regolancer:matrix.org)!

@ -64,6 +64,10 @@ func (r *regolancer) getChannelCandidates(fromPerc, toPerc, amount int64) error
for _, c := range r.channels {
if params.ExcludeChannelAge != 0 && uint64(info.BlockHeight)-getChannelAge(c.ChanId) < params.ExcludeChannelAge {
continue
}
if _, ok := r.excludeBoth[c.ChanId]; ok {
continue
}
@ -200,6 +204,12 @@ func parseScid(chanId string) int64 {
}
func getChannelAge(chanId uint64) uint64 {
shortChanId := lnwire.NewShortChanIDFromInt(chanId)
return uint64(shortChanId.BlockHeight)
}
func (r *regolancer) getChannelForPeer(ctx context.Context, node []byte) []*lnrpc.Channel {
channels, err := r.lnClient.ListChannels(ctx, &lnrpc.ListChannelsRequest{ActiveOnly: true, PublicOnly: true, Peer: node})

@ -79,6 +79,9 @@ func (r *regolancer) info(ctx context.Context) error {
}
}
fmt.Println()
if params.ExcludeChannelAge != 0 {
fmt.Printf("ChannelAge needs to be >= than: %s blocks\n", hiWhiteColor(params.ExcludeChannelAge))
}
fmt.Printf("Fail tolerance: %s ppm\n", formatAmt(int64(params.FailTolerance)))
printBooleanOption("Rapid rebalance", params.AllowRapidRebalance)
printBooleanOption("Lost profit accounting", params.LostProfit)

@ -45,6 +45,7 @@ type configParams struct {
ExcludeChannels []string `short:"e" long:"exclude-channel" description:"(DEPRECATED) don't use this channel at all (can be specified multiple times)" json:"exclude_channels" toml:"exclude_channels"`
ExcludeNodes []string `short:"d" long:"exclude-node" description:"(DEPRECATED) don't use this node for routing (can be specified multiple times)" json:"exclude_nodes" toml:"exclude_nodes"`
Exclude []string `long:"exclude" description:"don't use this node or your channel for routing (can be specified multiple times)" json:"exclude" toml:"exclude"`
ExcludeChannelAge uint64 `long:"exclude-channel-age" description:"channels with a lower channel age (in blocks) relative to the current blockheight are excluded when rebalancing" json:"exclude_channel_age" toml:"exclude_channel_age"`
To []string `long:"to" description:"try only this channel or node as target (should satisfy other constraints too; can be specified multiple times)" json:"to" toml:"to"`
From []string `long:"from" description:"try only this channel or node as source (should satisfy other constraints too; can be specified multiple times)" json:"from" toml:"from"`
FailTolerance int64 `long:"fail-tolerance" description:"a payment that differs from the prior attempt by this ppm will be cancelled" json:"fail_tolerance" toml:"fail_tolerance"`
@ -68,6 +69,7 @@ type configParams struct {
}
var params, cfgParams configParams
var info *lnrpc.GetInfoResponse
type failedRoute struct {
channelPair [2]*lnrpc.Channel
@ -104,7 +106,10 @@ type regolancer struct {
}
func loadConfig() {
flags.NewParser(&cfgParams, flags.None).Parse()
_, err := flags.NewParser(&cfgParams, flags.None).Parse()
if err != nil {
log.Fatalf("Error when parsing command line options: %s", err)
}
if cfgParams.Config == "" {
return
@ -313,7 +318,7 @@ func main() {
defer mainCtxCancel()
infoCtx, infoCtxCancel := context.WithTimeout(mainCtx, time.Second*time.Duration(params.TimeoutInfo))
defer infoCtxCancel()
info, err := r.lnClient.GetInfo(infoCtx, &lnrpc.GetInfoRequest{})
info, err = r.lnClient.GetInfo(infoCtx, &lnrpc.GetInfoRequest{})
if err != nil {
log.Fatal(err)
}

Loading…
Cancel
Save