get channel IDs for open channels in compact format

This commit is contained in:
Carsten Otto
2021-11-12 15:55:56 +01:00
parent d4659694d5
commit bc55943f9d
6 changed files with 56 additions and 8 deletions

View File

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@RestController
@RequestMapping("/legacy")
@@ -52,13 +53,18 @@ public class LegacyController {
@GetMapping("/open-channels")
public String getOpenChannelIds() {
return channelService.getOpenChannels().stream()
.map(Channel::getId)
.sorted()
return getOpenChannelIdsSorted()
.map(ChannelId::toString)
.collect(Collectors.joining(NEWLINE));
}
@GetMapping("/open-channels/compact")
public String getOpenChannelIdsCompact() {
return getOpenChannelIdsSorted()
.map(ChannelId::getCompactForm)
.collect(Collectors.joining(NEWLINE));
}
@GetMapping("/peer-pubkeys")
public String getPeerPubkeys() {
return channelService.getOpenChannels().stream()
@@ -93,4 +99,10 @@ public class LegacyController {
public long getOutgoingBaseFee(@PathVariable ChannelId channelId) {
return feeService.getOutgoingBaseFee(channelId).milliSatoshis();
}
private Stream<ChannelId> getOpenChannelIdsSorted() {
return channelService.getOpenChannels().stream()
.map(Channel::getId)
.sorted();
}
}