withdraw
Transfer funds from your Lightning wallet to external BOLT11 invoices using operator authentication, enabling secure withdrawals with built-in security cooldown periods.
Instructions
Withdraw funds from operator account to external Lightning invoice. REQUIRES OPERATOR KEY. Subject to security cooldown.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| invoice | Yes | BOLT11 invoice to pay out to |
Implementation Reference
- src/lightning-faucet.ts:969-1000 (handler)The `withdraw` method implementation in `LightningFaucetClient` handles sending funds to an external Lightning invoice.
async withdraw(invoice: string): Promise<{ amountSats: number; routingFeeSats: number; platformFeeSats: number; totalCost: number; paymentHash: string; newBalance: number; rawResponse: ApiResponse; }> { const result = await this.request<ApiResponse & { amount_sats?: number; routing_fee_sats?: number; platform_fee_sats?: number; total_cost?: number; payment_hash?: string; new_balance?: number; }>('withdraw', { invoice }); const amountSats = result.amount_sats || 0; const routingFeeSats = result.routing_fee_sats || 0; const platformFeeSats = result.platform_fee_sats || 0; return { amountSats, routingFeeSats, platformFeeSats, totalCost: result.total_cost || (amountSats + routingFeeSats + platformFeeSats), paymentHash: result.payment_hash || '', newBalance: result.new_balance || 0, rawResponse: result, }; } - src/index.ts:1419-1439 (handler)The MCP tool request handler for the 'withdraw' tool.
case 'withdraw': { const parsed = WithdrawSchema.parse(args); const result = await session.requireClient().withdraw(parsed.invoice); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: 'Withdrawal successful', amount_sats: result.amountSats, routing_fee_sats: result.routingFeeSats, platform_fee_sats: result.platformFeeSats, total_cost: result.totalCost, payment_hash: result.paymentHash, new_balance: result.newBalance, }, null, 2), }, ], }; } - src/index.ts:216-219 (schema)The Zod validation schema for the 'withdraw' tool.
const WithdrawSchema = z.object({ invoice: z.string().regex(/^ln(bc|tb|bcrt)1[a-z0-9]+$/i, 'Invalid BOLT11 invoice format') .describe('BOLT11 invoice to pay out to'), });