mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-26 17:34:27 +01:00
include fee configuration in channel details
This commit is contained in:
@@ -2,16 +2,19 @@ package de.cotto.lndmanagej.controller;
|
||||
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
import de.cotto.lndmanagej.controller.dto.ChannelDetailsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.FeeConfigurationDto;
|
||||
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.FeeConfiguration;
|
||||
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.FeeService;
|
||||
import de.cotto.lndmanagej.service.NodeService;
|
||||
import de.cotto.lndmanagej.service.OnChainCostService;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -29,12 +32,14 @@ public class ChannelDetailsController {
|
||||
private final Metrics metrics;
|
||||
private final BalanceService balanceService;
|
||||
private final OnChainCostService onChainCostService;
|
||||
private final FeeService feeService;
|
||||
|
||||
public ChannelDetailsController(
|
||||
ChannelService channelService,
|
||||
NodeService nodeService,
|
||||
BalanceService balanceService,
|
||||
OnChainCostService onChainCostService,
|
||||
FeeService feeService,
|
||||
Metrics metrics
|
||||
) {
|
||||
this.channelService = channelService;
|
||||
@@ -42,6 +47,7 @@ public class ChannelDetailsController {
|
||||
this.balanceService = balanceService;
|
||||
this.onChainCostService = onChainCostService;
|
||||
this.metrics = metrics;
|
||||
this.feeService = feeService;
|
||||
}
|
||||
|
||||
@GetMapping("/details")
|
||||
@@ -57,7 +63,8 @@ public class ChannelDetailsController {
|
||||
localChannel,
|
||||
remoteAlias,
|
||||
getBalanceInformation(channelId),
|
||||
getOnChainCosts(channelId)
|
||||
getOnChainCosts(channelId),
|
||||
getFeeConfiguration(channelId)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -71,4 +78,9 @@ public class ChannelDetailsController {
|
||||
Coins closeCosts = onChainCostService.getCloseCosts(channelId).orElse(Coins.NONE);
|
||||
return new OnChainCostsDto(openCosts, closeCosts);
|
||||
}
|
||||
|
||||
private FeeConfigurationDto getFeeConfiguration(ChannelId channelId) {
|
||||
FeeConfiguration feeConfiguration = feeService.getFeeConfiguration(channelId);
|
||||
return FeeConfigurationDto.createFrom(feeConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,15 @@ public record ChannelDetailsDto(
|
||||
String capacity,
|
||||
ChannelStatusDto status,
|
||||
BalanceInformationDto balance,
|
||||
OnChainCostsDto onChainCosts
|
||||
OnChainCostsDto onChainCosts,
|
||||
FeeConfigurationDto feeConfiguration
|
||||
) {
|
||||
public ChannelDetailsDto(
|
||||
LocalChannel localChannel,
|
||||
String remoteAlias,
|
||||
BalanceInformation balanceInformation,
|
||||
OnChainCostsDto onChainCosts
|
||||
OnChainCostsDto onChainCosts,
|
||||
FeeConfigurationDto feeConfiguration
|
||||
) {
|
||||
this(
|
||||
String.valueOf(localChannel.getId().getShortChannelId()),
|
||||
@@ -35,7 +37,8 @@ public record ChannelDetailsDto(
|
||||
String.valueOf(localChannel.getCapacity().satoshis()),
|
||||
ChannelStatusDto.createFrom(localChannel.getStatus()),
|
||||
BalanceInformationDto.createFrom(balanceInformation),
|
||||
onChainCosts
|
||||
onChainCosts,
|
||||
feeConfiguration
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package de.cotto.lndmanagej.controller.dto;
|
||||
|
||||
import de.cotto.lndmanagej.model.FeeConfiguration;
|
||||
|
||||
public record FeeConfigurationDto(
|
||||
long outgoingFeeRatePpm,
|
||||
long outgoingBaseFeeMilliSat,
|
||||
long incomingFeeRatePpm,
|
||||
long incomingBaseFeeMilliSat
|
||||
) {
|
||||
public static FeeConfigurationDto createFrom(FeeConfiguration feeConfiguration) {
|
||||
return new FeeConfigurationDto(
|
||||
feeConfiguration.outgoingFeeRate(),
|
||||
feeConfiguration.outgoingBaseFee().milliSatoshis(),
|
||||
feeConfiguration.incomingFeeRate(),
|
||||
feeConfiguration.incomingBaseFee().milliSatoshis()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user