Skip to main content

AI Spending Security

When you connect a wallet to the Lightning Enable MCP server, you let an AI agent spend Bitcoin on your behalf. Every paying tool spends from that wallet: pay_invoice, access_l402_resource, pay_l402_challenge, wallet_ops with action="send_onchain", agent_services with action="settle", create_lightning_enable_account, and renew_lightning_enable_subscription. This page covers what can go wrong and how to bound it. The exact config keys are in the MCP Complete Guide.

What can go wrong​

  • Unintended payments. The agent misreads your intent, pays the wrong invoice, pays more than expected, or pays twice.
  • Prompt injection. Content the agent reads (a web page, an API response, a marketplace listing) tells it to pay an attacker's invoice.
  • Credential leaks. A wallet API key, NWC connection string, or LND macaroon ends up in logs, screenshots, or version control.
  • Budget draining. Many small payments, each under a limit, add up.

Safeguards​

1. Use a dedicated, small wallet​

Never connect your main wallet or business funds. Give the agent its own wallet holding only what you are willing to lose; the balance is the hard ceiling no prompt can raise. Where the wallet supports it, also set a spend cap on the connection itself (for example, an Alby Hub per-connection budget).

L402 needs a wallet that returns the payment preimage: LND, Strike, or an NWC wallet such as CoinOS, CLINK, or Alby Hub. OpenNode and Primal can pay plain invoices but not L402 challenges. See Wallet Configuration.

2. Set limits in the config file before first use​

Limits live in ~/.lightning-enable/config.json (on Windows, C:\Users\<you>\.lightning-enable\config.json). The server creates it on first run with conservative defaults (see Budget Configuration); open the file and set your own:

{
"currency": "USD",
"tiers": {
"autoApprove": 0.10,
"logAndApprove": 1.00,
"formConfirm": 10.00,
"urlConfirm": 100.00
},
"limits": {
"maxPerPayment": 5.00,
"maxPerSession": 20.00,
"maxPerPaymentSats": 5000
},
"session": {
"cooldownSeconds": 2,
"requireApprovalForFirstPayment": true
}
}
  • Payments up to autoApprove go through; up to logAndApprove they go through and are logged; above that they need a confirmation code from you.
  • Anything above maxPerPayment, or beyond maxPerSession in total, is refused.
  • USD values are converted at payment time; if no BTC price source answers, the payment is refused. Sats keys (maxPerPaymentSats, maxPerSessionSats, autoApproveSats) need no price feed. When both are set, the stricter wins.
  • Set autoApprove to 0 to confirm every payment.

No MCP tool can raise these limits. The agent can only lower its runtime caps with budget(action="tighten"). To raise a limit, edit the file and restart the server. The LIGHTNING_ENABLE_MAX_PER_PAYMENT_SATS, LIGHTNING_ENABLE_MAX_PER_SESSION_SATS, and LIGHTNING_ENABLE_AUTO_APPROVE_SATS environment variables override the file, so treat the MCP client config that sets them with the same care.

3. Approve larger payments out of band​

When a payment needs confirmation:

  1. The payment tool returns requiresConfirmation without the code.
  2. The server delivers the code to you: by default it prints it to its console (stderr).
  3. You give the code to the agent, which calls the same payment tool again with confirmationNonce (.NET) or confirmation_nonce (Python).

The code is never returned in a tool result, so a prompt-injected agent can't approve its own payment. A code is bound to the exact amount, tool, and destination, and expires after two minutes by default. verify_confirmation_code only checks what a code authorizes; it never pays. On-chain sends (wallet_ops with action="send_onchain") always need a code.

Confirmation channels​

Set confirmation.channel (or LIGHTNING_ENABLE_CONFIRMATION_CHANNEL) to choose where the code goes:

ChannelWhere the code goesUse it for
stderr (default)The server consoleInteractive use in Claude Code, Claude Desktop, or a terminal
refuseNowhere; the payment is refusedUnattended or hosted runs
webhookA signed POST to confirmation.webhookUrlNotifying you in a chat app or pager
fileconfirmation.filePathHeadless runs you check later

In a hosted deployment, set LIGHTNING_ENABLE_HOSTED=1: when stdin is not a terminal, the default becomes refuse. Details are in the MCP Complete Guide.

Threat model​

The confirmation code and the config file protect you only if the agent can't read the MCP server's stderr or logs, and can't edit files on the server's host. That holds when Claude Desktop or an IDE starts the server as a subprocess. It does not hold for an agent with shell or filesystem access to the same machine: it could read its own code or edit config.json. For those agents, run the MCP server where the agent can't reach it (a separate user, host, or container), or use the refuse channel.

4. Protect wallet credentials​

  • Create a dedicated key or connection for the agent; don't reuse one.
  • Give it the narrowest permissions the wallet offers (for NWC, pay and balance only, plus a budget).
  • Keep keys out of version control, screenshots, and chat. Prefer the global client config or the config file over a project file you might commit.
  • Rotate the key or connection if it may have leaked, and when you stop using it.

5. Review what was spent​

After each session, ask the agent for receipts with source="durable" (the append-only log at ~/.lightning-enable/receipts.jsonl), and compare it with your wallet's own history. Turn on your wallet's payment notifications and low-balance alerts if it has them.

When not to let an agent pay​

Don't connect a wallet if the agent will run unattended for long periods with a confirmation channel nobody watches, if you haven't set limits, if the wallet holds business funds, or if you are using an MCP configuration you didn't write. Good fits are supervised development, testing, and small, bounded research tasks.

Where the money is​

Lightning Enable does not hold funds. The MCP server is software that runs on your machine and calls your wallet's API: Strike or OpenNode (which facilitate custody and settlement for your account), your own LND node, or an NWC wallet. Lightning Enable never sees your wallet credentials or your Bitcoin, and any account verification is between you and your wallet provider.

If you suspect unauthorized payments​

  1. Revoke or rotate the wallet key, NWC connection, or macaroon immediately.
  2. Check payment history in your wallet's own dashboard.
  3. Compare it with the durable receipts log.
  4. Update the MCP configuration with the new credential.
  5. Lower your limits, and work out how the payment was triggered before reconnecting.