mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-21 15:04:22 +01:00
add model for on chain costs
This commit is contained in:
@@ -8,12 +8,12 @@ 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;
|
||||
import de.cotto.lndmanagej.model.ChannelId;
|
||||
import de.cotto.lndmanagej.model.ClosedChannel;
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
import de.cotto.lndmanagej.model.FeeReport;
|
||||
import de.cotto.lndmanagej.model.LocalChannel;
|
||||
import de.cotto.lndmanagej.model.OpenCloseStatus;
|
||||
import de.cotto.lndmanagej.model.Policies;
|
||||
@@ -88,11 +88,11 @@ public class ChannelController {
|
||||
localChannel,
|
||||
remoteAlias,
|
||||
getBalanceInformation(channelId),
|
||||
getOnChainCosts(channelId),
|
||||
onChainCostService.getOnChainCostsForChannelId(channelId),
|
||||
getOffChainCosts(channelId),
|
||||
getPoliciesForChannel(localChannel),
|
||||
getCloseDetailsForChannel(localChannel),
|
||||
getFeeReportDto(localChannel.getId())
|
||||
getFeeReportFromService(localChannel.getId())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,11 +124,11 @@ public class ChannelController {
|
||||
@Timed
|
||||
@GetMapping("/fee-report")
|
||||
public FeeReportDto getFeeReport(@PathVariable ChannelId channelId) {
|
||||
return getFeeReportDto(channelId);
|
||||
return FeeReportDto.createFromModel(getFeeReportFromService(channelId));
|
||||
}
|
||||
|
||||
private FeeReportDto getFeeReportDto(ChannelId channelId) {
|
||||
return FeeReportDto.createFromModel(feeService.getFeeReportForChannel(channelId));
|
||||
private FeeReport getFeeReportFromService(ChannelId channelId) {
|
||||
return feeService.getFeeReportForChannel(channelId);
|
||||
}
|
||||
|
||||
private PoliciesDto getPoliciesForChannel(@Nullable LocalChannel channel) {
|
||||
@@ -144,12 +144,6 @@ public class ChannelController {
|
||||
.orElse(BalanceInformation.EMPTY);
|
||||
}
|
||||
|
||||
private OnChainCostsDto getOnChainCosts(ChannelId channelId) {
|
||||
Coins openCosts = onChainCostService.getOpenCostsForChannelId(channelId).orElse(Coins.NONE);
|
||||
Coins closeCosts = onChainCostService.getCloseCostsForChannelId(channelId).orElse(Coins.NONE);
|
||||
return new OnChainCostsDto(openCosts, closeCosts);
|
||||
}
|
||||
|
||||
private OffChainCostsDto getOffChainCosts(ChannelId channelId) {
|
||||
Coins rebalanceSource = offChainCostService.getRebalanceSourceCostsForChannel(channelId);
|
||||
Coins rebalanceTarget = offChainCostService.getRebalanceTargetCostsForChannel(channelId);
|
||||
|
||||
@@ -13,6 +13,7 @@ import de.cotto.lndmanagej.model.Channel;
|
||||
import de.cotto.lndmanagej.model.ChannelId;
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
import de.cotto.lndmanagej.model.Node;
|
||||
import de.cotto.lndmanagej.model.OnChainCosts;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
import de.cotto.lndmanagej.service.BalanceService;
|
||||
import de.cotto.lndmanagej.service.ChannelService;
|
||||
@@ -66,8 +67,7 @@ public class NodeController {
|
||||
@GetMapping("/details")
|
||||
public NodeDetailsDto getDetails(@PathVariable Pubkey pubkey) {
|
||||
Node node = nodeService.getNode(pubkey);
|
||||
Coins openCosts = onChainCostService.getOpenCostsWith(pubkey);
|
||||
Coins closeCosts = onChainCostService.getCloseCostsWith(pubkey);
|
||||
OnChainCosts onChainCosts = onChainCostService.getOnChainCostsForPeer(pubkey);
|
||||
Coins rebalanceSourceCosts = offChainCostService.getRebalanceSourceCostsForPeer(pubkey);
|
||||
Coins rebalanceTargetCosts = offChainCostService.getRebalanceTargetCostsForPeer(pubkey);
|
||||
BalanceInformation balanceInformation = balanceService.getBalanceInformationForPeer(pubkey);
|
||||
@@ -78,7 +78,7 @@ public class NodeController {
|
||||
toSortedList(channelService.getClosedChannelsWith(pubkey)),
|
||||
toSortedList(channelService.getWaitingCloseChannelsWith(pubkey)),
|
||||
toSortedList(channelService.getForceClosingChannelsWith(pubkey)),
|
||||
new OnChainCostsDto(openCosts, closeCosts),
|
||||
OnChainCostsDto.createFromModel(onChainCosts),
|
||||
new OffChainCostsDto(rebalanceSourceCosts, rebalanceTargetCosts),
|
||||
BalanceInformationDto.createFromModel(balanceInformation),
|
||||
node.online(),
|
||||
|
||||
@@ -23,10 +23,7 @@ public class OnChainCostsController {
|
||||
@Timed
|
||||
@GetMapping("/node/{pubkey}/on-chain-costs")
|
||||
public OnChainCostsDto getCostsForPeer(@PathVariable Pubkey pubkey) {
|
||||
return new OnChainCostsDto(
|
||||
onChainCostService.getOpenCostsWith(pubkey),
|
||||
onChainCostService.getCloseCostsWith(pubkey)
|
||||
);
|
||||
return OnChainCostsDto.createFromModel(onChainCostService.getOnChainCostsForPeer(pubkey));
|
||||
}
|
||||
|
||||
@Timed
|
||||
|
||||
@@ -2,7 +2,9 @@ package de.cotto.lndmanagej.controller.dto;
|
||||
|
||||
import de.cotto.lndmanagej.model.BalanceInformation;
|
||||
import de.cotto.lndmanagej.model.ChannelPoint;
|
||||
import de.cotto.lndmanagej.model.FeeReport;
|
||||
import de.cotto.lndmanagej.model.LocalChannel;
|
||||
import de.cotto.lndmanagej.model.OnChainCosts;
|
||||
import de.cotto.lndmanagej.model.OpenInitiator;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
|
||||
@@ -30,10 +32,10 @@ public record ChannelDetailsDto(
|
||||
ChannelDto channelDto,
|
||||
String remoteAlias,
|
||||
BalanceInformation balanceInformation,
|
||||
OnChainCostsDto onChainCosts,
|
||||
OnChainCosts onChainCosts,
|
||||
OffChainCostsDto offChainCosts,
|
||||
PoliciesDto policies,
|
||||
FeeReportDto feeReport
|
||||
FeeReport feeReport
|
||||
) {
|
||||
this(
|
||||
channelDto.channelIdShort(),
|
||||
@@ -49,11 +51,11 @@ public record ChannelDetailsDto(
|
||||
channelDto.totalReceived(),
|
||||
channelDto.status(),
|
||||
BalanceInformationDto.createFromModel(balanceInformation),
|
||||
onChainCosts,
|
||||
OnChainCostsDto.createFromModel(onChainCosts),
|
||||
offChainCosts,
|
||||
policies,
|
||||
channelDto.closeDetails(),
|
||||
feeReport
|
||||
FeeReportDto.createFromModel(feeReport)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -61,11 +63,11 @@ public record ChannelDetailsDto(
|
||||
LocalChannel localChannel,
|
||||
String remoteAlias,
|
||||
BalanceInformation balanceInformation,
|
||||
OnChainCostsDto onChainCosts,
|
||||
OnChainCosts onChainCosts,
|
||||
OffChainCostsDto offChainCosts,
|
||||
PoliciesDto policies,
|
||||
ClosedChannelDetailsDto closeDetails,
|
||||
FeeReportDto feeReport
|
||||
FeeReport feeReport
|
||||
) {
|
||||
this(
|
||||
new ChannelDto(localChannel, closeDetails),
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package de.cotto.lndmanagej.controller.dto;
|
||||
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
import de.cotto.lndmanagej.model.OnChainCosts;
|
||||
|
||||
public record OnChainCostsDto(String openCosts, String closeCosts) {
|
||||
public OnChainCostsDto(Coins openCosts, Coins closeCosts) {
|
||||
this(String.valueOf(openCosts.satoshis()), String.valueOf(closeCosts.satoshis()));
|
||||
public static OnChainCostsDto createFromModel(OnChainCosts onChainCosts) {
|
||||
long openSatoshi = onChainCosts.open().satoshis();
|
||||
long closeSatoshi = onChainCosts.close().satoshis();
|
||||
return new OnChainCostsDto(String.valueOf(openSatoshi), String.valueOf(closeSatoshi));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user