From 8dce412d53b0bad8c95cbd872da7d548eed54ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20A=2EP?= <53834183+Jossec101@users.noreply.github.com> Date: Wed, 17 Apr 2024 18:43:15 +0200 Subject: [PATCH] Hotfix, the simplification introduced a condition when the channel was already balanced, it tried to balance it. (#76) --- liquidator.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/liquidator.go b/liquidator.go index 3e21d80..d33690f 100644 --- a/liquidator.go +++ b/liquidator.go @@ -466,36 +466,32 @@ func manageChannelLiquidity(info ManageChannelLiquidityInfo) error { span.SetAttributes(attribute.String("nodeAlias", info.nodeInfo.GetAlias())) log.WithField("span", span).Infof("rebalancing via invoice on channel %v on node %v", channel.GetChanId(), info.nodeInfo.GetAlias()) - var payerPubKey string - var payeePubKey string - var swapAmount int64 switch { //Create an invoice for the swap amount from the remote node and pay with the rule's node case rule.MinimumLocalBalance != 0 && info.channelBalanceRatio < float64(rule.MinimumLocalBalance): { - swapAmount = helper.AbsInt64((swapAmountTarget - channel.LocalBalance)) + swapAmount := helper.AbsInt64((swapAmountTarget - channel.LocalBalance)) - payerPubKey = rule.NodePubkey - payeePubKey = rule.RemoteNodePubkey + err := invoiceRebalance(info, swapAmount, rule.NodePubkey, rule.RemoteNodePubkey) + if err != nil { + return err + } } //Create an invoice for the swap amount from the rule's node and pay with the remote node case rule.MinimumRemoteBalance != 0 && info.channelBalanceRatio > float64(rule.MinimumRemoteBalance): { - swapAmount = helper.AbsInt64((channel.RemoteBalance - swapAmountTarget)) + swapAmount := helper.AbsInt64((channel.RemoteBalance - swapAmountTarget)) - payerPubKey = rule.RemoteNodePubkey - payeePubKey = rule.NodePubkey + err := invoiceRebalance(info, swapAmount, rule.RemoteNodePubkey, rule.NodePubkey) + if err != nil { + return err + } } } - err := invoiceRebalance(info, swapAmount, payerPubKey, payeePubKey) - if err != nil { - return err - } - } case rule.MinimumLocalBalance != 0 && info.channelBalanceRatio < float64(rule.MinimumLocalBalance): {