deposit
Generate a deposit invoice (bolt11) for a specified amount and mint. If no mint is provided, all mints are tried concurrently, ensuring immediate invoice creation for payment. Facilitates secure and efficient fund deposits.
Instructions
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.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount in satoshis | |
| mintUrl | No | Mint URL to deposit to (optional - all mints tried concurrently if not provided) |
Implementation Reference
- wallet.ts:623-639 (handler)MCP tool handler for 'deposit': parses arguments, calls wallet.createDepositInvoice, returns formatted response with invoice.case 'deposit': const { amount, mintUrl } = args; if (!amount) { throw new Error('Amount is required'); } const invoice = await this.wallet.createDepositInvoice(amount, mintUrl); return { content: [{ type: 'text', text: `Deposit invoice created. Pay this invoice: ${invoice.bolt11}` }], invoice: invoice.bolt11, amount: invoice.amount, mintUrl: invoice.mintUrl, depositId: invoice.depositId };
- wallet.ts:550-559 (schema)Input schema definition for the 'deposit' tool in the ListTools response.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'] }
- wallet.ts:271-312 (helper)Core helper function createDepositInvoice that creates the Lightning invoice for deposit using NDKCashuWallet.deposit and sets up event listeners.async createDepositInvoice(amount: number, mintUrl?: string): Promise<{ bolt11: string; amount: number; mintUrl: string; depositId: string }> { if (!this.wallet || !this.walletData) throw new Error('Wallet not initialized'); try { // If no mint URL provided, use first available mint if (!mintUrl) { if (!this.walletData.mints || this.walletData.mints.length === 0) { throw new Error('No mints configured. Please add a mint first.'); } mintUrl = this.walletData.mints[0]; } // Add mint to wallet configuration if not already present if (!this.walletData.mints.includes(mintUrl)) { this.walletData.mints.push(mintUrl); this.wallet.mints = this.walletData.mints; this.saveWallet(); } const deposit: NDKCashuDeposit = this.wallet.deposit(amount, mintUrl); const invoice = await deposit.start(); // Generate unique ID for tracking this deposit const depositId = `deposit_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`; // Set up background monitoring for this deposit deposit.on("success", () => { console.log(`✅ Deposit ${depositId} completed successfully`); this.saveWallet(); }); deposit.on("error", (error) => { console.error(`❌ Deposit ${depositId} failed:`, error); }); return { bolt11: invoice, amount, mintUrl, depositId }; } catch (error) { console.error('Error creating deposit invoice:', error); throw error; } }