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 Add a Bitcoin Donation Button to a Website

permalink THAMER
#bitcoin#donations#python#website

A donation button can open a Bitcoin payment URI without exposing wallet credentials.

Implementation approach

Use a server-configured, independently validated address. The example checks the character boundary for HTML and URI construction, not the Bitcoin checksum. A fixed address is simple but exposes repeated donations to public correlation.

Source code

Python · 13 lines
1from html import escape
2import re
3
4def button(address):
5    if not re.fullmatch(r'[a-zA-Z0-9]{14,90}', address):
6        raise ValueError('invalid address characters')
7    return '<a href="bitcoin:' + escape(address, quote=True) + '">Donate Bitcoin</a>'
8
9if __name__ == '__main__':
10    assert button('tb1qsyntheticfixture').startswith('<a href="bitcoin:')
11    try: button('x" onclick="bad')
12    except ValueError: pass
13    else: raise AssertionError('unsafe input accepted')

Local validation

Run stage23-donation-button.py with Python 3. Fixtures are not valid Bitcoin addresses. This is an educational example, not a production donation service. No SEND operation is included.

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