0.1.1 • Published 19h ago
fake-bolt11
Licence
MIT
Version
0.1.1
Deps
2
Size
47 kB
Vulns
0
Weekly
0
fake-bolt11
Generate fake but spec-compliant BOLT11 Lightning invoices for testing purposes.
Installation
npm install fake-bolt11
# or
bun add fake-bolt11
# or
pnpm add fake-bolt11
Usage
import { createFakeInvoice } from "fake-bolt11";
// Create a simple invoice for 100 sats
const invoice = createFakeInvoice(100);
console.log(invoice);
// lnbc1u1p5j...
// With options
const customInvoice = createFakeInvoice(1000, {
network: "tb", // 'bc' (mainnet), 'tb' (testnet), 'bcrt' (regtest), 'tbs' (signet)
description: "Coffee",
expiry: 600, // 10 minutes
timestamp: 1234567890, // Custom timestamp
});
API
createFakeInvoice(amountSats, options?)
Creates a fake but spec-compliant BOLT11 invoice.
Parameters
amountSats(number): Amount in satoshisoptions(optional):network: Network prefix -'bc'(mainnet),'tb'(testnet),'bcrt'(regtest),'tbs'(signet). Default:'bc'description: Invoice description. Default:'Test invoice'expiry: Expiry in whole seconds from0throughNumber.MAX_SAFE_INTEGER. Default:3600(1 hour)paymentHash: 32-byte payment hash as hex string. Default: randompaymentSecret: 32-byte payment secret as hex string. Default: randomtimestamp: Unix timestamp in seconds. Default: current timeprivateKey: 32-byte private key for signing as hex string. Default: random
Returns
A BOLT11 encoded invoice string.
Notes
- Generated invoices have valid cryptographic signatures
- They cannot be paid on a real Lightning Network since the destination node doesn't exist
- Useful for testing melt quote creation, invoice parsing, and payment flows
License
MIT