Commit Graph

43 Commits

Author SHA1 Message Date
ShahanaFarooqui
b485a026f7 rpc: Removing description from json_command struct 2024-07-31 14:42:58 +09:30
ShahanaFarooqui
89c182e2be rpc: Removing category and verbose from json_command struct 2024-07-31 14:42:58 +09:30
ShahanaFarooqui
4b69c57d75 plugins: Remove requirements.txt for python plugins
Removing requirements.txt from clnrest and wss-proxy plugins due to their ever changing dependencies. We will only be dependent on pyproject.toml for more stable results.

Reference: https://github.com/ElementsProject/lightning/pull/7416#issuecomment-2181492069

Changelog-None.
2024-07-03 12:20:05 -07:00
ShahanaFarooqui
39626b9f8f clnrest: Fixes ssl_version deprecated warning
Reference Issue #6931: Fixes `Warning: option `ssl_version` is deprecated and it is ignored. Use ssl_context instead.`

Changelog-None.
2024-06-28 10:54:44 +09:30
ShahanaFarooqui
9f599365f9 clnrest: Updated requirements.txt (without coincurve)
As suggested by @cdecker, I compared `poetry show --tree` results from before/after `cd plugins/clnrest/ && poetry export --output requirements.txt && pip install -r requirements.txt` to check for any significant difference. There is no difference in the tree.

But poetry export removed coincurve & other dependencies from clnrest's requirements.txt.

Changelog-None.
2024-06-28 10:46:14 +09:30
Alex Myers
f109bc27e1 meta: update changelog for 24.05rc2 2024-05-29 20:16:44 -05:00
Alex Myers
c9f7b78473 meta: update python versions to 24.05
Changelog-None
2024-05-23 18:09:03 -05:00
ShahanaFarooqui
95a92b6e4b plugin/clnrest: Adding new config param as clnrest-swagger-root
- Updated config params and plugin
- Updated documentation

Changelog-Added: Added a new configuration for clnrest plugin to change the default Swagger UI path from `/` to custom url.
2024-04-24 11:13:27 -05:00
Rusty Russell
c4edec8e22 plugins/clnrest: simple wrapper to handle missing python3.
Apparently NixOS didn't have Python (sometimes!) so let's not assume.
By reusing the JSON "parsing" code from cowsay, we can self-disable
to handle this case.

Reported-by: Shahana Farooqui <shahana.farooqui@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Plugins: `clnrest` now correctly self-disables if Python not present at all.
2024-04-12 10:32:32 +02:00
Christian Decker
5e42f4681b release: Bump pyln package versions 2024-02-28 14:38:10 +01:00
Peter Neuroth
eb3b1b8134 clnrest: Import sys in except clause explicitly
This fixes a crash on startup of core-lightning where gevent could not
be imported. This happens before sys is imported and throws us into the
except clause which calls sys.
By importing it explicitly in the except clause we are not dependend of
the order of imports in the try bracket.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>

Changelog-Fixes: Plugin: clnrest crashed on startup when gevent was
missing.
2023-11-21 08:24:09 +01:00
Peter Neuroth
8f8202daa7 meta: Update release checklist
Add a version bump for clnrest and the main poetry.lock to the makefile
and update the release checklist to include the new target.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2023-11-16 15:20:33 +01:00
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
ShahanaFarooqui
9e9c3dbc00 clnrest: add gevent ssl monkey patch to remove warning log 2023-11-16 09:07:07 +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
Peter Neuroth
02ca226f88 CHANGELOG.md: Update for 23.11rc1
Update changelog, pyln versions, clnrest version and poetry.lock.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2023-11-03 14:49:12 +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
77e3c3a38e plugin/clnrest: Adjusting flask-cors install after rebase 2023-09-29 16:00:05 +09:30
ShahanaFarooqui
e010eece1b plugins/clnrest: Updated clnrest's requirements.txt
Even after migrating from pip install to poetry install for clnrest,
we still need to keep `plugins/clnrest/requirements.txt` for Fedora-28-amd64
build. `Dockerfile.builder.fedora` does not have poetry and will need
requirements.txt to install libraries with pip.

It is also required for non-developers who want to build cln from a tagged or master version.
2023-09-29 16:00:05 +09:30
ShahanaFarooqui
6a756256c0 plugins/clnrest: Adding pyproject.toml for Poetry install
Reference links:
https://github.com/ElementsProject/lightning/issues/6637
https://github.com/nix-community/poetry2nix

Changelog-Changed: Upgraded clnrest to poetry project.
2023-09-29 16:00:05 +09:30
ShahanaFarooqui
3108ff93b8 plugins/clnrest: Update content security policy for server 2023-09-19 11:40:15 +09: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
b0430cc897 plugins/clnrest: Update App server to dynamically add CORS settings 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
224a5dcbcf plugins/clnrest: Add CORS library 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
ShahanaFarooqui
761172001b plugin/clnrest: Deleting redundant README.md 2023-09-12 16:10: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
Dusty Daemon
8d5be61fcb clnrest: Change process method to fork
On mac the clnrest plugin hangs on log messages, causing it to never run.

This guide suggests switching to fork’ing instead of spwan’ing
https://superfastpython.com/multiprocessing-common-errors/#Error_2_print_Does_Not_Work_In_Child_Processes

Switching to fork fixes the hang on Mac.

Changelog-None
2023-08-24 19:36:42 +09:30
ShahanaFarooqui
18b928046b plugin/clnrest: Downgrading pyln-proto versino from 23.08 to 23.5.2
Bug fix: pip install from plugins/clnrest/requirements.txt was unable to find "not yet released" pyln-proto version 23.08.
2023-08-06 12:34:19 +09:30
Shahana Farooqui
c96d0c2643 plugin/clnrest: Updated pyln version to 23.08 in requirements.txt 2023-08-01 11:35:19 +09:30
Shahana Farooqui
637f314bc6 plugin/clnrest: Improved readme and comments
- Adding runes info in readme
- Added extra comments in the code
- System exit on shutdown
- Replaced single quotes with double quotes

Changelog-None
2023-07-30 16:50:04 +09:30
Shahana Farooqui
3fab4cc4f3 plugin/clnrest: Updating package
- Adding package initializer for future proofing
- Updated Pyln version
2023-07-30 16:50:04 +09:30
Shahana Farooqui
911d2c117e plugins/clnrest: Websocket Server
- Added Dependencies
- Updated WS client instructions
- WS Server
2023-07-25 19:20:16 +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
Rusty Russell
a6701bf180 plugins/clnrest: fail gracefully if dependencies not installed.
json and sys are Python built-in packages, so we can do this.

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