Typed Bitcoin Tool Inputs for AI Agents
Research scope
This is Stage 01, study 02, of Bitcoin for AI Agents. It is an educational reference design, not a live-tested integration or production SDK. The WAB Engine remains independent; wallet creation belongs to the Factory.
Architecture and rationale
A JSON schema describes an interface, but the executor must validate inputs independently. Restrict the network and address type, reject unknown fields and reject duplicate keys.
Reference implementation
This Python example validates the proposed balance tool payload without contacting the engine. The test network is the only enabled network in this example.
1import json
2
3
4def unique_pairs(pairs):
5 result = {}
6 for key, value in pairs:
7 if key in result:
8 raise ValueError("duplicate field")
9 result[key] = value
10 return result
11
12
13def balance_input(raw: str) -> dict:
14 data = json.loads(raw, object_pairs_hook=unique_pairs)
15 if not isinstance(data, dict) or set(data) != {"net", "type"}:
16 raise ValueError("invalid fields")
17 if data["net"] != "test" or data["type"] not in ("segwit", "taproot"):
18 raise ValueError("unsupported network or type")
19 return dataSecurity and limitations
A provider may ignore schema constraints. Python booleans are integers in some contexts, so future amount validation must explicitly reject booleans. Never silently default an absent network.
Applying the pattern
Keep the model-facing interface separate from trusted execution. Review the current engine API before mapping fields or response data. Use a dedicated test wallet and explicit network configuration for any future live evaluation. The example does not change the engine, its signed fee law, or Bitcoin Core.
