mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-25 08:54:21 +01:00
include balance and onchain costs in channel details
This commit is contained in:
@@ -3,12 +3,17 @@ package de.cotto.lndmanagej.controller;
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
import de.cotto.lndmanagej.controller.dto.ChannelDetailsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.ObjectMapperConfiguration;
|
||||
import de.cotto.lndmanagej.controller.dto.OnChainCostsDto;
|
||||
import de.cotto.lndmanagej.metrics.Metrics;
|
||||
import de.cotto.lndmanagej.model.BalanceInformation;
|
||||
import de.cotto.lndmanagej.model.ChannelId;
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
import de.cotto.lndmanagej.model.LocalChannel;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
import de.cotto.lndmanagej.service.BalanceService;
|
||||
import de.cotto.lndmanagej.service.ChannelService;
|
||||
import de.cotto.lndmanagej.service.NodeService;
|
||||
import de.cotto.lndmanagej.service.OnChainCostService;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -22,10 +27,20 @@ public class ChannelDetailsController {
|
||||
private final ChannelService channelService;
|
||||
private final NodeService nodeService;
|
||||
private final Metrics metrics;
|
||||
private final BalanceService balanceService;
|
||||
private final OnChainCostService onChainCostService;
|
||||
|
||||
public ChannelDetailsController(ChannelService channelService, NodeService nodeService, Metrics metrics) {
|
||||
public ChannelDetailsController(
|
||||
ChannelService channelService,
|
||||
NodeService nodeService,
|
||||
BalanceService balanceService,
|
||||
OnChainCostService onChainCostService,
|
||||
Metrics metrics
|
||||
) {
|
||||
this.channelService = channelService;
|
||||
this.nodeService = nodeService;
|
||||
this.balanceService = balanceService;
|
||||
this.onChainCostService = onChainCostService;
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
||||
@@ -38,7 +53,22 @@ public class ChannelDetailsController {
|
||||
}
|
||||
Pubkey remotePubkey = localChannel.getRemotePubkey();
|
||||
String remoteAlias = nodeService.getAlias(remotePubkey);
|
||||
boolean privateChannel = localChannel.isPrivateChannel();
|
||||
return new ChannelDetailsDto(localChannel.getId(), remotePubkey, remoteAlias, privateChannel);
|
||||
return new ChannelDetailsDto(
|
||||
localChannel,
|
||||
remoteAlias,
|
||||
getBalanceInformation(channelId),
|
||||
getOnChainCosts(channelId)
|
||||
);
|
||||
}
|
||||
|
||||
private BalanceInformation getBalanceInformation(ChannelId channelId) {
|
||||
return balanceService.getBalanceInformation(channelId)
|
||||
.orElse(BalanceInformation.EMPTY);
|
||||
}
|
||||
|
||||
private OnChainCostsDto getOnChainCosts(ChannelId channelId) {
|
||||
Coins openCosts = onChainCostService.getOpenCosts(channelId).orElse(Coins.NONE);
|
||||
Coins closeCosts = onChainCostService.getCloseCosts(channelId).orElse(Coins.NONE);
|
||||
return new OnChainCostsDto(openCosts, closeCosts);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user