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

How to Automate Digital Product Delivery After Bitcoin Payment

permalink THAMER
#bitcoin#e-commerce#payments#python

Use a durable entitlement record keyed by order. Grant access only after trusted payment reconciliation and an explicit confirmation policy. A unique record prevents duplicate grants, but external delivery still needs idempotency and recovery. Reorganizations require a separate access review.

Source code

Python · 16 lines
1import sqlite3
2
3def grant(db, order, customer, product, payment_state):
4    if payment_state != "paid": return False
5    with db:
6        db.execute("INSERT OR IGNORE INTO entitlement VALUES (?,?,?)",(order,customer,product))
7        row=db.execute("SELECT customer,product FROM entitlement WHERE order_id=?",(order,)).fetchone()
8        if row != (customer,product): raise ValueError("entitlement conflict")
9    return True
10
11if __name__ == "__main__":
12    db=sqlite3.connect(":memory:")
13    db.execute("CREATE TABLE entitlement(order_id TEXT PRIMARY KEY, customer TEXT, product TEXT)")
14    assert not grant(db,"o","c","p","underpaid")
15    assert grant(db,"o","c","p","paid") and grant(db,"o","c","p","paid")
16    assert db.execute("SELECT COUNT(*) FROM entitlement").fetchone()[0]==1

Local validation

Run stage24-digital-delivery.py with Python 3. The example uses synthetic data and does not execute live wallet operations. Production deployment requires authenticated access, durable storage, trusted chain evidence and integration testing.

Related documentation

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