Skip to content

Add Lightning Wallet example: Bitcoin payments for AI agents#297

Open
pfergi42 wants to merge 2 commits intoAgentlyHQ:mainfrom
pfergi42:example/lightning-wallet
Open

Add Lightning Wallet example: Bitcoin payments for AI agents#297
pfergi42 wants to merge 2 commits intoAgentlyHQ:mainfrom
pfergi42:example/lightning-wallet

Conversation

@pfergi42
Copy link
Copy Markdown

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

  • Check balance — wallet balance and budget status
  • Send payments — pay Lightning invoices (BOLT11), with decode-before-pay safety
  • Pay L402 APIs — automatically handles HTTP 402 payment challenges (pay Lightning invoice → retry with proof-of-payment token)
  • Manage sub-agents — create child agents with isolated wallets and daily spending limits, fund them, list their status

Files

  • aixyz.config.ts — 4 skills (balance, payments, L402, agent management)
  • app/agent.ts — ToolLoopAgent with wallet instructions
  • app/tools/lw.ts — safe CLI wrapper using execFile (no shell injection)
  • app/tools/*.ts — 6 tools wrapping the lw CLI

Why 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 install resolves dependencies
  • bun run build compiles without errors
  • Tools follow the existing example patterns (zod schemas, tool() wrapper)

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>
@vercel vercel Bot temporarily deployed to Preview – agent-travel March 19, 2026 14:19 Inactive
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated (UTC)
agent-boilerplate Skipped Skipped Mar 19, 2026 2:58pm
agent-chainlink Skipped Skipped Mar 19, 2026 2:58pm
agent-travel Skipped Skipped Mar 19, 2026 2:58pm
agent-with-custom-server Skipped Skipped Mar 19, 2026 2:58pm

Request Review

@vercel vercel Bot temporarily deployed to Preview – agent-with-custom-server March 19, 2026 14:19 Inactive
@vercel vercel Bot temporarily deployed to Preview – agent-boilerplate March 19, 2026 14:19 Inactive
@vercel vercel Bot temporarily deployed to Preview – agent-chainlink March 19, 2026 14:19 Inactive
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 19, 2026

Someone is attempting to deploy a commit to the Agently Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +11 to +12
const decoded = await lw(["decode-invoice", invoice]);
const payment = await lw(["pay-invoice", invoice]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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"]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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>
@vercel vercel Bot temporarily deployed to Preview – agent-travel March 19, 2026 14:58 Inactive
@vercel vercel Bot temporarily deployed to Preview – agent-chainlink March 19, 2026 14:58 Inactive
@vercel vercel Bot temporarily deployed to Preview – agent-with-custom-server March 19, 2026 14:58 Inactive
@vercel vercel Bot temporarily deployed to Preview – agent-boilerplate March 19, 2026 14:58 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant