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 Build a Self-Hosted Bitcoin Payment Gateway Without a Third-Party Processor

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

Separate the public checkout interface from the private wallet executor. Expose only the receive and observation operations needed by the merchant. Authenticate customers separately and keep the wallet credential server-side. This dispatch example demonstrates an allowlist, not a network gateway; self-hosting still requires a Bitcoin backend and operational security.

Source code

Python · 12 lines
1def dispatch(operation, payload, handlers):
2    if operation not in ("receive", "observe"): raise PermissionError("operation denied")
3    if type(payload) is not dict or set(payload) != {"order_id"} or type(payload["order_id"]) is not str or not payload["order_id"]:
4        raise ValueError("invalid request")
5    return handlers[operation](payload["order_id"])
6
7if __name__ == "__main__":
8    handlers={"receive":lambda order:{"order":order,"address":"fixture-only"},"observe":lambda order:{"state":"pending"}}
9    assert dispatch("observe",{"order_id":"o"},handlers)=={"state":"pending"}
10    try: dispatch("send",{"order_id":"o"},handlers)
11    except PermissionError: pass
12    else: raise AssertionError("send allowed")

Local validation

Run stage24-self-hosted-gateway.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