Programmable Bitcoin Orders: Explicit State Transitions
Programmable Bitcoin Orders: Explicit State Transitions
Separate order acceptance, payment verification and fulfillment.
Design and trust boundary
A paid order cannot be cancelled as if no funds arrived. A refund is a separate workflow. Persist transitions with compare-and-swap in production; this example only models the transition graph.
Independent reference implementation
1def advance(state, event):
2 transitions = {('open','accept'):'awaiting_payment',
3 ('awaiting_payment','verified_payment'):'paid',
4 ('paid','fulfill'):'fulfilled',
5 ('open','cancel'):'cancelled'}
6 if (state,event) not in transitions:
7 raise ValueError('invalid transition')
8 return transitions[state,event]
9
10assert advance('paid','fulfill') == 'fulfilled'
11try:
12 advance('paid','cancel')
13except ValueError:
14 pass
15else:
16 raise AssertionError('paid order cancelled')Operational boundaries
Run with Python 3. Assertions use synthetic data only. No wallet credentials, SEND or live API calls are included. Preserve the WAB Engine API and immutable signed fee law. Amounts are integer satoshis. Production use requires authenticated inputs, durable state and independent authorization. This is a proposed application pattern, not a production financial system.
Related research
https://thamer.org/learn/bitcoin-for-ai-agents-open-integration-guide
https://thamer.org/api
