Commit Graph

15 Commits

Author SHA1 Message Date
ShahanaFarooqui cc2665da7f clnrest: prefixing all rest config options with `cln`
This will allow users to use clnrest with c-lightning-REST without conflicts.
It was required for applications to have enough time for migrating from c-lightning-REST to clnrest.

Changelog-Changed:
config option `rest-certs` changed to `clnrest-certs`
config option `rest-protocol` changed to `clnrest-protocol`
config option `rest-host` changed to `clnrest-host`
config option `rest-port` changed to `clnrest-port`
config option `rest-cors-origins` changed to `clnrest-cors-origins`
config option `rest-csp` changed to `clnrest-csp`
2023-11-16 11:21:04 +01:00
Rusty Russell 8b84c8945b clnrest: don't convert *_msat fields to strings.
We have a global JSON encoder hack, which means that any field ending in msat gets special treatment (so we can safely talk to lightningd, even if a field expects satoshi amounts, we are explicit).  However, requests uses the JSON parser and DOES NOT want this conversion when sending it out as an HTTP response!

The simplest local fix we could find was Shahana's suggestion to iterate and covert away from Millisatoshi(): the reverse of what our JSON encoder does.

Fixes: https://github.com/ElementsProject/lightning/issues/6848
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-11-16 09:07:07 +01:00
Rusty Russell f2f6c73977 clnrest: don't try to handle plugin.rpc.call results.
It already throws an exception or error, or decodes the JSON response:
we can simply pass it through.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-11-16 09:07:07 +01:00
Tony Aldon baa9a96eb1 clnrest: code refactoring for:
- certificate generation
- config options validation
- log level from 'error' to 'info'
- sending method as None instead ""
- added `listclnrest-notifications` for websocket server rune method

Changelog-Fixed: websocket server notifications are available with
restriction of `readonly` runes
2023-10-31 10:21:22 -07:00
Rusty Russell c0782ee841 clnrest: correctly omit `method` to checkrune call if none is supplied.
Specifying the empty string is very different from not specifying it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-17 14:58:40 +10:30
ShahanaFarooqui 51578e1f77 plugins/clnrest: Add `rest-csp` option for config 2023-09-19 11:40:15 +09:30
ShahanaFarooqui eca3a33e69 plugins/clnrest: Update Websocket server to dynamically add CORS settings
Changelog-Added: New configurable Cross-Origin-Resource-Sharing(CSP) header for clnrest
2023-09-19 11:40:15 +09:30
ShahanaFarooqui 632e7abd05 plugins/clnrest: Add `rest-cors-origins` option for config 2023-09-19 11:40:15 +09:30
ShahanaFarooqui 6aa697ea3d plugins/clnrest: Rune authentication for websocket server 2023-09-19 11:40:15 +09:30
ShahanaFarooqui 9147996372 plugins/clnrest: Generate all three certs if missing
Generate client, server and CA certs for https and trusted CA update
2023-09-19 11:40:15 +09:30
Rusty Russell a4644550a2 clnrest: don't require nodeid (FIXME: needs screenshot updates!)
This was a misunderstanding: nodeid is useful for commando, where it's the
peer's nodeid, and Noise-XK guarantees that we know who that is.  It's
not useful for clnrest, so don't require it (it was our node id, which
is redundant).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-12 15:19:02 +09:30
ShahanaFarooqui e788f76f99 plugin/clnrest: do not read json payload if data length is zero
OpenAPI readme always includes `content-type: application/json` header, even when body parameters are empty.
But the server expects data if the content-type has been sent.
This results in a "Server Error" response for non-param requests from readme doc.
This only affects readme requests as it is designed to send the header by default.

Changelog-None
2023-08-31 16:13:35 +09:30
Shahana Farooqui 5e3ffc468b plugins/clnrest: removing notifications queue in favor of websocket server 2023-07-25 19:20:16 +09:30
Rusty Russell 2ab0b4af3e plugins/clnrest: disable ourselves unless rest-port is set.
This mirrors grpc's behavior, and avoids listening on ports without
explicit user permission.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-25 19:20:16 +09:30
Shahana Farooqui 21160aa6a7 plugin: clnrest
plugin: clnrest
2023-07-25 19:20:16 +09:30