create_invoice
Generate a Lightning Network invoice to request Bitcoin payments, specifying amount and optional memo for transaction tracking.
Instructions
Create a Lightning invoice to receive payment. Use get_invoice_status to check if paid.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount_sats | Yes | Amount in satoshis to request | |
| memo | No | Description/memo for the invoice |
Implementation Reference
- src/index.ts:931-952 (handler)MCP tool request handler for 'create_invoice' in src/index.ts.
case 'create_invoice': { const parsed = CreateInvoiceSchema.parse(args); const result = await session.requireClient().createInvoice(parsed.amount_sats, parsed.memo); const invoiceResponse: Record<string, unknown> = { success: true, message: `Invoice created for ${parsed.amount_sats} sats`, bolt11: result.bolt11, payment_hash: result.paymentHash, expires_at: result.expiresAt, }; if (result.rawResponse?.tip) { invoiceResponse.tip = result.rawResponse.tip; } return { content: [ { type: 'text', text: JSON.stringify(invoiceResponse, null, 2), }, ], }; } - src/lightning-faucet.ts:302-332 (handler)Implementation of the 'createInvoice' method in the LightningFaucetClient class.
async createInvoice( amountSats: number, memo?: string ): Promise<{ bolt11: string; paymentHash: string; expiresAt: string; rawResponse: CreateInvoiceResponse; }> { const data: Record<string, unknown> = { amount_sats: amountSats, }; if (memo) { data.memo = memo; } const result = await this.request<CreateInvoiceResponse>('create_invoice', data); const bolt11 = result.bolt11 || result.invoice || result.payment_request; if (!bolt11) { throw new Error('No invoice returned from API'); } return { bolt11, paymentHash: result.payment_hash || '', expiresAt: result.expires_at || '', rawResponse: result, }; } - src/index.ts:110-113 (schema)Zod input schema for the 'create_invoice' tool.
const CreateInvoiceSchema = z.object({ amount_sats: z.number().int().min(1).max(10_000_000).describe('Amount in satoshis to request'), memo: z.string().max(640).optional().describe('Description/memo for the invoice'), });