@@ -457,7 +457,7 @@ func manageChannelLiquidity(info ManageChannelLiquidityInfo) error {
457
457
458
458
switch {
459
459
//Both nodes are managed, then simply create 1 invoice and send it to the other node to pay it
460
- case info .lightningClients [rule .NodePubkey ] != nil && info .lightningClients [rule .RemoteNodePubkey ] != nil :
460
+ case info .lightningClients [rule .NodePubkey ] != nil && info .lightningClients [rule .RemoteNodePubkey ] != nil && rule . MinimumLocalBalance != 0 && info . channelBalanceRatio < float64 ( rule . MinimumLocalBalance ) :
461
461
{
462
462
//Add attribute to the span of swap requested
463
463
span .SetAttributes (attribute .String ("swapRequestedType" , "invoiceRebalance" ))
@@ -467,32 +467,33 @@ func manageChannelLiquidity(info ManageChannelLiquidityInfo) error {
467
467
468
468
log .WithField ("span" , span ).Infof ("rebalancing via invoice on channel %v on node %v" , channel .GetChanId (), info .nodeInfo .GetAlias ())
469
469
470
- switch {
471
470
//Create an invoice for the swap amount from the remote node and pay with the rule's node
472
- case rule .MinimumLocalBalance != 0 && info .channelBalanceRatio < float64 (rule .MinimumLocalBalance ):
473
- {
474
- swapAmount := helper .AbsInt64 ((swapAmountTarget - channel .LocalBalance ))
475
471
476
- err := invoiceRebalance (info , swapAmount , rule .NodePubkey , rule .RemoteNodePubkey )
477
- if err != nil {
478
- return err
479
- }
480
-
481
- }
482
- //Create an invoice for the swap amount from the rule's node and pay with the remote node
483
- case rule .MinimumRemoteBalance != 0 && info .channelBalanceRatio > float64 (rule .MinimumRemoteBalance ):
484
- {
485
- swapAmount := helper .AbsInt64 ((channel .RemoteBalance - swapAmountTarget ))
486
-
487
- err := invoiceRebalance (info , swapAmount , rule .RemoteNodePubkey , rule .NodePubkey )
488
- if err != nil {
489
- return err
490
- }
491
- }
472
+ swapAmount := helper .AbsInt64 ((swapAmountTarget - channel .LocalBalance ))
492
473
474
+ err := invoiceRebalance (info , swapAmount , rule .NodePubkey , rule .RemoteNodePubkey )
475
+ if err != nil {
476
+ return err
493
477
}
494
478
495
479
}
480
+ case info .lightningClients [rule .NodePubkey ] != nil && info .lightningClients [rule .RemoteNodePubkey ] != nil && rule .MinimumRemoteBalance != 0 && info .channelBalanceRatio > float64 (rule .MinimumRemoteBalance ):
481
+ {
482
+ //Add attribute to the span of swap requested
483
+ span .SetAttributes (attribute .String ("swapRequestedType" , "invoiceRebalance" ))
484
+ span .SetAttributes (attribute .String ("chanId" , fmt .Sprintf ("%v" , channel .GetChanId ())))
485
+ span .SetAttributes (attribute .String ("nodePubkey" , info .nodeInfo .GetIdentityPubkey ()))
486
+ span .SetAttributes (attribute .String ("nodeAlias" , info .nodeInfo .GetAlias ()))
487
+
488
+ log .WithField ("span" , span ).Infof ("rebalancing via invoice on channel %v on node %v" , channel .GetChanId (), info .nodeInfo .GetAlias ())
489
+ swapAmount := helper .AbsInt64 ((channel .RemoteBalance - swapAmountTarget ))
490
+
491
+ //Create an invoice for the swap amount from the rule's node and pay with the remote node
492
+ err := invoiceRebalance (info , swapAmount , rule .RemoteNodePubkey , rule .NodePubkey )
493
+ if err != nil {
494
+ return err
495
+ }
496
+ }
496
497
case rule .MinimumLocalBalance != 0 && info .channelBalanceRatio < float64 (rule .MinimumLocalBalance ):
497
498
{
498
499
swapAmount := helper .AbsInt64 ((swapAmountTarget - channel .LocalBalance ))
0 commit comments