Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix channel rebalancing bug #76

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions liquidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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):
{
Expand Down
Loading