mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-24 08:24:20 +01:00
add rebalance costs to channel details
This commit is contained in:
@@ -7,6 +7,7 @@ import de.cotto.lndmanagej.controller.dto.ChannelDto;
|
||||
import de.cotto.lndmanagej.controller.dto.ClosedChannelDetailsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.FeeReportDto;
|
||||
import de.cotto.lndmanagej.controller.dto.ObjectMapperConfiguration;
|
||||
import de.cotto.lndmanagej.controller.dto.OffChainCostsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.OnChainCostsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.PoliciesDto;
|
||||
import de.cotto.lndmanagej.model.BalanceInformation;
|
||||
@@ -21,6 +22,7 @@ import de.cotto.lndmanagej.service.BalanceService;
|
||||
import de.cotto.lndmanagej.service.ChannelService;
|
||||
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.PolicyService;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -42,6 +44,7 @@ public class ChannelController {
|
||||
private final OnChainCostService onChainCostService;
|
||||
private final PolicyService policyService;
|
||||
private final FeeService feeService;
|
||||
private final OffChainCostService offChainCostService;
|
||||
|
||||
public ChannelController(
|
||||
ChannelService channelService,
|
||||
@@ -49,7 +52,8 @@ public class ChannelController {
|
||||
BalanceService balanceService,
|
||||
OnChainCostService onChainCostService,
|
||||
PolicyService policyService,
|
||||
FeeService feeService
|
||||
FeeService feeService,
|
||||
OffChainCostService offChainCostService
|
||||
) {
|
||||
this.channelService = channelService;
|
||||
this.nodeService = nodeService;
|
||||
@@ -57,6 +61,7 @@ public class ChannelController {
|
||||
this.onChainCostService = onChainCostService;
|
||||
this.policyService = policyService;
|
||||
this.feeService = feeService;
|
||||
this.offChainCostService = offChainCostService;
|
||||
}
|
||||
|
||||
@Timed
|
||||
@@ -84,6 +89,7 @@ public class ChannelController {
|
||||
remoteAlias,
|
||||
getBalanceInformation(channelId),
|
||||
getOnChainCosts(channelId),
|
||||
getOffChainCosts(channelId),
|
||||
getPoliciesForChannel(localChannel),
|
||||
getCloseDetailsForChannel(localChannel),
|
||||
getFeeReportDto(localChannel.getId())
|
||||
@@ -144,6 +150,12 @@ public class ChannelController {
|
||||
return new OnChainCostsDto(openCosts, closeCosts);
|
||||
}
|
||||
|
||||
private OffChainCostsDto getOffChainCosts(ChannelId channelId) {
|
||||
Coins rebalanceSource = offChainCostService.getRebalanceSourceCostsForChannel(channelId);
|
||||
Coins rebalanceTarget = offChainCostService.getRebalanceTargetCostsForChannel(channelId);
|
||||
return new OffChainCostsDto(rebalanceSource, rebalanceTarget);
|
||||
}
|
||||
|
||||
private ClosedChannelDetailsDto getCloseDetailsForChannel(LocalChannel localChannel) {
|
||||
if (localChannel.isClosed()) {
|
||||
ClosedChannel closedChannel = localChannel.getAsClosedChannel();
|
||||
|
||||
@@ -21,6 +21,7 @@ public record ChannelDetailsDto(
|
||||
ChannelStatusDto status,
|
||||
BalanceInformationDto balance,
|
||||
OnChainCostsDto onChainCosts,
|
||||
OffChainCostsDto offChainCosts,
|
||||
PoliciesDto policies,
|
||||
ClosedChannelDetailsDto closeDetails,
|
||||
FeeReportDto feeReport
|
||||
@@ -30,6 +31,7 @@ public record ChannelDetailsDto(
|
||||
String remoteAlias,
|
||||
BalanceInformation balanceInformation,
|
||||
OnChainCostsDto onChainCosts,
|
||||
OffChainCostsDto offChainCosts,
|
||||
PoliciesDto policies,
|
||||
FeeReportDto feeReport
|
||||
) {
|
||||
@@ -48,6 +50,7 @@ public record ChannelDetailsDto(
|
||||
channelDto.status(),
|
||||
BalanceInformationDto.createFromModel(balanceInformation),
|
||||
onChainCosts,
|
||||
offChainCosts,
|
||||
policies,
|
||||
channelDto.closeDetails(),
|
||||
feeReport
|
||||
@@ -59,6 +62,7 @@ public record ChannelDetailsDto(
|
||||
String remoteAlias,
|
||||
BalanceInformation balanceInformation,
|
||||
OnChainCostsDto onChainCosts,
|
||||
OffChainCostsDto offChainCosts,
|
||||
PoliciesDto policies,
|
||||
ClosedChannelDetailsDto closeDetails,
|
||||
FeeReportDto feeReport
|
||||
@@ -68,6 +72,7 @@ public record ChannelDetailsDto(
|
||||
remoteAlias,
|
||||
balanceInformation,
|
||||
onChainCosts,
|
||||
offChainCosts,
|
||||
policies,
|
||||
feeReport
|
||||
);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package de.cotto.lndmanagej.controller.dto;
|
||||
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
|
||||
public record OffChainCostsDto(String rebalanceSource, String rebalanceTarget) {
|
||||
public OffChainCostsDto(Coins rebalanceSource, Coins rebalanceTarget) {
|
||||
this(
|
||||
String.valueOf(rebalanceSource.milliSatoshis()),
|
||||
String.valueOf(rebalanceTarget.milliSatoshis())
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user