How to assign API keys, enforce spending limits, and connect AI agents to Bitcoin wallets
AgentBTC uses a two-tier authentication model:
| Role | Key Type | Can Do | Can't Do |
|---|---|---|---|
| Owner | Owner API Key | Everything — create/delete wallets, view all agents, configure settings, make payments | Nothing restricted |
| Agent | Agent API Key | Access own wallet, check balance, make payments (within limits), create invoices | See other wallets, create/delete wallets, change own limits |
This separation ensures AI agents can only spend what you allow, from the wallet you assign them.
This is your master key. It has full admin access to the entire AgentBTC platform.
OWNER_API_KEY (or defaults to agentbtc-owner-test-key-2026 in development)Every wallet gets its own unique API key when created. It's scoped to that wallet only.
agent_{wallet_id}_{random_token} (e.g., agent_5300230a_EAZdGb6l_YsB-2PP6...)⚠️ Save the agent API key when you create the wallet! It cannot be recovered later.
Using Claude Desktop (with owner key):
"Create an agent wallet called Shopping Bot"
Or via the dashboard UI → Create Agent button.
You'll receive:
{
"agent_id": "5300230a",
"api_key": "agent_5300230a_EAZdGb6l_YsB-2PP6Bc9xcyEhrqN9H3KdSZw_DCoFck",
"message": "Created wallet 'Shopping Bot'"
}
Save that api_key — you'll need it for the agent's config.
Currently set via the database (dashboard UI coming soon):
INSERT INTO spending_policies (id, agent_id, max_per_tx, max_daily, max_monthly, allowed_destinations, enabled)
VALUES ('unique-id', '5300230a', 1100, 3000, 20000, '[]', 1);
| Field | Description | Example |
|---|---|---|
max_per_tx |
Maximum sats per single payment | 1100 (about $0.75) |
max_daily |
Maximum sats per day (resets at midnight) | 3000 (about $2.05) |
max_monthly |
Maximum sats per calendar month | 20000 (about $13.70) |
allowed_destinations |
JSON list of allowed payment destinations (empty = any) | [] |
Set any limit to 0 to disable that check (unlimited).
Create an MCP config using the agent's API key (not the owner key):
{
"mcpServers": {
"agentbtc": {
"command": "node",
"args": ["/path/to/agentbtc/mcp_server/index.js"],
"env": {
"AGENTBTC_API_URL": "http://localhost:8000",
"AGENTBTC_API_KEY": "agent_5300230a_EAZdGb6l_YsB-2PP6Bc9xcyEhrqN9H3KdSZw_DCoFck",
"AGENTBTC_LND_HOST": "https://your-node:8080",
"AGENTBTC_LND_MACAROON": "hex-macaroon"
}
}
}
}
With this config, the agent: - ✅ Can check its own balance - ✅ Can create invoices to receive payments - ✅ Can make payments (within spending limits) - ✅ Can view transaction history - ❌ Cannot see other wallets - ❌ Cannot create or delete wallets - ❌ Cannot exceed spending limits - ❌ Cannot operate if disabled by owner
An AI that needs to make payments — buying API access, paying for services, tipping.
Config: Agent API key + Lightning node credentials Limits: Set per-tx, daily, and monthly caps Example: Shopping Bot, API Consumer, Content Purchaser
AGENTBTC_API_KEY=agent_5300230a_xxx ← scoped to Shopping Bot wallet
A trusted AI that manages the platform — creating wallets for other agents, monitoring balances, adjusting settings.
Config: Owner API key + Lightning node credentials Limits: None (full access) Example: Your primary Claude Desktop session, an admin bot
AGENTBTC_API_KEY=agentbtc-owner-test-key-2026 ← full admin access
An AI that monitors wallet balances and transactions but can't make payments.
Config: Agent API key only (no LND credentials) Limits: Payment tools return "LND not configured" errors Example: Dashboard monitor, reporting bot, analytics agent
AGENTBTC_API_KEY=agent_xxx ← can read balance
(no AGENTBTC_LND_HOST) ← can't make payments
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"agentbtc": {
"command": "node",
"args": ["/path/to/agentbtc/mcp_server/index.js"],
"env": {
"AGENTBTC_API_URL": "http://localhost:8000",
"AGENTBTC_API_KEY": "your-key-here",
"AGENTBTC_LND_HOST": "https://your-node:8080",
"AGENTBTC_LND_MACAROON": "hex-macaroon"
}
}
}
}
Restart Claude Desktop after saving. The 13 AgentBTC tools appear automatically.
OpenClaw agents use the mcporter skill to access MCP servers. Add to config/mcporter.json in your workspace:
{
"mcpServers": {
"agentbtc": {
"transport": "stdio",
"command": "node",
"args": ["/path/to/agentbtc/mcp_server/index.js"],
"env": {
"AGENTBTC_API_URL": "http://localhost:8000",
"AGENTBTC_API_KEY": "your-key-here",
"AGENTBTC_LND_HOST": "https://your-node:8080",
"AGENTBTC_LND_MACAROON": "hex-macaroon"
}
}
}
}
The OpenClaw agent calls tools via mcporter:
mcporter call agentbtc.check_channel_balance
mcporter call agentbtc.get_agent_balance agent_id="Shopping Bot"
mcporter call agentbtc.pay_lightning_invoice invoice="lnbc..." agent="Shopping Bot"
Note: For a management agent (owner-level access), the OpenClaw agent needs the owner API key in its mcporter config. For a spending agent, use the agent's own API key.
Any platform that supports the Model Context Protocol (Cursor, Windsurf, Cline, etc.) can connect using the same config format. The MCP server is platform-agnostic — it speaks standard MCP over stdio.
When an agent makes a payment, this happens:
Agent requests payment (500 sats)
↓
MCP Server identifies agent (from API key or agent parameter)
↓
Decode invoice to get exact amount
↓
Check spending policy:
├── Is agent enabled? → No → BLOCKED
├── Amount > per-tx limit? → Yes → BLOCKED
├── Today's total + amount > daily limit? → Yes → BLOCKED
├── This month's total + amount > monthly limit? → Yes → BLOCKED
└── All checks pass → ALLOWED
↓
Pay via Lightning Network (direct LND connection)
↓
Log transaction against agent's wallet
↓
Return result to agent
| Scenario | Result |
|---|---|
| Agent disabled by owner | "Agent 'Shopping Bot' is disabled — payments blocked" |
| 2000 sats payment, 1100 sat per-tx limit | "Exceeds per-transaction limit (2000 > 1100 sats)" |
| Already spent 2800 today, 3000 daily limit, trying 500 | "Exceeds daily limit (3300 > 3000 sats, already spent 2800 today)" |
| Agent key tries to delete a wallet | "Owner access required to delete wallets" |
| Agent key tries to check another agent | "Cannot check another agent's spending policy" |
enabled to false blocks all operations immediately./api/v1/agents/{id}/transactions endpoint shows all recorded payments.| Task | Who | How |
|---|---|---|
| Create a wallet | Owner | Dashboard UI or create_agent_wallet MCP tool |
| Delete a wallet | Owner | Dashboard UI or delete_agent_wallet MCP tool |
| Set spending limits | Owner | Database (dashboard UI coming soon) |
| Disable an agent | Owner | Dashboard UI toggle |
| Check own balance | Agent | get_agent_balance with own name/ID |
| Make a payment | Agent | pay_lightning_invoice (policy enforced) |
| View own transactions | Agent | get_transaction_history |
| View all wallets | Owner | list_agent_wallets |
| View own wallet | Agent | list_agent_wallets (auto-scoped) |