event
event copied to clipboard
0.6 Beta2: c-lightning with spark end in spark error LightningError: No method
Describe the bug I try to connect to a c-lightning node via spark (via a cloudflare proxy). When I add this config Zeus cant connect. In the spark log I see the following:
POST /rpc 500 3.559 ms - 103
at Socket.emit (node:events:394:28)
LightningError: No method
at createError (/opt/spark/node_modules/error/typed.js:40:22)
at LightningClient.<anonymous> (/opt/spark/node_modules/clightning-client/index.js:122:28)
at Object.onceWrapper (node:events:514:26)
at LightningClient.emit (node:events:394:28)
at Interface.<anonymous> (/opt/spark/node_modules/clightning-client/index.js:76:17)
at Interface.emit (node:events:394:28)
at Interface._onLine (node:readline:487:10)
at Interface._normalWrite (node:readline:661:12)
at Socket.ondata (node:readline:269:10)
at Socket.emit (node:events:394:28)
To Reproduce Steps to reproduce the behavior:
- Add url (https://domain)
- Add key
- No cert. validation
- Save
- Zeus tries to connect
Expected behavior Zeus can connect
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Zeus Version 0.6 Beta2 /Beta1
- Clearnet
- Spark 0.3.1
Additional context Add any other context about the problem here.
Were you able to connect to this setup in earlier versions?
In beta1 I had the same error. Version before I was experiencing the flickering issue so couldn't test.
I have the same problem, it breaks the Zeus (Android) app for me. I'm unable to go to settings (app crashes) and every time I restart the app it automatically tries to connect to the node and then I'm stuck on the error again.
Same problem
Some more detail by running spark-wallet --verbose
On a regtest setup with latest c-lightning, Zeus wallet v0.6.6 (on Android) connected to spark via local LAN via port forwarding using JuiceSSH.
spark-wallet --verbose
clightning-client Connecting to /home/simon/.lightning2/regtest/lightning-rpc +0ms
clightning-client #1 --> getinfo [] +4ms
clightning-client Lightning client connected +4ms
clightning-client #1 <-- {
clightning-client id: '02632c9c6c15eb9fdaccd2c538ac1a4959f1aeb90fc6f6b462a953d4792b5aefb1',
clightning-client alias: 'CLtest',
clightning-client color: '02632c',
clightning-client num_peers: 0,
clightning-client num_pending_channels: 0,
clightning-client num_active_channels: 0,
clightning-client num_inactive_channels: 0,
clightning-client address: [],
clightning-client binding: [ { type: 'ipv4', address: '192.168.1.185', port: 9935 } ],
clightning-client version: 'v0.12.0-260-g49ed0a4',
clightning-client blockheight: 1615,
clightning-client network: 'regtest',
clightning-client msatoshi_fees_collected: 0,
clightning-client fees_collected_msat: '0msat',
clightning-client 'lightning-dir': '/home/simon/.lightning2/regtest',
clightning-client our_features: {
clightning-client init: '08a088282a69a2',
clightning-client node: '08a088282a69a2',
clightning-client channel: '',
clightning-client invoice: '02000020024100'
clightning-client }
clightning-client } +2ms
Connected to c-lightning v0.12.0-260-g49ed0a4 with id 02632c9c6c15eb9fdaccd2c538ac1a4959f1aeb90fc6f6b462a953d4792b5aefb1 on network regtest at /home/simon/.lightning2/regtest/lightning-rpc
clightning-client Connecting to /home/simon/.lightning2/regtest/lightning-rpc +291ms
superagent GET https://www.bitstamp.net/api/v2/ticker/btcusd +0ms
HTTP server running on http://localhost:9837
clightning-client Lightning client connected +60ms
clightning-client #1 --> listinvoices [] +0ms
clightning-client #1 <-- {
clightning-client invoices: [
clightning-client {
clightning-client label: '1',
clightning-client bolt11: 'lnbcrt100p1p33nv35sp5lwem8tra785wptyh6h89fdzkc8e39yqx3rzkadj97r9kr9w63cmqpp5efwfzwrlzmfslwsxkl5y988jraxf63p8hcjc3sxtl43kj6wgxg9qdqzxyxqyjw5qcqp29qxsqysgq2de3836j9zscc0ddyrf3qf4u2tvfvqmk79dnq9nf8szfuh4zxkjnxju4lmrvxktvv9tsmxyspxcqpqstgzy6qytle2a6mjfh422e5ugp6fvtrr',
clightning-client payment_hash: 'ca5c91387f16d30fba06b7e8429cf21f4c9d4427be2588c0cbfd636969c8320a',
clightning-client msatoshi: 10,
clightning-client amount_msat: '10msat',
clightning-client status: 'expired',
clightning-client description: '1',
clightning-client expires_at: 1663233204
clightning-client }
clightning-client ]
clightning-client } +1ms
clightning-client #2 --> waitanyinvoice [ 0 ] +1ms
superagent GET https://www.bitstamp.net/api/v2/ticker/btcusd -> 200 +120ms
clightning-client #2 --> undefined [] +32s
clightning-client #2 <-- { code: -32600, message: 'No method' } +2ms
LightningError: No method
at createError (/home/simon/.npm-global/lib/node_modules/spark-wallet/node_modules/error/typed.js:40:22)
at LightningClient.<anonymous> (/home/simon/.npm-global/lib/node_modules/spark-wallet/node_modules/clightning-client/index.js:122:28)
at Object.onceWrapper (events.js:421:26)
at LightningClient.emit (events.js:314:20)
at Interface.<anonymous> (/home/simon/.npm-global/lib/node_modules/spark-wallet/node_modules/clightning-client/index.js:76:17)
at Interface.emit (events.js:314:20)
at Interface._onLine (readline.js:329:10)
at Interface._normalWrite (readline.js:474:12)
at Socket.ondata (readline.js:186:10)
at Socket.emit (events.js:314:20)
POST /rpc 500 19.550 ms - 103
-- snip --
It looks spark-wallet
tries to call an undefined method, as shown by the lines:
clightning-client #2 --> undefined [] +32s
clightning-client #2 <-- { code: -32600, message: 'No method' } +2ms
Not sure what it means, but the error seems related to Zeus
because the (original) Spark
app on same setup works fine.
@SimonVrouwe what version of Zeus are you running?
v0.6.6
I wish the Sparks logs were better. It's still unclear what RPC is attempting to be called that doesn't exist.
On initial connection the following endpoints should be called:
onChainBalance + lnBalance: listfunds
getFees: getinfo
+ listforwards
+listpeers
+ listchannels
getNodeInfo: listnodes
I wonder if any of these have been changed or removed at some point
The debug logs of c-lightning (--log-level=io:rpc
) show that the "method" field is missing from the json.
2022-10-19T17:50:24.797Z jsonrpc#51: [IN] 7b226a736f6e727063223a22322e30222c22706172616d73223a5b5d2c226964223a2232227d
2022-10-19T17:50:24.797Z jsonrpc#51: [OUT] 7b226a736f6e727063223a22322e30222c226964223a2232222c226572726f72223a7b22636f6465223a2d33323630302c226d657373616765223a224e6f206d6574686f64227d7d0a0a
which decode to:
In [13]: s = '7b226a736f6e727063223a22322e30222c22706172616d73223a5b5d2c226964223a2232227d'
In [14]: bytes.fromhex(s).decode('utf-8')
Out[14]: '{"jsonrpc":"2.0","params":[],"id":"2"}'
In [15]: s = '7b226a736f6e727063223a22322e30222c226964223a2232222c226572726f72223a7b22636f6465223a2d33323630302c226d657373616765223a224e6f206d6574686f64227d7d0a0a'
In [16]: bytes.fromhex(s).decode('utf-8')
Out[16]: '{"jsonrpc":"2.0","id":"2","error":{"code":-32600,"message":"No method"}}\n\n'```
I wonder what's triggering this. We're going have to jump in a debug this one step by step. Will try to do so soon.
Could this potentially be a Spark vs Sparko thing?
Ok I did some digging, running:
Zeus latest master b1343552990c on AVD emulator (3.7_WVGA_Nexus_One_API_30)
(regtest) c-lightning v0.11.2 with --allow-deprecated-apis=true
and running Spark DEBUG=* node ./dist/cli.js -k --no-rates --force-tls
, shows the original "LightningError: No method"
clightning-client #2 --> undefined [] +44s
clightning-client #2 <-- { code: -32600, message: 'No method' } +1ms
express:router serveStatic : /rpc +4ms
express:router <anonymous> : /rpc +0ms
LightningError: No method
at createError (/home/simon/git/SimonVrouwe/spark-wallet/node_modules/error/typed.js:40:22)
at LightningClient.<anonymous> (/home/simon/git/SimonVrouwe/spark-wallet/node_modules/clightning-client/index.js:122:28)
at Object.onceWrapper (node:events:628:26)
at LightningClient.emit (node:events:513:28)
at Interface.<anonymous> (/home/simon/git/SimonVrouwe/spark-wallet/node_modules/clightning-client/index.js:76:17)
at Interface.emit (node:events:513:28)
at Interface._onLine (node:readline:491:10)
at Interface._normalWrite (node:readline:665:12)
at Socket.ondata (node:readline:272:10)
at Socket.emit (node:events:513:28)
compression no compression: size below threshold +3ms
morgan log request +5ms
POST /rpc 500 9.121 ms - 103
Here is the relevant code on Zeus side that makes POST requests to Spark's /rpc
route:
https://github.com/ZeusLN/zeus/blob/b1343552990ce3be81274d3fb07397a39b3a5205/backends/Spark.ts#L10-L35
rpcmethod
is the name of a c-lightning rpc method (or a internal _xxx
Spark method).
param
contains parameter's { key: values }
, to be passed as arguments to the rpc method.
For a getinfo
rpc call, the bode will look like:
body: "{\"method\":\"getinfo\",\"params\":{}}"
On the Spark server end, it parses the body as a json
:
https://github.com/shesek/spark-wallet/blob/112fd9bb835f4ee10feeeb46d6c6ebeb78db1c61/src/app.js#L30
app.use(require('body-parser').json())
But correct parsing only seems to work if the POST header contains 'Content-Type': 'application/json'
, which is missing.
After parsing the body, Spark handles the /rpc
route:
// RPC API
app.post('/rpc', proute(async (req, res) => {
req.setTimeout(5 * 60 * 1000)
res.send(await (ln[req.body.method]
? ln[req.body.method](...req.body.params)
: ln.call(req.body.method, req.body.params)))
}))
where ln.call(req.body.method, req.body.params)
points to 'clightning-client' instance that makes the c-lightning rpc call:
https://github.com/shesek/lightning-client-js/blob/ec0c6956eaf44a2fca93bacf4b9ab4798b9cdf20/index.js#L103-L112
call(method, args = []) {
const _self = this;
const callInt = ++this.reqcount;
const sendObj = {
jsonrpc: '2.0',
method,
params: args,
id: ''+callInt
};
You can see that call(method, args = [])
expects args
to be an array !
And also it seem clightning-client
doesn't support key=value params
and thus requires an array of positional arguments.
A quick fix of the POST header and passing params
as an array brings us further:
- const headers: any = { 'X-Access': accessKey };
+ const headers: any = {
+ 'Content-Type': 'application/json',
+ 'X-Access': accessKey
+ };
if (range) {
headers.Range = `${range.unit}=${range.slice}`;
}
- const body = JSON.stringify({ method: rpcmethod, params: param });
+
+ /* Spark-wallet '/rpc' API (v0.3.2-rc) does not support keywords.
+ * "params" should be an array of parameter values in the correct order
+ * per c-lightning's API https://lightning.readthedocs.io */
+ const body =
+ JSON.stringify({ method: rpcmethod, params: Object.values(param) });
But also reveals new issues, i.e. params
args for some /rpc
calls not to be in the correct order and network issues related to ReactNativeBlobUtil.fetch
. Which I also trying to fix, see my working branch
It makes me wonder, when was the last time Zeus+Spark worked correctly? What am I missing?
BTW a earlier version of Zeus v0.6.0
(I could build) showed the same issue.
I think I found it: it's failing cause it doesn't have RESTUtils.supportsAccounts
defined and therefore it fails on this line when the wallet starts up https://github.com/ZeusLN/zeus/blob/master/views/Wallet/Wallet.tsx#L180
Spark is unsupported. Our implementation is for Sparko only.