Bitcoin Digital Commerce: Idempotent Product Entitlements
Bitcoin Digital Commerce: Idempotent Product Entitlements
Issue one entitlement per paid order without duplicating delivery rights.
Design and trust boundary
An entitlement is not proof of file delivery. A trusted payment verifier must authorize issuance. Bind the order to its buyer and product; enforce access control at download time. A persistent database and transactional outbox are needed for external delivery.
Independent reference implementation
1import sqlite3
2
3def grant(db, order, buyer, product):
4 with db:
5 db.execute('INSERT OR IGNORE INTO grants VALUES (?,?,?)',(order,buyer,product))
6 row = db.execute('SELECT buyer,product FROM grants WHERE id=?',(order,)).fetchone()
7 if row != (buyer,product):
8 raise ValueError('order binding conflict')
9 return row
10
11db=sqlite3.connect(':memory:')
12db.execute('CREATE TABLE grants(id TEXT PRIMARY KEY,buyer TEXT NOT NULL,product TEXT NOT NULL)')
13assert grant(db,'o1','b1','p1') == grant(db,'o1','b1','p1')
14try:
15 grant(db,'o1','b2','p1')
16except ValueError:
17 pass
18else:
19 raise AssertionError('binding changed')
20assert db.execute('SELECT count(*) FROM grants').fetchone()[0] == 1
21db.close()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
