pay
Process Lightning network payments by submitting a Bolt11 invoice, enabling efficient transaction handling for AI agents via the MCP Money server.
Instructions
Pay a Lightning invoice
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bolt11 | Yes | Lightning invoice to pay |
Implementation Reference
- wallet.ts:640-661 (handler)MCP tool dispatch handler for 'pay': extracts bolt11 argument, calls wallet.pay(), and returns formatted success/failure response.case 'pay': const { bolt11 } = args; if (!bolt11) { throw new Error('bolt11 invoice is required'); } const payResult = await this.wallet.pay(bolt11); if (payResult && payResult.success !== false) { return { content: [{ type: 'text', text: 'Payment successful' }], success: true, bolt11, payResult }; } else { return { content: [{ type: 'text', text: 'Payment failed' }], success: false, bolt11, payResult }; }
- wallet.ts:426-438 (handler)Core wallet pay function: invokes lnPay on the NDKCashuWallet instance with the bolt11 invoice and handles errors.async pay(bolt11: string): Promise<any> { if (!this.wallet) throw new Error('Wallet not initialized'); try { const result = await this.wallet.lnPay({ pr: bolt11 }); this.saveWallet(); return result; } catch (error) { console.error('Error making payment:', error); throw error; } }
- wallet.ts:562-570 (schema)Tool schema definition: specifies name, description, input schema requiring 'bolt11' string for the Lightning invoice.name: 'pay', description: 'Pay a Lightning invoice', inputSchema: { type: 'object', properties: { bolt11: { type: 'string', description: 'Lightning invoice to pay' } }, required: ['bolt11'] }
- wallet.ts:530-597 (registration)Tool registration in the listTools response: includes 'pay' in the array of available tools returned by the server.tools: [ { name: 'get_balance', description: 'Get the total wallet balance', inputSchema: { type: 'object', properties: {}, required: [] } }, { name: 'get_mint_balances', description: 'Get balance breakdown per mint', inputSchema: { type: 'object', properties: {}, required: [] } }, { name: 'deposit', description: 'Create a deposit invoice (bolt11) for the specified amount and mint. Returns the invoice immediately for payment. If no mint is specified, all mints will be tried concurrently and the first successful response will be used.', inputSchema: { type: 'object', properties: { amount: { type: 'number', description: 'Amount in satoshis' }, mintUrl: { type: 'string', description: 'Mint URL to deposit to (optional - all mints tried concurrently if not provided)' } }, required: ['amount'] } }, { name: 'pay', description: 'Pay a Lightning invoice', inputSchema: { type: 'object', properties: { bolt11: { type: 'string', description: 'Lightning invoice to pay' } }, required: ['bolt11'] } }, { name: 'zap', description: 'Send a zap to a user', inputSchema: { type: 'object', properties: { recipient: { type: 'string', description: 'User npub or NIP-05 identifier to zap' }, amount: { type: 'number', description: 'Amount in satoshis' }, comment: { type: 'string', description: 'Optional comment' } }, required: ['recipient', 'amount'] } }, { name: 'add_mint', description: 'Add a mint to the wallet', inputSchema: { type: 'object', properties: { mintUrl: { type: 'string', description: 'Mint URL to add' } }, required: ['mintUrl'] } } ] };