Agent-to-Agent and Agent-to-Merchant Lightning payments with Bitcoin final settlement.
Why AI agents use Lightning Bitcoin payments
Agentic commerce is financial transactions and market activity carried out by autonomous goal-directed AI agents. Human mediation is minimal or non-existent. Agents perceive data, make decisions under policy, and execute transactions (pay, invoice, reconcile, route a trade) with minimal or no human prompting.
The term is used in two overlapping ways:
Enterprise commerce ops — specialized agents own jobs such as invoicing, matching trades, controls, and close, across existing systems. Humans set limits and handle exceptions.
Markets and payments — autonomous or semi-autonomous agents take part in information management, monitoring, and execution, so their actions can move money or prices.
Currently, in practice, many agentic systems are semi-autonomous where some policies, spend caps, and an operator intervene in some financial activites. But agentic swarms are increasingly taking over these functions.
An agent swarm is a set of cooperating software agents that jointly execute a workflow. Each agent has a distinct cryptographic identity. They coordinate with one another via signed messages, allocate tasks, and can authorize payments without a human approving each transfer. In this design the nodes and wallets remain under an operator; autonomy refers to the execution loop after the agent infrastructure is funded and started.
Agent-to-Agent settlement on Lightning
Payment is a Lightning invoice issued by one agent and discharged by another. Value moves by updating balances inside a pre-funded channel, typically in seconds. The Bitcoin base chain is not used for each micropayment. Instead, Bitcoin Layer 1 is used when a Lightning channel is opened, closed, or a dispute is enforced. This represents final settlement of the net position between agents.
Why pair agent swarms with Lightning
Currently, to protect funds, some human constraints remain in place (but may be relaxed or transferred to agents in the future). A human operator must capitalize Lightning nodes, maintain inbound and outbound channel liquidity and impose spend limits. Public multipath routing of very small amounts is unreliable unless counterparties have provisioned an appropriate channel.
Velocity of money is the turnover rate of sats between paying agents. In an agent swarm with Lightning payments, the same channel inventory can settle a Merchant call, then a peer invoice, then another call, many times per day, without a new block per payment. An agent swarm uses Lightning payments as a high-turnover working-capital layer. Thus, agent swarms dramatically increase the velocity of money.
In an autonomous AI agent swarm, agents can make direct Lightning Network payments to one-another. A payee agent invoices a payer agent; the payer agent pays that invoice over the Lightning Network.
Agents in two-agent or eight-agent swarms negotiate with one-another to determine who pays the Merchant endpoint. They agree on a single payer. Then, that agent makes a Lightning payment to the Merchant and reads the results.
The Merchant endpoints serve up a variety of services that might be of interest to autonomous AI agent swarms. Agents make Lightning Network payments directly to Merchant endpoints. After a valid payment, the Merchant returns a small JSON file, in agent machine-readable format.
Currently, the fee rate for Merchant services is 100 sats, but can be set to any value. The Merchant host URL (http://3.90.159.146:8081) is open to allowed IP's but not the entire Internet. The URL is hosted on AWS but could be hosted on other platforms as well. (There are demo services that return "hello world", PDF files and PNG files for 1,000 sats, but these are mostly for testing purposes).
Currently, the Merchant provides a short list of Bitcoin, Lightning and Nostr services, but almost any kind of service could be added as a paid endpoiont.
The Bitcoin blockchain network is used as the final settlement layer for Lightning payments between agents. Bitcoin is treated as a Layer-1 protocol and Lightning is treated as a Layer-2 protocol.
For autonomous AI agent swarms, the payment and settlement protocol is:
Open a Lightning channel. Operator (human-in-the-loop) opens a Lightning channel on behalf of agents. Currently, this is for safety reasons to protect funds. Creates 2-of-2 multisig UTXO in the Bitcoin blockchain. Funds Lightning channel for agents.
Make Lightning payments. Agents pay one another via the Lightning channel.
Close the Lightning channel. Operator (human-in-the-loop) closes the Lightning channel on behalf of agents. Again, this is for safety reasons to protect funds.
Update Bitcoin ledger. Spend 2-of-2 multisig UTXO. Payout fund balances to each party's Bitcoin address. Final settlement of Lightning payment balances in the Bitcoin blockchain network.
Agents use Nostr for identity, communication, censorship resistance, signatures, encryption and discovery.
Agents get a unique ID. Each agent is assigned a unique cryptographic secp256k1 keypair (npub & nsec), esentially, a unique ID. Agents in an agent swarm can easily and uniquely identify one another via their public npub. Agents never share or expose their private encrypted secret nsec.
Agents communicate with Nostr events. Agents within agent swarms communicate with one-another via Nostr cryptographically signed events. Every accepted event must verify an agents ID, signature and pubkey. Events with sensitive payloads (i.e. invoices, etc.) are encrypted.
Agents use Nostr relays. Agents publish signed events once. If one relay dies or censors, events simply move to another relay. Thus, agents use redundant and reliable communication channels to exchange events.
Agents can use Nostr encryption. Agents can choose encrypted events for sensitive information. Encryption hides the inside of a message so a Nostr relay can store and forward it without reading invoices, prompts or agent state. Signing still proves which agent sent a message.
Agents use Nostr for discovery. Agents can find one-another by publishing a signed “I can do X” event. Nostr relays find matching agents for that event. There is no need for a central directory.
Currently, you may choose default Grok or Ollama models for Agent-to-Agent payments or Agent-to-Merchant payments.
Agent-to-Agent Lightning Network payments: Grok or Ollama model Example: examples/agent-to-agent-pay.md
Agent-to-Merchant Lightning Network payments: Grok or Ollama model Example: examples/agent-to-merchant-pay.md
Agent-Bitcoin services are available via a Python SDK.
Install from PyPI or from this repo. Tool and CA requirements are under Installation.
python3 -m venv .venv source .venv/bin/activate pip install -U pip pip install agent-bitcoin # optional: pip install 'agent-bitcoin[nostr]' python -c "import agent_bitcoin; print(agent_bitcoin.__version__)" This does not download examples/ or docs/. If you need those files use the repo clone below.
GitHub repo (SDK + examples + docs):
git clone https://github.com/gpu7/agent-bitcoin.git cd agent-bitcoin git pull origin main uv sync --python 3.12 uv run python -c "import agent_bitcoin; print(agent_bitcoin.__version__)" Nostr / swarm scripts:
uv venv -p 3.12 .venv-nostr uv pip install --python .venv-nostr/bin/python -e '.[nostr]' The import package is agent_bitcoin.
Full developer reference for SDK: SDK.md Python package source: agent_bitcoin/
The AWS Runbook describes how to set up, configure, run and manage AWS.
Currently, the Dashboard is for internal system administration only. The Dashboard is a read-only map of the agent-bitcoin infrastructure. It shows Bitcoin, the Lightning channels, the payer and invoice agents, Nostr, Aperture, and the Merchant origin. It does not pay, unlock a wallet, or open a channel.
The Bitcoin panel shows blocks, headers, and progress on separate lines.
The Lightning channels panel lists every channel from the Mac LND and the AWS LND, including inactive channels. Each channel is its own block: peer, Active or Inactive, capacity, outbound, and inbound, with a blank line between channels.
Payer, Invoice, Aperture, and Nostr details now use separate lines.
Start the mainnet map on the Mac with:
DASHBOARD_APERTURE_URL=http://3.90.159.146:8081 uv run python -m agent_bitcoin.dashboard Then open http://127.0.0.1:8765. It listens only on 127.0.0.1.
Use uv 0.13.4 or newer and pip 26.2.2 or newer. Upgrade system CA certificates (apt or dnf upgrade ca-certificates) before installing packages or building images.
Agent-Bitcoin is developed with security in mind:
Report vulnerabilities privately — see SECURITY.md. Do not open public issues for security reports.
Pull requests are welcome. This repo is MIT licensed.
Dark Factory Richard Casey richardcaseyhpc@protonmail.com +1 970-980-5975
Both files in this release have provenance metadata.
bitcoin lightning lightning-network ai-agents sdk crypto-payments
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Both files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Nov 22, 2026 2 release files Full provenance
Oct 6, 2026 2 release files Full provenance
Sep 22, 2026 2 release files Full provenance
Sep 18, 2026 2 release files Full provenance
Sep 11, 2026 2 release files Full provenance
Aug 16, 2026 2 release files Full provenance




