add rebalance amounts to channel/node details

This commit is contained in:
Carsten Otto
2021-12-15 13:38:42 +01:00
parent dede9ea6db
commit 6e813b7852
9 changed files with 101 additions and 17 deletions

View File

@@ -23,6 +23,7 @@ import de.cotto.lndmanagej.service.NodeService;
import de.cotto.lndmanagej.service.OffChainCostService;
import de.cotto.lndmanagej.service.OnChainCostService;
import de.cotto.lndmanagej.service.PolicyService;
import de.cotto.lndmanagej.service.RebalanceService;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -43,6 +44,7 @@ public class ChannelController {
private final PolicyService policyService;
private final FeeService feeService;
private final OffChainCostService offChainCostService;
private final RebalanceService rebalanceService;
public ChannelController(
ChannelService channelService,
@@ -51,7 +53,8 @@ public class ChannelController {
OnChainCostService onChainCostService,
PolicyService policyService,
FeeService feeService,
OffChainCostService offChainCostService
OffChainCostService offChainCostService,
RebalanceService rebalanceService
) {
this.channelService = channelService;
this.nodeService = nodeService;
@@ -60,6 +63,7 @@ public class ChannelController {
this.policyService = policyService;
this.feeService = feeService;
this.offChainCostService = offChainCostService;
this.rebalanceService = rebalanceService;
}
@Timed
@@ -90,7 +94,9 @@ public class ChannelController {
offChainCostService.getOffChainCostsForChannel(channelId),
getPoliciesForChannel(localChannel),
getCloseDetailsForChannel(localChannel),
getFeeReportFromService(localChannel.getId())
getFeeReportFromService(localChannel.getId()),
rebalanceService.getRebalanceAmountFromChannel(localChannel.getId()),
rebalanceService.getRebalanceAmountToChannel(localChannel.getId())
);
}

View File

@@ -21,6 +21,7 @@ import de.cotto.lndmanagej.service.FeeService;
import de.cotto.lndmanagej.service.NodeService;
import de.cotto.lndmanagej.service.OffChainCostService;
import de.cotto.lndmanagej.service.OnChainCostService;
import de.cotto.lndmanagej.service.RebalanceService;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -40,6 +41,7 @@ public class NodeController {
private final OffChainCostService offChainCostService;
private final BalanceService balanceService;
private final FeeService feeService;
private final RebalanceService rebalanceService;
public NodeController(
NodeService nodeService,
@@ -47,7 +49,8 @@ public class NodeController {
OnChainCostService onChainCostService,
OffChainCostService offChainCostService,
BalanceService balanceService,
FeeService feeService
FeeService feeService,
RebalanceService rebalanceService
) {
this.nodeService = nodeService;
this.channelService = channelService;
@@ -55,6 +58,7 @@ public class NodeController {
this.offChainCostService = offChainCostService;
this.balanceService = balanceService;
this.feeService = feeService;
this.rebalanceService = rebalanceService;
}
@Timed
@@ -81,7 +85,9 @@ public class NodeController {
OffChainCostsDto.createFromModel(offChainCosts),
BalanceInformationDto.createFromModel(balanceInformation),
node.online(),
getFeeReportDto(pubkey)
getFeeReportDto(pubkey),
String.valueOf(rebalanceService.getRebalanceAmountFromPeer(pubkey).milliSatoshis()),
String.valueOf(rebalanceService.getRebalanceAmountToPeer(pubkey).milliSatoshis())
);
}

View File

@@ -2,6 +2,7 @@ package de.cotto.lndmanagej.controller.dto;
import de.cotto.lndmanagej.model.BalanceInformation;
import de.cotto.lndmanagej.model.ChannelPoint;
import de.cotto.lndmanagej.model.Coins;
import de.cotto.lndmanagej.model.FeeReport;
import de.cotto.lndmanagej.model.LocalChannel;
import de.cotto.lndmanagej.model.OffChainCosts;
@@ -27,7 +28,9 @@ public record ChannelDetailsDto(
OffChainCostsDto offChainCosts,
PoliciesDto policies,
ClosedChannelDetailsDto closeDetails,
FeeReportDto feeReport
FeeReportDto feeReport,
String rebalanceSourceAmount,
String rebalanceTargetAmount
) {
public ChannelDetailsDto(
ChannelDto channelDto,
@@ -36,7 +39,9 @@ public record ChannelDetailsDto(
OnChainCosts onChainCosts,
OffChainCosts offChainCosts,
PoliciesDto policies,
FeeReport feeReport
FeeReport feeReport,
Coins rebalanceSourceAmount,
Coins rebalanceTargetAmount
) {
this(
channelDto.channelIdShort(),
@@ -56,10 +61,13 @@ public record ChannelDetailsDto(
OffChainCostsDto.createFromModel(offChainCosts),
policies,
channelDto.closeDetails(),
FeeReportDto.createFromModel(feeReport)
FeeReportDto.createFromModel(feeReport),
String.valueOf(rebalanceSourceAmount.milliSatoshis()),
String.valueOf(rebalanceTargetAmount.milliSatoshis())
);
}
@SuppressWarnings("PMD.ExcessiveParameterList")
public ChannelDetailsDto(
LocalChannel localChannel,
String remoteAlias,
@@ -68,7 +76,9 @@ public record ChannelDetailsDto(
OffChainCosts offChainCosts,
PoliciesDto policies,
ClosedChannelDetailsDto closeDetails,
FeeReport feeReport
FeeReport feeReport,
Coins rebalanceSourceAmount,
Coins rebalanceTargetAmount
) {
this(
new ChannelDto(localChannel, closeDetails),
@@ -77,7 +87,9 @@ public record ChannelDetailsDto(
onChainCosts,
offChainCosts,
policies,
feeReport
feeReport,
rebalanceSourceAmount,
rebalanceTargetAmount
);
}
}

View File

@@ -18,6 +18,8 @@ public record NodeDetailsDto(
OffChainCostsDto offChainCosts,
BalanceInformationDto balance,
boolean online,
FeeReportDto feeReport
FeeReportDto feeReport,
String rebalanceSourceAmount,
String rebalanceTargetAmount
) {
}