Bitcoin Micropayment Agents: Aggregating Small Obligations
Bitcoin Micropayment Agents: Aggregating Small Obligations
Research question
Small obligations may be accumulated in an internal ledger before a separately approved on-chain payment.
Architecture and trust boundary
Separate the model, business ledger, operator authorization and local wallet executor. The model may propose an action but cannot establish financial evidence or grant itself permission. Keep BTC KEY out of prompts, browser contexts and business logs. A restricted tool does not turn the underlying credential into a restricted key.
Source implementation
1def aggregate(entries):
2 seen = set()
3 totals = {}
4 for event_id, payee, sat in entries:
5 if event_id in seen or type(sat) is not int or sat <= 0:
6 raise ValueError('invalid obligation')
7 seen.add(event_id)
8 totals[payee] = totals.get(payee,0) + sat
9 if totals[payee] > 21_000_000*100_000_000:
10 raise ValueError('amount overflow')
11 return totals
12
13if __name__ == '__main__':
14 assert aggregate([('a','merchant',3),('b','merchant',7)]) == {'merchant':10}
15 try: aggregate([('a','m',3),('a','m',3)])
16 except ValueError: pass
17 else: raise AssertionError('duplicate accepted')Integration with WAB ENGINE
The local executor can request Testnet SegWit balance using POST /api/v5/btc/wallet/balance with X-BTC-KEY and JSON body {"net":"test","type":"segwit"}. A balance is not settlement evidence. Any future SEND must bind authorization to the exact intent, use persistent idempotency and preserve the wallet's signed birth fee law. Treat the sender total and recipient net amount as distinct accounting values under the applicable inclusive fee law; never assume they are equal. No SEND is implemented here.
Limitations and failure handling
Internal obligations are not Bitcoin settlement and may introduce custody and accounting responsibilities. The example does not create a transaction or guarantee that an aggregate is spendable. Dust, miner fees and signed fee law remain engine concerns.
The included assertions exercise synthetic inputs only. No live engine, model or blockchain connection was tested. Fail closed on ambiguous financial state; investigate before retrying writes.
References
- https://thamer.org/api
- https://thamer.org/engine
- https://developer.bitcoin.org/devguide/transactions.html
These links are reference pointers, not a claim of current external documentation verification.
