npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

lnpay

v1.1.4

Published

NPM Package for LNPay.co API.

Downloads

22

Readme

LNPay NodeJS API

npm version NPM Known Vulnerabilities License: MIT


The goal of the LNPay API is to create a toolkit interface for interaction between nodes and external services.


Donate

Help me to stack sats! :blush:

Donate via Lightning Network!


Features


Installation

Using npm:

$ npm install lnpay

Using yarn:

$ yarn add lnpay

Usage

Initial Config

Initial LNPay configuration.

import LNPay from 'lnpay';

const lnpay = LNPay({
  secretKey: 'pak_O0iUMxk8kK_qUzkT4YKFvp1ZsUtp',
  walletAccessKey: 'waka_kqvaiFFl4Tjq4rgAXlwsu6',
});

Create Wallet

Create a new wallet and corresponding access keys.

Official Documentation / Code Example

Parameters:

  • {Object} params - Params object.
  • {string} params.user_label - An internal identifier for this
const wallet = await lnpay.createWallet({
  user_label: 'My Wallet',
});
console.log(wallet);

Get Balance

Returns info about the wallet, including balance.

Official Documentation / Code Example

const balance = await lnpay.getBalance();
console.log(balance);

Get Transactions

Get a list of wallet transactions that have been SETTLED. This includes only transactions that have an impact on wallet balance. These DO NOT include unsettled/unpaid invoices.

Official Documentation / Code Example

Parameters:

  • {Object} [params] - Params object.
  • {number} [params.page] - Page number.
const transactions = await lnpay.getTransactions({
  page: 1,
});
console.log(transactions);

Generate Invoice

Generate a new Invoice payment.

Official Documentation / Code Example

Parameters:

  • {Object} params - Params object.
  • {number} params.num_satoshis - The number of satoshis of the invoice.
  • {Object} [params.passThru] - JSON object. you can reference these parameters later via webhooks, etc. Good for ticket # or a certain ID.
  • {string} [params.description_hash] - base64 encoded hash of payment. If this is provided, memo will be ignored.
  • {Object} [params.memo] - Add a memo text.
  • {Object} [params.expiry] - Expires in seconds, defaults to 86400 (1 day)
const invoice = await lnpay.generateInvoice({
  num_satoshis: 100,
  passThru: {
    order_id: '100',
  },
  description_hash: 'MTIzNDY1Nzg5N...',
  memo: 'Invoice memo.',
  expiry: 86400, // 1 day
});
console.log(invoice);

Pay Invoice

Generate an LN payment invoice from the specified wallet.

Official Documentation / Code Example

Parameters:

  • {Object} params - Params object.
  • {string} params.payment_request - Payment request string.
  • {Object} [params.passThru] - JSON object of custom data to pass thru.
const payInvoice = await lnpay.payInvoice({
  payment_request: 'lnbc50n1p0qjf84p...',
  passThru: {
    order_id: '100',
  },
});
console.log(payInvoice);

Keysend

Initiate a keysend payment from your wallet to a destination pubkey.

Official Documentation / Code Example

Parameters:

  • {Object} params - Params object.
  • {number} params.dest_pubkey - Pubkey of destination node.
  • {Object} params.num_satoshis - The number of satoshis of the invoice.
  • {string} [params.passThru] - Data to pass along with this invoice for webhooks (e.g. ticketId, etc)
  • {Object} [params.custom_records] - key:value pairs to be sent in the onion. key must be an integer greater than 65536. value must be a string, encoded binary data is not supported. Too many values here will break things.
const keysend = await lnpay.keysend({
  passThru: {
    order_id: '100',
  },
  dest_pubkey: '033868c219bdb51a3...',
  num_satoshis: 1,
});
console.log(keysend);

Transfer Between Wallets

This section describes how to transfer sats between wallets within LNPay.

Official Documentation / Code Example

Parameters:

  • {Object} params - Params object.
  • {string} params.dest_wallet_id - Destination wallet access key (WAK) or wallet_id
  • {number} params.num_satoshis - Sats for this transfer
  • {string} params.memo - Memo note for this transfer
  • {string} params.lnPayParams - JSON array of custom data to pass thru.
const transfer = await lnpay.transfer({
  dest_wallet_id: 'w_n743yizWqe43Oz',
  num_satoshis: 1,
  memo: 'Transfer Memo',
  lnPayParams: {
    order_id: '100',
  },
});
console.log(transfer);

LN Url Withdraw

Generate an LNURL-withdraw link.

Official Documentation / Code Example

Parameters:

  • {Object} [params] - Params object.
  • {boolean} [params.public] - (default: false) if set to true, the LNURL will be a one-time allowable withdraw for the amount set with no sensitive data in the LNURL. Good for public use.
  • {string} [params.passThru] - Base64 encoded json of data to use in webhooks, etc
  • {string} [params.memo] - Memo note for the invoice.
  • {number} [params.num_satoshis] - Max number of satoshis this LNURL is good for. If blank max wallet balance is used.
const lnUrlWithdraw = await lnpay.lnUrlWithdraw({
  public: false,
  memo: 'LNURL Withdraw memo',
  num_satoshis: 3,
});
console.log(lnUrlWithdraw);

Get Invoice Status

Retrieve a LN transaction (invoice). This is usually used to see if a transaction has been settled or not, and for how much.

Official Documentation / Code Example

Parameters:

  • {Object} params - Params object.
  • {string} params.id - Transaction id. e.g. lntx_82yveCX2Wn0EkkdyzvyBv
const getInvoice = await lnpay.getInvoice({
  id: 'lntx_82yveCX2Wn0EkkdyzvyBv',
});
console.log(getInvoice);

Create Paywall

Retrieve a LN transaction (invoice). This is usually used to see if a transaction has been settled or not, and for how much.

Official Documentation / Code Example

Parameters:

  • {Object} params - Params object.
  • {string} params.destination_url
  • {string} params.memo
  • {string} params.short_url
  • {number} params.num_satoshis
const paywall = await lnpay.createPaywall({
  destination_url: 'https://bigsun.xyz',
  memo: 'This is my memo',
  short_url: 'bigsun',
  num_satoshis: 100,
});
console.log(paywall);

References


Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.


License

MIT