add self payments endpoints (aggregated per peer)

This commit is contained in:
Carsten Otto
2021-12-09 13:59:20 +01:00
parent fb8fd3134f
commit 9a8549b527
6 changed files with 180 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ import com.codahale.metrics.annotation.Timed;
import de.cotto.lndmanagej.controller.dto.ObjectMapperConfiguration;
import de.cotto.lndmanagej.controller.dto.SelfPaymentDto;
import de.cotto.lndmanagej.model.ChannelId;
import de.cotto.lndmanagej.model.Pubkey;
import de.cotto.lndmanagej.service.SelfPaymentsService;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.GetMapping;
@@ -23,6 +24,22 @@ public class SelfPaymentsController {
this.selfPaymentsService = selfPaymentsService;
}
@Timed
@GetMapping("/channel/{channelId}/self-payments-from-channel")
public List<SelfPaymentDto> getSelfPaymentsFromChannel(@PathVariable ChannelId channelId) {
return selfPaymentsService.getSelfPaymentsFromChannel(channelId).stream()
.map(SelfPaymentDto::createFromModel)
.toList();
}
@Timed
@GetMapping("/node/{pubkey}/self-payments-from-peer")
public List<SelfPaymentDto> getSelfPaymentsFromPeer(@PathVariable Pubkey pubkey) {
return selfPaymentsService.getSelfPaymentsFromPeer(pubkey).stream()
.map(SelfPaymentDto::createFromModel)
.toList();
}
@Timed
@GetMapping("/channel/{channelId}/self-payments-to-channel")
public List<SelfPaymentDto> getSelfPaymentsToChannel(@PathVariable ChannelId channelId) {
@@ -32,9 +49,9 @@ public class SelfPaymentsController {
}
@Timed
@GetMapping("/channel/{channelId}/self-payments-from-channel")
public List<SelfPaymentDto> getSelfPaymentsFromChannel(@PathVariable ChannelId channelId) {
return selfPaymentsService.getSelfPaymentsFromChannel(channelId).stream()
@GetMapping("/node/{pubkey}/self-payments-to-peer")
public List<SelfPaymentDto> getSelfPaymentsToPeer(@PathVariable Pubkey pubkey) {
return selfPaymentsService.getSelfPaymentsToPeer(pubkey).stream()
.map(SelfPaymentDto::createFromModel)
.toList();
}