Skip to content

Commit

Permalink
Merge pull request #164 from Ride-The-Lightning/Release-v0.10.2
Browse files Browse the repository at this point in the history
Release v0.10.2
  • Loading branch information
saubyk authored Mar 12, 2023
2 parents 7f884ee + a3467da commit f81f694
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 31 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ For running the server, rename the file `sample-cl-rest-config.json` to `cl-rest

NOTE: Node.js plugins might not work with lightningd.service setting `MemoryDenyWriteExecute=true` as it denies the creation of writable and executable memory mappings. Ref: https://github.com/Ride-The-Lightning/c-lightning-REST/issues/116

If running as a plugin, configure the below options in your c-lightning `config` file:
If running as a plugin, configure the below options in your core lightning `config` file:
- `rest-port`
- `rest-docport`
- `rest-protocol`
Expand All @@ -72,7 +72,7 @@ You can choose from the below options to run the API server

Access the APIs on the default port 3001 or the port configured in the config file.

#### Option 2: Run as c-lightning plugin
#### Option 2: Run as a core lightning plugin
Pass arguments when launching lightningd:

`$ lightningd --plugin=PATH_TO_PLUGIN [--rest-port=N] [--rest-protocol=http|https] [--rest-execmode=MODE]`
Expand Down Expand Up @@ -228,7 +228,7 @@ C-Lightning commands covered by this API suite is [here](docs/CLTCommandCoverage
- rpc (/v1/rpc) - `POST`: additional access to RPC comands. Examples of body param for rpc:

#### No param
`{"method": "getinfo}`
`{"method": "getinfo"}`
#### One param
`{"method":"signmessage", "params": ["message"]}`
#### Multiple params
Expand Down
19 changes: 18 additions & 1 deletion cl-rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,24 @@ const PORT = config.PORT;
const EXECMODE = config.EXECMODE;
const DOCPORT = config.DOCPORT;
const DOMAIN = config.DOMAIN || "localhost";
const BIND = config.BIND || "::";

// Check if any interface on the device has an IPv6 address
const os = require('os');
const networkInterfaces = os.networkInterfaces();
const hasIPv6 = Object.values(networkInterfaces).some((interfaces) => {
return interfaces.some((iface) => {
return iface.family === 'IPv6';
});
});
if (hasIPv6)
var bindaddr = config.BIND || "::";
else
var bindaddr = config.BIND || "0.0.0.0";

const BIND = bindaddr;
global.logger.log("--------------");
global.logger.log("Bind address -> " + BIND);
global.logger.log("--------------");

//Create certs folder
try {
Expand Down
55 changes: 38 additions & 17 deletions controllers/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,17 @@ exports.listChannels = (req,res) => {
}

//Function # 3
//Invoke the 'setchannelfee' command update the fee policy of a channel
//Invoke the 'setchannel' command to update the fee policy of a channel
//Arguments - Channel id (required), Base rate (optional), PPM rate (optional)
/**
* @swagger
* /channel/setChannelFee:
* post:
* tags:
* - Channel Management
* name: setchannelfee
* name: setchannel
* summary: Update channel fee policy
* description: Core documentation - https://lightning.readthedocs.io/lightning-setchannelfee.7.html
* description: Core documentation - https://lightning.readthedocs.io/lightning-setchannel.7.html
* parameters:
* - in: body
* name: id
Expand All @@ -248,6 +248,18 @@ exports.listChannels = (req,res) => {
* name: ppm
* description: Optional value that is added proportionally per-millionths to any routed payment volume in satoshi
* type: integer
* - in: body
* name: htlcmin
* description: Optional value that limits how small an HTLC channel will forward
* type: string
* - in: body
* name: htlcmax
* description: Optional value that limits how large an HTLC channel will forward
* type: string
* - in: body
* name: enforcedelay
* description: Number of seconds to delay before enforcing the new fees/htlc max (default 600)
* type: integer
* security:
* - MacaroonAuth: []
* responses:
Expand All @@ -256,21 +268,27 @@ exports.listChannels = (req,res) => {
* schema:
* type: object
* properties:
* base:
* type: string
* description: base
* ppm:
* type: string
* description: ppm
* peer_id:
* type: string
* description: peer_id
* description: node pubkey of the peer
* channel_id:
* type: string
* description: channel_id
* description: channel_id of the channel
* fee_base_msat:
* type: string
* description: the resulting fee base
* fee_proportional_millionths:
* type: string
* description: the resulting fee ppm
* minimum_htlc_out_msat:
* type: string
* description: the resulting htlcmin node will advertize
* maximum_htlc_out_msat:
* type: string
* description: the resulting htlcmax node will advertize
* short_channel_id:
* type: string
* description: short_channel_id
* description: the short_channel_id (if locked in)
* 500:
* description: Server error
*/
Expand All @@ -282,13 +300,16 @@ exports.setChannelFee = (req,res) => {
//Set required params
var id = req.body.id;
//Set optional params
var base = (req.body.base) ? req.body.base : null;
var ppm = (req.body.ppm) ? req.body.ppm : null;
var feebase = (req.body.base) ? req.body.base : null;
var feeppm = (req.body.ppm) ? req.body.ppm : null;
var htlcmin = (req.body.htlcmin) ? req.body.htlcmin : null;
var htlcmax = (req.body.htlcmax) ? req.body.htlcmax : null;
var enforcedelay = (req.body.enforcedelay) ? req.body.enforcedelay : null;

//Call the setchannelfee command with the params
//Call the setchannel command with the params
global.logger.log(req.body);
ln.setchannelfee(id, base, ppm).then(data => {
global.logger.log('setChannelfee success');
ln.setchannel(id, feebase, feeppm,htlcmin, htlcmax, enforcedelay).then(data => {
global.logger.log('setChannel success');
global.logger.log(data);
res.status(201).json(data);
}).catch(err => {
Expand Down
35 changes: 28 additions & 7 deletions controllers/payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ var wsServer = require('../utils/webSocketServer');
* name: exemptfee
* description: Amount for which the maxfeepercent check is skipped
* type: integer
* - in: body
* name: localinvreqid
* description: Used by offers to link a payment attempt to a local invoice_request offer created
* type: string
* - in: body
* name: exclude
* description: JSON array of short-channel-id/direction or node-id which should be excluded from consideration for routing
* type: object
* - in: body
* name: maxfee
* description: Creates an absolute limit on the fee paid. If you specify maxfee you cannot specify either maxfeepercent & exemptfee
* type: integer
* - in: body
* name: description
* description: Only required for bolt11 invoices which do not contain a description themselves, but contain a description hash
* type: string
* security:
* - MacaroonAuth: []
* responses:
Expand All @@ -60,9 +76,6 @@ var wsServer = require('../utils/webSocketServer');
* schema:
* type: object
* properties:
* id:
* type: integer
* description: id
* payment_hash:
* type: string
* description: payment_hash
Expand Down Expand Up @@ -90,9 +103,9 @@ var wsServer = require('../utils/webSocketServer');
* payment_preimage:
* type: string
* description: payment_preimage
* bolt11:
* type: string
* description: bolt11
* parts:
* type: object
* description: how many attempts this took
* 500:
* description: Server error
* schema:
Expand Down Expand Up @@ -129,6 +142,10 @@ exports.payInvoice = (req,res) => {
var retry_for = (req.body.retry_for) ? req.body.retry_for : null;
var maxdelay = (req.body.maxdelay) ? req.body.maxdelay : null;
var exemptfee = (req.body.exemptfee) ? req.body.exemptfee : null;
var lclnvrqd = (req.body.localinvreqid) ? req.body.localinvreqid : null;
var xcld = (req.body.exclude) ? req.body.exclude : null;
var mxf = (req.body.maxfee) ? req.body.maxfee : null;
var dscrptn = (req.body.description) ? req.body.description : null;

//Call the pay command
ln.pay(bolt11=invoice,
Expand All @@ -138,7 +155,11 @@ exports.payInvoice = (req,res) => {
maxfeepercent=maxfeepercent,
retry_for=retry_for,
maxdelay = maxdelay,
exemptfee=exemptfee).then(data => {
exemptfee=exemptfee,
localinvreqid=lclnvrqd,
exclude=xcld,
maxfee=mxf,
description=dscrptn).then(data => {
global.logger.log('pay invoice success');
res.status(201).json(data);
}).catch(err => {
Expand Down
3 changes: 2 additions & 1 deletion methods.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@
"peerswap-removepeer",
"peerswap-resendmsg",
"peerswap-swap-in",
"peerswap-swap-out"
"peerswap-swap-out",
"setchannel"
]
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "c-lightning-rest",
"version": "0.10.1",
"version": "0.10.2",
"description": "c-lightning REST API suite",
"main": "cl-rest.js",
"scripts": {
Expand Down

0 comments on commit f81f694

Please sign in to comment.