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

Versioned Bitcoin Agent Payment Envelopes

permalink THAMER
#agent-protocols#ai-agents#bitcoin#python#security

Versioned Bitcoin Agent Payment Envelopes

Define a bounded, versioned request before authorization.

Design and trust boundary

The envelope binds sender, recipient, amount, network and expiry to a request identifier. It deliberately omits a destination address: this is a negotiation message, not a SEND contract. Resolve the actual destination and wallet in a separate approved intent. The restricted ASCII and integer profile avoids many serialization ambiguities; it is not a general JSON canonicalization standard. Reject duplicate JSON keys at the transport parser before calling this function.

Independent reference implementation

Python · 19 lines
1# SPDX-License-Identifier: 0BSD
2import json, hashlib, re
3
4def encode(p):
5    if set(p) != {'version','sender','recipient','request_id','net','amount_sat','expires'}:
6        raise ValueError('fields')
7    if type(p['version']) is not int or p['version'] != 1 or p['net'] != 'test':
8        raise ValueError('version or network')
9    for k in ('sender','recipient','request_id'):
10        if type(p[k]) is not str or not re.fullmatch(r'[A-Za-z0-9_-]{1,64}',p[k]):
11            raise ValueError(k)
12    if type(p['amount_sat']) is not int or not 0 < p['amount_sat'] <= 2100000000000000:
13        raise ValueError('amount')
14    if type(p['expires']) is not int or not 0 < p['expires'] < 2**53:
15        raise ValueError('expiry')
16    return b'bitcoin-agent-request-v1\x00' + json.dumps(p,sort_keys=True,separators=(',',':'),ensure_ascii=True).encode()
17
18p=dict(version=1,sender='buyer',recipient='seller',request_id='r1',net='test',amount_sat=1000,expires=2000000000)
19assert hashlib.sha256(encode(p)).digest() != hashlib.sha256(encode(dict(p,amount_sat=1001))).digest()

Validation and limitations

Run the example with Python 3. Assertions use synthetic fixtures and do not contact a wallet or agent service. This is a proposed application-level pattern, not an established interoperability standard. Keep BTC KEY outside agent messages. The WAB Engine API and signed fee law remain unchanged.

Related research

https://thamer.org/learn/bitcoin-for-ai-agents-open-integration-guide

https://thamer.org/api

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