# invoices

> Methods for working with BOLT 11 payment requests

Latest version **6.1.4** (published 2026-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install invoices
pnpm add invoices
yarn add invoices
bun add invoices
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 6.1.4 |
| Published | 2026-08-28 |
| First published | 2020-01-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=22 |
| Dependencies | 5 |
| Unpacked size | 140.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Alex Bosworth |
| Maintainers | alexbosworth |
| Keywords | bolt11, invoice, lightning, lightning-network, payment-request |

## Links

- npm: https://www.npmjs.com/package/invoices
- Repository: https://github.com/alexbosworth/invoices
- Homepage: https://github.com/alexbosworth/invoices#readme
- Issues: https://github.com/alexbosworth/invoices/issues
- npm.io page: https://npm.io/package/invoices

## Dependencies (5)

- [bech32](https://npm.io/package/bech32.md) 2.0.0
- [bolt07](https://npm.io/package/bolt07.md) 2.0.0
- [bolt09](https://npm.io/package/bolt09.md) 3.0.0
- [tiny-secp256k1](https://npm.io/package/tiny-secp256k1.md) 2.2.4
- [@alexbosworth/blockchain](https://npm.io/package/@alexbosworth/blockchain.md) 4.5.3

## Recent versions

- 6.1.4 (latest) — 2026-08-28
- 6.1.3 — 2026-08-22
- 6.1.2 — 2026-08-22
- 6.1.1 — 2026-08-21
- 6.1.0 — 2026-08-13
- 6.0.5 — 2026-08-10
- 6.0.4 — 2026-08-10
- 6.0.3 — 2026-08-10
- 6.0.2 — 2026-08-10
- 6.0.1 — 2026-08-10
- 6.0.0 — 2026-08-07
- 5.0.2 — 2026-02-21
- 5.0.1 — 2026-02-21
- 5.0.0 — 2026-01-22
- 4.0.0 — 2025-04-30
- … 29 more at https://npm.io/package/invoices/versions

## README

# Invoices

Utility methods for parsing Lightning Network BOLT 11 payment requests, as well
as encoding unsigned requests and signing payment requests.

## Methods

### byteDecodeRequest

Derive a payment request from request data.

    {
      encoded: <Payment Request Details Hex String>
      [mtokens]: <Millitokens Number String>
      network: <Network Name String>
      words: <Words Count Number>
    }

    @throws
    <Error>

    @returns
    {
      request: <BOLT 11 Encoded Payment Request String>
    }

Example:

```node
const {byteDecodeRequest} = require('invoices');

// Get a BOLT 11 payment request for this invoice data
const {request} = byteDecodeRequest({
  encoded: paymentRequestDetailsHexString,
  mtokens: '0',
  network: 'bitcoin',
});
```

### byteEncodeRequest

Derive bytes for payment request details

    {
      request: <BOLT 11 Encoded Payment Request String>
    }

    @throws
    <Error>

    @returns
    {
      encoded: <Payment Request Details Hex String>
      mtokens: <Millitokens Number String>
      network: <Network Name String>
      words: <Word Length Number>
    }

Example:

```node
const {byteEncodeRequest} = require('invoices');

// Get the bytes for a payment request
const {encoded, mtokens, network} = byteEncodeRequest({
  request: bolt11EncodedPaymentRequestString,
});
```

### 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:

```node
const {createSignedRequest} = require('invoices');

// 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]: <Fee Rate 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:

```node
const {createUnsignedRequest} = require('invoices');

const unsignedComponents = createUnsignedRequest({
  destination: nodePublicKey,
  id: rHashHexString,
  network: 'bitcoin',
});
// Use createSignedRequest and a signature to create a complete request
```

### parsePaymentRequest

Parse a BOLT 11 payment request into its component data

Note: either description or description_hash will be returned

    {
      request: <BOLT 11 Payment Request String>
    }

    @throws
    <Error>

    @returns
    {
      [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>
        is_required: <Feature Support is Required To Pay Bool>
        type: <Feature Type String>
      }]
      id: <Payment Request Hash String>
      is_expired: <Invoice is Expired Bool>
      [mtokens]: <Requested Milli-Tokens Value String> (can exceed Number limit)
      network: <Network Name String>
      [payment]: <Payment Identifier Hex Encoded 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]: <Fee Rate Millitokens Per Million Number>
        public_key: <Forward Edge Public Key Hex String>
      }]]
      [safe_tokens]: <Requested Chain Tokens Rounded Up Number>
      [tokens]: <Requested Chain Tokens Number> (note: can differ from mtokens)
    }

```node
const {parsePaymentRequest} = require('invoices');

// Decoded details of the payment request
const requestDetails = parsePaymentRequest({request: 'paymentRequestString'});
```

---
_Source: https://npm.io/package/invoices · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
