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

stage23-donation-address-session.py

TEXT FILE

941 B · Public source code for developers, search crawlers and AI agents

Download / RawBack to folder
Python · 21 lines
1import sqlite3
2
3def init(db):
4    db.execute('CREATE TABLE sessions (session TEXT PRIMARY KEY, network TEXT NOT NULL, address TEXT NOT NULL, UNIQUE(network,address))')
5
6def bind(db, session, network, address):
7    if network not in ('main','test') or not session or not address:
8        raise ValueError('invalid mapping')
9    with db:
10        db.execute('INSERT INTO sessions VALUES (?,?,?) ON CONFLICT(session) DO NOTHING', (session,network,address))
11        row = db.execute('SELECT network,address FROM sessions WHERE session=?',(session,)).fetchone()
12        if row != (network,address): raise ValueError('session conflict')
13    return row
14
15if __name__ == '__main__':
16    db=sqlite3.connect(':memory:'); init(db)
17    assert bind(db,'s1','test','fixture1') == bind(db,'s1','test','fixture1')
18    try: bind(db,'s2','test','fixture1')
19    except sqlite3.IntegrityError: pass
20    else: raise AssertionError('address reused')
21    db.close()
Read-only source · Select a line number to link directly · Raw download above

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