Agent-to-Agent Bitcoin Payment Requests: Canonical Intent
Agent-to-Agent Bitcoin Payment Requests: Canonical Intent
Research question
An agent-to-agent request is a proposal, not a payment authorization. Bind the request ID, network, wallet scope, destination and sender total to a stable digest.
Architecture and trust boundary
Treat model output and messages from other agents as untrusted proposals. Authenticate principals outside the model, keep BTC KEY in an isolated local executor, and separate authorization from execution. A request identifier is not authorization. Preserve the wallet's original signed fee law; distinguish sender total from recipient net amount.
Source implementation
1# SPDX-License-Identifier: 0BSD
2import hashlib
3import json
4
5def digest(intent):
6 fields = {"request_id", "wallet", "net", "to", "amount_sat"}
7 if set(intent) != fields or intent["net"] != "test":
8 raise ValueError("invalid intent")
9 if any(type(intent[k]) is not str or not intent[k] for k in fields - {"amount_sat"}):
10 raise ValueError("invalid identifier")
11 n = intent["amount_sat"]
12 if type(n) is not int or not 0 < n <= 21_000_000 * 100_000_000:
13 raise ValueError("invalid amount")
14 return hashlib.sha256(json.dumps(intent, sort_keys=True, separators=(",", ":"), ensure_ascii=True).encode()).hexdigest()
15
16p = dict(request_id="r1", wallet="demo", net="test", to="synthetic-destination", amount_sat=1000)
17assert digest(p) != digest(dict(p, request_id="r2"))
18assert digest(p) != digest(dict(p, amount_sat=1001))Integration with WAB ENGINE
A trusted executor can query POST /api/v5/btc/wallet/balance using X-BTC-KEY and JSON body {"net":"test","type":"segwit"}. The examples do not call this endpoint or implement SEND. A balance does not prove payment settlement. Any future write integration must persist the intent, approval, idempotency identity and execution evidence before allowing recovery or retries.
Limitations and failure handling
The digest is not a signature. Authenticate transport and validate the actual Bitcoin address and fee law before approval. This example defines an application-specific message, not an implementation of an external A2A standard.
The included assertions use synthetic data only. No live engine, model or blockchain connection was tested.
References
- https://thamer.org/api
- https://thamer.org/engine
- https://developer.bitcoin.org/devguide/transactions.html
Reference pointers only; external documentation was not reverified for this stage.
