lnd
lnd copied to clipboard
/v1/graph/nodemetrics method unresponsive
trafficstars
Background
I am trying to determine the Betweenness centrality of my node by using the REST API endpoint /v1/graph/nodemetrics and instead my node returns NoMethodError.
Endpoint: https://api.lightning.community/#v1-graph-nodemetrics
Your environment
- lnd 0.15.0-beta
Steps to reproduce
In Ruby:
require 'faraday'
class LndAPI
attr_accessor :host, :port, :macaroon
def initialize(host:, port:, macaroon:)
@host = host
@port = port
@macaroon = macaroon # hex needed for auth header
@conn = Faraday.new(
url: "https://#{@host}:#{@port}",
headers: {'Grpc-Metadata-macaroon' => @macaroon}
) do |faraday|
faraday.response :raise_error
end
end
def graph_nodemetrics(metric_types)
if metric_types == nil
metric_types = '1'
else
metric_types = metric_types
end
metric_types = metric_types.to_s
begin
request_response = @conn.get("/v1/graph/nodemetrics", { types: metric_types })
rescue => e
puts "LND API Error!"
puts e.response[:status] #=> 404
puts e.response[:headers] #=> { ... }
puts e.response[:body] #=> "..."
parsed_response_body = JSON.parse(e.response[:body])
return parsed_response_body
else
puts "LND API Success!"
parsed_response_body = JSON.parse(request_response.body)
return parsed_response_body
end
end
def parse(response)
JSON.parse(response.body)
end
end
node = ...
lnd = LndAPI.new(host:node.host, port:node.port, macaroon:node.macaroon_hex)
lnd_response = lnd.graph_nodemetrics(1)
Expected behaviour
I expected a response with the field betweenness_centrality showing my node's betweenness.
Actual behaviour
Response:
NoMethodError (undefined method `[]' for nil:NilClass)
@jmarbach couple of questions for you:
- have you tried the same rpc via the cli?
- try it with LND v0.15.1. I am able to get a response on the cli on 0.15.1
Also note that nodemetrics will return the betweenness metric for all the nodes on the graph, not just yours. You'll need to search for your node from the response. We can possibly improve this rpc by adding a node pubkey argument.
Closing due to inactivity.