mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-22 15:35:10 +01:00
compute sweep costs
This commit is contained in:
@@ -40,4 +40,10 @@ public class OnChainCostsController {
|
||||
.orElseThrow(() -> new CostException("Unable to get close costs for channel with ID " + channelId));
|
||||
}
|
||||
|
||||
@Timed
|
||||
@GetMapping("/channel/{channelId}/sweep-costs")
|
||||
public long getSweepCostsForChannel(@PathVariable ChannelId channelId) throws CostException {
|
||||
return onChainCostService.getSweepCostsForChannelId(channelId).map(Coins::satoshis)
|
||||
.orElseThrow(() -> new CostException("Unable to get sweep costs for channel with ID " + channelId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,15 @@ package de.cotto.lndmanagej.controller.dto;
|
||||
|
||||
import de.cotto.lndmanagej.model.OnChainCosts;
|
||||
|
||||
public record OnChainCostsDto(String openCosts, String closeCosts) {
|
||||
public record OnChainCostsDto(String openCosts, String closeCosts, String sweepCosts) {
|
||||
public static OnChainCostsDto createFromModel(OnChainCosts onChainCosts) {
|
||||
long openSatoshi = onChainCosts.open().satoshis();
|
||||
long closeSatoshi = onChainCosts.close().satoshis();
|
||||
return new OnChainCostsDto(String.valueOf(openSatoshi), String.valueOf(closeSatoshi));
|
||||
long sweepSatoshi = onChainCosts.sweep().satoshis();
|
||||
return new OnChainCostsDto(
|
||||
String.valueOf(openSatoshi),
|
||||
String.valueOf(closeSatoshi),
|
||||
String.valueOf(sweepSatoshi)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user