README
Lightning Network Service
Overview
The core of this project is a gRPC interface for node.js projects, available through npm.
Supported LND versions:
- v0.14.0-beta to v0.14.2-beta
- v0.13.0-beta to v0.13.4-beta
- v0.12.0-beta to v0.12.1-beta
- v0.11.0-beta to v0.11.1-beta
For typescript-ready methods, check out https://github.com/alexbosworth/lightning#readme
Installing LND
There is a guide to installing LND on the LND repository: https://github.com/lightningnetwork/lnd/blob/master/docs/INSTALL.md
Example LND configuration options (~/.lnd/lnd.conf)
[Application Options]
externalip=IP
rpclisten=0.0.0.0:10009
[Bitcoin]
bitcoin.active=1
bitcoin.mainnet=1
bitcoin.node=bitcoind
If you are interacting with your node remotely, make sure to set (in
[Application Options]
)
tlsextradomain=YOURDOMAIN
If you're adding TLS settings, regenerate the cert and key by stopping lnd, deleting the tls.cert and tls.key - then restart lnd to regenerate.
If you're going to use extended gRPC APIs, make sure to add the APIs to make tags.
make && make install tags="autopilotrpc chainrpc invoicesrpc routerrpc signrpc walletrpc watchtowerrpc wtclientrpc"
Using gRPC
You can install ln-service service via npm
npm install ln-service
To use authenticated methods you will need to provide LND credentials.
To export the credentials via a command, you can install
balanceofsatoshis:
npm install -g balanceofsatoshis
and export via bos credentials --cleartext
Or you can export them manually:
Run base64
on the tls.cert and admin.macaroon files to get the encoded
authentication data to create the LND connection. You can find these files in
the LND directory. (~/.lnd or ~/Library/Application Support/Lnd)
base64 tls.cert
base64 data/chain/bitcoin/mainnet/admin.macaroon
Be careful to avoid copying any newline characters in creds. To exclude them:
base64 -w0 ~/.lnd/tls.cert
base64 -w0 ~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
You can then use these to interact with your LND node directly:
const lnService = require('ln-service');
const {lnd} = lnService.authenticatedLndGrpc({
cert: 'base64 encoded tls.cert',
macaroon: 'base64 encoded admin.macaroon',
socket: '127.0.0.1:10009',
});
// Callback syntax
lnService.getWalletInfo({lnd}, (err, result) => {
const nodeKey = result.public_key;
});
// Promise syntax
const nodePublicKey = (await lnService.getWalletInfo({lnd})).public_key;
An unauthenticatedLndGrpc function is also available
for unlocker
methods.
All Methods
- addPeer - Connect to a peer
- authenticatedLndGrpc - LND API Object
- broadcastChainTransaction - Push a chain tx
- cancelHodlInvoice - Cancel a held or any open invoice
- cancelPendingChannel - Cancel a pending open channel
- changePassword - Change the wallet unlock password
- closeChannel - Terminate an open channel
- connectWatchtower - Connect a watchtower
- createChainAddress - Get a chain address to receive at
- createHodlInvoice - Make a HODL HTLC invoice
- createInvoice - Make a regular invoice
- createSeed - Generate a wallet seed for a new wallet
- createSignedRequest - create a signed payment request
- createUnsignedRequest - create an unsigned invoice
- createWallet - Make a new wallet
- decodePaymentRequest - Decode a Lightning invoice
- deleteFailedPayAttempts - Remove records of failed pay attempts
- deleteFailedPayments - Remove records of payments that failed
- deleteForwardingReputations - Wipe node reps
- deletePayment - Delete the record of a single past payment
- deletePayments - Delete entire history of past payments
- deletePendingChannel - Delete a pending channel that will never confirm due to a conflicting confirmed transaction
- diffieHellmanComputeSecret - Get DH shared key
- disableChannel - Disable a channel for outgoing payments
- disconnectWatchtower - Disconnect a watchtower
- enableChannel - Enable a channel for outgoing payments
- fundPendingChannels - Fund pending open channels
- fundPsbt - Create an unsigned PSBT with funding inputs and spending outputs
- getAccessIds - Get granted macaroon root access ids
- getAutopilot - Get autopilot status or node scores
- getBackup - Get a backup of a channel
- getBackups - Get a backup for all channels
- getChainBalance - Get the confirmed chain balance
- getChainFeeEstimate - Get a chain fee estimate
- getChainFeeRate - Get the fee rate for a conf target
- getChainTransactions - Get all chain transactions
- getChannel - Get graph information about a channel
- getChannelBalance - Get the balance of channel funds
- getChannels - Get all open channels
- getClosedChannels - Get previously open channels
- getConnectedWatchtowers - Get connected towers
- getFailedPayments - Get payments that were failed back
- getFeeRates - Get current routing fee rates
- getForwardingConfidence - Get pairwise confidence
- getForwardingReputations - Get graph reputations
- getForwards - Get forwarded routed payments
- getHeight - Get the current best chain height and block hash
- getIdentity - Get the node's identity key
- getInvoice - Get a previously created invoice
- getInvoices - Get all previously created invoices
- getLockedUtxos - Get all previously locked UTXOs
- getMasterPublicKeys - Get a list of master pub keys
- getMethods - Get available methods and associated permissions
- getNetworkCentrality - Get centrality score for nodes
- getNetworkGraph - Get the channels and nodes of the graph
- getNetworkInfo - Get high-level graph info
- getNode - Get graph info about a single node and its channels
- getPathfindingSettings - Get pathfinding system settings
- getPayment - Get a past payment
- getPayments - Get all past payments
- getPeers - Get all connected peers
- getPendingChainBalance - Get pending chain balance
- getPendingChannels - Get channels in pending states
- getPendingPayments - Get in-flight outgoing payments
- getPublicKey - Get a public key out of the seed
- getRouteConfidence - Get confidence in a route
- getRouteThroughHops - Get a route through nodes
- getRouteToDestination - Get a route to a destination
- getSweepTransactions - Get transactions sweeping to self
- getTowerServerInfo - Get information about tower server
- getUtxos - Get on-chain unspent outputs
- getWalletInfo - Get general wallet info
- getWalletStatus - Get the status of the wallet
- getWalletVersion - Get the build and version of the LND
- grantAccess - Grant an access credential macaroon
- grpcProxyServer - REST proxy server for calling to gRPC
- isDestinationPayable - Check can pay to destination
- lockUtxo - Lock a UTXO temporarily to prevent it being used
- openChannel - Open a new channel
- openChannels - Open channels with external funding
- parsePaymentRequest - Parse a BOLT11 Payment Request
- partiallySignPsbt - Sign a PSBT without finalizing it
- pay - Send a payment
- payViaPaymentDetails - Pay using decomposed details
- payViaPaymentRequest - Pay using a payment request
- payViaRoutes - Make a payment over specified routes
- prepareForChannelProposal - setup for a channel proposal
- probe - Find a payable route by attempting a fake payment
- probeForRoute - Actively probe to find a payable route
- proposeChannel - Offer a channel proposal to a peer
- recoverFundsFromChannel - Restore a channel
- recoverFundsFromChannels - Restore all channels
- removePeer - Disconnect from a connected peer
- requestChainFeeIncrease - Request a CPFP spend on a UTXO
- restrictMacaroon - Add limitations to a macaroon
- revokeAccess - Revoke all access macaroons given to an id
- routeFromChannels - Convert channel series to a route
- sendMessageToPeer - Send a custom message to a peer
- sendToChainAddress - Send on-chain to an address
- sendToChainAddresses - Send on-chain to addresses
- sendToChainOutputScripts - Send to on-chain script outputs
- setAutopilot - Turn autopilot on and set autopilot scores
- settleHodlInvoice - Accept a HODL HTLC invoice
- signBytes - Sign over arbitrary bytes with node keys
- signMessage - Sign a message with the node identity key
- signPsbt - Sign and finalize an unsigned PSBT using internal keys
- signTransaction - Sign an on-chain transaction
- stopDaemon - Stop lnd
- subscribeToBackups - Subscribe to channel backups
- subscribeToBlocks - Subscribe to on-chain blocks
- subscribeToChainAddress - Subscribe to receives
- subscribeToChainSpend - Subscribe to chain spends
- subscribeToChannels - Subscribe to channel statuses
- subscribeToForwardRequests - Interactively route
- subscribeToForwards - Subscribe to HTLC events
- subscribeToGraph - Subscribe to network graph updates
- subscribeToInvoice - Subscribe to invoice updates
- subscribeToInvoices - Subscribe to all invoices
- subscribeToOpenRequests - Approve open requests
- subscribeToPastPayment - Subscribe to a payment
- subscribeToPastPayments - Subscribe to all sent payments
- subscribeToPayViaDetails - Pay using details
- subscribeToPayViaRequest - Pay using a request
- subscribeToPayViaRoutes - Pay using routes
- subscribeToPeerMessages - Listen to incoming custom messages
- subscribeToPeers - Subscribe to peers connectivity
- subscribeToProbe - Subscribe to a probe for a route
- subscribeToProbeForRoute - Probe for a route
- subscribeToRpcRequests - Subscribe to rpc requests
- subscribeToTransactions - Subscribe to chain tx
- subscribeToWalletStatus - Subscribe to node state
- unauthenticatedLndGrpc - LND for locked lnd APIs
- unlockUtxo - Release a locked UTXO so that it can be used again
- unlockWallet - Unlock a locked lnd
- updateChainTransaction - Update a chain transaction
- updateConnectedWatchtower - Update watchtower
- updatePathfindingSettings - Update pathfinding configuration
- updateRoutingFees - Change routing fees
- verifyAccess - Verify a macaroon has access
- verifyBackup - Verify a channel backup
- verifyBackups - Verify a set of channel backups
- verifyBytesSignature - Verify a signature over bytes
- verifyMessage - Verify a message signed by a node identity
Additional Libraries
- bolt01 - bolt01 messaging utilities
- bolt03 - bolt03 transaction utilities
- bolt07 - bolt07 channel gossip utilities
- bolt09 - bolt09 feature flag utilities
- invoices - bolt11 request utilities
- lightning - methods with typescript typing support
- ln-accounting - accounting records
- ln-docker-daemons
- run regtest integration tests
- ln-pathfinding - pathfinding utilities
- ln-sync - metadata helper methods
- probing - payment probing utilities
- psbt - BIP 174 PSBT utilities
addPeer
Add a peer if possible (not self, or already connected)
Requires peers:write
permission
timeout
is not supported in LND 0.11.1 and below
{
[is_temporary]: <Add Peer as Temporary Peer Bool> // Default: false
lnd: <Authenticated LND API Object>
public_key: <Public Key Hex String>
[retry_count]: <Retry Count Number>
[retry_delay]: <Delay Retry By Milliseconds Number>
socket: <Host Network Address And Optional Port String> // ip:port
[timeout]: <Connection Attempt Timeout Milliseconds Number>
}
@returns via cbk or Promise
Example:
const {addPeer} = require('ln-service');
const socket = hostIp + ':' + portNumber;
await addPeer({lnd, socket, public_key: publicKeyHexString});
authenticatedLndGrpc
Initiate a gRPC API Methods Object for authenticated methods
Both the cert and macaroon expect the entire serialized LND generated file
{
[cert]: <Base64 or Hex Serialized LND TLS Cert>
[macaroon]: <Base64 or Hex Serialized Macaroon String>
[socket]: <Host:Port String>
}
@throws
<Error>
@returns
{
lnd: {
autopilot: <Autopilot API Methods Object>
chain: <ChainNotifier API Methods Object>
default: <Default API Methods Object>
invoices: <Invoices API Methods Object>
router: <Router API Methods Object>
signer: <Signer Methods API Object>
tower_client: <Watchtower Client Methods Object>
tower_server: <Watchtower Server Methods API Object>
wallet: <WalletKit gRPC Methods API Object>
version: <Version Methods API Object>
}
}
Example:
const lnService = require('ln-service');
const {lnd} = lnService.authenticatedLndGrpc({
cert: 'base64 encoded tls.cert',
macaroon: 'base64 encoded admin.macaroon',
socket: '127.0.0.1:10009',
});
const wallet = await lnService.getWalletInfo({lnd});
broadcastChainTransaction
Publish a raw blockchain transaction to Blockchain network peers
Requires LND built with walletrpc
tag
{
[description]: <Transaction Label String>
lnd: <Authenticated LND API Object>
transaction: <Transaction Hex String>
}
@returns via cbk or Promise
{
id: <Transaction Id Hex String>
}
Example:
const {broadcastChainTransaction} = require('ln-service');
const transaction = hexEncodedTransactionString;
// Broadcast transaction to the p2p network
const {id} = await broadcastChainTransaction({lnd, transaction});
cancelHodlInvoice
Cancel an invoice
This call can cancel both HODL invoices and also void regular invoices
Requires LND built with invoicesrpc
Requires invoices:write
permission
{
id: <Payment Preimage Hash Hex String>
lnd: <Authenticated RPC LND API Object>
}
Example:
const {cancelHodlInvoice} = require('ln-service');
const id = paymentRequestPreimageHashHexString;
await cancelHodlInvoice({id, lnd});
cancelPendingChannel
Cancel an external funding pending channel
{
id: <Pending Channel Id Hex String>
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
Example:
const {cancelPendingChannel, openChannels} = require('ln-service');
const channelsToOpen = [{capacity: 1e6, partner_public_key: publicKey}];
const {pending} = await openChannels({lnd, channels: channelsToOpen});
const [id] = pending;
// Cancel the pending channel open request
await cancelPendingChannel({id, lnd});
changePassword
Change wallet password
Requires locked LND and unauthenticated LND connection
{
current_password: <Current Password String>
lnd: <Unauthenticated LND API Object>
new_password: <New Password String>
}
@returns via cbk or Promise
Example:
const {changePassword} = require('ln-service');
await changePassword({lnd, current_password: pass, new_password: newPass});
closeChannel
Close a channel.
Either an id or a transaction id / transaction output index is required
If cooperatively closing, pass a public key and socket to connect
Requires info:read
, offchain:write
, onchain:write
, peers:write
permissions
{
[address]: <Request Sending Local Channel Funds To Address String>
[id]: <Standard Format Channel Id String>
[is_force_close]: <Is Force Close Bool>
lnd: <Authenticated LND API Object>
[public_key]: <Peer Public Key String>
[socket]: <Peer Socket String>
[target_confirmations]: <Confirmation Target Number>
[tokens_per_vbyte]: <Tokens Per Virtual Byte Number>
[transaction_id]: <Transaction Id Hex String>
[transaction_vout]: <Transaction Output Index Number>
}
@returns via cbk or Promise
{
transaction_id: <Closing Transaction Id Hex String>
transaction_vout: <Closing Transaction Vout Number>
}
Example:
const {closeChannel} = require('ln-service');
const closing = await closeChannel({id, lnd});
connectWatchtower
Connect to a watchtower
This method requires LND built with wtclientrpc
build tag
Requires offchain:write
permission
{
lnd: <Authenticated LND API Object>
public_key: <Watchtower Public Key Hex String>
socket: <Network Socket Address IP:PORT String>
}
Example:
const {connectWatchtower, getTowerServerInfo} = require('ln-service');
const {tower} = await getTowerServerInfo({lnd: towerServerLnd});
const [socket] = tower.sockets;
await connectWatchtower({lnd, socket, public_key: tower.public_key});
createChainAddress
Create a new receive address.
Requires address:write
permission
{
[format]: <Receive Address Type String> // "np2wpkh" || "p2wpkh"
[is_unused]: <Get As-Yet Unused Address Bool>
lnd: <Authenticated LND API Object>
}
Example:
const {createChainAddress} = require('ln-service');
const format = 'p2wpkh';
const {address} = await createChainAddress({format, lnd});
createHodlInvoice
Create HODL invoice. This invoice will not settle automatically when an HTLC arrives. It must be settled separately with the secret preimage.
Warning: make sure to cancel the created invoice before its CLTV timeout.
Requires LND built with invoicesrpc
tag
Requires address:write
, invoices:write
permission
{
[cltv_delta]: <Final CLTV Delta Number>
[description]: <Invoice Description String>
[description_hash]: <Hashed Description of Payment Hex String>
[expires_at]: <Expires At ISO 8601 Date String>
[id]: <Payment Hash Hex String>
[is_fallback_included]: <Is Fallback Address Included Bool>
[is_fallback_nested]: <Is Fallback Address Nested Bool>
[is_including_private_channels]: <Invoice Includes Private Channels Bool>
lnd: <Authenticated LND API Object>
[mtokens]: <Millitokens String>
[tokens]: <Tokens Number>
}
@returns via cbk or Promise
{
[chain_address]: <Backup Address String>
created_at: <ISO 8601 Date String>
description: <Description String>
id: <Payment Hash Hex String>
mtokens: <Millitokens String>
request: <BOLT 11 Encoded Payment Request String>
[secret]: <Hex Encoded Payment Secret String>
tokens: <Tokens Number>
}
Example:
const {createHash, randomBytes} = require('crypto');
const {createHodlInvoice, settleHodlInvoice} = require('ln-service');
const {subscribeToInvoice} = require('ln-service');
const randomSecret = () => randomBytes(32);
const sha256 = buffer => createHash('sha256').update(buffer).digest('hex');
// Choose an r_hash for this invoice, a single sha256, on say randomBytes(32)
const secret = randomSecret();
const id = sha256(secret);
// Supply an authenticatedLndGrpc object for an lnd built with invoicesrpc tag
const {request} = await createHodlInvoice({id, lnd});
// Share the request with the payer and wait for a payment
const sub = subscribeToInvoice({id, lnd});
sub.on('invoice_updated', async invoice => {
// Only actively held invoices can be settled
if (!invoice.is_held) {
return;
}
// Use the secret to claim the funds
await settleHodlInvoice({lnd, secret: secret.toString('hex')});
});
createInvoice
Create a Lightning invoice.
Requires address:write
, invoices:write
permission
payment
is not supported on LND 0.11.1 and below
{
[cltv_delta]: <CLTV Delta Number>
[description]: <Invoice Description String>
[description_hash]: <Hashed Description of Payment Hex String>
[expires_at]: <Expires At ISO 8601 Date String>
[is_fallback_included]: <Is Fallback Address Included Bool>
[is_fallback_nested]: <Is Fallback Address Nested Bool>
[is_including_private_channels]: <Invoice Includes Private Channels Bool>
lnd: <Authenticated LND API Object>
[secret]: <Payment Preimage Hex String>
[mtokens]: <Millitokens String>
[tokens]: <Tokens Number>
}
@returns via cbk or Promise
{
[chain_address]: <Backup Address String>
created_at: <ISO 8601 Date String>
[description]: <Description String>
id: <Payment Hash Hex String>
[mtokens]: <Millitokens String>
[payment]: <Payment Identifying Secret Hex String>
request: <BOLT 11 Encoded Payment Request String>
secret: <Hex Encoded Payment Secret String>
[tokens]: <Tokens Number>
}
Example:
const {createInvoice} = require('ln-service');
// Create a zero value invoice
const invoice = await createInvoice({lnd});
createSeed
Create a wallet seed
Requires unlocked lnd and unauthenticated LND API Object
{
lnd: <Unauthenticated LND API Object>
[passphrase]: <Seed Passphrase String>
}
@returns via cbk or Promise
{
seed: <Cipher Seed Mnemonic String>
}
Example:
const {createSeed, createWallet} = require('ln-service');
const {seed} = await createSeed({lnd});
// Use the seed to create a wallet
await createWallet({lnd, seed, password: '123456'});
createSignedRequest
Assemble a signed payment request
{
destination: <Destination Public Key Hex String>
hrp: <Request Human Readable Part String>
signature: <Request Hash Signature Hex String>
tags: [<Request Tag Word Number>]
}
@throws
<Error>
@returns
{
request: <BOLT 11 Encoded Payment Request String>
}
Example:
const {createSignedRequest} = require('ln-service');
// Get hrp and signature from createUnsignedRequest
// Get signature via standard private key signing, or LND signBytes
const {request} = createSignedRequest({
destination: nodePublicKey,
hrp: amountAndNetworkHrp,
signature: signedPreimageHash,
tags: paymentRequestTags,
});
createUnsignedRequest
Create an unsigned payment request
{
[chain_addresses]: [<Chain Address String>]
[cltv_delta]: <CLTV Delta Number>
[created_at]: <Invoice Creation Date ISO 8601 String>
[description]: <Description String>
[description_hash]: <Description Hash Hex String>
destination: <Public Key String>
[expires_at]: <ISO 8601 Date String>
features: [{
bit: <BOLT 09 Feature Bit Number>
}]
id: <Preimage SHA256 Hash Hex String>
[mtokens]: <Requested Milli-Tokens Value String> (can exceed Number limit)
network: <Network Name String>
[payment]: <Payment Identifier Hex String>
[routes]: [[{
[base_fee_mtokens]: <Base Fee Millitokens String>
[channel]: <Standard Format Channel Id String>
[cltv_delta]: <Final CLTV Expiration Blocks Delta Number>
[fee_rate]: <Fees Charged in Millitokens Per Million Number>
public_key: <Forward Edge Public Key Hex String>
}]]
[tokens]: <Requested Chain Tokens Number> (note: can differ from mtokens)
}
@returns
{
hash: <Payment Request Signature Hash Hex String>
hrp: <Human Readable Part of Payment Request String>
preimage: <Signature Hash Preimage Hex String>
tags: [<Data Tag Number>]
}
Example:
const {createUnsignedRequest} = require('ln-service');
const unsignedComponents = createUnsignedRequest({
destination: nodePublicKey,
id: rHashHexString,
network: 'bitcoin',
});
// Use createSignedRequest and a signature to create a complete request
createWallet
Create a wallet
Requires unlocked lnd and unauthenticated LND API Object
{
lnd: <Unauthenticated LND API Object>
[passphrase]: <AEZSeed Encryption Passphrase String>
password: <Wallet Password String>
seed: <Seed Mnemonic String>
}
@returns via cbk or Promise
{
macaroon: <Base64 Encoded Admin Macaroon String>
}
Example:
const {createWallet} = require('ln-service');
const {seed} = await createSeed({lnd});
await createWallet({lnd, seed, password: 'password'});
decodePaymentRequest
Get decoded payment request
Requires offchain:read
permission
{
lnd: <Authenticated LND API Object>
request: <BOLT 11 Payment Request String>
}
@returns via cbk or Promise
{
chain_address: <Fallback Chain Address String>
[cltv_delta]: <Final CLTV Delta Number>
created_at: <Payment Request Created At ISO 8601 Date String>
description: <Payment Description String>
description_hash: <Payment Longer Description Hash Hex String>
destination: <Public Key Hex String>
expires_at: <ISO 8601 Date String>
features: [{
bit: <BOLT 09 Feature Bit Number>
is_known: <Feature is Known Bool>
is_required: <Feature Support is Required To Pay Bool>
type: <Feature Type String>
}]
id: <Payment Hash Hex String>
is_expired: <Invoice is Expired Bool>
mtokens: <Requested Millitokens String>
[payment]: <Payment Identifier Hex Encoded String>
routes: [[{
[base_fee_mtokens]: <Base Routing Fee In Millitokens String>
[channel]: <Standard Format Channel Id String>
[cltv_delta]: <CLTV Blocks Delta Number>
[fee_rate]: <Fee Rate In Millitokens Per Million Number>
public_key: <Forward Edge Public Key Hex String>
}]]
safe_tokens: <Requested Tokens Rounded Up Number>
tokens: <Requested Tokens Rounded Down Number>
}
Example:
const {decodePaymentRequest} = require('ln-service');
const request = 'bolt11EncodedPaymentRequestString';
const details = await decodePaymentRequest({lnd, request});
deleteFailedPayAttempts
Delete failed payment attempt records
Requires offchain:write
permission
Method not supported on LND 0.12.1 or below
id
is not supported on LND 0.13.4 or below
{
[id]: <Delete Only Failed Attempt Records For Payment With Hash Hex String>
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
Example:
const {deleteFailedPayAttempts} = require('ln-service');
// Eliminate all the records of past failed payment attempts
await deleteFailedPayAttempts({lnd});
deleteFailedPayments
Delete failed payment records
Requires offchain:write
permission
Method not supported on LND 0.12.1 or below
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
Example:
const {deleteFailedPayments} = require('ln-service');
// Eliminate all the records of past failed payments
await deleteFailedPayments({lnd});
deleteForwardingReputations
Delete all forwarding reputations
Requires offchain:write
permission
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
Example:
const {deleteForwardingReputations} = require('ln-service');
// Delete all routing reputations to clear pathfinding memory
await deleteForwardingReputations({});
deletePayment
Delete a payment record
Requires offchain:write
permission
Note: this method is not supported on LND 0.13.4 and below
{
id: <Payment Preimage Hash Hex String>
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
Example:
const {deletePayment} = require('ln-service');
// Eliminate the records of a payment
await deletePayment({id, lnd});
deletePayments
Delete all records of payments
Requires offchain:write
permission
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
Example:
const {deletePayments} = require('ln-service');
// Eliminate all the records of past payments
await deletePayments({lnd});
deletePendingChannel
Delete a pending channel
Pass the confirmed conflicting transaction that spends the same input to make sure that no funds are being deleted.
This method is not supported on LND 0.13.3 and below
{
confirmed_transaction: <Hex Encoded Conflicting Transaction String>
lnd: <Authenticated LND API Object>
pending_transaction: <Hex Encoded Pending Transaction String>
pending_transaction_vout: <Pending Channel Output Index Number>
}
@returns via cbk or Promise
const {deletePendingChannel} = require('ln-service');
// Delete a stuck pending channel
await deletePendingChannel({
lnd,
confirmed_transaction: confirmedTransactionHex,
pending_transaction: stuckPendingChannelOpenTxHex,
pending_transaction_vout: pendingChannelOutputIndexNumber,
});
diffieHellmanComputeSecret
Derive a shared secret
Key family and key index default to 6 and 0, which is the node identity key
Requires LND built with signerrpc
build tag
Requires signer:generate
permission
{
[key_family]: <Key Family Number>
[key_index]: <Key Index Number>
lnd: <Authenticated LND API Object>
partner_public_key: <Public Key Hex String>
}
@returns via cbk or Promise
{
secret: <Shared Secret Hex String>
}
disableChannel
Mark a channel as temporarily disabled for outbound payments and forwards
Note: this method is not supported in LND versions 0.12.1 and below
Requires offchain:write
permission
{
lnd: <Authenticated LND API Object>
transaction_id: <Channel Funding Transaction Id Hex String>
transaction_vout: <Channel Funding Transaction Output Index Number>
}
@returns via cbk or Promise
Example:
const {disableChannel} = await require('ln-service');
const [channel] = (await getChannels({lnd})).channels;
// Disable outgoing traffic via the channel
await disableChannel({
lnd,
transaction_id: channel.transaction_id,
transaction_vout: channel.transaction_vout,
});
disconnectWatchtower
Disconnect a watchtower
Requires LND built with wtclientrpc
build tag
Requires offchain:write
permission
{
lnd: <Authenticated LND API Object>
public_key: <Watchtower Public Key Hex String>
}
@returns via cbk or Promise
const {disconnectWatchtower, getConnectedWatchtowers} = require('ln-service');
const [tower] = (await getConnectedWatchtowers({lnd})).towers;
await disconnectWatchtower({lnd, public_key: tower.public_key});
enableChannel
Mark a channel as enabled for outbound payments and forwards
Setting is_force_enable
will prevent future automated disabling/enabling
Note: this method is not supported in LND versions 0.12.1 and below
Requires offchain:write
permission
{
[is_force_enable]: <Force Channel Enabled Bool>
lnd: <Authenticated LND API Object>
transaction_id: <Channel Funding Transaction Id Hex String>
transaction_vout: <Channel Funding Transaction Output Index Number>
}
@returns via cbk or Promise
Example:
const {enableChannel} = await require('ln-service');
const [channel] = (await getChannels({lnd})).channels;
// Enable outgoing traffic via the channel
await enableChannel({
lnd,
transaction_id: channel.transaction_id,
transaction_vout: channel.transaction_vout,
});
fundPendingChannels
Fund pending channels
Requires offchain:write
, onchain:write
permissions
{
channels: [<Pending Channel Id Hex String>]
funding: <Signed Funding Transaction PSBT Hex String>
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
const {fundPendingChannels, openChannels} = require('ln-service');
const channelsToOpen = [{capacity: 1e6, partner_public_key: publicKey}];
const {pending} = await openChannels({lnd, channel: channelsToOpen});
const channels = pending.map(n => n.id);
// Fund the pending open channels request
await fundPendingChannels({channels, lnd, funding: psbt});
fundPsbt
Lock and optionally select inputs to a partially signed transaction
Specify outputs or PSBT with the outputs encoded
If there are no inputs passed, internal UTXOs will be selected and locked
Requires onchain:write
permission
Requires LND built with walletrpc
tag
This method is not supported in LND 0.11.1 and below
Specifying 0 for min_confirmations
is not supported in LND 0.13.0 and below
{
[fee_tokens_per_vbyte]: <Chain Fee Tokens Per Virtual Byte Number>
[inputs]: [{
transaction_id: <Unspent Transaction Id Hex String>
transaction_vout: <Unspent Transaction Output Index Number>
}]
lnd: <Authenticated LND API Object>
[min_confirmations]: <Spend UTXOs With Minimum Confirmations Number>
[outputs]: [{
address: <Chain Address String>
tokens: <Send Tokens Tokens Number>
}]
[target_confirmations]: <Confirmations To Wait Number>
[psbt]: <Existing PSBT Hex String>
}
@returns via cbk or Promise
{
inputs: [{
[lock_expires_at]: <UTXO Lock Expires At ISO 8601 Date String>
[lock_id]: <UTXO Lock Id Hex String>
transaction_id: <Unspent Transaction Id Hex String>
transaction_vout: <Unspent Transaction Output Index Number>
}]
outputs: [{
is_change: <Spends To a Generated Change Output Bool>
output_script: <Output Script Hex String>
tokens: <Send Tokens Tokens Number>
}]
psbt: <Unsigned PSBT Hex String>
}
Example:
const {fundPsbt} = require('ln-service');
const address = 'chainAddress';
const tokens = 1000000;
// Create an unsigned PSBT that sends 1mm to a chain address
const {psbt} = await fundPsbt({lnd, outputs: [{address, tokens}]});
// This PSBT can be used with signPsbt to sign and finalize for broadcast
getAccessIds
Get outstanding access ids given out
Note: this method is not supported in LND versions 0.11.1 and below
Requires macaroon:read
permission
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
ids: [<Root Access Id Number>]
}
Example:
const {getAccessIds, grantAccess} = require('ln-service');
// Create a macaroon that can be used to make off-chain payments
const {macaroon} = await grantAccess({lnd, id: '1', is_ok_to_pay: true});
// Get outstanding ids
const {ids} = await getAccessIds({lnd});
// The specified id '1' will appear in the ids array
getAutopilot
Get Autopilot status
Optionally, get the score of nodes as considered by the autopilot. Local scores reflect an internal scoring that includes local channel info
Permission info:read
is required
{
lnd: <Authenticated LND Object>
[node_scores]: [<Get Score For Public Key Hex String>]
}
@returns via cbk or Promise
{
is_enabled: <Autopilot is Enabled Bool>
nodes: [{
local_preferential_score: <Local-adjusted Pref Attachment Score Number>
local_score: <Local-adjusted Externally Set Score Number>
preferential_score: <Preferential Attachment Score Number>
public_key: <Node Public Key Hex String>
score: <Externally Set Score Number>
weighted_local_score: <Combined Weighted Locally-Adjusted Score Number>
weighted_score: <Combined Weighted Score Number>
}]
}
Example:
const {getAutopilot} = require('ln-service');
const isAutopilotEnabled = (await getAutopilot({lnd})).is_enabled;
getBackup
Get the static channel backup for a channel
Requires offchain:read
permission
{
lnd: <Authenticated LND API Object>
transaction_id: <Funding Transaction Id Hex String>
transaction_vout: <Funding Transaction Output Index Number>
}
@returns via cbk or Promise
{
backup: <Channel Backup Hex String>
}
Example:
const {getBackup, getChannels} = require('ln-service');
const [channel] = (await getChannels({lnd})).channels;
const {backup} = await getBackup({
lnd,
transaction_id: channel.transaction_id,
transaction_vout: channel.transaction_vout,
});
getBackups
Get all channel backups
Requires offchain:read
permission
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
backup: <All Channels Backup Hex String>
channels: [{
backup: <Individualized Channel Backup Hex String>
transaction_id: <Channel Funding Transaction Id Hex String>
transaction_vout: <Channel Funding Transaction Output Index Number>
}]
}
Example:
const {getBackups} = require('ln-service');
const {backup} = await getBackups({lnd});
getChainBalance
Get balance on the chain.
Requires onchain:read
permission
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
chain_balance: <Confirmed Chain Balance Tokens Number>
}
Example:
const {getChainBalance} = require('ln-service');
const chainBalance = (await getChainBalance({lnd})).chain_balance;
getChainFeeEstimate
Get a chain fee estimate for a prospective chain send
Requires onchain:read
permission
{
lnd: <Authenticated LND API Object>
send_to: [{
address: <Address String>
tokens: <Tokens Number>
}]
[target_confirmations]: <Target Confirmations Number>
}
@returns via cbk or Promise
{
fee: <Total Fee Tokens Number>
tokens_per_vbyte: <Fee Tokens Per VByte Number>
}
Example:
const {getChainFeeEstimate} = require('ln-service');
const sendTo = [{address: 'chainAddressString', tokens: 100000000}];
const {fee} = await getChainFeeEstimate({lnd, send_to: sendTo});
getChainFeeRate
Get chain fee rate estimate
Requires LND built with walletrpc
tag
Requires onchain:read
permission
{
[confirmation_target]: <Future Blocks Confirmation Number>
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
tokens_per_vbyte: <Tokens Per Virtual Byte Number>
}
Example:
const {getChainFeeRate} = require('ln-service');
const fee = (await getChainFeeRate({lnd, confirmation_target: 6})).tokens_per_vbyte;
getChainTransactions
Get chain transactions.
Requires onchain:read
permission
{
[after]: <Confirmed After Current Best Chain Block Height Number>
[before]: <Confirmed Before Current Best Chain Block Height Number>
lnd: <Authenticated LND Object>
}
@returns via cbk or Promise
{
transactions: [{
[block_id]: <Block Hash String>
[confirmation_count]: <Confirmation Count Number>
[confirmation_height]: <Confirmation Block Height Number>
created_at: <Created ISO 8601 Date String>
[description]: <Transaction Label String>
[fee]: <Fees Paid Tokens Number>
id: <Transaction Id String>
is_confirmed: <Is Confirmed Bool>
is_outgoing: <Transaction Outbound Bool>
output_addresses: [<Address String>]
tokens: <Tokens Including Fee Number>
[transaction]: <Raw Transaction Hex String>
}]
}
Example:
const {getChainTransactions} = require('ln-service');
const {transactions} = await getChainTransactions({lnd});
getChannelBalance
Get balance across channels.
Requires offchain:read
permission
channel_balance_mtokens
is not supported on LND 0.11.1 and below
inbound
and inbound_mtokens
are not supported on LND 0.11.1 and below
pending_inbound
is not supported on LND 0.11.1 and below
unsettled_balance
is not supported on LND 0.11.1 and below
unsettled_balance_mtokens
is not supported on LND 0.11.1 and below
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
channel_balance: <Channels Balance Tokens Number>
[channel_balance_mtokens]: <Channels Balance Millitokens String>
[inbound]: <Inbound Liquidity Tokens Number>
[inbound_mtokens]: <Inbound Liquidity Millitokens String>
pending_balance: <Pending On-Chain Channels Balance Tokens Number>
[pending_inbound]: <Pending On-Chain Inbound Liquidity Tokens Number>
[unsettled_balance]: <In-Flight Tokens Number>
[unsettled_balance_mtokens]: <In-Flight Millitokens String>
}
Example:
const {getChannelBalance} = require('ln-service');
const balanceInChannels = (await getChannelBalance({lnd})).channel_balance;
getChannel
Get graph information about a channel on the network
Requires info:read
permission
{
id: <Standard Format Channel Id String>
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
capacity: <Maximum Tokens Number>
id: <Standard Format Channel Id String>
policies: [{
[base_fee_mtokens]: <Base Fee Millitokens String>
[cltv_delta]: <Locktime Delta Number>
[fee_rate]: <Fees Charged Per Million Millitokens Number>
[is_disabled]: <Channel Is Disabled Bool>
[max_htlc_mtokens]: <Maximum HTLC Millitokens Value String>
[min_htlc_mtokens]: <Minimum HTLC Millitokens Value String>
public_key: <Node Public Key String>
[updated_at]: <Policy Last Updated At ISO 8601 Date String>
}]
transaction_id: <Transaction Id Hex String>
transaction_vout: <Transaction Output Index Number>
[updated_at]: <Last Update Epoch ISO 8601 Date String>
}
Example:
const {getChannel} = await require('ln-service');
const id = '0x0x0';
const channelDetails = await getChannel({id, lnd});
getChannels
Get channels
Requires offchain:read
permission
in_channel
, in_payment
, is_forward
, out_channel
, out_payment
,
payment
are not supported on LND 0.11.1 and below
{
[is_active]: <Limit Results To Only Active Channels Bool> // false
[is_offline]: <Limit Results To Only Offline Channels Bool> // false
[is_private]: <Limit Results To Only Private Channels Bool> // false
[is_public]: <Limit Results To Only Public Channels Bool> // false
lnd: <Authenticated LND gRPC API Object>
[partner_public_key]: <Only Channels With Public Key Hex String>
}
@returns via cbk or Promise
{
channels: [{
capacity: <Channel Token Capacity Number>
commit_transaction_fee: <Commit Transaction Fee Number>
commit_transaction_weight: <Commit Transaction Weight Number>
[cooperative_close_address]: <Coop Close Restricted to Address String>
[cooperative_close_delay_height]: <Prevent Coop Close Until Height Number>
id: <Standard Format Channel Id String>
is_active: <Channel Active Bool>
is_closing: <Channel Is Closing Bool>
is_opening: <Channel Is Opening Bool>
is_partner_initiated: <Channel Partner Opened Channel Bool>
is_private: <Channel Is Private Bool>
local_balance: <Local Balance Tokens Number>
[local_csv]: <Local CSV Blocks Delay Number>
[local_dust]: <Remote Non-Enforceable Amount Tokens Number>
[local_given]: <Local Initially Pushed Tokens Number>
[local_max_htlcs]: <Local Maximum Attached HTLCs Number>
[local_max_pending_mtokens]: <Local Maximum Pending Millitokens String>
[local_min_htlc_mtokens]: <Local Minimum HTLC Millitokens String>
local_reserve: <Local Reserved Tokens Number>
partner_public_key: <Channel Partner Public Key String>
past_states: <Total Count of Past Channel States Number>
pending_payments: [{
id: <Payment Preimage Hash Hex String>
[in_channel]: <Forward Inbound From Channel Id String>
[in_payment]: <Payment Index on Inbound Channel Number>
[is_forward]: <Payment is a Forward Bool>
is_outgoing: <Payment Is Outgoing Bool>
[out_channel]: <Forward Outbound To Channel Id String>
[out_payment]: <Payment Index on Outbound Channel Number>
[payment]: <Payment Attempt Id Number>
timeout: <Chain Height Expiration Number>
tokens: <Payment Tokens Number>
}]
received: <Received Tokens Number>
remote_balance: <Remote Balance Tokens Number>
[remote_csv]: <Remote CSV Blocks Delay Number>
[remote_dust]: <Remote Non-Enforceable Amount Tokens Number>
[remote_given]: <Remote Initially Pushed Tokens Number>
[remote_max_htlcs]: <Remote Maximum Attached HTLCs Number>
[remote_max_pending_mtokens]: <Remote Maximum Pending Millitokens String>
[remote_min_htlc_mtokens]: <Remote Minimum HTLC Millitokens String>
remote_reserve: <Remote Reserved Tokens Number>
sent: <Sent Tokens Number>
[time_offline]: <Monitoring Uptime Channel Down Milliseconds Number>
[time_online]: <Monitoring Uptime Channel Up Milliseconds Number>
transaction_id: <Blockchain Transaction Id String>
transaction_vout: <Blockchain Transaction Vout Number>
unsettled_balance: <Unsettled Balance Tokens Number>
}]
}
Example:
const {getChannels} = require('ln-service');
// Get the channels and count how many there are
const channelsCount = (await getChannels({lnd})).length;
getClosedChannels
Get closed out channels
Multiple close type flags are supported.
Requires offchain:read
permission
{
[is_breach_close]: <Only Return Breach Close Channels Bool>
[is_cooperative_close]: <Only Return Cooperative Close Channels Bool>
[is_funding_cancel]: <Only Return Funding Canceled Channels Bool>
[is_local_force_close]: <Only Return Local Force Close Channels Bool>
[is_remote_force_close]: <Only Return Remote Force Close Channels Bool>
lnd: <Authenticated LND gRPC API Object>
}
@returns via cbk or Promise
{
channels: [{
capacity: <Closed Channel Capacity Tokens Number>
[close_balance_spent_by]: <Channel Balance Output Spent By Tx Id String>
[close_balance_vout]: <Channel Balance Close Tx Output Index Number>
close_payments: [{
is_outgoing: <Payment Is Outgoing Bool>
is_paid: <Payment Is Claimed With Preimage Bool>
is_pending: <Payment Resolution Is Pending Bool>
is_refunded: <Payment Timed Out And Went Back To Payer Bool>
[spent_by]: <Close Transaction Spent By Transaction Id Hex String>
tokens: <Associated Tokens Number>
transaction_id: <Transaction Id Hex String>
transaction_vout: <Transaction Output Index Number>
}]
[close_confirm_height]: <Channel Close Confirmation Height Number>
[close_transaction_id]: <Closing Transaction Id Hex String>
final_local_balance: <Channel Close Final Local Balance Tokens Number>
final_time_locked_balance: <Closed Channel Timelocked Tokens Number>
[id]: <Closed Standard Format Channel Id String>
is_breach_close: <Is Breach Close Bool>
is_cooperative_close: <Is Cooperative Close Bool>
is_funding_cancel: <Is Funding Cancelled Close Bool>
is_local_force_close: <Is Local Force Close Bool>
[is_partner_closed]: <Channel Was Closed By Channel Peer Bool>
[is_partner_initiated]: <Channel Was Initiated By Channel Peer Bool>
is_remote_force_close: <Is Remote Force Close Bool>
partner_public_key: <Partner Public Key Hex String>
transaction_id: <Channel Funding Transaction Id Hex String>
transaction_vout: <Channel Funding Output Index Number>
}]
}
Example:
const {getClosedChannels} = require('ln-service');
const breachCount = await getClosedChannels({lnd, is_breach_close: true});
getConnectedWatchtowers
Get a list of connected watchtowers and watchtower info
Requires LND built with wtclientrpc
build tag
Requires offchain:read
permission
Includes previously connected watchtowers
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
max_session_update_count: <Maximum Updates Per Session Number>
sweep_tokens_per_vbyte: <Sweep Tokens per Virtual Byte Number>
backups_count: <Total Backups Made Count Number>
failed_backups_count: <Total Backup Failures Count Number>
finished_sessions_count: <Finished Updated Sessions Count Number>
pending_backups_count: <As Yet Unacknowledged Backup Requests Count Number>
sessions_count: <Total Backup Sessions Starts Count Number>
towers: [{
is_active: <Tower Can Be Used For New Sessions Bool>
public_key: <Identity Public Key Hex String>
sessions: [{
backups_count: <Total Successful Backups Made Count Number>
max_backups_count: <Backups Limit Number>
pending_backups_count: <Backups Pending Acknowledgement Count Number>
sweep_tokens_per_vbyte: <Fee Rate in Tokens Per Virtual Byte Number>
}]
sockets: [<Tower Network Address IP:Port String>]
}]
}
Example:
const {getConnectedWatchtowers} = require('ln-service');
const {towers} = (await getConnectedWatchtowers({lnd}));
getFailedPayments
Get failed payments made through channels.
Requires offchain:read
permission
{
[limit]: <Page Result Limit Number>
lnd: <Authenticated LND API Object>
[token]: <Opaque Paging Token String>
}
@returns via cbk or Promise
{
payments: [{
attempts: [{
[failure]: {
code: <Error Type Code Number>
[details]: {
[channel]: <Standard Format Channel Id String>
[height]: <Error Associated Block Height Number>
[index]: <Failed Hop Index Number>
[mtokens]: <Error Millitokens String>
[policy]: {
base_fee_mtokens: <Base Fee Millitokens String>
cltv_delta: <Locktime Delta Number>
fee_rate: <Fees Charged in Millitokens Per Million Number>
[is_disabled]: <Channel is Disabled Bool>
max_htlc_mtokens: <Maximum HLTC Millitokens Value String>
min_htlc_mtokens: <Minimum HTLC Millitokens Value String>
updated_at: <Updated At ISO 8601 Date String>
}
[timeout_height]: <Error CLTV Timeout Height Number>
[update]: {
chain: <Chain Id Hex String>
channel_flags: <Channel Flags Number>
extra_opaque_data: <Extra Opaque Data Hex String>
message_flags: <Message Flags Number>
signature: <Channel Update Signature Hex String>
}
}
message: <Error Message String>
}
[index]: <Payment Add Index Number>
[confirmed_at]: <Payment Confirmed At ISO 8601 Date String>
is_confirmed: <Payment Attempt Succeeded Bool>
is_failed: <Payment Attempt Failed Bool>
is_pending: <Payment Attempt is Waiting For Resolution Bool>
route: {
fee: <Route Fee Tokens Number>
fee_mtokens: <Route Fee Millitokens String>
hops: [{
channel: <Standard Format Channel Id String>
channel_capacity: <Channel Capacity Tokens Number>
fee: <Fee Number>
fee_mtokens: <Fee Millitokens String>
forward: <Forward Tokens Number>
forward_mtokens: <Forward Millitokens String>
[public_key]: <Forward Edge Public Key Hex String>
[timeout]: <Timeout Block Height Number>
}]
mtokens: <Total Fee-Inclusive Millitokens String>
[payment]: <Payment Identifier Hex String>
timeout: <Timeout Block Height Number>
tokens: <Total Fee-Inclusive Tokens Number>
[total_mtokens]: <Total Millitokens String>
}
}]
created_at: <Payment at ISO-8601 Date String>
[destination]: <Destination Node Public Key Hex String>
id: <Payment Preimage Hash String>
[index]: <Payment Add Index Number>
is_confirmed: <Payment is Confirmed Bool>
is_outgoing: <Transaction Is Outgoing Bool>
mtokens: <Millitokens Attempted to Pay to Destination String>
[request]: <BOLT 11 Payment Request String>
safe_tokens: <Payment Tokens Attempted to Pay Rounded Up Number>
tokens: <Rounded Down Tokens Attempted to Pay to Destination Number>
}]
[next]: <Next Opaque Paging Token String>
}
getFeeRates
Get a rundown on fees for channels
Requires offchain:read
permission
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
channels: [{
base_fee: <Base Flat Fee Tokens Rounded Up Number>
base_fee_mtokens: <Base Flat Fee Millitokens String>
id: <Standard Format Channel Id String>
transaction_id: <Channel Funding Transaction Id Hex String>
transaction_vout: <Funding Outpoint Output Index Number>
}]
}
Example:
const {getFeeRates} = require('ln-service');
const {channels} = await getFeeRates({lnd});
getForwardingConfidence
Get the confidence in being able to send between a direct pair of nodes
{
from: <From Public Key Hex String>
lnd: <Authenticated LND gRPC API Object>
mtokens: <Millitokens To Send String>
to: <To Public Key Hex String>
}
@returns via cbk or Promise
{
confidence: <Success Confidence Score Out Of One Million Number>
}
Example:
const {getForwardingConfidence} = require('ln-service');
const from = nodeAPublicKey;
const mtokens = '10000';
const to = nodeBPublicKey;
// Given two nodes, get confidence score out of 1,000,000 in forwarding success
const {confidence} = await getForwardingConfidence({from, lnd, mtokens, to});
getForwardingReputations
Get the set of forwarding reputations
Requires offchain:read
permission
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
nodes: [{
peers: [{
[failed_tokens]: <Failed to Forward Tokens Number>
[forwarded_tokens]: <Forwarded Tokens Number>
[last_failed_forward_at]: <Failed Forward At ISO-8601 Date String>
[last_forward_at]: <Forwarded At ISO 8601 Date String>
to_public_key: <To Public Key Hex String>
}]
public_key: <Node Identity Public Key Hex String>
}]
}
const {getForwardingReputations} = require('ln-service');
const {nodes} = await getForwardingReputations({lnd});
getForwards
Get forwarded payments, from oldest to newest
When using an "after" date a "before" date is required.
If a next token is returned, pass it to get additional page of results.
Requires offchain:read
permission
{
[after]: <Get Only Payments Forwarded At Or After ISO 8601 Date String>
[before]: <Get Only Payments Forwarded Before ISO 8601 Date String>
[limit]: <Page Result Limit Number>
lnd: <Authenticated LND API Object>
[token]: <Opaque Paging Token String>
}
@returns via cbk or Promise
{
forwards: [{
created_at: <Forward Record Created At ISO 8601 Date String>
fee: <Fee Tokens Charged Number>
fee_mtokens: <Approximated Fee Millitokens Charged String>
incoming_channel: <Incoming Standard Format Channel Id String>
mtokens: <Forwarded Millitokens String>
outgoing_channel: <Outgoing Standard Format Channel Id String>
tokens: <Forwarded Tokens Number>
}]
[next]: <Contine With Opaque Paging Token String>
}
Example:
const {getForwards} = require('ln-service');
const {forwards} = await getForwards({lnd});
getHeight
Lookup the current best block height
LND with chainrpc
build tag and onchain:read
permission is suggested
Otherwise, info:read
permission is required
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
current_block_hash: <Best Chain Hash Hex String>
current_block_height: <Best Chain Height Number>
}
Example:
const {getHeight} = require('ln-service');
// Check for the current best chain block height
const height = (await getHeight({lnd})).current_block_height;
getIdentity
Lookup the identity key for a node
LND with walletrpc
build tag and address:read
permission is suggested
Otherwise, info:read
permission is required
{
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
public_key: <Node Identity Public Key Hex String>
}
Example:
const {getIdentity} = require('ln-service');
// Derive the identity public key of the backing LND node
const nodePublicKey = (await getIdentity({lnd})).public_key;
getInvoice
Lookup a channel invoice.
The received value and the invoiced value may differ as invoices may be over-paid.
Requires invoices:read
permission
payment
is not supported on LND 0.11.1 and below
{
id: <Payment Hash Id Hex String>
lnd: <Authenticated LND API Object>
}
@returns via cbk or Promise
{
[chain_address]: <Fallback Chain Address String>
cltv_delta: <CLTV Delta Number>
[confirmed_at]: <Settled at ISO 8601 Date String>
created_at: <ISO 8601 Date String>
description: <Description String>
[description_hash]: <Description Hash Hex String>
expires_at: <ISO 8601 Date String>
features: [{
bit: <BOLT 09 Feature Bit Number>
is_known: <Feature is Known Bool>
is_required: <Feature Support is Required To Pay Bool>
type: <Feature Type String>
}]
id: <Payment Hash String>
[is_canceled]: <Invoice is Canceled Bool>
is_confirmed: <Invoice is Confirmed Bool>
[is_held]: <HTLC is Held Bool>
is_private: <Invoice is Private Bool>
[is_push]: <Invoice is Push Payment Bool>
mtokens: <Millitokens String>
[payment]: <Payment Identifying Secret Hex String>
payments: [{
[confirmed_at]: <Payment Settled At ISO 8601 Date String>
created_at: <Payment Held Since ISO 860 Date String>
created_height: <Payment Held Since Block Height Number>
in_channel: <Incoming Payment Through Channel Id String>
is_canceled: <Payment is Canceled Bool>
is_confirmed: <Payment is Confirmed Bool>
is_held: <Payment is Held Bool>
messages: [{
type: <Message Type Number String>
value: <Raw Value Hex String>
}]
mtokens: <Incoming Payment Millitokens String>
[pending_index]: <Pending Payment Channel HTLC Index Number>
timeout: <HTLC CLTV Timeout Height Number>
tokens: <Payment Tokens Number>
}]
received: <Received Tokens Number>
received_mtokens: <Received Millitokens String>
[request]: <Bolt 11 Invoice String>
secret: <Secret Preimage Hex String>
tokens: <Tokens Number>
}
Example:
const {getInvoice} = require('ln-service');
const invoiceDetails = await getInvoice({id, lnd});
getInvoices
Get all created invoices.
If a next token is returned, pass it to get another page of invoices.
Requires invoices:read
permission
Invoice payment
is not supported on LND 0.11.1 and below
{
[is_unconfirmed]: <Omit Canceled and Settled Invoices Bool>
[limit]: <Page Result Limit Number>
lnd: <Authenticated LND API Object>
[token]: <Opaque Paging Token String>
}
@returns via cbk or Promise
{
invoices: [{
[chain_address]: <Fallback Chain Address String>
cltv_delta: <Final CLTV Delta Number>
[confirmed_at]: <Settled at ISO 8601 Date String>
[confirmed_index]: <Confirmed Index Number>
created_at: <ISO 8601 Date String>
description: <Description String>
[description_hash]: <Description Hash Hex String>
expires_at: <ISO 8601 Date String>
features: [{
bit: <BOLT 09 Feature Bit Number>
is_known: <Feature is Known Bool>
is_required: <Feature Support is Required To Pay Bool>
type: <Feature Type String>
}]
id: <Payment Hash Hex String>
index: <Index Number>
[is_canceled]: <Invoice is Canceled Bool>
is_confirmed: <Invoice is Confirmed Bool>
[is_held]: <HTLC is Held Bool>
is_private: <Invoice is Private Bool>
[is_push]: <Invoice is Push Payment Bool>
mtokens: <Millitokens String>
[payment]: <Payment Identifying Secret Hex String>
payments: [{
[canceled_at]: <Payment Canceled At ISO 8601 Date String>
[confirmed_at]: <Payment Settled At ISO 8601 Date String>
created_at: <Payment Held Since ISO 860 Date String>
created_height: <Payment Held Since Block Height Number>
in_channel: <Incoming Payment Through Channel Id String>
is_canceled: <Payment is Canceled Bool>
is_confirmed: <Payment is Confirmed Bool>
is_held: <Payment is Held Bool>
messages: [{
type: <Message Type Number String>
value: <Raw Value Hex String>
}]
mtokens: <Incoming Payment Millitokens String>
[pending_index]: <Pending Payment Channel HTLC Index Number>
timeout: <HTLC CLTV Timeout Height Number>
tokens: <Payment Tokens Number>
[total_mtokens]: <Total Millitokens String>
}]
received: <Received Tokens Number>
received_mtokens: <Received Millitokens String>
[request]: <Bolt 11 Invoice String>
secret: <Secret Preimage Hex String>
tokens: <Tokens Number>
}]
[next]: <Next Opaque Paging Token String>
}
Example:
const {getInvoices} = require('ln-service');
const {invoices} = await getInvoices({lnd});
getLockedUtxos
Get locked unspent transaction outputs
Requires onchain:read
permission
Requires LND built with walletrpc
build tag
This method is not supported on