# fake-bolt11

Generate fake but spec-compliant [BOLT11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) Lightning invoices for testing purposes.

## Installation

```bash
npm install fake-bolt11
# or
bun add fake-bolt11
# or
pnpm add fake-bolt11
```

## Usage

```typescript
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 satoshis
- `options` (optional):
  - `network`: Network prefix - `'bc'` (mainnet), `'tb'` (testnet), `'bcrt'` (regtest), `'tbs'` (signet). Default: `'bc'`
  - `description`: Invoice description. Default: `'Test invoice'`
  - `expiry`: Expiry time in seconds. Default: `3600` (1 hour)
  - `paymentHash`: 32-byte payment hash as hex string. Default: random
  - `paymentSecret`: 32-byte payment secret as hex string. Default: random
  - `timestamp`: Unix timestamp in seconds. Default: current time
  - `privateKey`: 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
