Files
lnd-manageJ/application/src/main/java/de/cotto/lndmanagej/controller/LegacyController.java
2021-11-12 09:06:55 +01:00

35 lines
1.1 KiB
Java

package de.cotto.lndmanagej.controller;
import de.cotto.lndmanagej.model.ChannelId;
import de.cotto.lndmanagej.model.Pubkey;
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;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/api/node/{pubkey}/")
public class LegacyController {
private final NodeService nodeService;
public LegacyController(NodeService nodeService) {
this.nodeService = nodeService;
}
@GetMapping("/alias")
public String getAlias(@PathVariable Pubkey pubkey) {
return nodeService.getAlias(pubkey);
}
@GetMapping("/open-channels")
public List<String> getOpenChannelIds(@PathVariable Pubkey pubkey) {
return nodeService.getOpenChannelIds(pubkey).stream()
.map(ChannelId::toString)
.collect(Collectors.toList());
}
}