mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-24 08:24:20 +01:00
add remote pubkey and alias to channel details
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user