mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-22 07:24:23 +01:00
get alias for pubkey via REST controller
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package de.cotto.lndmanagej.controller;
|
||||
|
||||
import de.cotto.lndmanagej.grpc.GrpcNodeInfo;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/node/")
|
||||
public class NodeController {
|
||||
private final GrpcNodeInfo grpcNodeInfo;
|
||||
|
||||
public NodeController(GrpcNodeInfo grpcNodeInfo) {
|
||||
this.grpcNodeInfo = grpcNodeInfo;
|
||||
}
|
||||
|
||||
@GetMapping("/{pubkey}/alias")
|
||||
public String getAlias(@PathVariable Pubkey pubkey) {
|
||||
return grpcNodeInfo.getNode(pubkey).alias();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package de.cotto.lndmanagej.controller;
|
||||
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@Component
|
||||
public class PubkeyConverter implements Converter<String, Pubkey> {
|
||||
public PubkeyConverter() {
|
||||
// default constructor
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pubkey convert(@Nonnull String source) {
|
||||
return Pubkey.create(source);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user