Ride-The-Lightning / c-lightning-REST

REST APIs for Core Lightning written with node.js
MIT License
120 stars 43 forks source link

[Feature request] option to specify the `.lightning` path #60

Closed openoms closed 3 years ago

openoms commented 3 years ago

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.

crabel99 commented 3 years ago

I run lightningd through systemd and my path to the socket is in the runtime directory /run/lightningd/lightning-rpc Not being able to specify that in either the lightning.conf with a rest-rpc-path=PATH or in cl-rest-config.json with RPCPATHmakes it very difficult to get the REST endpoint up and running.

Current working workaround is to use systemd as the lightning-rpc socket is created at runtime and the plugin will not connect. lightning-rest.service

[Service]
Environment="LN_PATH=/run/lightningd/"
ExecStart=/usr/bin/node /opt/c-lightning-REST/cl-rest.js

Where LN_PATH is used in ./app.js

and to modify ./lightning-client-js.js

const JSONParser = require('jsonparse')
const LightningError = require('error/typed')({ type: 'lightning', message: 'lightning-client error' })
const methods = require('./methods');

//const defaultRpcPath = path.join(require('os').homedir(), '.lightning')
const defaultRpcPath = path.join('/run', 'lightningd')
    , fStat = (...p) => fs.statSync(path.join(...p))
    , fExists = (...p) => fs.existsSync(path.join(...p))
saubyk commented 3 years ago

@openoms and @crabel99

Configuration for lightning-rpc location was already configurable via an environment variable LN_PATH. With the linked PR, we are making it easier to configure by adding an additional config parameter LNRPCPATH.

saubyk commented 3 years ago

Merged to the release branch for v0.5.0