diff --git a/Makefile b/Makefile index 2778ae4..5a734fd 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ BASE_DIR=/script OS=linux ARCH=386 ARM= -GORPC_COMMIT=52b0b2cd43735132e59da994177f4242d51cae1a +GORPC_COMMIT=74f2f7d93d0def078470d7cb0c86430bd3a44725 default: fmt lint $(CC) build -o $(NAME) cmd/go-lnmetrics.reporter/main.go @@ -27,5 +27,5 @@ build: dep: $(CC) get -u github.com/LNOpenMetrics/lnmetrics.utils - $(CC) get -u github.com/vincenzopalazzo/glightning@$(GORPC_COMMIT) + $(CC) get -u github.com/vincenzopalazzo/cln4go@$(GORPC_COMMIT) $(CC) mod vendor diff --git a/cmd/go-lnmetrics.reporter/main.go b/cmd/go-lnmetrics.reporter/main.go index ce2d1ff..0273fd7 100644 --- a/cmd/go-lnmetrics.reporter/main.go +++ b/cmd/go-lnmetrics.reporter/main.go @@ -17,10 +17,6 @@ func main() { panic(err) } - if err := metricsPlugin.RegisterMethods(); err != nil { - panic(err) - } - // To set the time the following doc is followed // https://pkg.go.dev/github.com/robfig/cron?utm_source=godoc metricsPlugin.RegisterRecurrentEvt("@every 30m") diff --git a/go.mod b/go.mod index 136a6f3..9742a49 100644 --- a/go.mod +++ b/go.mod @@ -7,27 +7,22 @@ require ( github.com/elastic/go-sysinfo v1.8.1 github.com/kinbiko/jsonassert v1.1.1 github.com/robfig/cron/v3 v3.0.1 + github.com/vincenzopalazzo/cln4go/client v0.0.0-20221029082447-17087277873c + github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20221029082447-17087277873c github.com/vincenzopalazzo/glightning v0.8.3-0.20211027092546-52b0b2cd4373 - golang.org/x/net v0.0.0-20221004154528-8021a29435af + golang.org/x/net v0.1.0 ) require ( - github.com/davecgh/go-spew v1.1.1 // indirect github.com/elastic/go-windows v1.0.1 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect - github.com/niftynei/glightning v0.8.2 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect - github.com/stretchr/objx v0.1.0 // indirect - github.com/stretchr/testify v1.7.0 // indirect github.com/syndtr/goleveldb v1.0.0 // indirect - github.com/vincenzopalazzo/cln4go/client v0.0.0-20221012145526-0442164fefe5 // indirect - github.com/vincenzopalazzo/cln4go/comm v0.0.0-20221004174515-cc8bea295b3e // indirect - github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20221005115405-d332acb5a206 // indirect - golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect + github.com/vincenzopalazzo/cln4go v0.0.1-beta.6.0.20221029141026-74f2f7d93d0d // indirect + github.com/vincenzopalazzo/cln4go/comm v0.0.0-20221029082447-17087277873c // indirect + golang.org/x/sys v0.1.0 // indirect howett.net/plist v1.0.0 // indirect ) diff --git a/go.sum b/go.sum index 2a69fb2..66e38c4 100644 --- a/go.sum +++ b/go.sum @@ -1,126 +1,84 @@ -github.com/LNOpenMetrics/lnmetrics.utils v0.0.0-20211109065240-8b2308c6c67a h1:7iW63gQpyrTJiw1tIrZKomXSGIRrOwDrVKssMEESh8E= -github.com/LNOpenMetrics/lnmetrics.utils v0.0.0-20211109065240-8b2308c6c67a/go.mod h1:6PC0XEUljl08AHdHdMQtR2tGJ1o9Jzg8yt7nioTnlE4= -github.com/LNOpenMetrics/lnmetrics.utils v0.0.0-20211111065808-b086ef397a1d h1:C/UZkW5fWKce0gyH7RoxYKJkXdLjJ/r5Lk/GrKLQZgg= -github.com/LNOpenMetrics/lnmetrics.utils v0.0.0-20211111065808-b086ef397a1d/go.mod h1:6PC0XEUljl08AHdHdMQtR2tGJ1o9Jzg8yt7nioTnlE4= -github.com/LNOpenMetrics/lnmetrics.utils v0.0.2 h1:USJE6C1dhiNUjiQ29iQ3MHxxZt9Y0atpt1VZ4M9vJbM= -github.com/LNOpenMetrics/lnmetrics.utils v0.0.2/go.mod h1:6PC0XEUljl08AHdHdMQtR2tGJ1o9Jzg8yt7nioTnlE4= -github.com/LNOpenMetrics/lnmetrics.utils v0.0.3 h1:emd43at2elU8FDAeJhTDNkMF1/cbYR0lFS0iyka34Go= -github.com/LNOpenMetrics/lnmetrics.utils v0.0.3/go.mod h1:6PC0XEUljl08AHdHdMQtR2tGJ1o9Jzg8yt7nioTnlE4= -github.com/LNOpenMetrics/lnmetrics.utils v0.0.6 h1:fO6nTbMsLzJDEHRRfyS+QUSEzmyXHCaOWOpmttlYGrE= -github.com/LNOpenMetrics/lnmetrics.utils v0.0.6/go.mod h1:6PC0XEUljl08AHdHdMQtR2tGJ1o9Jzg8yt7nioTnlE4= -github.com/LNOpenMetrics/lnmetrics.utils v0.0.7 h1:iLorvC+QIkkiXztqwGe6lcNws3wiRhx38i/9y4Erf68= -github.com/LNOpenMetrics/lnmetrics.utils v0.0.7/go.mod h1:6PC0XEUljl08AHdHdMQtR2tGJ1o9Jzg8yt7nioTnlE4= github.com/LNOpenMetrics/lnmetrics.utils v0.0.9 h1:1J3IR7BfJ/b495gMbckBs1a2MPWju/x3Vbhpp7BWriY= github.com/LNOpenMetrics/lnmetrics.utils v0.0.9/go.mod h1:oAoVWZLOyx78lI3rQihZ+QZpGwlZEJvwoVXyt4vcmoA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/elastic/go-sysinfo v1.7.1 h1:Wx4DSARcKLllpKT2TnFVdSUJOsybqMYCNQZq1/wO+s0= -github.com/elastic/go-sysinfo v1.7.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= github.com/elastic/go-sysinfo v1.8.1 h1:4Yhj+HdV6WjbCRgGdZpPJ8lZQlXZLKDAeIkmQ/VRvi4= github.com/elastic/go-sysinfo v1.8.1/go.mod h1:JfllUnzoQV/JRYymbH3dO1yggI3mV2oTKSXsDHM+uIM= -github.com/elastic/go-windows v1.0.0 h1:qLURgZFkkrYyTTkvYpsZIgf83AUsdIHfvlJaqaZ7aSY= -github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU= github.com/elastic/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0= github.com/elastic/go-windows v1.0.1/go.mod h1:FoVvqWSun28vaDQPbj2Elfc0JahhPB7WQEGa3c814Ss= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= -github.com/kinbiko/jsonassert v1.0.2 h1:UzNDYv5K8UsSHXS3Opsf0ZNz2NQCHl96OC3dlTytUtE= -github.com/kinbiko/jsonassert v1.0.2/go.mod h1:QRwBwiAsrcJpjw+L+Q4WS8psLxuUY+HylVZS/4j74TM= -github.com/kinbiko/jsonassert v1.1.0 h1:AakKgkRFsuzE1FNLYrcxTI7ga5YYcbujOUbSf8l+WmU= -github.com/kinbiko/jsonassert v1.1.0/go.mod h1:QRwBwiAsrcJpjw+L+Q4WS8psLxuUY+HylVZS/4j74TM= github.com/kinbiko/jsonassert v1.1.1 h1:DB12divY+YB+cVpHULLuKePSi6+ui4M/shHSzJISkSE= github.com/kinbiko/jsonassert v1.1.1/go.mod h1:NO4lzrogohtIdNUNzx8sdzB55M4R4Q1bsrWVdqQ7C+A= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/niftynei/glightning v0.8.2 h1:UySBoNya9BbrL9qrWG0sw7vY5MMtireo4mnN9dJ+GJY= -github.com/niftynei/glightning v0.8.2/go.mod h1:nOHtsM1ZfMwOxwl6LE72U611ozP+IBj/xVkJ+9vwtd4= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 h1:c8R11WC8m7KNMkTv/0+Be8vvwo4I3/Ut9AC2FW8fX3U= -github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= -github.com/vincenzopalazzo/cln4go/client v0.0.0-20221005115405-d332acb5a206 h1:kr01zM8hAEema0RDaCgHTlWhFYqDhmkoMHShWf3Xelc= -github.com/vincenzopalazzo/cln4go/client v0.0.0-20221005115405-d332acb5a206/go.mod h1:7X4Hn+hwG3Ts/S3tgEqsowfUHZqyjx7/1z/8oDw7Muw= -github.com/vincenzopalazzo/cln4go/client v0.0.0-20221012145526-0442164fefe5 h1:x4DPhmvZF0EFLrMlIRBnOpWXHuam8EYMkhV3z9bIOZs= -github.com/vincenzopalazzo/cln4go/client v0.0.0-20221012145526-0442164fefe5/go.mod h1:7X4Hn+hwG3Ts/S3tgEqsowfUHZqyjx7/1z/8oDw7Muw= -github.com/vincenzopalazzo/cln4go/comm v0.0.0-20221004174515-cc8bea295b3e h1:GPQaUcmrl5Uq/5A5sMuxd2YvUXdT4HGNi4DF0VLCxfo= -github.com/vincenzopalazzo/cln4go/comm v0.0.0-20221004174515-cc8bea295b3e/go.mod h1:zyOWcz5aSHCsLuZLaVBTjbRnxlf5Ac+Rfhu5Ciuyy2c= -github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20221004174515-cc8bea295b3e h1:IzXcyI2XVWxG8QIj6Z2O7kRUF7yXrLb91HmXr48BEAM= -github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20221004174515-cc8bea295b3e/go.mod h1:vb+knVG7/MR+oTnDRRwDH7WqO6U0FbcRNWjQeu0xdds= -github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20221005115405-d332acb5a206 h1:feiSo3LFRqAwJpMPK7IFxZZkLDg/kCTgQdwkf1unxI8= -github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20221005115405-d332acb5a206/go.mod h1:vb+knVG7/MR+oTnDRRwDH7WqO6U0FbcRNWjQeu0xdds= -github.com/vincenzopalazzo/glightning v0.8.2 h1:k9UV9jH2pcinPI4Wdnz7tXTUDHqp4b0DTvBwno333dI= -github.com/vincenzopalazzo/glightning v0.8.2/go.mod h1:zNMKjmjwMOPLoeWV7/u6NgC3o/VUGha/Vb1x2AsM3T0= -github.com/vincenzopalazzo/glightning v0.8.3-0.20211003143735-95b507670bac h1:ENgsB0hQsAf2E1g+kOwcdpzErFvMYi0fMMyinCLJHzk= -github.com/vincenzopalazzo/glightning v0.8.3-0.20211003143735-95b507670bac/go.mod h1:zNMKjmjwMOPLoeWV7/u6NgC3o/VUGha/Vb1x2AsM3T0= +github.com/vincenzopalazzo/cln4go v0.0.1-beta.6.0.20221029141026-74f2f7d93d0d h1:w3wR8NcWxzr07oTKWmsLdSKm+wT++f4DP3W0pj3Ux04= +github.com/vincenzopalazzo/cln4go v0.0.1-beta.6.0.20221029141026-74f2f7d93d0d/go.mod h1:2NnveaBEhWeXc6SAyTLGIYRJsVq+5RjTRKh105b8Y2M= +github.com/vincenzopalazzo/cln4go/client v0.0.0-20221028180519-7a564f57564f h1:VfVoQ/ErWVq+RYDDaAGY2AcP4qJq42Y+cTN3WjbMNnI= +github.com/vincenzopalazzo/cln4go/client v0.0.0-20221028180519-7a564f57564f/go.mod h1:7X4Hn+hwG3Ts/S3tgEqsowfUHZqyjx7/1z/8oDw7Muw= +github.com/vincenzopalazzo/cln4go/client v0.0.0-20221029082447-17087277873c h1:siKXggPRTUZzY207ENKuMHxi8gx1g0QGMWAC/FiyTWs= +github.com/vincenzopalazzo/cln4go/client v0.0.0-20221029082447-17087277873c/go.mod h1:7X4Hn+hwG3Ts/S3tgEqsowfUHZqyjx7/1z/8oDw7Muw= +github.com/vincenzopalazzo/cln4go/comm v0.0.0-20221028180519-7a564f57564f h1:xlqwV/K0TcQ0E8VNBDCl7tJRW7YVW8AvdWQqfeaQJ6Y= +github.com/vincenzopalazzo/cln4go/comm v0.0.0-20221028180519-7a564f57564f/go.mod h1:zyOWcz5aSHCsLuZLaVBTjbRnxlf5Ac+Rfhu5Ciuyy2c= +github.com/vincenzopalazzo/cln4go/comm v0.0.0-20221029082447-17087277873c h1:Uw67JqeF6xhQkf9/Otx919yHnR3C0ydyWsnAG7l7V6M= +github.com/vincenzopalazzo/cln4go/comm v0.0.0-20221029082447-17087277873c/go.mod h1:zyOWcz5aSHCsLuZLaVBTjbRnxlf5Ac+Rfhu5Ciuyy2c= +github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20221028180519-7a564f57564f h1:wqIA8NHORith74k0ye30OlAxgCTZCMzuG2S/VLRmZZs= +github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20221028180519-7a564f57564f/go.mod h1:vb+knVG7/MR+oTnDRRwDH7WqO6U0FbcRNWjQeu0xdds= +github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20221029082447-17087277873c h1:9kgJtp328cRQr4Q5DFahr0byvdNKCoas/5Xve0QpgTM= +github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20221029082447-17087277873c/go.mod h1:vb+knVG7/MR+oTnDRRwDH7WqO6U0FbcRNWjQeu0xdds= github.com/vincenzopalazzo/glightning v0.8.3-0.20211027092546-52b0b2cd4373 h1:pWuDyPTLlvK1YcYP0ZuZIZA86yIxODO1Dxg45bWTrdQ= github.com/vincenzopalazzo/glightning v0.8.3-0.20211027092546-52b0b2cd4373/go.mod h1:ZxbrqNnk5I0/qZo0Xgs+8RIhLUD0qeQkhHR7lLW0MM0= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20221004154528-8021a29435af h1:wv66FM3rLZGPdxpYL+ApnDe2HzHcTFta3z5nsc13wI4= -golang.org/x/net v0.0.0-20221004154528-8021a29435af/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= +gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M= -howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM= howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= diff --git a/internal/plugin/cln4go_init.go b/internal/plugin/cln4go_init.go index e8ee92c..c741f3c 100644 --- a/internal/plugin/cln4go_init.go +++ b/internal/plugin/cln4go_init.go @@ -40,12 +40,12 @@ func OnInit[T MetricsPluginState](plugin *cln4go.Plugin[T], request map[string]a } metricsPlugin.SetStorage(dbPlugin) - err = parseOptionsPlugin(plugin) + err = parseOptionsPlugin[T](plugin) if err != nil { panic(err) } // FIXME: Load all the metrics in the datatabase that are registered from the user - metric, err := loadMetricIfExist(plugin, 1) + metric, err := loadMetricIfExist[T](plugin, 1) if err != nil { panic(err) @@ -75,12 +75,17 @@ func parseOptionsPlugin[T MetricsPluginState](plugin *cln4go.Plugin[T]) error { }) } - noProxy, _ := plugin.GetOpt("lnmetrics-noproxy") + str, _ := json.Marshal(plugin.Options) + plugin.Log("info", string(str)) + noProxy, found := plugin.GetOpt("lnmetrics-noproxy") + plugin.Log("info", fmt.Sprintf("no proxy found: %t", found)) proxy, _ := plugin.GetConf("proxy") if proxy != nil && !noProxy.(bool) { - addr, _ := plugin.GetConf("address") - port, _ := plugin.GetConf("port") - server, err := graphql.NewWithProxy(urls, addr.(string), port.(uint64)) + proxyVar := proxy.(map[string]any) + addr := proxyVar["address"] + port := proxyVar["port"] + portCast := port.(float64) + server, err := graphql.NewWithProxy(urls, addr.(string), uint64(portCast)) if err != nil { return err } @@ -104,7 +109,7 @@ func loadMetricIfExist[T MetricsPluginState](plugin *cln4go.Plugin[T], id int) ( switch id { case 1: - return loadLastMetricOne(plugin) + return loadLastMetricOne[T](plugin) default: return nil, fmt.Errorf("Metric with is %d and name %s not supported", id, metricName) } diff --git a/internal/plugin/cln4go_plugin.go b/internal/plugin/cln4go_plugin.go index 662b481..a070e7e 100644 --- a/internal/plugin/cln4go_plugin.go +++ b/internal/plugin/cln4go_plugin.go @@ -1,9 +1,13 @@ package plugin import ( + "encoding/json" + "fmt" "time" + "github.com/LNOpenMetrics/go-lnmetrics.reporter/internal/cache" "github.com/LNOpenMetrics/lnmetrics.utils/log" + "github.com/elastic/go-sysinfo" cln4go "github.com/vincenzopalazzo/cln4go/plugin" ) @@ -11,9 +15,15 @@ func ConfigureCLNPlugin[T MetricsPluginState](state T) (*cln4go.Plugin[T], error plugin := cln4go.New(state, false, OnInit[T]) plugin.RegisterOption("lnmetrics-urls", "string", "", "URLs of remote servers", false) - plugin.RegisterOption("lnmetrics-noproxy", "flag", "false", + plugin.RegisterOption("lnmetrics-noproxy", "bool", "false", "Disable the usage of proxy in case only for the go-lnmmetrics.reporter", false) plugin.RegisterNotification("shutdown", &OnShoutdown[T]{}) + + plugin.RegisterRPCMethod("metric_one", "", "return the metrics calculated by the plugin", NewMetricPlugin[T]()) + // FIXME: register the force rpc command only in developer mode + plugin.RegisterRPCMethod("lnmetrics-force-update", "", "trigget the update to the server (caution)", &ForceUpdateRPC[T]{}) + plugin.RegisterRPCMethod("lnmetrics-info", "", "return the information regarding the lnmetrics plugin", &LNMetricsInfoRPC[T]{}) + plugin.RegisterRPCMethod("lnmetrics-clean", "", "clean the lnmetrics cache", &LNMetricsCleanCacheRPC[T]{}) return plugin, nil } @@ -30,3 +40,71 @@ func (self *OnShoutdown[T]) Call(plugin *cln4go.Plugin[T], payload map[string]an plugin.GetState().GetCron().Stop() log.GetInstance().Info("Close command received") } + +type LNMetricsInfoRPC[T MetricsPluginState] struct{} + +// Would be cool if it is possible auto-generate a structure from a +// file, so this will be inside the binary, and we can avoid the hard coded +// file. +type info struct { + Name string + Version string + LangVersion string + Architecture string + MaxProcs int + StoragePath string + Metrics []string + ProxyEnabled bool +} + +func (self *LNMetricsInfoRPC[T]) Call(plugin *cln4go.Plugin[T], payload map[string]any) (map[string]any, error) { + metricsSupp := make([]string, 0) + for key := range plugin.GetState().GetMetrics() { + metricsSupp = append(metricsSupp, MetricsSupported[key]) + } + goInfo := sysinfo.Go() + resp := info{ + Name: "go-lnmetrics.reporter", + Version: "v0.0.5-rc1", + LangVersion: goInfo.Version, + Architecture: goInfo.Arch, + MaxProcs: goInfo.MaxProcs, + StoragePath: plugin.State.GetStorage().GetDBPath(), + Metrics: metricsSupp, + ProxyEnabled: plugin.GetState().IsWithProxy(), + } + // FIXME: support encode function inside the method + var res map[string]any + bytes, err := json.Marshal(resp) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(bytes, &res); err != nil { + return nil, err + } + + return res, nil +} + +type LNMetricsCleanCacheRPC[T MetricsPluginState] struct{} + +func (self *LNMetricsCleanCacheRPC[T]) Call(plugin *cln4go.Plugin[T], payload map[string]any) (map[string]any, error) { + cmdStr, found := payload["cmd"] + if !found { + return nil, fmt.Errorf("please specify the command that you want to call") + } + cmd := cmdStr.(string) + if cmd != "clean" { + return nil, fmt.Errorf("command %s node found", cmd) + } + + if err := cache.GetInstance().CleanCache(); err != nil { + log.GetInstance().Errorf("CleanCacheRPC rpc call return the following error during the %s cmd: %s", cmd, err) + return nil, fmt.Errorf("clean cache operation return the following error: %s", err) + } + response := map[string]any{ + "result": "cleaning operation succeeded", + } + return response, nil +} diff --git a/internal/plugin/cln4go_plugin_state.go b/internal/plugin/cln4go_plugin_state.go index e3cbc83..761988b 100644 --- a/internal/plugin/cln4go_plugin_state.go +++ b/internal/plugin/cln4go_plugin_state.go @@ -32,5 +32,7 @@ type MetricsPluginState interface { CallOnStopOnMetrics(metric Metric, msg *Msg) + CallUpdateOnMetric(metric Metric, msg *Msg) + GetMetrics() map[int]Metric } diff --git a/internal/plugin/diagnostic.go b/internal/plugin/diagnostic.go index 6ad97cb..fd11886 100644 --- a/internal/plugin/diagnostic.go +++ b/internal/plugin/diagnostic.go @@ -4,91 +4,64 @@ import ( "encoding/json" "fmt" - "github.com/vincenzopalazzo/glightning/jrpc2" + cln4go "github.com/vincenzopalazzo/cln4go/plugin" ) -type MetricOneRpcMethod struct { - StartPeriod string `json:"start"` - EndPeriod string `json:"end"` +type MetricOneRpcMethod[T MetricsPluginState] struct{} - // Metric Reference - plugin *MetricsPlugin `json:"-"` +func NewMetricPlugin[T MetricsPluginState]() *MetricOneRpcMethod[T] { + return &MetricOneRpcMethod[T]{} } -func (instance *MetricOneRpcMethod) Name() string { - return "metric_one" -} - -func NewMetricPlugin(plugin *MetricsPlugin) *MetricOneRpcMethod { - return &MetricOneRpcMethod{ - StartPeriod: "", - EndPeriod: "", - plugin: plugin, - } -} - -func (instance *MetricOneRpcMethod) New() any { - return NewMetricPlugin(instance.plugin) -} - -func (instance *MetricOneRpcMethod) Call() (jrpc2.Result, error) { - metricOne, found := instance.plugin.Metrics[1] - +func (instance *MetricOneRpcMethod[T]) Call(plugin *cln4go.Plugin[T], payload map[string]any) (map[string]any, error) { + // FIXME: take variable from the payload. + metricOne, found := plugin.GetState().GetMetrics()[1] + var result map[string]any if !found { return nil, fmt.Errorf("Metric with id %d not found", 1) } - if instance.StartPeriod == "" && - instance.EndPeriod == "" { - return nil, fmt.Errorf("Missing at list the start parameter in the rpc method") + startPeriod, startFound := payload["start"] + //endPeriod, endFound := payload["end"] + + if !startFound { + return nil, fmt.Errorf("methor arg missing: need to specify the start period") } - if instance.StartPeriod == "now" { - return metricOne, nil + if startPeriod.(string) == "now" { + // FIXME: encode the result inside a map + return result, nil } - if instance.StartPeriod == "last" { - jsonValue, err := instance.plugin.Storage.LoadLastMetricOne() + if startPeriod.(string) == "last" { + jsonValue, err := plugin.GetState().GetStorage().LoadLastMetricOne() if err != nil { return nil, err } if err := json.Unmarshal([]byte(*jsonValue), &metricOne); err != nil { return nil, err } - return metricOne, nil + + // FIXME: encode the result inside a map + return result, nil } return nil, fmt.Errorf("We don't support the filter operation right now") } // ForceUpdateRPC enable the force update command -type ForceUpdateRPC struct { - // the instance of the plugin - plugin *MetricsPlugin -} +type ForceUpdateRPC[T MetricsPluginState] struct{} -func NewForceUpdateRPC(plugin *MetricsPlugin) *ForceUpdateRPC { - return &ForceUpdateRPC{plugin} -} - -func (instance *ForceUpdateRPC) New() any { - return instance -} - -func (instance *ForceUpdateRPC) Name() string { - return "lnmetrics-force-update" -} - -func (instance *ForceUpdateRPC) Call() (jrpc2.Result, error) { - for _, metric := range instance.plugin.Metrics { +func (instance *ForceUpdateRPC[T]) Call(plugin *cln4go.Plugin[T], payload map[string]any) (map[string]any, error) { + for _, metric := range plugin.GetState().GetMetrics() { msg := Msg{ cmd: "plugin_rpc_method", params: map[string]any{"event": "on_force_update"}, } - instance.plugin.callUpdateOnMetric(metric, &msg) + plugin.GetState().CallUpdateOnMetric(metric, &msg) + } + response := map[string]any{ + "result": "force call update on all the metrics succeeded", } - response := struct { - result string - }{result: "force call update on all the metrics succeeded"} return response, nil } diff --git a/internal/plugin/metrics_one.go b/internal/plugin/metrics_one.go index 0f21af7..5c76391 100644 --- a/internal/plugin/metrics_one.go +++ b/internal/plugin/metrics_one.go @@ -137,7 +137,7 @@ func (instance *MetricOne) onEvent(nameEvent string, lightning cln4go.Client) (* // and this mean that can be out of the gossip map. } - listConfig, err := ln.ListConfig(lightning) + listConfig, err := ln.ListConfigs(lightning) if err != nil { log.GetInstance().Errorf("Error during the list config rpc command: %s", err) return nil, err @@ -368,7 +368,7 @@ func (instance *MetricOne) checkChannelInCache(lightning cln4go.Client, channelI } if !inCache { - node, err := ln.GetNode(lightning, &channelID) + node, err := ln.GetNode(lightning, channelID) if err != nil { log.GetInstance().Errorf("Error in command listNodes in makeChannelsSummary: %s", err) return nil, err diff --git a/internal/plugin/plugin.go b/internal/plugin/plugin.go index 7079863..b884e2c 100644 --- a/internal/plugin/plugin.go +++ b/internal/plugin/plugin.go @@ -72,40 +72,6 @@ func (plugin *MetricsPlugin) RegisterMetrics(id int, metric Metric) error { return nil } -func (plugin *MetricsPlugin) RegisterMethods() error { - method := NewMetricPlugin(plugin) - rpcMethod := glightning.NewRpcMethod(method, "Show diagnostic node") - rpcMethod.LongDesc = "Show the metric one data of the lightning network node. An example metric_one start=last" - rpcMethod.Category = "lnmetrics" - if err := plugin.Plugin.RegisterMethod(rpcMethod); err != nil { - return err - } - - infoMethod := NewPluginRpcMethod(plugin) - infoRpcMethod := glightning.NewRpcMethod(infoMethod, "Show go-lnmetrics.reporter info") - infoRpcMethod.Category = "lnmetrics" - infoRpcMethod.LongDesc = "Return the info od the env where the plugin is running. An example is \"lnmetrics-info" - if err := plugin.Plugin.RegisterMethod(infoRpcMethod); err != nil { - return err - } - - cacheMethod := NewCleanCacheRPC(plugin) - cacheRPCMethod := glightning.NewRpcMethod(cacheMethod, "Clean all the lnmetrics cache") - cacheRPCMethod.Category = "lnmetrics" - cacheRPCMethod.LongDesc = "Clean the cache made by the plugin during the time. An example is \"lnmetrics-cache clean" - if err := plugin.Plugin.RegisterMethod(cacheRPCMethod); err != nil { - return err - } - - forceUpdate := NewForceUpdateRPC(plugin) - forceUpdateRPC := glightning.NewRpcMethod(forceUpdate, "call the update on all the plugin") - forceUpdateRPC.Category = "lnmetrics" - if err := plugin.Plugin.RegisterMethod(forceUpdateRPC); err != nil { - return err - } - return nil -} - func (self *MetricsPlugin) GetMetrics() map[int]Metric { return self.Metrics } @@ -115,7 +81,7 @@ func (self *MetricsPlugin) GetCron() *cron.Cron { } // nolint -func (plugin *MetricsPlugin) callUpdateOnMetric(metric Metric, msg *Msg) { +func (plugin *MetricsPlugin) CallUpdateOnMetric(metric Metric, msg *Msg) { if err := metric.UpdateWithMsg(msg, plugin.Rpc); err != nil { log.GetInstance().Errorf("Error during update metrics event: %s", err) } @@ -171,7 +137,7 @@ func (plugin *MetricsPlugin) RegisterOneTimeEvt(after string) { } time.AfterFunc(duration, func() { log.GetInstance().Debug("Calling on time function function") - // TODO: Should C-Lightning send a on init event like notification? + // FIXME: Should C-Lightning send a on init event like notification? for _, metric := range plugin.Metrics { go func(instance *MetricsPlugin, metric Metric) { err := metric.OnInit(instance.GetRpc()) diff --git a/internal/plugin/plugin_rpc.go b/internal/plugin/plugin_rpc.go deleted file mode 100644 index 817f06e..0000000 --- a/internal/plugin/plugin_rpc.go +++ /dev/null @@ -1,92 +0,0 @@ -package plugin - -import ( - "fmt" - "github.com/LNOpenMetrics/go-lnmetrics.reporter/internal/cache" - "github.com/LNOpenMetrics/lnmetrics.utils/log" - sysinfo "github.com/elastic/go-sysinfo" - "github.com/vincenzopalazzo/glightning/jrpc2" -) - -type PluginRpcMethod struct { - metricsPlugin *MetricsPlugin `json:"-"` -} - -// Would be cool if it is possible auto-generate a structure from a -// file, so this will be inside the binary, and we can avoid the hard coded -// file. -type info struct { - Name string - Version string - LangVersion string - Architecture string - MaxProcs int - StoragePath string - Metrics []string - ProxyEnabled bool -} - -func NewPluginRpcMethod(pluginMetrics *MetricsPlugin) *PluginRpcMethod { - return &PluginRpcMethod{ - metricsPlugin: pluginMetrics, - } -} - -func (instance PluginRpcMethod) Name() string { - return "lnmetrics-info" -} - -func (instance *PluginRpcMethod) New() any { - return instance -} - -func (instance *PluginRpcMethod) Call() (jrpc2.Result, error) { - metricsSupp := make([]string, 0) - for key := range instance.metricsPlugin.Metrics { - metricsSupp = append(metricsSupp, MetricsSupported[key]) - } - goInfo := sysinfo.Go() - return info{ - Name: "go-lnmetrics.reporter", - Version: "v0.0.5-rc1", - LangVersion: goInfo.Version, - Architecture: goInfo.Arch, - MaxProcs: goInfo.MaxProcs, - StoragePath: instance.metricsPlugin.Storage.GetDBPath(), - Metrics: metricsSupp, - ProxyEnabled: instance.metricsPlugin.WithProxy, - }, nil -} - -// CleanCacheRPC RPC call to clean up the plugin cache. -type CleanCacheRPC struct { - Cmd string -} - -func NewCleanCacheRPC(plugin *MetricsPlugin) *CleanCacheRPC { - return &CleanCacheRPC{} -} - -func (instance *CleanCacheRPC) New() any { - return instance -} - -func (instance CleanCacheRPC) Name() string { - return "lnmetrics-cache" -} - -func (instance *CleanCacheRPC) Call() (jrpc2.Result, error) { - - if instance.Cmd != "clean" { - return nil, fmt.Errorf("command %s node found", instance.Cmd) - } - - if err := cache.GetInstance().CleanCache(); err != nil { - log.GetInstance().Errorf("CleanCacheRPC rpc call return the following error during the %s cmd: %s", instance.Cmd, err) - return nil, fmt.Errorf("clean cache operation return the following error: %s", err) - } - response := struct { - Result string `json:"result"` - }{Result: "cleaning operation succeeded"} - return response, nil -} diff --git a/pkg/ln/client.go b/pkg/ln/client.go index d8e1887..32a9996 100644 --- a/pkg/ln/client.go +++ b/pkg/ln/client.go @@ -1,6 +1,8 @@ package ln import ( + "fmt" + "github.com/LNOpenMetrics/go-lnmetrics.reporter/pkg/model" cln4go "github.com/vincenzopalazzo/cln4go/client" ) @@ -18,8 +20,8 @@ func ListForwards(client cln4go.Client) ([]*model.Forward, error) { } // / FIXME: check if it is possible improve the way to return a map -func ListConfig(client cln4go.Client) (map[string]any, error) { - result, err := cln4go.Call[cln4go.Client, map[string]any, map[string]any](client, "listconfig", model.EmpityPayload) +func ListConfigs(client cln4go.Client) (map[string]any, error) { + result, err := cln4go.Call[cln4go.Client, map[string]any, map[string]any](client, "listconfigs", model.EmpityPayload) if err != nil { return nil, err } @@ -31,7 +33,10 @@ func GetInfo(client cln4go.Client) (*model.GetInfoResp, error) { } func SignMessage(client cln4go.Client, content *string) (*model.SignMessageResp, error) { - return cln4go.Call[cln4go.Client, map[string]any, model.SignMessageResp](client, "signmessage", model.EmpityPayload) + req := map[string]any{ + "message": content, + } + return cln4go.Call[cln4go.Client, map[string]any, model.SignMessageResp](client, "signmessage", req) } // FIXME: can exist some node with mode channels @@ -54,11 +59,14 @@ func ListChannels(client cln4go.Client, nodeId *string) ([]*model.ListChannelsCh return resp.Channels, nil } -func GetNode(client cln4go.Client, channelId *string) (*model.ListNodesNode, error) { - res, err := ListNodes(client, channelId) +func GetNode(client cln4go.Client, channelId string) (*model.ListNodesNode, error) { + res, err := ListNodes(client, &channelId) if err != nil { return nil, err } + if len(res) == 0 { + return nil, fmt.Errorf("node %s not found", channelId) + } return res[0], nil } diff --git a/pkg/model/model.go b/pkg/model/model.go index 8ac817b..034f604 100644 --- a/pkg/model/model.go +++ b/pkg/model/model.go @@ -11,7 +11,7 @@ import ( var EmpityPayload = make(map[string]any) type ListFundsResp struct { - Channels []*ListFundsChannel + Channels []*ListFundsChannel `json:"channels"` } type ListFundsChannel struct { @@ -71,11 +71,11 @@ type SignMessageResp struct { } type ListChannelReq struct { - ChannelId *string + ChannelId *string `json:"short_channel_id"` } type ListChannelsResp struct { - Channels []*ListChannelsChannel + Channels []*ListChannelsChannel `json:"channels"` } type ListChannelsChannel struct { @@ -100,11 +100,11 @@ func (self *ListChannelsChannel) HtlcMaxMsat() *string { } type ListNodesReq struct { - ChannelId *string + ChannelId *string `json:"id"` } type ListNodesResp struct { - Nodes []*ListNodesNode + Nodes []*ListNodesNode `json:"nodes"` } type ListNodesNode struct { @@ -115,7 +115,7 @@ type ListNodesNode struct { } type ListPeersResp struct { - Peers []*ListPeersPeer + Peers []*ListPeersPeer `json:"peers"` } type ListPeersReq struct {