Add Lightning Wallet example: Bitcoin payments for AI agents#297
Add Lightning Wallet example: Bitcoin payments for AI agents#297pfergi42 wants to merge 2 commits intoAgentlyHQ:mainfrom
Conversation
Demonstrates an aixyz agent with a Bitcoin Lightning wallet using lightning-wallet-mcp. The agent can check balances, pay invoices, access L402-protected APIs with automatic micropayments, and manage sub-agents with spending limits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
|
Someone is attempting to deploy a commit to the Agently Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b299194492
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const decoded = await lw(["decode-invoice", invoice]); | ||
| const payment = await lw(["pay-invoice", invoice]); |
There was a problem hiding this comment.
Use supported
lw invoice commands
The sendPayment tool calls lw with decode-invoice and pay-invoice, but Lightning Faucet’s documented CLI command set uses lw decode <invoice> and lw pay <invoice>. With these subcommands, invoice payments will fail at runtime with an unknown-command error, so this example’s primary payment flow is broken whenever the tool is invoked.
Useful? React with 👍 / 👎.
| inputSchema: z.object({}), | ||
| execute: async () => { | ||
| const balance = await lw(["balance"]); | ||
| const budget = await lw(["budget-status"]); |
There was a problem hiding this comment.
Remove unsupported
budget-status CLI call
The balance tool runs lw budget-status after lw balance, but budget-status is not part of the documented lw commands. In practice this causes checkBalance to throw even when the balance call succeeds, so the agent cannot reliably answer the “check balance” capability advertised by this example.
Useful? React with 👍 / 👎.
- decode-invoice → decode - pay-invoice → pay - Remove budget-status call (balance already includes budget info) Addresses Codex review feedback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Adds a new example demonstrating an aixyz agent with a Bitcoin Lightning wallet using lightning-wallet-mcp.
Per @fuxingloh's suggestion in #289.
What the agent can do
Files
aixyz.config.ts— 4 skills (balance, payments, L402, agent management)app/agent.ts— ToolLoopAgent with wallet instructionsapp/tools/lw.ts— safe CLI wrapper usingexecFile(no shell injection)app/tools/*.ts— 6 tools wrapping thelwCLIWhy this is useful
L402 (Lightning HTTP 402) lets APIs charge per-request with instant Bitcoin micropayments. This example shows how an aixyz agent can autonomously pay for API access, manage funds across multiple sub-agents, and handle the full payment lifecycle — from checking balance to settling invoices.
Test plan
bun installresolves dependenciesbun run buildcompiles without errors