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

stage11-invoice-validation.py

TEXT FILE

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

Download / RawBack to folder
Python · 17 lines
1import re
2
3def btc_to_sat(text):
4    if not isinstance(text,str) or not re.fullmatch(r'[0-9]{1,8}(\.[0-9]{1,8})?',text):
5        raise ValueError('invalid decimal')
6    whole, _, fraction = text.partition('.')
7    sat = int(whole)*100_000_000 + int(fraction.ljust(8,'0'))
8    if not 0 < sat <= 21_000_000*100_000_000:
9        raise ValueError('out of range')
10    return sat
11
12if __name__ == '__main__':
13    assert btc_to_sat('0.00000001') == 1
14    assert btc_to_sat('0.0012') == 120000
15    try: btc_to_sat('0.000000001')
16    except ValueError: pass
17    else: raise AssertionError('fractional satoshi accepted')
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