create_withdraw_link
Generate LNURL-withdraw links for receiving Lightning payments via QR codes. Specify an amount or sweep full wallet balance to facilitate secure fund transfers.
Instructions
Create an LNURL-withdraw link for the operator to receive funds. Opens in browser for QR code scanning with any Lightning wallet. Omit amount_sats to sweep full balance. REQUIRES OPERATOR KEY.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount_sats | No | Amount in sats to withdraw (omit to sweep full balance) |
Implementation Reference
- src/lightning-faucet.ts:1006-1044 (handler)The handler method in the LightningFaucetClient class that executes the 'create_withdraw_link' tool logic by making an API request.
async createWithdrawLink(amountSats?: number): Promise<{ lnurl: string; paymentUrl: string; qrUrl: string; amountSats: number; platformFeeSats: number; maxRoutingFeeSats: number; totalDebitSats: number; expiresAt: string; rawResponse: ApiResponse; }> { const params: Record<string, unknown> = {}; if (amountSats !== undefined) { params.amount_sats = amountSats; } const result = await this.request<ApiResponse & { lnurl?: string; payment_url?: string; qr_url?: string; amount_sats?: number; platform_fee_sats?: number; max_routing_fee_sats?: number; total_debit_sats?: number; expires_at?: string; }>('create_withdraw_link', params); return { lnurl: result.lnurl || '', paymentUrl: result.payment_url || '', qrUrl: result.qr_url || '', amountSats: result.amount_sats || 0, platformFeeSats: result.platform_fee_sats || 0, maxRoutingFeeSats: result.max_routing_fee_sats || 0, totalDebitSats: result.total_debit_sats || 0, expiresAt: result.expires_at || '', rawResponse: result, }; } - src/index.ts:1441-1465 (registration)The MCP server tool handler implementation for 'create_withdraw_link' which calls the client method.
case 'create_withdraw_link': { const amountSats = args && typeof args === 'object' && 'amount_sats' in args ? (args as Record<string, unknown>).amount_sats as number | undefined : undefined; const result = await session.requireClient().createWithdrawLink(amountSats); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: `Withdraw link created for ${result.amountSats} sats. Open the payment URL in a browser and scan the QR code with your Lightning wallet.`, payment_url: result.paymentUrl, qr_url: result.qrUrl, amount_sats: result.amountSats, platform_fee_sats: result.platformFeeSats, max_routing_fee_sats: result.maxRoutingFeeSats, total_debit_sats: result.totalDebitSats, expires_at: result.expiresAt, lnurl: result.lnurl, }, null, 2), }, ], }; }