add rebalance amounts endpoints, rename controller

This commit is contained in:
Carsten Otto
2021-12-15 13:16:22 +01:00
parent 911614569c
commit dede9ea6db
6 changed files with 220 additions and 69 deletions

View File

@@ -4,6 +4,7 @@ import com.codahale.metrics.annotation.Timed;
import de.cotto.lndmanagej.model.ChannelId;
import de.cotto.lndmanagej.model.Pubkey;
import de.cotto.lndmanagej.service.OffChainCostService;
import de.cotto.lndmanagej.service.RebalanceService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -11,11 +12,13 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/")
public class OffChainCostsController {
public class RebalancesController {
private final OffChainCostService offChainCostService;
private final RebalanceService rebalanceService;
public OffChainCostsController(OffChainCostService offChainCostService) {
public RebalancesController(OffChainCostService offChainCostService, RebalanceService rebalanceService) {
this.offChainCostService = offChainCostService;
this.rebalanceService = rebalanceService;
}
@Timed
@@ -24,21 +27,45 @@ public class OffChainCostsController {
return offChainCostService.getRebalanceSourceCostsForPeer(pubkey).milliSatoshis();
}
@Timed
@GetMapping("/node/{pubkey}/rebalance-source-amount")
public long getRebalanceSourceAmountForPeer(@PathVariable Pubkey pubkey) {
return rebalanceService.getRebalanceAmountFromPeer(pubkey).milliSatoshis();
}
@Timed
@GetMapping("/channel/{channelId}/rebalance-source-costs")
public long getRebalanceSourceCostsForChannel(@PathVariable ChannelId channelId) {
return offChainCostService.getRebalanceSourceCostsForChannel(channelId).milliSatoshis();
}
@Timed
@GetMapping("/channel/{channelId}/rebalance-source-amount")
public long getRebalanceSourceAmountForChannel(@PathVariable ChannelId channelId) {
return rebalanceService.getRebalanceAmountFromChannel(channelId).milliSatoshis();
}
@Timed
@GetMapping("/node/{pubkey}/rebalance-target-costs")
public long getRebalanceTargetCostsForPeer(@PathVariable Pubkey pubkey) {
return offChainCostService.getRebalanceTargetCostsForPeer(pubkey).milliSatoshis();
}
@Timed
@GetMapping("/node/{pubkey}/rebalance-target-amount")
public long getRebalanceTargetAmountForPeer(@PathVariable Pubkey pubkey) {
return rebalanceService.getRebalanceAmountToPeer(pubkey).milliSatoshis();
}
@Timed
@GetMapping("/channel/{channelId}/rebalance-target-costs")
public long getRebalanceTargetCostsForChannel(@PathVariable ChannelId channelId) {
return offChainCostService.getRebalanceTargetCostsForChannel(channelId).milliSatoshis();
}
@Timed
@GetMapping("/channel/{channelId}/rebalance-target-amount")
public long getRebalanceTargetAmountForChannel(@PathVariable ChannelId channelId) {
return rebalanceService.getRebalanceAmountToChannel(channelId).milliSatoshis();
}
}