add remote pubkey and alias to channel details

This commit is contained in:
Carsten Otto
2021-11-19 17:12:08 +01:00
parent 854786c1e2
commit 840938676e
4 changed files with 37 additions and 8 deletions

View File

@@ -4,7 +4,9 @@ import com.codahale.metrics.MetricRegistry;
import de.cotto.lndmanagej.metrics.Metrics;
import de.cotto.lndmanagej.model.ChannelId;
import de.cotto.lndmanagej.model.LocalChannel;
import de.cotto.lndmanagej.model.Pubkey;
import de.cotto.lndmanagej.service.ChannelService;
import de.cotto.lndmanagej.service.NodeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -14,10 +16,12 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/api/channel/{channelId}")
public class ChannelDetailsController {
private final ChannelService channelService;
private final NodeService nodeService;
private final Metrics metrics;
public ChannelDetailsController(ChannelService channelService, Metrics metrics) {
public ChannelDetailsController(ChannelService channelService, NodeService nodeService, Metrics metrics) {
this.channelService = channelService;
this.nodeService = nodeService;
this.metrics = metrics;
}
@@ -28,6 +32,8 @@ public class ChannelDetailsController {
if (localChannel == null) {
throw new NotFoundException();
}
return new ChannelDetailsDto(localChannel.getId());
Pubkey remotePubkey = localChannel.getRemotePubkey();
String remoteAlias = nodeService.getAlias(remotePubkey);
return new ChannelDetailsDto(localChannel.getId(), remotePubkey, remoteAlias);
}
}

View File

@@ -3,6 +3,11 @@ package de.cotto.lndmanagej.controller;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import de.cotto.lndmanagej.model.ChannelId;
import de.cotto.lndmanagej.model.Pubkey;
public record ChannelDetailsDto(@JsonSerialize(using = ToStringSerializer.class) ChannelId channelId) {
public record ChannelDetailsDto(
@JsonSerialize(using = ToStringSerializer.class) ChannelId channelId,
@JsonSerialize(using = ToStringSerializer.class) Pubkey remotePubkey,
String remoteAlias
) {
}