mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-22 15:35:10 +01:00
add fee-configuration endpoint for channel
This commit is contained in:
@@ -24,6 +24,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/channel/{channelId}")
|
||||
@Import(ObjectMapperConfiguration.class)
|
||||
@@ -69,6 +71,21 @@ public class ChannelController {
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/fee-configuration")
|
||||
public FeeConfigurationDto getFeeConfiguration(@PathVariable ChannelId channelId) {
|
||||
metrics.mark(MetricRegistry.name(getClass(), "getFeeConfiguration"));
|
||||
LocalChannel localChannel = channelService.getLocalChannel(channelId).orElse(null);
|
||||
return getFeeConfiguration(localChannel);
|
||||
}
|
||||
|
||||
private FeeConfigurationDto getFeeConfiguration(@Nullable LocalChannel channel) {
|
||||
if (channel == null || channel.getStatus().openCloseStatus() != OpenCloseStatus.OPEN) {
|
||||
return FeeConfigurationDto.EMPTY;
|
||||
}
|
||||
FeeConfiguration feeConfiguration = feeService.getFeeConfiguration(channel.getId());
|
||||
return FeeConfigurationDto.createFrom(feeConfiguration);
|
||||
}
|
||||
|
||||
private BalanceInformation getBalanceInformation(ChannelId channelId) {
|
||||
return balanceService.getBalanceInformation(channelId)
|
||||
.orElse(BalanceInformation.EMPTY);
|
||||
@@ -79,12 +96,4 @@ public class ChannelController {
|
||||
Coins closeCosts = onChainCostService.getCloseCosts(channelId).orElse(Coins.NONE);
|
||||
return new OnChainCostsDto(openCosts, closeCosts);
|
||||
}
|
||||
|
||||
private FeeConfigurationDto getFeeConfiguration(LocalChannel channel) {
|
||||
if (channel.getStatus().openCloseStatus() == OpenCloseStatus.OPEN) {
|
||||
FeeConfiguration feeConfiguration = feeService.getFeeConfiguration(channel.getId());
|
||||
return FeeConfigurationDto.createFrom(feeConfiguration);
|
||||
}
|
||||
return new FeeConfigurationDto(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ public record FeeConfigurationDto(
|
||||
long incomingFeeRatePpm,
|
||||
long incomingBaseFeeMilliSat
|
||||
) {
|
||||
public static final FeeConfigurationDto EMPTY =
|
||||
new FeeConfigurationDto(0, 0, 0, 0);
|
||||
|
||||
public static FeeConfigurationDto createFrom(FeeConfiguration feeConfiguration) {
|
||||
return new FeeConfigurationDto(
|
||||
feeConfiguration.outgoingFeeRate(),
|
||||
|
||||
Reference in New Issue
Block a user