Building a Bitcoin AI Payment Agent: Lessons from Live Testnet Engineering
A Bitcoin AI payment agent is not a wallet consensus engine. It interprets user intent and invokes a separate, deterministic Bitcoin execution service. That distinction became essential during our Testnet experiments with a Go gateway, an independent Bitcoin Engine, and Llama 3.3 70B through OpenRouter.
What we built
The gateway accepts a JSON chat request, asks a language model to select a supported tool, and calls the Bitcoin Engine over HTTP. The engine owns wallet state, UTXO selection, transaction construction, signing, and its wallet-specific signed fee law. The AI gateway must not rewrite that fee law or invent wallet authority.
The experimental interface exposed receive, balance, UTXOs, send, transaction status, and watch-related operations. A stateless iteration removed chat-history storage, so each request stood alone. A later design explored adding bbolt back only for SEND deduplication.
A failure worth publishing
In an earlier experiment, a model interpreted an instruction to send Bitcoin to an address with no amount and supplied 10,000 satoshis itself. The engine executed a valid request received from the gateway. This was an authorization failure in the agent layer, not evidence of an engine bug. We introduced deterministic Go checks rather than relying on prompt instructions alone.
What the later tests established
A request without an amount was answered with a question, not a transaction. A request for 8,000 sats was blocked by the Go guard with SEND_MINIMUM_9000_SAT. An explicit 10,000-sat send without a request ID was blocked with SEND_REQUEST_ID_REQUIRED. Balance and UTXO tool calls returned real engine data. A 20,000-sat total send succeeded on Testnet: the recipient received 18,000 sats under the wallet's inclusive 10% fee law. The engine returned a transaction ID.
Two separate 20,000-sat sends to the same address, each with a newly generated request ID, both succeeded. That showed the proposed destination cooldown had not been proven active in the running deployment. It did not prove that either transaction was a duplicate: the user deliberately issued two requests.
What is not yet proven
Successful tool calls do not establish safe automatic retry behavior, robust request-ID conflict handling, or Mainnet readiness. A result wrapper can report gateway success while the nested engine response reports AMOUNT_TOO_SMALL. We treat these as separate layers.
Engineering takeaway
Keep the AI conversational and the executor deterministic. Test refusal cases before successful transfers. Record original engine outcomes and distinguish confirmed rejection from an unknown outcome after a network interruption. Publish failures alongside successes; that is how the boundary between an AI agent and a financial system becomes testable.
Related reading
- /learn/how-to-test-bitcoin-ai-agent-on-testnet/
- /learn/bitcoin-ai-send-idempotency-with-bbolt/
- /ask/can-an-ai-agent-invent-bitcoin-send-amount/
