DEV Community

Tuf Ti
Tuf Ti

Posted on

I built a two-way bridge between Bitcoin Lightning and the AI agent economy published

Last week I shipped the first confirmed cross-protocol AI agent payment: a USDC-holding agent automatically paid a Lightning-gated service, no human in the loop. Today I shipped the other direction.

If you missed last week: the bridge lets an AI agent with a USDC wallet on Base call a Lightning-native API service (L402 protocol). The agent hits the service, gets a 402 response with a Lightning invoice, pays it automatically, and receives the data. The whole thing happens in the background while the agent just sees a successful API call.

The question I kept getting: what about the other way?

Today I answered it.

What shipped today

A Bitcoin holder can now fund an AI agent's service budget by paying a Lightning invoice.

The flow:

# Create a deposit invoice for your agent account
curl -X POST https://api.ideafactorylab.org/proxy/deposit/lightning \
  -H "X-CW-Key: your_proxy_key" \
  -d '{"amount_sats": 10000}'

# Returns a real Lightning invoice
# Pay it from any Lightning wallet
# Within 30 seconds, your agent proxy account is credited
Enter fullscreen mode Exit fullscreen mode

That's it. Sats go in. USDC-equivalent credit comes out. Your agent starts spending it on API calls.

The full picture

The proxy sits between AI agents and paid API services. It handles three payment protocols:

  • x402 -- Coinbase's HTTP payment standard, USDC on Base
  • L402 -- Lightning Labs' standard, Bitcoin Lightning invoices
  • Bridge -- converts between them transparently

When an agent calls POST /proxy/do with a task, the proxy:

  1. Searches 2,835 indexed services for the best match
  2. Probes the service to check it's alive (A-F quality grades)
  3. Detects which payment protocol the service requires
  4. Pays it using whatever the agent has available
  5. Returns the result

The agent doesn't need to know whether the service uses Lightning or USDC. The proxy handles the translation.

The channel details

The Lightning node runs LND on mainnet with a 200,000 sat channel through CoinGate. The inbound/outbound capacity is balanced 50/50 so both bridge directions have room to operate.

Invoice settlement detection runs on a 30-second polling loop. When an invoice settles, the account balance is credited atomically before removing from the pending queue. Duplicate detection via r_hash prevents double-crediting.

The deposit endpoint has rate limiting (3 pending invoices per key) and validates amounts (100-190,000 sats, no negative or fractional).

Try it

No account needed:

npx cinderwright "Bitcoin price"
Enter fullscreen mode Exit fullscreen mode

That runs an AI agent that pays a specialized service for the answer using a real micropayment.

Or visit api.ideafactorylab.org and type any question in the demo box.

With an account ($0.10 free credit, no deposit required):

# Get a proxy key
curl -X POST https://api.ideafactorylab.org/proxy/setup \
  -d '{"wallet": "your_base_wallet_address"}'

# Make a call
curl -X POST https://api.ideafactorylab.org/proxy/do \
  -H "X-CW-Key: your_key" \
  -d '{"task": "current ETH price"}'
Enter fullscreen mode Exit fullscreen mode

Fund with Lightning:

curl -X POST https://api.ideafactorylab.org/proxy/deposit/lightning \
  -H "X-CW-Key: your_key" \
  -d '{"amount_sats": 5000}'
# Returns a Lightning invoice. Pay it. Balance credited within 30s.
Enter fullscreen mode Exit fullscreen mode

For Claude users

There's an MCP server that connects Claude directly to the index:

{
  "mcpServers": {
    "cinderwright": {
      "command": "npx",
      "args": ["cinderwright-mcp-server"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

After that, Claude can search services, call them, and pay autonomously.

What's next

The index has 2,835 services but the quality grades are uneven -- most are sitting at the default 50/100 reliability score because the canary hasn't run at scale yet. Running the full grading sweep is next, which will significantly improve routing decisions.

The other gap is Python. LangChain, AutoGen, CrewAI agents are all Python-first. A pip install cinderwright package that gives those frameworks a one-liner integration would open up the bulk of the agent developer audience.

If you're building agents and want to test either bridge direction, the free demo is live. Happy to answer questions about the routing logic or protocol details in the comments.


Source and MCP server: github.com/cinderwright-ai/cinderwright-api

Top comments (0)