THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Goose and Bitcoin: Minimal extension contract

permalink THAMER
#ai-agents#bitcoin#goose#python#wab-engine

Research question

How can a developer using Goose design a Bitcoin integration without handing a coding agent control of a funded wallet? This study proposes a development workflow, not a supported plugin or a live-tested integration.

Architecture and trust boundary

An MCP extension can expose a narrow tool contract; the extension host must enforce it independently of model instructions.

The operator-controlled application may call POST /api/v5/btc/wallet/balance with JSON fields net: test and type: segwit. The engine credential belongs only to that application. The model receives an explicitly approved projection of the result, not raw headers, identity records or recovery material. Balance is private information even though it does not spend funds.

Reference source

The following standalone Python example works with a synthetic response envelope. The additional function illustrates the study-specific boundary; it is not a native Goose plugin. The numeric fixture is invented and is not blockchain evidence.

Python · 19 lines
1"""Offline reference: no network, no credentials, no transaction execution."""
2import json
3
4FIXTURE = '{"ok":true,"result":{"balance_sat":12500}}'
5
6def balance_sat(raw: str) -> int:
7    envelope = json.loads(raw)
8    if not isinstance(envelope, dict) or envelope.get("ok") is not True:
9        raise ValueError("engine did not report success")
10    result = envelope.get("result")
11    if not isinstance(result, dict):
12        raise ValueError("missing result")
13    amount = result.get("balance_sat")
14    if type(amount) is not int or amount < 0:
15        raise ValueError("invalid satoshi amount")
16    return amount
17
18def extension_result(raw: str) -> dict:
19    return {"content": [{"type": "text", "text": json.dumps({"balance_sat": balance_sat(raw), "mode": "fixture"})}], "isError": False}
Source: /repo/ai-agents/stage04/goose/example.py · Raw file · Read-only excerpt

Developer workflow

Ask Goose to review a balance-only tool definition and design an extension that returns minimized output.

Start with synthetic success and failure responses. Check that an unsuccessful envelope, missing result, Boolean amount or negative amount is rejected. Review generated changes manually. Keep the real client and its secret outside the agent's editable workspace and prevent the agent from directly reaching the engine. An operator may subsequently adapt the Stage 02 HTTP example to a dedicated Testnet wallet after reviewing the actual API contract. Never treat a coding agent's approval dialog as authorization to spend Bitcoin.

Limitations and next steps

This is an educational reference, not a complete deployment. No live engine calls, agent sessions or payments were tested for this study. Platform configuration varies by release; consult upstream documentation before implementing native tools. A future payment design must bind approval to a unique intent, preserve the same idempotency key across retries and leave the engine's signed fee law unchanged.

References

  • Upstream project: https://github.com/block/goose
  • Engine API: https://thamer.org/api
  • Engine overview: https://thamer.org/engine
  • Source: https://thamer.org/repo/ai-agents/stage04/goose/example.py

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects