mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-24 16:34:19 +01:00
add /api/node/PUBKEY/on-chain-costs
This commit is contained in:
@@ -8,6 +8,7 @@ import de.cotto.lndmanagej.controller.dto.OnChainCostsDto;
|
||||
import de.cotto.lndmanagej.metrics.Metrics;
|
||||
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.Pubkey;
|
||||
import de.cotto.lndmanagej.service.ChannelService;
|
||||
@@ -54,8 +55,8 @@ public class NodeController {
|
||||
public NodeDetailsDto getDetails(@PathVariable Pubkey pubkey) {
|
||||
mark("getDetails");
|
||||
Node node = nodeService.getNode(pubkey);
|
||||
String openCosts = String.valueOf(onChainCostService.getOpenCostsWith(pubkey).satoshis());
|
||||
String closeCosts = String.valueOf(onChainCostService.getCloseCostsWith(pubkey).satoshis());
|
||||
Coins openCosts = onChainCostService.getOpenCostsWith(pubkey);
|
||||
Coins closeCosts = onChainCostService.getCloseCostsWith(pubkey);
|
||||
return new NodeDetailsDto(
|
||||
pubkey,
|
||||
node.alias(),
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package de.cotto.lndmanagej.controller;
|
||||
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
import de.cotto.lndmanagej.controller.dto.OnChainCostsDto;
|
||||
import de.cotto.lndmanagej.metrics.Metrics;
|
||||
import de.cotto.lndmanagej.model.ChannelId;
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
import de.cotto.lndmanagej.service.OnChainCostService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -21,6 +23,15 @@ public class OnChainCostsController {
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
||||
@GetMapping("/node/{pubkey}/on-chain-costs")
|
||||
public OnChainCostsDto getCostsForPeer(@PathVariable Pubkey pubkey) {
|
||||
metrics.mark(MetricRegistry.name(getClass(), "getCostsForPeer"));
|
||||
return new OnChainCostsDto(
|
||||
onChainCostService.getOpenCostsWith(pubkey),
|
||||
onChainCostService.getCloseCostsWith(pubkey)
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/channel/{channelId}/open-costs")
|
||||
public long getOpenCostsForChannel(@PathVariable ChannelId channelId) throws CostException {
|
||||
metrics.mark(MetricRegistry.name(getClass(), "getOpenCostsForChannel"));
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
package de.cotto.lndmanagej.controller.dto;
|
||||
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
|
||||
public record OnChainCostsDto(String openCosts, String closeCosts) {
|
||||
public OnChainCostsDto(Coins openCosts, Coins closeCosts) {
|
||||
this(String.valueOf(openCosts.satoshis()), String.valueOf(closeCosts.satoshis()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user