Bitcoin Commerce Agents: Order State and Payment Evidence
Bitcoin Commerce Agents: Order State and Payment Evidence
Research question
An order must not become fulfilled merely because an agent claims that payment succeeded.
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 transition(state, event):
2 allowed = {('created','reviewed'):'approved',
3 ('approved','broadcast_observed'):'pending',
4 ('pending','settlement_verified'):'settled',
5 ('settled','fulfillment_authorized'):'fulfilled'}
6 if (state,event) not in allowed:
7 raise ValueError('invalid transition')
8 return allowed[state,event]
9
10if __name__ == '__main__':
11 assert transition('pending','settlement_verified') == 'settled'
12 try: transition('created','settlement_verified')
13 except ValueError: pass
14 else: raise AssertionError('invalid transition 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
Events are trusted inputs in this fragment, not model messages. A production state machine needs authenticated evidence, durable transactions, duplicate-event handling and a reorganization policy.
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.
