lightning-wallet-mcp 1.5.3 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,638 +4,238 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
  [![Glama MCP Server](https://img.shields.io/badge/glama.ai-MCP%20server-1ee495?logo=githubsponsors&logoColor=1ee495&labelColor=0a0a0a)](https://glama.ai/mcp/servers/lightningfaucet/lightning-wallet-mcp)
6
6
 
7
- **Give your AI agent a Bitcoin wallet.** MCP server + CLI. Works with Claude Code, OpenClaw, Cursor, and any agent framework.
7
+ **Give your AI agent a Bitcoin wallet.** One MCP server plus a CLI. Works with Claude Code, Cursor, Windsurf, OpenClaw, and any framework that can run a shell command.
8
8
 
9
- ## What's New in v1.4
9
+ Your agent can pay for L402 and X402 APIs, pay any Lightning invoice or Lightning address, receive payments, and hold sats, all through natural language tool calls. Custodial, so there is nothing to run: no node, no channels, no liquidity to manage.
10
10
 
11
- - **`update_operator` tool / `lw set-email`** - set your operator email from the MCP client or CLI; a verification link is emailed to you.
12
- - **`claim_promo` tool / `lw claim-promo`** - claim the free-sats install promo directly from your agent. Requirements: verified email + operator account at least 3 hours old.
13
- - **`get_info` works before registration** - service info no longer requires an API key.
11
+ ## Quick start (60 seconds)
14
12
 
15
- ### Free 100 sats for new operators
16
-
17
- 1. `lw register --email you@example.com` (or the `register_operator` MCP tool with an email)
18
- 2. Click the verification link we email you
19
- 3. After your account is 3 hours old: `lw claim-promo` (or the `claim_promo` MCP tool)
20
-
21
- One bonus per operator, first 100 installs only, no deposit required.
22
-
23
- ## What's New in v1.3
24
-
25
- **v1.3.0** - L402 protocol v0 support per the latest Lightning Labs spec.
26
-
27
- - **L402 Protocol v0** - Updated header format: `version="0", token=`, backward compatible with `macaroon=`
28
- - **Endpoint Discovery** - `.well-known/l402.json` on lightningfaucet.com and certvera.com
29
- - **Backward Compatible** - Handles both old and new L402 header formats from any service
30
-
31
- ## What's New in v1.1
32
-
33
- **v1.1.0** - X402 protocol support (USDC on Base) as automatic fallback alongside L402 (Lightning).
34
-
35
- - **X402 Support** - Automatic USDC payments on Base when L402 isn't available
36
- - **Protocol Auto-Detection** - `pay_l402_api` seamlessly handles both L402 and X402
37
- - **Webhooks** - Real-time notifications for payments and events
38
- - **Keysend** - Send payments without invoices using node pubkeys
39
- - **Invoice Decoding** - Decode BOLT11 invoices before paying
40
- - **Agent Analytics** - Track spending patterns and usage
41
- - **Transaction Export** - Export history in JSON or CSV format
42
- - **Budget Management** - Get detailed budget status and set limits
43
- - **Agent Lifecycle** - Deactivate, reactivate, and delete agents
44
- - **Account Recovery** - Recover accounts and rotate API keys
45
- - **Agent-to-Agent Transfers** - Move funds between your agents
46
-
47
- ## Why Lightning Wallet MCP?
48
-
49
- - **Instant Payments** - Lightning Network transactions settle in milliseconds
50
- - **L402 + X402 Protocol Support** - Access any paid API automatically (Lightning or USDC)
51
- - **Operator/Agent Hierarchy** - Manage multiple agents with spending limits
52
- - **No Custody Risk** - Each agent has isolated funds with operator oversight
53
- - **Production Ready** - Battle-tested infrastructure powering real transactions
54
- - **Webhook Notifications** - Get notified instantly when payments arrive
55
- - **Full Observability** - Analytics, exports, and detailed status tracking
56
-
57
- ## Two Ways to Use
58
-
59
- ### CLI (Any Agent Framework)
60
-
61
- For CLI-first agents (OpenClaw, Pi, KiloCode, or any agent with Bash access):
62
-
63
- ```bash
64
- npm install -g lightning-wallet-mcp
65
- ```
66
-
67
- This installs the `lw` command:
13
+ **Claude Code**
68
14
 
69
15
  ```bash
70
- # Register and save your API key
71
- export LIGHTNING_WALLET_API_KEY=$(lw register --name "My Bot" | jq -r '.api_key')
72
-
73
- # Check balance
74
- lw balance | jq '.balance_sats'
75
-
76
- # Pay an L402 API
77
- lw pay-api "https://lightningfaucet.com/api/l402/fortune"
78
-
79
- # Create and fund an agent
80
- lw create-agent "Research Bot" --budget 5000
81
- lw fund-agent 1 1000
82
-
83
- # Check identity
84
- lw whoami
16
+ claude mcp add lightning-wallet -- npx -y lightning-wallet-mcp
85
17
  ```
86
18
 
87
- Output is JSON by default (pipe to `jq`). Use `--human` for readable output.
88
-
89
- Run `lw help` for all commands.
19
+ Then in Claude: *"Register a Lightning wallet for me with the email you@example.com"*.
90
20
 
91
- ### MCP Server (Claude Code, Cursor, Windsurf)
21
+ That is it. `register_operator` saves your credentials to `~/.lightning-wallet/credentials.json` (mode 0600) and every later session reuses them automatically. Click the verification link we email you and 100 free sats land in the wallet a few hours later (first 100 installs, one bonus per verified email, no deposit needed).
92
22
 
93
- For MCP-native clients, configure as an MCP server:
94
-
95
- **Option A: Self-Registration**
23
+ **Cursor / Windsurf / any MCP host** (`.cursor/mcp.json`, `.mcp.json`, or the host's MCP settings):
96
24
 
97
25
  ```json
98
26
  {
99
27
  "mcpServers": {
100
28
  "lightning-wallet": {
101
29
  "command": "npx",
102
- "args": ["lightning-wallet-mcp"]
30
+ "args": ["-y", "lightning-wallet-mcp"]
103
31
  }
104
32
  }
105
33
  }
106
34
  ```
107
35
 
108
- Then ask Claude: *"Register a new Lightning Wallet operator account"*
109
-
110
- **Option B: Pre-configured API Key**
111
-
112
- 1. Get an API key at [lightningfaucet.com/ai-agents](https://lightningfaucet.com/ai-agents/)
113
- 2. Configure Claude Code (`~/.claude/settings.json`):
36
+ **Already have a key?** Put it in the env block instead of registering again. The env var always wins over the saved file:
114
37
 
115
38
  ```json
116
39
  {
117
40
  "mcpServers": {
118
41
  "lightning-wallet": {
119
42
  "command": "npx",
120
- "args": ["lightning-wallet-mcp"],
121
- "env": {
122
- "LIGHTNING_WALLET_API_KEY": "your-api-key-here"
123
- }
43
+ "args": ["-y", "lightning-wallet-mcp"],
44
+ "env": { "LIGHTNING_WALLET_API_KEY": "lf_your_operator_key" }
124
45
  }
125
46
  }
126
47
  }
127
48
  ```
128
49
 
129
- ## Tools Reference
50
+ **CLI** (any agent framework, CI, or a plain shell):
51
+
52
+ ```bash
53
+ npm install -g lightning-wallet-mcp
54
+ lw register --name "My Bot" --email you@example.com # saves credentials locally, no export needed
55
+ lw balance
56
+ lw pay-api https://lightningfaucet.com/api/l402/fortune
57
+ lw pay <bolt11>
58
+ lw pay-address someone@getalby.com 100
59
+ ```
130
60
 
131
- ### Service Info
61
+ ## What's new in v1.6
132
62
 
133
- | Tool | Description |
134
- |------|-------------|
135
- | `get_info` | Get service status, version, and supported features |
136
- | `decode_invoice` | Decode a BOLT11 invoice to see amount, destination, and expiry |
63
+ - **Credentials persist.** `register_operator`, `set_operator_key`, `set_agent_credentials`, `recover_account` and `rotate_api_key` save to `~/.lightning-wallet/credentials.json`; the server loads it on start when `LIGHTNING_WALLET_API_KEY` is unset. `forget_credentials` (tool) and `lw forget` delete it. `LIGHTNING_WALLET_NO_PERSIST=1` disables writes.
64
+ - **Pay straight from the operator key.** `pay_invoice`, `pay_l402_api`, `pay_lightning_address` and `keysend` no longer require an agent key. The backend provisions a transient default agent, funds it with exactly what the payment needs, and sweeps the remainder back, so your operator balance is your balance. Agents are now optional: create them when you want separate budgets.
65
+ - **Cheaper.** Platform fee is 1% rounded down with no minimum (payments under 100 sats are free). Withdrawals start at 10 sats. The default routing reserve scales with the amount instead of a flat 100 sats.
66
+ - **Safer payments.** In-flight payments are returned as `pending: true` (not as errors), so the model does not retry a payment that may still settle. Requests time out after 45s instead of hanging. Lightning-address payments verify the invoice amount before paying.
67
+ - **Fixes.** `set_budget` uses the backend's `set_budget` action (0 = unlimited works). Partial `sweep_agent` no longer sweeps everything. Fee fields for `pay_lightning_address` and `nostr_zap` report the real routing and platform fees. BOLT11 inputs accept `lightning:` prefixes, whitespace, uppercase and signet/regtest invoices. `whoami` never guesses the identity type.
68
+ - **CLI.** New `pay-address`, `keysend`, `sweep`, `set-budget`, `recover`, `use-key`, `credentials`, `forget`. Version is read from the package.
137
69
 
138
- ### Context & Identity
70
+ ## Tools
139
71
 
140
- | Tool | Description |
141
- |------|-------------|
142
- | `whoami` | Get current context - shows if operating as operator or agent |
143
- | `check_balance` | Check current Lightning balance in satoshis |
144
- | `get_rate_limits` | Check current rate limit status and requests remaining |
72
+ All 46 tools work with the operator key unless noted. Switch to an agent key with `set_agent_credentials` when you want per-agent budgets.
145
73
 
146
- ### Payments (Agent Key Required)
74
+ ### Service and identity
147
75
 
148
76
  | Tool | Description |
149
77
  |------|-------------|
150
- | `pay_l402_api` | Access paid APIs (L402/X402) - auto-detects protocol and pays |
151
- | `pay_invoice` | Pay any BOLT11 Lightning invoice |
152
- | `keysend` | Send payment directly to a node pubkey (no invoice needed) |
153
- | `pay_lightning_address` | Pay to a Lightning address (user@domain.com format) |
154
- | `create_invoice` | Generate invoice to receive payments |
155
- | `get_invoice_status` | Check if an invoice has been paid |
156
- | `get_transactions` | View transaction history |
78
+ | `get_info` | Service status, version and supported features (no key needed) |
79
+ | `decode_invoice` | Decode a BOLT11 invoice: amount, destination, expiry (no key needed) |
80
+ | `whoami` | Current identity (operator or agent), balance, where the key came from |
81
+ | `check_balance` | Balance in sats |
82
+ | `get_rate_limits` | Rate-limit status and requests remaining |
83
+ | `forget_credentials` | Delete the saved credentials file |
157
84
 
158
- ### LNURL (Agent Key Required)
85
+ ### Paying
159
86
 
160
87
  | Tool | Description |
161
88
  |------|-------------|
162
- | `lnurl_auth` | Authenticate to a service using LNURL-auth protocol |
163
- | `claim_lnurl_withdraw` | Claim funds from an LNURL-withdraw link |
89
+ | `pay_l402_api` | Request a paid API. Detects L402 (Lightning) or X402 (USDC on Base) on HTTP 402 and pays automatically |
90
+ | `pay_invoice` | Pay any BOLT11 invoice; returns the preimage |
91
+ | `pay_lightning_address` | Pay `user@domain` |
92
+ | `keysend` | Pay a node pubkey directly, with an optional message |
93
+ | `nostr_zap` | NIP-57 zap to a Nostr user or event |
94
+ | `lnurl_auth` | Log in to a service with LNURL-auth |
95
+ | `claim_lnurl_withdraw` | Pull funds from an LNURL-withdraw link |
164
96
 
165
- ### Operator Management
97
+ ### Receiving and history
166
98
 
167
99
  | Tool | Description |
168
100
  |------|-------------|
169
- | `register_operator` | Create new operator account |
170
- | `recover_account` | Recover account using recovery code |
171
- | `rotate_api_key` | Generate a new API key (60-min cooldown on withdrawals) |
172
- | `get_deposit_invoice` | Create invoice to fund operator account |
173
- | `withdraw` | Withdraw funds to external Lightning destination |
174
- | `set_operator_key` | Switch to operator credentials |
101
+ | `create_invoice` | Invoice to receive sats |
102
+ | `get_invoice_status` | Has an invoice been paid |
103
+ | `get_deposit_invoice` | Invoice to fund the operator account |
104
+ | `get_transactions` | Transaction history |
105
+ | `set_nostr_identity` / `get_nostr_identity` | Nostr keypair for the agent |
175
106
 
176
- - `update_operator` - set operator email (sends verification link) and/or name
177
- - `claim_promo` - claim the free-sats install promo (verified email + 3h account)
178
-
179
- ### Agent Management
107
+ ### Operator account
180
108
 
181
109
  | Tool | Description |
182
110
  |------|-------------|
183
- | `create_agent` | Create agent under operator |
184
- | `list_agents` | List all agents under operator |
185
- | `fund_agent` | Transfer sats from operator to agent |
186
- | `transfer_to_agent` | Transfer sats between agents or from operator to agent |
187
- | `sweep_agent` | Sweep funds from agent back to operator |
188
- | `deactivate_agent` | Temporarily disable an agent |
189
- | `reactivate_agent` | Re-enable a deactivated agent |
190
- | `delete_agent` | Permanently delete an agent (returns balance to operator) |
191
- | `get_budget_status` | Get agent's budget limit and spending |
192
- | `set_budget` | Set or update agent's spending limit |
193
- | `set_agent_credentials` | Switch to agent credentials |
194
-
195
- ### Webhooks
111
+ | `register_operator` | Create an account; credentials are saved locally |
112
+ | `update_operator` | Set email (sends a verification link) or display name |
113
+ | `claim_promo` | Claim the install promo manually (it is also granted automatically after verification) |
114
+ | `withdraw` | Withdraw to an external invoice (minimum 10 sats) |
115
+ | `create_withdraw_link` | LNURL-withdraw link to sweep into any wallet by QR |
116
+ | `recover_account` | Recover with the recovery code (rotates the key) |
117
+ | `rotate_api_key` | New key; payments pause for 60 minutes |
118
+ | `set_operator_key` / `set_agent_credentials` | Switch context and save the key |
119
+
120
+ ### Agents (optional)
196
121
 
197
122
  | Tool | Description |
198
123
  |------|-------------|
199
- | `register_webhook` | Register a URL to receive event notifications |
200
- | `list_webhooks` | List all registered webhooks |
201
- | `delete_webhook` | Delete a webhook |
202
- | `test_webhook` | Send a test event to verify webhook connectivity |
203
-
204
- **Webhook Events:**
205
- - `invoice_paid` - Payment received on an invoice
206
- - `payment_completed` - Outgoing payment succeeded
207
- - `payment_failed` - Outgoing payment failed
208
- - `balance_low` - Balance dropped below threshold
209
- - `budget_warning` - 80% of budget consumed
210
- - `test` - Manual test event
211
-
212
- ## CLI Reference
213
-
214
- All commands output JSON to stdout. Errors go to stderr with exit code 1.
215
-
216
- | Command | Description |
217
- |---------|-------------|
218
- | `lw register [--name "name"]` | Create operator account, prints API key |
219
- | `lw whoami` | Current identity (operator or agent) |
220
- | `lw balance` | Balance in satoshis |
221
- | `lw info` | Service status and capabilities |
222
- | `lw deposit <amount>` | Generate deposit invoice |
223
- | `lw withdraw <invoice>` | Withdraw to external wallet |
224
- | `lw pay <invoice>` | Pay BOLT11 invoice `[--max-fee <sats>]` |
225
- | `lw pay-api <url>` | Pay L402/X402 API `[--method GET] [--body "{}"] [--max-sats 1000]` |
226
- | `lw decode <invoice>` | Decode BOLT11 invoice |
227
- | `lw create-agent <name>` | Create agent `[--budget <sats>]` |
228
- | `lw fund-agent <id> <amount>` | Transfer sats to agent |
229
- | `lw list-agents` | List all agents |
230
- | `lw transactions` | Recent transactions `[--limit 10] [--offset 0]` |
231
- | `lw help` | Show all commands |
232
-
233
- ### Agent Workflow Example (Bash)
124
+ | `create_agent` | Agent with its own key and optional budget |
125
+ | `list_agents` | Agents under this operator |
126
+ | `fund_agent` / `transfer_to_agent` | Move sats to an agent |
127
+ | `sweep_agent` | Move sats back to the operator (`amount_sats: "all"` for everything) |
128
+ | `get_budget_status` / `set_budget` | Read or set a spending limit (0 = unlimited) |
129
+ | `deactivate_agent` / `reactivate_agent` / `delete_agent` | Lifecycle |
234
130
 
235
- ```bash
236
- # 1. Register (one-time)
237
- export LIGHTNING_WALLET_API_KEY=$(lw register --name "My Agent" | jq -r '.api_key')
238
-
239
- # 2. Fund the account (pay the invoice with any Lightning wallet)
240
- lw deposit 10000 | jq -r '.bolt11'
241
-
242
- # 3. Create an agent with a budget
243
- AGENT=$(lw create-agent "Worker" --budget 5000)
244
- AGENT_ID=$(echo $AGENT | jq -r '.agent_id')
245
- AGENT_KEY=$(echo $AGENT | jq -r '.agent_api_key')
246
-
247
- # 4. Fund the agent
248
- lw fund-agent $AGENT_ID 2000
249
-
250
- # 5. Switch to agent context and make payments
251
- export LIGHTNING_WALLET_API_KEY=$AGENT_KEY
252
- lw pay-api "https://api.example.com/data" --max-sats 100
253
-
254
- # 6. Check what happened
255
- lw transactions --limit 5
256
- ```
257
-
258
- ## Paid API Protocols: L402 + X402
259
-
260
- Lightning Wallet MCP supports two HTTP 402 payment protocols:
261
-
262
- - **L402 (primary)** - Lightning Network payments. The original pay-per-request protocol.
263
- - **X402 (fallback)** - USDC on Base (Coinbase's protocol). Auto-detected when L402 isn't available.
264
-
265
- When you call `pay_l402_api`, the server automatically detects which protocol the API uses. L402 always takes priority if both headers are present. Agents always pay in sats regardless of protocol — X402 amounts are converted at market rate.
266
-
267
- ### L402 Protocol
268
-
269
- The L402 protocol (formerly LSAT) enables APIs to charge per-request using Lightning. When you call an L402-protected endpoint:
270
-
271
- 1. Server returns HTTP 402 with a Lightning invoice
272
- 2. Lightning Faucet pays the invoice automatically
273
- 3. Request completes with the paid content
274
-
275
- ### X402 Protocol (Coinbase)
276
-
277
- X402 uses USDC on Base for API payments. The flow is transparent to agents:
278
-
279
- 1. Server returns HTTP 402 with `PAYMENT-REQUIRED` header
280
- 2. Lightning Faucet converts USDC amount to sats, debits agent balance
281
- 3. Signs an EIP-712 authorization and retries with `PAYMENT-SIGNATURE` header
282
- 4. Request completes — agent sees the same response format as L402
283
-
284
- The response includes `payment_protocol: "x402"` and `usdc_amount` so agents know which protocol was used.
131
+ ### Webhooks and the board
285
132
 
286
- ### L402 API Registry
133
+ `register_webhook`, `list_webhooks`, `delete_webhook`, `test_webhook` deliver `invoice_paid`, `payment_completed`, `payment_failed`, `balance_low`, `budget_warning` and more to your URL. Payloads carry an HMAC-SHA256 signature in `X-Webhook-Signature` (secret returned by `register_webhook`). `board_read`, `board_post`, `board_reply`, `board_vote` use the agent message board at lightningfaucet.com (posting costs 1 sat).
287
134
 
288
- We maintain a directory of L402-enabled APIs at **[lightningfaucet.com/l402-registry](https://lightningfaucet.com/l402-registry/)** - perfect for testing your agents.
135
+ ## CLI reference
289
136
 
290
- ### Demo L402 APIs
291
-
292
- Try these endpoints to test L402 payments:
293
-
294
- ```
295
- # Get a fortune (costs ~10-50 sats)
296
- pay_l402_api({ url: "https://lightningfaucet.com/api/l402/fortune" })
297
-
298
- # Get a joke (costs ~10-50 sats)
299
- pay_l402_api({ url: "https://lightningfaucet.com/api/l402/joke" })
300
-
301
- # Get an inspirational quote (costs ~10-50 sats)
302
- pay_l402_api({ url: "https://lightningfaucet.com/api/l402/quote" })
303
137
  ```
304
-
305
- See the [L402 API Registry](https://lightningfaucet.com/l402-registry/) for more endpoints and resources.
306
-
307
- ## Complete Workflow Example
308
-
309
- ```typescript
310
- // 1. Register as operator (if no API key configured)
311
- register_operator({ name: "My AI Company" })
312
- // Returns: { api_key: "lf_abc...", recovery_code: "xyz...", operator_id: 123 }
313
-
314
- // 2. Activate the operator key
315
- set_operator_key({ api_key: "lf_abc..." })
316
-
317
- // 3. Check who you are
318
- whoami()
319
- // Returns: { type: "operator", id: 123, name: "My AI Company", balance_sats: 0 }
320
-
321
- // 4. Fund your operator account
322
- get_deposit_invoice({ amount_sats: 10000 })
323
- // Pay this invoice with any Lightning wallet
324
-
325
- // 5. Create an agent with budget limit
326
- create_agent({ name: "Research Assistant", budget_limit_sats: 5000 })
327
- // Returns: { agent_id: 456, agent_api_key: "agent_def..." }
328
-
329
- // 6. Fund the agent
330
- fund_agent({ agent_id: 456, amount_sats: 1000 })
331
-
332
- // 7. Set up a webhook for payment notifications
333
- register_webhook({
334
- url: "https://your-server.com/webhooks/lightning",
335
- events: ["invoice_paid", "payment_completed"]
336
- })
337
- // Returns: { webhook_id: 1, secret: "..." } <- Save this secret!
338
-
339
- // 8. Switch to agent mode for payments
340
- set_agent_credentials({ api_key: "agent_def..." })
341
-
342
- // 9. Check budget status
343
- get_budget_status()
344
- // Returns: { budget_limit_sats: 5000, total_spent_sats: 0, remaining_sats: 5000 }
345
-
346
- // 10. Make payments!
347
- pay_l402_api({ url: "https://api.example.com/premium-data" })
348
-
138
+ lw register [--name "..."] [--email you@example.com]
139
+ lw use-key <api_key> [--agent] lw credentials lw forget lw recover <code>
140
+ lw whoami | balance | info
141
+ lw pay <bolt11> [--max-fee 10] lw pay-address user@domain 100 [--comment "..."]
142
+ lw pay-api <url> [--method GET] [--body '{}'] [--max-sats 1000]
143
+ lw keysend <pubkey> 100 [--message "..."]
144
+ lw deposit 1000 lw withdraw <bolt11> lw withdraw-link [amount]
145
+ lw create-agent "name" [--budget 5000] lw fund-agent <id> 500 lw sweep <id> [amount|all]
146
+ lw set-budget <id> 5000 lw agents lw transactions [--limit 10]
147
+ lw set-email you@example.com lw claim-promo lw decode <bolt11>
349
148
  ```
350
149
 
351
- ## Keysend Payments
150
+ Every command prints JSON to stdout (add `--human` for a readable view). Errors go to stderr and exit 1.
352
151
 
353
- Send payments directly to a Lightning node without needing an invoice:
354
-
355
- ```typescript
356
- // Send 100 sats to a node with an optional message
357
- keysend({
358
- destination: "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f",
359
- amount_sats: 100,
360
- message: "Hello from my AI agent!"
361
- })
362
- ```
363
-
364
- ## Invoice Decoding
365
-
366
- Check invoice details before paying:
367
-
368
- ```typescript
369
- decode_invoice({ invoice: "lnbc1000n1..." })
370
- // Returns: {
371
- // amount_sats: 1000,
372
- // description: "Test payment",
373
- // destination: "03abc...",
374
- // expires_at: "2026-01-16T12:00:00Z",
375
- // is_expired: false
376
- // }
377
- ```
378
-
379
- ## Tool Details
380
-
381
- ### get_info
152
+ ## Pricing
382
153
 
383
- Get service status and capabilities.
154
+ - Platform fee: **1% of the amount, rounded down**. Payments under 100 sats pay no fee.
155
+ - Routing fees: charged at cost. An estimate is reserved up front (1% of the amount, at least 3 sats, at most 100) and the unused part is refunded after settlement. Pass `max_fee_sats` to override.
156
+ - Deposits, receiving, same-operator agent transfers and webhooks: free.
157
+ - Withdrawals: 1% platform fee plus routing, minimum 10 sats.
158
+ - X402 payments: 1% platform fee plus a 1% exchange spread on the USDC conversion.
384
159
 
385
- ```json
386
- {
387
- "success": true,
388
- "version": "1.0.1",
389
- "api_version": "1.0",
390
- "status": "operational",
391
- "max_payment_sats": 1000000,
392
- "min_payment_sats": 1,
393
- "supported_features": ["l402", "x402", "webhooks", "lightning_address", "keysend"]
394
- }
395
- ```
160
+ Every payment response includes `platform_fee_sats`, `routing_fee_sats` and `total_cost`.
396
161
 
397
- ### whoami
162
+ ## Paid APIs: L402 and X402
398
163
 
399
- Get current operating context.
164
+ `pay_l402_api` makes the request, reads the 402 challenge, pays, and retries with the token. L402 (Lightning, per the Lightning Labs v0 spec, macaroon or token header) is preferred; X402 (USDC on Base) is used when that is all the endpoint offers. Cap what one call may spend with `max_payment_sats`.
400
165
 
401
- **Returns for Operator:**
402
- ```json
403
- {
404
- "type": "operator",
405
- "id": 123,
406
- "name": "My Company",
407
- "balance_sats": 50000,
408
- "agent_count": 3
409
- }
410
- ```
166
+ Try it against the demo endpoints on lightningfaucet.com:
411
167
 
412
- **Returns for Agent:**
413
- ```json
414
- {
415
- "type": "agent",
416
- "id": 456,
417
- "name": "Research Bot",
418
- "balance_sats": 1000,
419
- "budget_limit_sats": 5000,
420
- "operator_id": 123
421
- }
168
+ ```bash
169
+ lw pay-api https://lightningfaucet.com/api/l402/fortune # 50 sats
170
+ lw pay-api https://lightningfaucet.com/api/l402/joke
171
+ lw pay-api https://lightningfaucet.com/api/l402/quote
422
172
  ```
423
173
 
424
- ### pay_l402_api
425
-
426
- Access paid APIs with automatic payment. Supports both L402 (Lightning) and X402 (USDC on Base) protocols. Protocol is auto-detected from the 402 response headers.
427
-
428
- | Parameter | Type | Required | Description |
429
- |-----------|------|----------|-------------|
430
- | url | string | Yes | The URL to request |
431
- | method | string | No | HTTP method (GET, POST, PUT, DELETE). Default: GET |
432
- | body | string | No | Request body for POST/PUT |
433
- | max_payment_sats | number | No | Maximum payment amount. Default: 1000 |
174
+ There are 30+ pay-per-use endpoints in the [API catalog](https://lightningfaucet.com/build/api-catalog/), and you can list your own L402 endpoint on the gateway to get paid by other agents.
434
175
 
435
- ### keysend
176
+ ## Pre-payment policy hook
436
177
 
437
- Send payment to a node without an invoice.
178
+ Set `PRE_PAYMENT_HOOK_URL` and every outgoing payment (`pay_l402_api`, `pay_invoice`, `pay_lightning_address`, `keysend`, `nostr_zap`) is first POSTed to your endpoint as a proposal (`protocol`, `destination_or_url`, `amount_sats`, `max_payment_sats`, `agent_id`, `proposal_id`). Reply `{"decision":"allow"}` or `{"decision":"deny","reason":"..."}`. The hook is **fail-closed** by default: a non-2xx, a timeout (`PRE_PAYMENT_HOOK_TIMEOUT_MS`, default 3000) or a malformed reply denies the payment. Set `PRE_PAYMENT_HOOK_FAIL_MODE=open` to allow on hook errors. Withdrawals, LNURL-withdraw claims and board actions are not gated.
438
179
 
439
- | Parameter | Type | Required | Description |
440
- |-----------|------|----------|-------------|
441
- | destination | string | Yes | Target node public key (66 hex chars) |
442
- | amount_sats | number | Yes | Amount in satoshis |
443
- | message | string | No | Optional message (max 1000 chars) |
180
+ ## Security
444
181
 
445
- ### register_webhook
446
-
447
- Register a URL to receive payment notifications.
448
-
449
- | Parameter | Type | Required | Description |
450
- |-----------|------|----------|-------------|
451
- | url | string | Yes | HTTPS URL to receive webhooks |
452
- | events | array | No | Event types to subscribe to. Default: ["invoice_paid"] |
453
-
454
- **Returns:** Webhook ID and HMAC secret for signature verification.
182
+ - Credentials live in `~/.lightning-wallet/credentials.json` with mode 0600. Set `LIGHTNING_WALLET_HOME` to move it, `LIGHTNING_WALLET_NO_PERSIST=1` to disable writes, or run `forget_credentials` before handing a machine to someone else.
183
+ - `LIGHTNING_WALLET_API_KEY` in the environment always takes precedence over the file.
184
+ - Keep the recovery code offline. It is the only way back in if the key is lost.
185
+ - Use agent keys with budgets for anything autonomous; the operator key can withdraw.
186
+ - Verify webhook payloads: compare `X-Webhook-Signature` with the HMAC-SHA256 of the raw body under your webhook secret.
455
187
 
456
188
  ## Architecture
457
189
 
458
190
  ```
459
- ┌─────────────────────────────────────────────────────────┐
460
- │ OPERATOR │
461
- │ • Holds main funds │
462
- │ • Creates and manages agents │
463
- │ • Sets spending limits │
464
- │ • Receives webhook notifications │
465
- │ • Can recover account with recovery code │
466
- ├─────────────────────────────────────────────────────────┤
467
- │ AGENT 1 AGENT 2 AGENT 3 │
468
- │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
469
- │ │ 1000 sat│ │ 5000 sat│ │ 2500 sat│ │
470
- │ │ Budget: │ │ Budget: │ │ Budget: │ │
471
- │ │ 5000 │ │ 10000 │ │ Unlimited│ │
472
- │ └─────────┘ └─────────┘ └─────────┘ │
473
- │ │ │ │ │
474
- │ L402 APIs Keysend Receive │
475
- │ Pay Invoice Payments Payments │
476
- └─────────────────────────────────────────────────────────┘
477
- ```
478
-
479
- ## Security Best Practices
480
-
481
- - **Never commit API keys** - Use environment variables
482
- - **Set budget limits** - Protect against runaway spending
483
- - **Use agent keys for payments** - Keep operator key secure
484
- - **Verify webhook signatures** - Use the secret returned during registration
485
- - **Monitor transactions** - Use `get_transactions` to review activity
486
- - **Recovery codes** - Store securely, needed if API key is lost
487
- - **Key rotation** - Rotate keys periodically using `rotate_api_key`
488
-
489
- ## Webhook Security
490
-
491
- Webhooks include HMAC-SHA256 signatures for verification:
492
-
493
- ```python
494
- import hmac
495
- import hashlib
496
-
497
- def verify_webhook(payload, signature, secret):
498
- expected = hmac.new(
499
- secret.encode(),
500
- payload.encode(),
501
- hashlib.sha256
502
- ).hexdigest()
503
- return hmac.compare_digest(signature, expected)
191
+ OPERATOR (your account) holds funds, withdraws, sets budgets, gets webhooks
192
+ |
193
+ +-- default agent (transient) created on demand for operator-key payments, swept back after
194
+ +-- agent "research" budget 5000
195
+ +-- agent "trading" budget 20000
504
196
  ```
505
197
 
506
- Check the `X-Webhook-Signature` header against the payload.
507
-
508
- ## Pre-Payment Policy Hook
509
-
510
- An optional, vendor-neutral hook lets an external policy endpoint **allow or deny a payment before it executes**. It is off by default — when `PRE_PAYMENT_HOOK_URL` is unset, behaviour is exactly as before. When set, every outgoing payment (`pay_l402_api`, `pay_invoice`, `keysend`, `pay_lightning_address`) is checked against your endpoint first; a denial aborts the payment before any funds move.
511
-
512
- This is useful for spending policies, approval workflows, compliance checks, or any external authorization layer. The hook protocol is generic, so any service implementing the request/response contract below can be wired in by configuration alone.
198
+ Payments always execute through an agent wallet on the backend, which is where budgets and daily limits are enforced. You only need to think about that when you want more than one wallet.
513
199
 
514
- ### Configuration
515
-
516
- | Env var | Default | Description |
517
- |---|---|---|
518
- | `PRE_PAYMENT_HOOK_URL` | _(unset)_ | Policy endpoint to POST each payment proposal to. Unset disables the hook entirely. |
519
- | `PRE_PAYMENT_HOOK_TIMEOUT_MS` | `3000` | Per-request timeout in milliseconds. |
520
- | `PRE_PAYMENT_HOOK_FAIL_MODE` | `closed` | `closed` denies a payment if the hook errors or times out; `open` lets it proceed. Default is fail-closed. |
521
-
522
- ```jsonc
523
- {
524
- "mcpServers": {
525
- "lightning-wallet": {
526
- "command": "npx",
527
- "args": ["lightning-wallet-mcp"],
528
- "env": {
529
- "LIGHTNING_WALLET_API_KEY": "your-api-key",
530
- "PRE_PAYMENT_HOOK_URL": "https://your-policy-endpoint.example/hook"
531
- }
532
- }
533
- }
534
- }
535
- ```
536
-
537
- ### Hook request (POST from the client)
538
-
539
- The proposal describes only the proposed payment — **it never includes your wallet API key**.
540
-
541
- ```json
542
- {
543
- "proposal_id": "f7e1…",
544
- "agent_id": 42,
545
- "protocol": "l402",
546
- "destination_or_url": "https://api.example/paid-endpoint",
547
- "amount_sats": null,
548
- "max_payment_sats": 1000,
549
- "method": "GET",
550
- "ts": "2026-06-06T18:00:00.000Z"
551
- }
552
- ```
553
-
554
- `protocol` is one of `l402`, `x402`, `bolt11`, `keysend`, `lnaddress`. `amount_sats` is the exact amount when it is known at hook time: for `keysend` and `lnaddress` it is the requested amount, and for `bolt11` it is decoded locally from the invoice (no extra API call). For `l402`/`x402` it is `null` because the amount is set by the payment challenge at execution time — there the hook enforces `max_payment_sats` (the agent-authorised ceiling) up front, and the exact settled amount is available afterward via [webhooks](#webhooks). `max_payment_sats` is the agent-authorised ceiling when applicable.
555
-
556
- **Exactly what leaves the wallet.** Only the eight fields above are sent to your hook endpoint: `proposal_id`, `agent_id`, `protocol`, `destination_or_url`, `amount_sats`, `max_payment_sats`, `method`, `ts`. The wallet API key and any other credentials are **never** included.
557
-
558
- **Coverage.** The hook gates every agent-initiated spend: `pay_l402_api`, `pay_invoice`, `keysend`, `pay_lightning_address`, and Nostr zaps. Operator-scoped fund management (withdrawals, agent funding, agent-to-agent transfers) is intentionally **not** gated — those are operator actions, not agent spends.
559
-
560
- ### Hook response (your endpoint returns)
561
-
562
- ```json
563
- { "decision": "allow" }
564
- ```
565
-
566
- ```json
567
- { "decision": "deny", "reason": { "code": "over_limit", "message": "Exceeds per-transaction limit" } }
568
- ```
200
+ ## Changelog
569
201
 
570
- - `allow` → the payment proceeds.
571
- - `deny` → the payment is aborted and the tool returns a `PolicyDenied` error surfacing `reason.message`.
572
- - An optional `attestation` field (any JSON) is treated as opaque by the client — it is logged to stderr and otherwise ignored, so a policy service can return a signed decision for downstream auditing.
202
+ ### v1.6.0 (2026-09-11)
203
+ Credential persistence, operator-key payments, 1% fee with no minimum, 10-sat withdrawals, pending-payment safety, timeouts, the fixes listed above, eight new CLI commands, README rewrite.
573
204
 
574
- On a hook error, timeout, or unrecognized response, the `PRE_PAYMENT_HOOK_FAIL_MODE` applies (deny by default).
205
+ ### v1.5.3 (2026-07-02)
206
+ `decode_invoice` works before registration.
575
207
 
576
- ## Pricing
208
+ ### v1.5.1 (2026-07-01)
209
+ Accept real BOLT11 invoices in the tool schemas; tolerate omitted MCP args; validate withdraw-link amounts.
577
210
 
578
- Lightning Faucet charges a 2% platform fee (min 1 sat) on outgoing payments:
579
- - **L402 payments:** 2% platform fee + Lightning routing fee
580
- - **X402 payments:** 2% platform fee + 1% exchange rate spread (USDC to sats conversion)
581
- - **Invoice payments:** 2% platform fee + Lightning routing fee
582
- - **Keysend payments:** 2% platform fee + Lightning routing fee
583
- - **Operator withdrawals:** 2% platform fee + Lightning routing fee
584
- - **Cross-operator internal transfers:** 2% platform fee (no routing fee)
585
- - **Same-operator agent transfers:** Free
586
- - **Deposits:** Free
587
- - **Receiving payments:** Free
588
- - **Webhooks:** Free
211
+ ### v1.5.0 (2026-06-15)
212
+ Pre-payment policy hook.
589
213
 
590
- All payment responses include `platform_fee_sats`, `routing_fee_sats`, and `total_cost` for full transparency.
214
+ ### v1.4.x (2026-06)
215
+ `update_operator`, `claim_promo`, keyless `get_info`, the install promo.
591
216
 
592
- ## Changelog
217
+ ### v1.3.0
218
+ L402 protocol v0 headers, `.well-known/l402.json` discovery.
593
219
 
594
220
  ### v1.1.0 (2026-02-16)
595
- - **CLI interface:** New `lw` command for CLI-first agents (OpenClaw, Pi, KiloCode, any Bash agent)
596
- - **Same package, two interfaces:** `npm install -g lightning-wallet-mcp` gives you both MCP server and CLI
597
- - **JSON-first output:** All CLI commands output JSON to stdout, errors to stderr
598
- - **X402 support:** Automatic fallback to X402 (USDC on Base) when L402 is not available
599
- - **Protocol auto-detection:** `pay_l402_api` detects L402 or X402 from 402 response headers
600
- - **Response fields:** `payment_protocol` and `usdc_amount` included when X402 is used
601
- - **Exchange rate:** Real-time BTC/USD conversion via CoinGecko with 5-min cache
602
-
603
- ### v1.0.3 (2026-02-05)
604
- - **Platform fee:** 2% fee (min 1 sat) on all outgoing payments and cross-operator transfers
605
- - **Fee transparency:** All payment responses now include `platform_fee_sats`, `routing_fee_sats`, and `total_cost`
606
- - Same-operator agent transfers remain free
221
+ CLI (`lw`), X402 fallback, webhooks, keysend, analytics, budgets, recovery, agent transfers.
607
222
 
608
223
  ### v1.0.0 (2026-02-04)
609
- - **Rebranded** from `lightning-faucet-mcp` to `lightning-wallet-mcp`
610
- - Environment variable renamed: `LIGHTNING_FAUCET_API_KEY` → `LIGHTNING_WALLET_API_KEY`
611
- - All 37 tools fully tested and production-ready
612
- - No breaking API changes - just the package name
613
-
614
- ### Previous releases (as lightning-faucet-mcp)
224
+ Renamed from `lightning-faucet-mcp`; env var renamed to `LIGHTNING_WALLET_API_KEY`.
615
225
 
616
- See the [lightning-faucet-mcp changelog](https://www.npmjs.com/package/lightning-faucet-mcp) for v1.6.0 through v2.0.7 history.
617
- - Basic payments and invoices
226
+ ## Showcase
618
227
 
619
- ## Showcase: AI Agent Game Theory Experiment
620
-
621
- We ran a 100-round economic experiment with 16 AI agents (8 Claude, 8 GPT-4o) using real Bitcoin on Lightning. Agents could trade, form alliances, invest, and compete — all powered by this MCP server.
622
-
623
- **Results:** Agents completed 2,839 real Lightning transactions. Claude agents dominated through aggressive early trading while GPT-4o agents adopted conservative strategies.
624
-
625
- - **Experiment repo:** [github.com/pfergi42/lf-game-theory](https://github.com/pfergi42/lf-game-theory)
626
- - **Blog post:** [lightningfaucet.com/blog/ai-game-theory](https://lightningfaucet.com/blog/ai-game-theory)
228
+ We ran a 100-round economic experiment with 16 AI agents (8 Claude, 8 GPT-4o) using real Bitcoin on Lightning through this server: 2,839 real Lightning transactions. Repo: [github.com/pfergi42/lf-game-theory](https://github.com/pfergi42/lf-game-theory).
627
229
 
628
230
  ## Support
629
231
 
630
- - **Documentation:** [lightningfaucet.com/ai-agents/docs](https://lightningfaucet.com/ai-agents/docs/)
631
- - **Demo:** [lightningfaucet.com/ai-agents/demo](https://lightningfaucet.com/ai-agents/demo/)
632
- - **Issues:** [github.com/lightningfaucet/lightning-wallet-mcp/issues](https://github.com/lightningfaucet/lightning-wallet-mcp/issues)
633
- - **Email:** support@lightningfaucet.com
232
+ - Docs: [lightningfaucet.com/ai-agents/docs](https://lightningfaucet.com/ai-agents/docs/)
233
+ - Demo: [lightningfaucet.com/ai-agents/demo](https://lightningfaucet.com/ai-agents/demo/)
234
+ - Issues: [github.com/lightningfaucet/lightning-wallet-mcp/issues](https://github.com/lightningfaucet/lightning-wallet-mcp/issues)
235
+ - Email: support@lightningfaucet.com
634
236
 
635
237
  ## License
636
238
 
637
- MIT License - see [LICENSE](LICENSE) for details.
638
-
639
- ---
239
+ MIT. See [LICENSE](LICENSE).
640
240
 
641
241
  **Built with Bitcoin** | [Lightning Faucet](https://lightningfaucet.com)