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 Verify Bitcoin Website Payments Before Delivery

permalink THAMER
#bitcoin#payments#python#website

Never accept a browser callback or a transaction ID alone as proof of payment. Match trusted chain observations against the expected output and confirmation policy.

Implementation approach

Normalize verified observations from your backend before calling this function. The script does not fetch blockchain data. A reorganization can invalidate a previously accepted observation; production systems must reconcile and hold irreversible delivery until their risk threshold is met.

Source code

Python · 9 lines
1def paid(invoice, output):
2    return (output.get('canonical') is True and output.get('network')==invoice['network'] and output.get('address')==invoice['address'] and type(output.get('sats')) is int and output['sats']>=invoice['sats'] and type(output.get('confirmations')) is int and output['confirmations']>=invoice['min_confirmations'])
3
4if __name__=='__main__':
5    invoice=dict(network='test',address='fixture',sats=5000,min_confirmations=2)
6    output=dict(network='test',address='fixture',sats=5000,confirmations=2,canonical=True)
7    assert paid(invoice,output)
8    assert not paid(invoice,dict(output,canonical=False))
9    assert not paid(invoice,dict(output,sats=4999))

Local validation

Run python3 stage22-payment-verification.py. The assertions use synthetic fixtures, not real Bitcoin addresses or payments. This is a reference example, not a complete production checkout. No SEND operation is included.

Related documentation

https://thamer.org/api

https://thamer.org/learn/bitcoin-ai-agents-advanced-research-guide

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