ride-the-lightning / c-lightning-rest Goto Github PK
View Code? Open in Web Editor NEWREST APIs for Core Lightning written with node.js
License: MIT License
REST APIs for Core Lightning written with node.js
License: MIT License
I'm running a regtest network with two c-lightning nodes and one channel between the two. When I query channel/listChannels
, on both nodes I am provided the same channel which is expected. However, I am unable to determine which node opened this channel based on the data returned.
alice
[
{
"id": "030baa91a579432ad819a8d175bd69262443a5a7197bfde0a112cf29ff489023be",
"connected": true,
"state": "CHANNELD_NORMAL",
"short_channel_id": "108x1x0",
"channel_id": "2c029d05f60b7a6073e62f45b487b0935e05f3eb0f9ba24abc5861dcebf686c4",
"funding_txid": "c486f6ebdc6158bc4aa29b0febf3055e93b087b4452fe673607a0bf6059d022c",
"private": false,
"msatoshi_to_us": 250000000,
"msatoshi_total": 250000000,
"their_channel_reserve_satoshis": 2500,
"our_channel_reserve_satoshis": 2500,
"spendable_msatoshi": 247274000,
"alias": "bob"
}
]
bob
[
{
"id": "03e8b189c71cd8346d6afbd773b403e603472339ff190413644b075fab844a9a3b",
"connected": true,
"state": "CHANNELD_NORMAL",
"short_channel_id": "108x1x0",
"channel_id": "2c029d05f60b7a6073e62f45b487b0935e05f3eb0f9ba24abc5861dcebf686c4",
"funding_txid": "c486f6ebdc6158bc4aa29b0febf3055e93b087b4452fe673607a0bf6059d022c",
"private": false,
"msatoshi_to_us": 0,
"msatoshi_total": 250000000,
"their_channel_reserve_satoshis": 2500,
"our_channel_reserve_satoshis": 2500,
"spendable_msatoshi": 0,
"alias": "alice"
}
]
Does c-lightning provide info about which node initiated the channel opening that could then be made available in this REST api? LND includes an initiator
boolean for each channel it returns via RPC.
I am making this request here because I am working on adding c-lightning support to my project Polar. I am using this library to communicate with the nodes. In order to display the network graph consistently with directional channels, I need to know which node opened the channel originally.
* - in: query
* name: expiry
* description: Expiry time period for the invoice (seconds)
* type: integer
* - in: query
* name: private
* description: Include routing hints for private channels (true or 1)
* type: string
Expiry and private parameters are supposed to be in the query string, but they are actually read from the body.
Just wondering if this only exposes limited functionality or if it exposes the entire suite of rpc commands? TIA.
See this line:
c-lightning-REST/controllers/channel.js
Line 77 in 22bb6c3
It double-bangs the input for the announce
field which controls if a private channel should be opened. Since it double-bangs inputs for '0'
and 'false'
the resulting boolean will always be equal tor true
so the channel will always be public.
Implement macaroons for a bearer token based access solution.
A macaroon called access.macaroon
, should be generated when the server is run for the first time. The generated macaroon should be passed in the request headers of the APIs for verification and authentication.
macaroon library which can be utilized:
https://github.com/go-macaroon/js-macaroon
Sample implementations (Thanks Oli @guggero)
https://github.com/guggero/cryptography-toolkit
Create a config JSON file, to handle a variety of params.
E.g. Port, Password etc.
I'm running node cl-rest.js
and I get this:
Reading config file
/hom.../c-lightning-REST-0.5.0/app.js:37
global.ln = require('./lightning-client-js')(global.config.LNRPCPATH.trim() || process.env.LN_PATH);
^
TypeError: Cannot read property 'trim' of undefined
at Object.<anonymous> (/hom.../c-lightning-REST-0.5.0/app.js:37:70)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/hom.../c-lightning-REST-0.5.0/cl-rest.js:1:13)
at Module._compile (internal/modules/cjs/loader.js:778:30)
Hi,
For your interest ElementsProject/lightning#3603 removes some fields in the API which have been deprecated for several (6 iirc) months.
Namely:
description
field in sendpay
.satoshi
field in fundchannel_start
(now amount
). Note also this commit ElementsProject/lightning@49e2153 .localfeatures
and globalfeatures
fields in listnodes
, listpeers
, peer_connected
.force
bool in close
.Since now RTL relies on your wrapper, just wanted you to know ! ๐
This is a feature request, that the REST interface accept value for feerate that are composed of digits, possibly followed by "perk" and then a w or a b, as a passthrough to fundchannel as described at https://lightning.readthedocs.io/lightning-fundchannel.7.html.
If feerate is set to something other than urgent
, normal
, slow
, or [digits followed by perkw
or perkb
], then it should return an error, "[feerate value submitted] is not a valid value for feerate," and fail the operation.
See #79 for more context.
When the content type header is not present in the request specifying it is JSON, the body is not properly parsed and it will fail with different errors depending on the endpoint called.
Usually with a 500 error thrown by lightning internally, which is really misleading.
Being a rest client would be nice to do more validation on the parameters (returning 400 or 422 when mandatory parameters are missing) and 415 when the content type is not JSON as expected.
C-lightning cli commands to cover:
I upgraded REST from 0.4.2 to 0.6.0, everything else stayed the same:
In web interface I got message "Authentication Failed!". Terminal showed error:
ERROR: GetInfo => Get Info Error: {"name":"StatusCodeError","statusCode":401,"message":"401 - {\"message\":\"Authentication Failed!\",\"error\":\"Bad Macaroon!\"}","error":{"message":"Authentication Failed!","error":"Bad Macaroon!"},"options":{"url":"https://localhost:3003/v1/getinfo","rejectUnauthorized":false,"json":true,"headers":{},"method":"GET","qs":{},"simple":true,"resolveWithFullResponse":false,"transform2xxOnly":false},"response":{"statusCode":401,"body":{"message":"Authentication Failed!","error":"Bad Macaroon!"},"headers":{"x-powered-by":"Express","access-control-allow-origin":"*","access-control-allow-headers":"Origin, X-Requested-With, Content-Type, Accept, Authorization, filePath, macaroon, encodingtype","access-control-allow-methods":"GET, POST, PATCH, PUT, DELETE, OPTIONS","content-type":"application/json; charset=utf-8","content-length":"60","etag":"W/\"3c-vlPpTAIpLJB8R2+JnaMJMQ8jWWM\"","date":"Wed, 22 Dec 2021 17:11:03 GMT","connection":"close"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"localhost:3003","port":"3003","hostname":"localhost","hash":null,"search":null,"query":null,"pathname":"/v1/getinfo","path":"/v1/getinfo","href":"https://localhost:3003/v1/getinfo"},"method":"GET","headers":{"accept":"application/json"}}}}
I poked it a bit. Solution was to create copy of RTL-Config.json file with empty "multiPassHashed": "" line, which resulted in error:
Error: Error: Node Authentication can be set with multiPass only. Please set multiPass in RTL-Config.json
I deleted this new RTL-Config.json file and renamed original RTL-Config.json file back correctly with original unchanged "multiPassHashed": "pass hash" line. After RTL restart it worked. So essentially nothing changed in settup but now it works. Weird.
openChannel API need additional parameters to enable the user to open channel in response to a liquidity add.
Optional params to be added:
compact_lease
request_amt
C-lightning cli commands to cover:
getinfo
api, upon server startgetinfo
failsAdd option for private channels.
Add fee rate and min conf options to the withdraw api
According to the documentation the rpc endpoint can be used with the following body:
{"method":"getinfo"}
I have added the following log in the line 128 (in lightning-client-js.js )
global.logger.log("sendObj: " + JSON.stringify(sendObj));
And this is the result in the logs
plugin-plugin.js: sendObj: {\"jsonrpc\":\"2.0\",\"params\":[],\"id\":\"22\"}
Of course, later lightningd fails with "no method" error.
PS: Added more logs to rpc.js and saw that the req.body
object contains the method property... but then req.body.method
is undefined.
Steps to install
git clone https://github.com/Ride-The-Lightning/c-lightning-REST.git
cd c-lightning-REST
git checkout v0.3.0
npm install --only=prod
Produces the following output
billy@AcerUbuntu:~/builds/test/c-lightning-REST$ npm install --only=prod
npm WARN [email protected] No repository field.
added 146 packages from 126 contributors and audited 251 packages in 1.559s
found 0 vulnerabilities
I then run node cl-rest.js
and get
WARN: /home/billy/.lightning/lightning-rpc is missing, using the bitcoin mainnet subdirectory at /home/billy/.lightning/bitcoin instead.
/home/billy/builds/test/c-lightning-REST/node_modules/macaroon/macaroon.js:30
const utf8Encoder = new TextEncoder();
^
TypeError: TextEncoder is not a constructor
at Object.<anonymous> (/home/billy/builds/test/c-lightning-REST/node_modules/macaroon/macaroon.js:30:21)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/billy/builds/test/c-lightning-REST/utils/tasteMacaroon.js:1:80)
at Module._compile (module.js:569:30)
Currently, the server always listens on all interfaces.
Four main functions need to be supported for enabling support for Offers on C-Lightning-REST
Note offers is currently an experimental addition to C-Lightning. The command suite for offers can be enabled on C-Lighning by adding a experimental-offers
in the config file.
For more information on Offers, refer to http://bolt12.org
REST API server linkage with c-lightning should be encrypted via an SSL connection.
Just installed Release v0.4.3-beta-maintenance on Linux (Ubuntu 20.04)
Followed the instructions, but when I try to start the server with "$ node cl-rest.js", I get this error:
nternal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/home/rob/cl-rest/c-lightning-REST-0.4.3/app.js:1:13)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Below tickets cover the issue details:
lightningd/plugins#134
Ride-The-Lightning/RTL#439
The listChannels
endpoint currently will always return the first channel per peer. This works well most of the time, except if I open a channel with a peer, then close that channel, then open a new channel with that same peer within 100 blocks. In this case, the listChannels
endpoint will return the closed channel instead of the open channel. As a consumer of the API, I am typically more interested in open channels to display in my UI than closed channels.
Here's a terminal session showing the CLI output from c-lightning in the scenario I mentioned above.
Connected to a peer with no open channels
clightning@bob:/$ lightning-cli listpeers
{
"peers": [
{
"id": "028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df",
"connected": true,
"netaddr": [
"172.19.0.3:35734"
],
"globalfeatures": "",
"localfeatures": "02a2a1",
"features": "02a2a1",
"channels": []
}
]
}
Open first channel
clightning@bob:/$ lightning-cli fundchannel 028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df 200000 253perkw
{
"tx": "02000000000101a79d24d9d2aa28605d89ff2b96615f74dcd91b7bb31be33a90168d7658bafe990100000000ffffffff02a086010000000000220020caaf9ce350d2712dbcdcb28a4395a6b60682e5697b86bdb52ba6da53cc316bdb06bb0d00000000001600145245a1202e81ebdd9a68d1e6534627accfea64cb0247304402205c784dede4340d39bcc3a53892b41df8b2cdc06f052825579fd9f2bff5f12c350220215b021858094a197b3c6469dacb56c095808d166e83746a0a94c862a4d5b15f012102b76b8df3fcd36980d3de63c5304678a7e73d21d596ee3935972c1498d23a956a00000000",
"txid": "b6b2d96e2916e9225603cc1b40a08e1ddd71145d4a88a3e851cb116fd58e94dc",
"channel_id": "dc948ed56f11cb51e8a3884a5d1471dd1d8ea0401bcc035622e916296ed9b2b6"
}
... mined 6 blocks ...
clightning@bob:/$ lightning-cli listpeers
{
"peers": [
{
"id": "028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df",
"connected": true,
"netaddr": [
"172.19.0.3:35734"
],
"globalfeatures": "",
"localfeatures": "02a2a1",
"features": "02a2a1",
"channels": [
{
"state": "CHANNELD_NORMAL",
"scratch_txid": "6dfe671db3b799b3f02fa530bf75daf92a25ed1b4be072eaef0d670b8864e72d",
"owner": "channeld",
"short_channel_id": "108x1x0",
"direction": 1,
"channel_id": "dc948ed56f11cb51e8a3884a5d1471dd1d8ea0401bcc035622e916296ed9b2b6",
"funding_txid": "b6b2d96e2916e9225603cc1b40a08e1ddd71145d4a88a3e851cb116fd58e94dc",
"close_to_addr": "bcrt1qxuayjd98w5awrq8fvklsmezglr6908p7jxm5a9",
"close_to": "0014373a4934a7753ae180e965bf0de448f8f4579c3e",
"private": false,
"funding_allocation_msat": {
"028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df": 0,
"0310848d51c020306ffc36387f7e79239e6cdfe112fda5d09067df826e45db8e03": 100000000
},
"funding_msat": {
"028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df": "0msat",
"0310848d51c020306ffc36387f7e79239e6cdfe112fda5d09067df826e45db8e03": "100000000msat"
},
"msatoshi_to_us": 100000000,
"to_us_msat": "100000000msat",
"msatoshi_to_us_min": 100000000,
"min_to_us_msat": "100000000msat",
"msatoshi_to_us_max": 100000000,
"max_to_us_msat": "100000000msat",
"msatoshi_total": 100000000,
"total_msat": "100000000msat",
"dust_limit_satoshis": 546,
"dust_limit_msat": "546000msat",
"max_htlc_value_in_flight_msat": 18446744073709551615,
"max_total_htlc_in_msat": "18446744073709551615msat",
"their_channel_reserve_satoshis": 1000,
"their_reserve_msat": "1000000msat",
"our_channel_reserve_satoshis": 1000,
"our_reserve_msat": "1000000msat",
"spendable_msatoshi": 98774000,
"spendable_msat": "98774000msat",
"htlc_minimum_msat": 0,
"minimum_htlc_in_msat": "0msat",
"their_to_self_delay": 6,
"our_to_self_delay": 144,
"max_accepted_htlcs": 483,
"status": [
"CHANNELD_NORMAL:Funding transaction locked. Channel announced."
],
"in_payments_offered": 0,
"in_msatoshi_offered": 0,
"in_offered_msat": "0msat",
"in_payments_fulfilled": 0,
"in_msatoshi_fulfilled": 0,
"in_fulfilled_msat": "0msat",
"out_payments_offered": 0,
"out_msatoshi_offered": 0,
"out_offered_msat": "0msat",
"out_payments_fulfilled": 0,
"out_msatoshi_fulfilled": 0,
"out_fulfilled_msat": "0msat",
"htlcs": []
}
]
}
]
}
Close the first channel
clightning@bob:/$ lightning-cli close 028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df
{
"tx": "0200000001dc948ed56f11cb51e8a3884a5d1471dd1d8ea0401bcc035622e916296ed9b2b60000000000ffffffff01e985010000000000160014373a4934a7753ae180e965bf0de448f8f4579c3e00000000",
"txid": "eb1844c3428adee17917489609b1f36bc04308b5f97ec6f7a38a0c095a8c395e",
"type": "mutual"
}
... mined 6 blocks ...
clightning@bob:/$ lightning-cli listpeers
{
"peers": [
{
"id": "028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df",
"connected": true,
"netaddr": [
"172.19.0.3:35734"
],
"globalfeatures": "",
"localfeatures": "02a2a1",
"features": "02a2a1",
"channels": [
{
"state": "ONCHAIN",
"scratch_txid": "eb1844c3428adee17917489609b1f36bc04308b5f97ec6f7a38a0c095a8c395e",
"owner": "onchaind",
"short_channel_id": "108x1x0",
"direction": 1,
"channel_id": "dc948ed56f11cb51e8a3884a5d1471dd1d8ea0401bcc035622e916296ed9b2b6",
"funding_txid": "b6b2d96e2916e9225603cc1b40a08e1ddd71145d4a88a3e851cb116fd58e94dc",
"close_to_addr": "bcrt1qxuayjd98w5awrq8fvklsmezglr6908p7jxm5a9",
"close_to": "0014373a4934a7753ae180e965bf0de448f8f4579c3e",
"private": false,
"funding_allocation_msat": {
"028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df": 0,
"0310848d51c020306ffc36387f7e79239e6cdfe112fda5d09067df826e45db8e03": 100000000
},
"funding_msat": {
"028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df": "0msat",
"0310848d51c020306ffc36387f7e79239e6cdfe112fda5d09067df826e45db8e03": "100000000msat"
},
"msatoshi_to_us": 100000000,
"to_us_msat": "100000000msat",
"msatoshi_to_us_min": 100000000,
"min_to_us_msat": "100000000msat",
"msatoshi_to_us_max": 100000000,
"max_to_us_msat": "100000000msat",
"msatoshi_total": 100000000,
"total_msat": "100000000msat",
"dust_limit_satoshis": 546,
"dust_limit_msat": "546000msat",
"max_htlc_value_in_flight_msat": 18446744073709551615,
"max_total_htlc_in_msat": "18446744073709551615msat",
"their_channel_reserve_satoshis": 1000,
"their_reserve_msat": "1000000msat",
"our_channel_reserve_satoshis": 1000,
"our_reserve_msat": "1000000msat",
"spendable_msatoshi": 98774000,
"spendable_msat": "98774000msat",
"htlc_minimum_msat": 0,
"minimum_htlc_in_msat": "0msat",
"their_to_self_delay": 6,
"our_to_self_delay": 144,
"max_accepted_htlcs": 483,
"status": [
"CLOSINGD_SIGEXCHANGE:We agreed on a closing fee of 183 satoshi for tx:eb1844c3428adee17917489609b1f36bc04308b5f97ec6f7a38a0c095a8c395e",
"ONCHAIN:Tracking mutual close transaction",
"ONCHAIN:All outputs resolved: waiting 94 more blocks before forgetting channel"
],
"in_payments_offered": 0,
"in_msatoshi_offered": 0,
"in_offered_msat": "0msat",
"in_payments_fulfilled": 0,
"in_msatoshi_fulfilled": 0,
"in_fulfilled_msat": "0msat",
"out_payments_offered": 0,
"out_msatoshi_offered": 0,
"out_offered_msat": "0msat",
"out_payments_fulfilled": 0,
"out_msatoshi_fulfilled": 0,
"out_fulfilled_msat": "0msat",
"htlcs": []
}
]
}
]
}
The closed channel is still returned in listpeers
for 94 more blocks.
Open a second channel to the same peer
clightning@bob:/$ lightning-cli fundchannel 028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df 200000 253perkw
{
"tx": "02000000000101dc948ed56f11cb51e8a3884a5d1471dd1d8ea0401bcc035622e916296ed9b2b60100000000ffffffff02400d030000000000220020c5eca2521e0762a55b01e47c3b6474aa426f59592333e450171606bfbfbd66a02cad0a000000000016001471fb637e70a6fb9c228987b3d6aafe7608b1c025024730440220019e0b61edc3a96665a5aa2d963217703828f2b2cf0feb04c57b5e60e18b268b022078fbdc17b393fc14cab463b547869869976016a5c62510ffe59152b9c17dfc12012102efadcc55ea613773d02404ceb874af5454efd61d23e3089b015e1cbc1cdfa1b000000000",
"txid": "6447af31f13e55fbc061c7d1f429768080b9b41869073a194a06f7a8e9657ef6",
"channel_id": "f67e65e9a8f7064a193a076918b4b980807629f4d1c761c0fb553ef131af4764"
}
... mined 6 blocks ...
clightning@bob:/$ lightning-cli listpeers
{
"peers": [
{
"id": "028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df",
"connected": true,
"netaddr": [
"172.19.0.3:35734"
],
"globalfeatures": "",
"localfeatures": "02a2a1",
"features": "02a2a1",
"channels": [
{
"state": "ONCHAIN",
"scratch_txid": "eb1844c3428adee17917489609b1f36bc04308b5f97ec6f7a38a0c095a8c395e",
"owner": "onchaind",
"short_channel_id": "108x1x0",
"direction": 1,
"channel_id": "dc948ed56f11cb51e8a3884a5d1471dd1d8ea0401bcc035622e916296ed9b2b6",
"funding_txid": "b6b2d96e2916e9225603cc1b40a08e1ddd71145d4a88a3e851cb116fd58e94dc",
"close_to_addr": "bcrt1qxuayjd98w5awrq8fvklsmezglr6908p7jxm5a9",
"close_to": "0014373a4934a7753ae180e965bf0de448f8f4579c3e",
"private": false,
"funding_allocation_msat": {
"028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df": 0,
"0310848d51c020306ffc36387f7e79239e6cdfe112fda5d09067df826e45db8e03": 100000000
},
"funding_msat": {
"028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df": "0msat",
"0310848d51c020306ffc36387f7e79239e6cdfe112fda5d09067df826e45db8e03": "100000000msat"
},
"msatoshi_to_us": 100000000,
"to_us_msat": "100000000msat",
"msatoshi_to_us_min": 100000000,
"min_to_us_msat": "100000000msat",
"msatoshi_to_us_max": 100000000,
"max_to_us_msat": "100000000msat",
"msatoshi_total": 100000000,
"total_msat": "100000000msat",
"dust_limit_satoshis": 546,
"dust_limit_msat": "546000msat",
"max_htlc_value_in_flight_msat": 18446744073709551615,
"max_total_htlc_in_msat": "18446744073709551615msat",
"their_channel_reserve_satoshis": 1000,
"their_reserve_msat": "1000000msat",
"our_channel_reserve_satoshis": 1000,
"our_reserve_msat": "1000000msat",
"spendable_msatoshi": 98774000,
"spendable_msat": "98774000msat",
"htlc_minimum_msat": 0,
"minimum_htlc_in_msat": "0msat",
"their_to_self_delay": 6,
"our_to_self_delay": 144,
"max_accepted_htlcs": 483,
"status": [
"CLOSINGD_SIGEXCHANGE:We agreed on a closing fee of 183 satoshi for tx:eb1844c3428adee17917489609b1f36bc04308b5f97ec6f7a38a0c095a8c395e",
"ONCHAIN:Tracking mutual close transaction",
"ONCHAIN:All outputs resolved: waiting 88 more blocks before forgetting channel"
],
"in_payments_offered": 0,
"in_msatoshi_offered": 0,
"in_offered_msat": "0msat",
"in_payments_fulfilled": 0,
"in_msatoshi_fulfilled": 0,
"in_fulfilled_msat": "0msat",
"out_payments_offered": 0,
"out_msatoshi_offered": 0,
"out_offered_msat": "0msat",
"out_payments_fulfilled": 0,
"out_msatoshi_fulfilled": 0,
"out_fulfilled_msat": "0msat",
"htlcs": []
},
{
"state": "CHANNELD_NORMAL",
"scratch_txid": "0d26070961086234a2b85eb6ce721d7883ef37c5642442dac703c438297248db",
"owner": "channeld",
"short_channel_id": "120x1x0",
"direction": 1,
"channel_id": "f67e65e9a8f7064a193a076918b4b980807629f4d1c761c0fb553ef131af4764",
"funding_txid": "6447af31f13e55fbc061c7d1f429768080b9b41869073a194a06f7a8e9657ef6",
"close_to_addr": "bcrt1q5gymqdr3u5x8c6pj5hxrsdmregnzam28thjjkr",
"close_to": "0014a209b03471e50c7c6832a5cc383763ca262eed47",
"private": false,
"funding_allocation_msat": {
"028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df": 0,
"0310848d51c020306ffc36387f7e79239e6cdfe112fda5d09067df826e45db8e03": 200000000
},
"funding_msat": {
"028a44f455d0e048f933b1baa7484540876be56dcc6e719b33e676856c80a350df": "0msat",
"0310848d51c020306ffc36387f7e79239e6cdfe112fda5d09067df826e45db8e03": "200000000msat"
},
"msatoshi_to_us": 200000000,
"to_us_msat": "200000000msat",
"msatoshi_to_us_min": 200000000,
"min_to_us_msat": "200000000msat",
"msatoshi_to_us_max": 200000000,
"max_to_us_msat": "200000000msat",
"msatoshi_total": 200000000,
"total_msat": "200000000msat",
"dust_limit_satoshis": 546,
"dust_limit_msat": "546000msat",
"max_htlc_value_in_flight_msat": 18446744073709551615,
"max_total_htlc_in_msat": "18446744073709551615msat",
"their_channel_reserve_satoshis": 2000,
"their_reserve_msat": "2000000msat",
"our_channel_reserve_satoshis": 2000,
"our_reserve_msat": "2000000msat",
"spendable_msatoshi": 197774000,
"spendable_msat": "197774000msat",
"htlc_minimum_msat": 0,
"minimum_htlc_in_msat": "0msat",
"their_to_self_delay": 6,
"our_to_self_delay": 144,
"max_accepted_htlcs": 483,
"status": [
"CHANNELD_NORMAL:Funding transaction locked. Channel announced."
],
"in_payments_offered": 0,
"in_msatoshi_offered": 0,
"in_offered_msat": "0msat",
"in_payments_fulfilled": 0,
"in_msatoshi_fulfilled": 0,
"in_fulfilled_msat": "0msat",
"out_payments_offered": 0,
"out_msatoshi_offered": 0,
"out_offered_msat": "0msat",
"out_payments_fulfilled": 0,
"out_msatoshi_fulfilled": 0,
"out_fulfilled_msat": "0msat",
"htlcs": []
}
]
}
]
}
In the final listpeers
output, you can see that the closed channel is at index 0
and the open channel is at index 1
. The current c-lightning-REST listChannels
endpoint will always return the channel at index 0
. It will never return the open channel and my app consuming the API would not be aware that this open channel even exists.
I believe it would be better to search the array for open channels first and return it if it finds one. Since c-lightning only supports one open channel per peer, there should only ever be 0 or 1 open channels.
funderupdate
is required to support the nodes intending to publish liquidity ads
This should be a POST API call, with the following options:
When I run this via Option 1: Run as c-lightning plugin
all looks fine at first in the .lightning/debug.log
:
plugin-plugin.js --- Starting the cl-rest server ---
INFO plugin-plugin.js Changing the working directory to :/opt/src/c-lightning-REST
INFO plugin-plugin.js Reading SSL cert and key
INFO plugin-plugin.js Reading rootkey for macaroon
INFO plugin-plugin.js macaroon converted to base64:
INFO plugin-plugin.js <REDACTED>Q=
INFO plugin-plugin.js --- cl-rest api server is ready and listening on port: 3001 ---
However the the api server is not running and I'll see:
$ ps aux | grep node
lightning 1393 0.0 0.0 0 0 ? Z 10:31 0:00 [node] <defunct>
Which means it crashed for some reason. But there's no more info in the .lightning/debug.log
. Is there any way to debug c-lightning plugins? Or is there a way I can write the whole STDOUT to a file when it is run as plugin?
If I run the api-server standalone it works and there's no crash.
c-lightning-REST dies if payment fails
UNUSUAL plugin-plugin.js: Killing plugin: Failed to parse JSON response 'SyntaxError: Unexpected token { in JSON at position 888? at JSON.parse ()? at Plugin.mainLoop (/home/madbaker/c-lightning-REST/node_modules/clightningjs/src/plugin.js:164:20)? at Socket. (/home/madbaker/c-lightning-REST/node_modules/clightningjs/src/plugin.js:209:12)? at Socket.emit (events.js:314:20)? at emitReadable (_stream_readable.js:557:12)? at processTicksAndRejections (internal/process/task_queues.js:83:21)?SyntaxError: Unexpected token { in JSON at position 888? at JSON.parse ()? at Plugin.mainLoop (/home/madbaker/c-lightning-REST/node_modules/clightningjs/src/plugin.js:164:20)? at Socket. (/home/madbaker/c-lightning-REST/node_modules/clightningjs/src/plugin.js:209:12)? at Socket.emit (events.js:314:20)? at emitReadable (_stream_readable.js:557:12)? at processTicksAndRejections (internal/process/task_queues.js:83:21)?{"jsonrpc":"2.0","method":"log","params":{"level":"warn","message":"{"type":"lightning","message":"Ran out of routes to try after 62 attempts: see paystatus
","name":"LightningError","code":210,"attempts":[{"status":"failed","failreason":"failed: WIRE_TEMPORARY_CHANNEL_FAILURE (reply from remote)","partid":1,"amount":"1000000msat"},{"status":"failed","failreason":"failed: WIRE_TEMPORARY_CHANNEL_FAILURE (reply from remote)","partid":2,"amount":"1000000msat","parent_partid":1},{"status":"failed","failreason":"failed: WIRE_TEMPORARY_CHANNEL_FAILURE (reply from remote)","partid":3,"amount":"1000000msat","parent_partid":2},{"status":"failed","failreason":"failed: WIRE_TEMPORARY_CHANNEL_FAILURE (reply from remote)","partid":4,"amount":"1000000msat","parent_partid":3},{"status":"failed","failreason":"failed: WIRE_TEMPORARY_CHANNEL_FAILURE (reply from remote)","partid":5,"amount":"1000000msat","parent_partid":4},{"status":"failed","failreason":"failed: WIRE_TEMPORARY_CHANNEL_FAILURE (reply from remote)","partid":6'
listpayments
command has been moved from plugin to core and changed to listsendpays
.
Aliases for channels makes for easy understanding of the routing traffic in the UI.
Fetch alias for each channel in the forwarding history records.
Please add pagination for listForwards API, so that applications can limit the number of records per request.
Reference Issue:
Ride-The-Lightning/RTL#737
The API opens access to lightning-rpc
allowing uncredentialed access on the local machine into those ports. If a user were to become compromised an attacker would have direct access into lightning-rpc
. Would be better if we could control access to the REST API uri's, either through a permissioned unix domain socket or through token authentication over https.
Most of the logging done by the plugin would in my opinion qualify as debug information, and it feels like it is spamming the c-lightning output.
Specifically all the information about successful retrieval of information I don't find very relevant unless I am debugging.
Can you please change the log level of such information to DEBUG?
The readme says:
RPCCOMMANDS (Default: ["*"])
so it seems to be a list. But I am having hard time figuring out what format to use in clightning config or on the command line.
Decode function is general purpose decoding utility which can help decode offers, bolt11 and bolt12 invoices.
Currently it is assumed that c-lightning-REST is run by the same user as the lightningd.
For the user bitcoin
it looks for the lightning-rpc
in
/home/bitcoin/.lightning/lightning-rpc
which is normally non-existent.
In case lightning is run with multiple networks on the node
can symlink to
/home/bitcoin/.lightning/lightning-rpc
from the chosen network directory e.g:
sudo ln -s /home/bitcoin/.lightning/signet/lightning-rpc /home/bitcoin/.lightning/
To be able to specify the .lightning
directory path (and within the lightning-rpc
) would be make it possible to run multiple c-lightning-REST servers parallel for the different networks.
Fetch the payment description from the decodeinvoice
command to include in the response for listpayments
The current listtransactions
command output lists the on-chain Bitcoin transactions on the node. This output can be simplified for better consumption by the UI applications. Similar to the way on-chain transactions are listed by LND.
The simplified view should list the below fields in the output for each transaction:
This API would enable to return the information on all the nodes from the graph, including the information about liquidity ads.
The command to be invoked is listnodes
, with an optional param to specify a particular node ID
Great work on the library! Are there plans to including a websocket to subscribe to invoices that are paid?
Add API support for datastore APIs, which can be used by plugins to persist data on the node database.
This feature is available from version 0.10.2 onwards.
Three APIs can be added to support the feature:
Add api for disconnecting peer
Add Alias in the API response.
Identify Inbound/Outbound peers
If I understand the security of using https instead of http, I think allowing the user to tell CLRest what the CN property of the self-signed certificate is makes sense. Currently, it defaults to "localhost" and the instance of Zeus LN on my mobile gets an error that the IP address of my node is not the CN of the certificate:
Error: Hostname (my node's IP address) NOT verified:
certificate: sha256/...=
DN: CN=localhost,O=baz...
subjectAltNames: []
Am I interpreting this error correctly?
Is it possible for the plugin to create the self-signed certificate using a value supplied in the config for subj '/CN=localhost'
? If so, the default self-signed certificate would then be useful on remote devices that the public key without making other adjustments.
Serve API documentation locally with Swagger or some other tool, to simplify documentation support for the APIs
Need support for waitinvoice to improve the UX of invoice generation and payment in the applications.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.