Install the package via npm:
npm install install lnd-lib --save
Draws heavily on https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/javascript.md, and https://api.lightning.community/.
const lndLib = require('lnd-lib')
const Lightning = new lndLib.Lightning({certPath, macaroonPath, lndAddress, protoPath})
-
[certPath]Optional. Path to certificate. Defaults to~/.lnd/tls.certon Linux and~/Library/Application Support/Lnd/tls.certon Mac. -
[macaroonPath]Optional. Macaroon Path. Defaults to~/.lnd/admin.macaroonon Linux and~/Library/Application Support/admin.macaroonon Mac. -
[lndAddress]Optional. Lnd address. Defaults tolocalhost:10009. -
[protoPath]Optional. Path torpc.proto. Defaults to./rpc.proto(included in this repo).
Fetches certificate, rpc.proto etc. and creates sets up an RPC connection to LND.
Lightning.initialize().then((resp)=>{
....
})
Connects to another LND peer.
Lightning.connect({addr, pubKey, host, perm}).then((resp)=>{
....
})
-
[addr]Optional. TODO..(need to either have
[addr]or[pubKey]and[host]) -
[pubKey]Optional. TODO.. -
[host]Optional. TODO.. -
[perm]Optional. TODO..
Returns basic information related to the Lightning node.
Lightning.getInfo().then((resp)=>{
....
})
Returns the wallet's balance (total utxos, confirmed and unconfirmed).
Lightning.walletBalance().then((resp)=>{
....
})
Generates a new wallet address.
Lightning.newAddress(addressType).then((resp)=>{
....
})
[addressType]:
Either:
-
Lightning.addressType.p2wkhor -
Lightning.addressType.np2wkh. -
Defaults to
Lightning.addressType.p2wkh
Returns a list of all connected peers.
Lightning.listPeers().then((resp)=>{
....
})
Attempts to open a channel to an existing peer.
Lightning.openChannel(
{
nodePubkey,
localFundingAmount,
pushSatoshis,
targetConf,
satoshisPerByte,
minHtlcMsat,
_private,
minHtlcMsat,
remoteCsvDelay
},
statusCallback
).then((resp)=>{
....
})
-
[nodePubkey]TODO -
[localFundingAmount]TODO -
[pushSatoshis]Optional. TODO -
[targetConf]Optional. TODO -
[satoshisPerByte]Optional. TODO -
[_private]Optional. TODO -
[minHtlcMsat]Optional. TODO -
[remoteCsvDelay]Optional. TODO -
[statusCallback]TODO
Returns the total channel balance for all open channels.
Lightning.channelBalance().then((resp)=>{
....
})
Returns a list of all open channels.
Lightning.listChannels().then((resp)=>{
....
})
Adds a new invoice, expressing intent for a future payment.
Lightning.addInvoice({amt}).then((resp)=>{
....
})
[amt]TODO
Decodes a payment request.
Lightning.decodePayReq({payReq}).then((resp)=>{
....
})
[payReq]TODO
Sends a payment over Lightning.
Lightning.sendPayment({payReq}).then((resp)=>{
....
})
[payReq]TODO
Returns the latest authenticated state for a particular channel.
Lightning.getChanInfo({chanId}).then((resp)=>{
....
})
[chanId]TODO
Attempts to close an existing channel.
Lightning.closeChannel(
{
chanId,
channelPoint,
force,
targetConf,
satoshisPerByte
}
).then((resp)=>{
....
})
-
[chanId]TODO -
[channelPoint]TODO -
[force]TODO -
[targetConf]TODO -
[satoshisPerByte]TODO
Disconnects from an existing peer.
Lightning.disconnect({pubKey}).then((resp)=>{
....
})
[pubKey]TODO
Implement remaining lightning functionality.