https://github.com/interledger-deprecated/lnd-lib
A library for interacting with an LND server
https://github.com/interledger-deprecated/lnd-lib
bitcoin lightning lnd
Last synced: 5 months ago
JSON representation
A library for interacting with an LND server
- Host: GitHub
- URL: https://github.com/interledger-deprecated/lnd-lib
- Owner: interledger-deprecated
- License: apache-2.0
- Created: 2018-08-20T09:47:32.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-27T22:45:53.000Z (over 7 years ago)
- Last Synced: 2025-08-09T10:06:59.139Z (10 months ago)
- Topics: bitcoin, lightning, lnd
- Language: JavaScript
- Size: 87.9 KB
- Stars: 0
- Watchers: 8
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lnd-lib
[](https://greenkeeper.io/)
# Installation
Install the package via `npm`:
```
npm install install lnd-lib --save
```
# Introduction
Draws heavily on , and .
# Usage
```
const lndLib = require('lnd-lib')
const Lightning = new lndLib.Lightning({certPath, macaroonPath, lndAddress, protoPath})
```
* `[certPath]` Optional. Path to certificate. Defaults to `~/.lnd/tls.cert` on Linux and `~/Library/Application Support/Lnd/tls.cert` on Mac.
* `[macaroonPath]` Optional. Macaroon Path. Defaults to `~/.lnd/admin.macaroon` on Linux and `~/Library/Application Support/admin.macaroon` on Mac.
* `[lndAddress]` Optional. Lnd address. Defaults to `localhost:10009`.
* `[protoPath]` Optional. Path to `rpc.proto`. Defaults to `./rpc.proto` (included in this repo).
## Methods
#### initialize
Fetches certificate, rpc.proto etc. and creates sets up an RPC connection to LND.
```
Lightning.initialize().then((resp)=>{
....
})
```
#### connect
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..
#### getInfo
Returns basic information related to the Lightning node.
```
Lightning.getInfo().then((resp)=>{
....
})
```
#### walletBalance
Returns the wallet's balance (total utxos, confirmed and unconfirmed).
```
Lightning.walletBalance().then((resp)=>{
....
})
```
#### newAddress
Generates a new wallet address.
```
Lightning.newAddress(addressType).then((resp)=>{
....
})
```
`[addressType]`:
Either:
* `Lightning.addressType.p2wkh` or
* `Lightning.addressType.np2wkh`.
* Defaults to `Lightning.addressType.p2wkh`
#### listPeers
Returns a list of all connected peers.
```
Lightning.listPeers().then((resp)=>{
....
})
```
#### openChannel
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
#### channelBalance
Returns the total channel balance for all open channels.
```
Lightning.channelBalance().then((resp)=>{
....
})
```
#### listChannels
Returns a list of all open channels.
```
Lightning.listChannels().then((resp)=>{
....
})
```
#### addInvoice
Adds a new invoice, expressing intent for a future payment.
```
Lightning.addInvoice({amt}).then((resp)=>{
....
})
```
* `[amt]` TODO
#### decodePayReq
Decodes a payment request.
```
Lightning.decodePayReq({payReq}).then((resp)=>{
....
})
```
* `[payReq]` TODO
#### sendPayment
Sends a payment over Lightning.
```
Lightning.sendPayment({payReq}).then((resp)=>{
....
})
```
* `[payReq]` TODO
#### getChanInfo
Returns the latest authenticated state for a particular channel.
```
Lightning.getChanInfo({chanId}).then((resp)=>{
....
})
```
* `[chanId]` TODO
#### closeChannel
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
#### disconnect
Disconnects from an existing peer.
```
Lightning.disconnect({pubKey}).then((resp)=>{
....
})
```
* `[pubKey]` TODO
## TODO:
Implement remaining lightning functionality.