npm package: @jbaczuk/c-lightning-rpc
Description: Node.js API client for C-Lightning
Author: Jordan Baczuk
Latest version: 1.0.1

# c-lightning-rpc
[![NPM](https://img.shields.io/npm/v/@jbaczuk/c-lightning-rpc.svg)](https://www.npmjs.com/package/@jbaczuk/c-lightning-rpc)  

Node.js c-lightning RPC client library

# Installation
`$ npm i --save @jbaczuk/c-lightning-rpc`

# Usage
```
const LightningRpc = require('../c-lightning-rpc')

l = new LightningRpc('/home/<username>/.lightning/lightning-rpc')

l.listpeers()
.then((response) => {
    console.debug('TEST ', response)
})
```

## Available Commands
```
feerates
    Return feerate estimates, either satoshi-per-kw ({style} perkw) or satoshi-per-kb ({style} perkb).

connect
    Connect to {id} at {host} (which can end in ':port' if not default). {id} can also be of the form id@host

listnodes
    Show node {id} (or all, if no {id}), in our local network view

getroute
    Show route to {id} for {msatoshi}, using {riskfactor} and optional {cltv} (default 9). If specified search from {fromid} otherwise use this node as source. Randomize the route with up to {fuzzpercent} (0.0 -> 100.0, default 5.0) using {seed} as an arbitrary-size string seed.

listchannels
    Show channel {short_channel_id} (or all known channels, if no {short_channel_id})

invoice
    Create an invoice for {msatoshi} with {label} and {description} with optional {expiry} seconds (default 1 hour) and optional {preimage} (default autogenerated)

listinvoices
    Show invoice {label} (or all, if no {label})

delinvoice
    Delete unpaid invoice {label} with {status}

delexpiredinvoice
    Delete all expired invoices that expired as of given {maxexpirytime} (a UNIX epoch time), or all expired invoices if not specified

autocleaninvoice
    Set up autoclean of expired invoices. Perform cleanup every {cycle_seconds} (default 3600), or disable autoclean if 0. Clean up expired invoices that have expired for {expired_by} seconds (default 86400). 

waitanyinvoice
    Wait for the next invoice to be paid, after {lastpay_index} (if supplied)

waitinvoice
    Wait for an incoming payment matching the invoice with {label}, or if the invoice expires

decodepay
    Decode {bolt11}, using {description} if necessary

help
    List available commands, or give verbose help on one command.

stop
    Shut down the lightningd process

getinfo
    Show information about this node

getlog
    Show logs, with optional log {level} (info|unusual|debug|io)

fundchannel
    Fund channel with {id} using {satoshi} (or 'all') satoshis, at optional {feerate}

listconfigs
    List all configuration options, or with [config], just that one.

sendpay
    Send along {route} in return for preimage of {payment_hash}

waitsendpay
    Wait for payment attempt on {payment_hash} to succeed or fail, but only up to {timeout} seconds.

listpayments
    Show outgoing payments

pay
    Send payment specified by {bolt11} with optional {msatoshi} (if and only if {bolt11} does not have amount), {description} (required if {bolt11} uses description hash), {riskfactor} (default 1.0), {maxfeepercent} (default 0.5) the maximum acceptable fee as a percentage (e.g. 0.5 => 0.5%), {exemptfee} (default 5000 msat) disables the maxfeepercent check for fees below the threshold, {retry_for} (default 60) the integer number of seconds before we stop retrying, and {maxdelay} (default 500) the maximum number of blocks we allow the funds to possibly get locked

listpeers
    Show current peers, if {level} is set, include logs for {id}

close
    Close the channel with {id} (either peer ID, channel ID, or short channel ID). If {force} (default false) is true, force a unilateral close after {timeout} seconds (default 30), otherwise just schedule a mutual close later and fail after timing out.

disconnect
    Disconnect from {id} that has previously been connected to using connect

ping
    Send peer {id} a ping of length {len} (default 128) asking for {pongbytes} (default 128)

withdraw
    Send to {destination} address {satoshi} (or 'all') amount via Bitcoin transaction, at optional {feerate}

newaddr
    Get a new {bech32, p2sh-segwit} address to fund a channel (default is bech32)

dev-listaddrs
    Show addresses list up to derivation {index} (default is the last bip32 index)

listfunds
    Show available funds from the internal wallet

dev-rescan-outputs
    Synchronize the state of our funds with bitcoind
```