Lightning Bitcoin payments for autonomous AI Agents
A lightweight Python SDK that enables AI agents to send and receive Lightning/Bitcoin payments.
| Doc | Who it's for |
|---|---|
| SDK.md | App & agent developers (install, API, fees, quotes, LLM agents, HTTP API) |
| docs/backend.md | Operators: AWS/Mac regtest dual-node lab |
| docs/signet.md | Operators: dual-node signet (current pre-mainnet lab) |
| docs/mainnet-pilot.md | Mainnet pilot Phases 0–8 (ops complete; ≤50k dual-node) |
| docs/public-routing-loop.md | Topology A′: public channels + first Loop Out done; capital HOLD; Autoloop off |
Features
- Simple, agent-friendly API (
create_client) - Create and pay Lightning invoices (payee creates, payer pays)
- Explicit invoice quotes for independent agents (
create_invoice_quote/pay_invoice_quote) — one BOLT11 for the requested amount - LND transports: docker
lncli(lab default) or gRPC + macaroon (docs/lnd-client.md) - Networks: regtest (default), signet, testnet; mainnet only with explicit latch
- Pydantic models and structured errors
- Optional LLM payment decision agent (PAY / REJECT / CONFIRM — never executes pays)
- Balance checks (Lightning and on-chain)
- Operator tooling: dual-node health, SCB backup, daily ops (docs/index.md)
- Optional Aperture L402 HTTP gateway (regtest PoC; Mac pays AWS
:8081) — docs/l402-aperture.md
Roles: payee and payer
| Role | Does |
|---|---|
| Payee | Creates the invoice (and quote); receives X sats over Lightning |
| Payer | Validates quote / budget; pays the BOLT11 amount (plus optional Lightning routing fee limit) |
Either physical node (AWS agent LND or Mac counterparty LND) can act as payee or payer depending on who creates the invoice.
Payment amounts
There is no platform / transaction fee. A requested payment of X sats creates and pays a BOLT11 for exactly X. Lightning routing fees (the fee_limit_sats / routing_fee_limit_sats cap) are separate and still apply when paying.
| Rule | Default |
|---|---|
| Platform / transaction fee | None |
| Minimum Lightning invoice amount | 1,000 sats (MIN_PAYMENT_SATS) |
For independent agents, prefer create_invoice_quote so the payer sees amount_sats / total_cost_sats without shared env. Details: SDK.md.
There is no collect_transaction_fee / POST /send-fee. Mainnet pays stay latch-gated — see docs/mainnet-pilot.md.
Installation
From PyPI
pip install agent-bitcoin
From source
git clone https://github.com/gpu7/agent-bitcoin.git
cd agent-bitcoin
uv sync
More detail (optional LangChain / Grok / Ollama deps): SDK.md.
Quick start
from agent_bitcoin import create_client
client = create_client()
# Payee: invoice + explicit quote for independent payers
quote = client.create_invoice_quote(memo="Test payment", amount_sats=2000)
# quote.payment_request, amount_sats, total_cost_sats (equals amount)
# Payer: validate / decision inputs, then pay Lightning amount
inputs = client.build_payer_decision_inputs(quote, routing_fee_limit_sats=200)
if inputs.quote_valid:
result = client.pay_invoice_quote(quote, routing_fee_limit_sats=200)
if result.success:
print(f"Paid {result.amount} sats (LN); total_cost was {quote.total_cost_sats}")
Bare create_invoice / pay_invoice remain available for simple lab flows.
Configure LND via env (LND_NETWORK, LND_TRANSPORT=docker|grpc, container or gRPC cert/macaroon).
Full API → SDK.md.
Regtest operators → docs/backend.md.
Signet operators → docs/signet.md.
Security
Agent-Bitcoin is developed with security in mind:
- Secrets stay out of the repository — API keys, wallet material, and host credentials are configured via environment and local ops practice, not committed source
- Least privilege for network and node access (admin/API/RPC not left open to the whole internet in operator deployments)
- Conservative defaults for payment amounts and fees (see SDK.md)
- Authenticated payment APIs — backend balance/invoice/pay routes require an API key when deployed
- Bounded autonomous payment decisions — hard amount limits in code before any LLM approval
- Mainnet kill switches — e.g.
AGENT_BITCOIN_ALLOW_MAINNET,AGENT_BITCOIN_ALLOW_AUTOPAY, daily spend caps - Operator health checks — dual-node signet health, backups (docs/daily-ops-signet.md, docs/security-hardening.md)
- Regtest / signet first for lab work; mainnet is never the implicit default (pilot ops complete under ≤50k dual-node — docs/mainnet-pilot.md)
Report vulnerabilities privately — see SECURITY.md. Do not open public issues for security reports.
Documentation
| Link | Description |
|---|---|
| SDK.md | Python SDK, quotes, fees, LLM agents, Backend HTTP API |
| docs/index.md | Full docs index (signet, mainnet readiness, backup, health, liquidity) |
| docs/backend.md | Regtest dual-node workflow |
| docs/signet.md | Signet dual-node lab |
| docs/mainnet-pilot.md | Mainnet pilot Phases 0–8 (ops complete; ≤50k dual-node) |
| docs/public-routing-loop.md | Public routing + Loop on AWS (topology A′; HOLD) |
| examples/ | Runnable sample scripts (incl. signet product path) |
| CHANGELOG.md | Release history |
| SECURITY.md | Security policy and vulnerability reporting |
Repository
License
MIT License — see LICENSE.
Support
Richard Casey richardcaseyhpc@protonmail.com +1 970-980-5975
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_bitcoin-26.2.0.tar.gz.
File metadata
- Download URL: agent_bitcoin-26.2.0.tar.gz
- Upload date:
- Size: 163.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc316f06b33c5de8789fc38cea5ad86924b27520dbf2239b4d2ff8bfa724241a
|
|
| MD5 |
23a2ccacdc269a90ca71aa0161ac35ea
|
|
| BLAKE2b-256 |
0a890a1e8a0cd5f00847ba840ba6be0ab5e679bdca82af09add7e6193ba2e6ba
|
Provenance
The following attestation bundles were made for agent_bitcoin-26.2.0.tar.gz:
Publisher:
release.yml on gpu7/agent-bitcoin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_bitcoin-26.2.0.tar.gz -
Subject digest:
fc316f06b33c5de8789fc38cea5ad86924b27520dbf2239b4d2ff8bfa724241a - Sigstore transparency entry: 2493227933
- Sigstore integration time:
-
Permalink:
gpu7/agent-bitcoin@457d56c8b30e4b065afd8feae97805c0b0681b36 -
Branch / Tag:
refs/tags/v26.2.0 - Owner: https://github.com/gpu7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@457d56c8b30e4b065afd8feae97805c0b0681b36 -
Trigger Event:
push
-
Statement type:
File details
Details for the file agent_bitcoin-26.2.0-py3-none-any.whl.
File metadata
- Download URL: agent_bitcoin-26.2.0-py3-none-any.whl
- Upload date:
- Size: 50.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9355a07a5c199d8b63d80e318754f61393f877229d1925951ea9b5d4ac399782
|
|
| MD5 |
acc70ba07e3cd8ee7f4b00bc53ee8d09
|
|
| BLAKE2b-256 |
3f46b31de7f51b2dffd6843b5a011cf2da1e21430c11910de75baaa4c315bca1
|
Provenance
The following attestation bundles were made for agent_bitcoin-26.2.0-py3-none-any.whl:
Publisher:
release.yml on gpu7/agent-bitcoin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_bitcoin-26.2.0-py3-none-any.whl -
Subject digest:
9355a07a5c199d8b63d80e318754f61393f877229d1925951ea9b5d4ac399782 - Sigstore transparency entry: 2493228310
- Sigstore integration time:
-
Permalink:
gpu7/agent-bitcoin@457d56c8b30e4b065afd8feae97805c0b0681b36 -
Branch / Tag:
refs/tags/v26.2.0 - Owner: https://github.com/gpu7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@457d56c8b30e4b065afd8feae97805c0b0681b36 -
Trigger Event:
push
-
Statement type: