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

receive.py

TEXT FILE

1.1 KB · Public source code for developers, search crawlers and AI agents

Download / RawBack to folder
Python · 25 lines
1import json, os, urllib.request
2class NoRedirect(urllib.request.HTTPRedirectHandler):
3    def redirect_request(self, req, fp, code, msg, headers, newurl):
4        return None
5
6def receive(address_type: str) -> str:
7    if address_type not in ("segwit", "taproot"):
8        raise ValueError("unsupported address type")
9    key = os.environ["WAB_BTC_KEY"]
10    req = urllib.request.Request(
11        "http://127.0.0.1:7070/api/v5/btc/wallet/receive",
12        data=json.dumps({"net":"test", "type":address_type}).encode(),
13        headers={"Content-Type":"application/json", "X-BTC-KEY":key}, method="POST")
14    opener = urllib.request.build_opener(urllib.request.ProxyHandler({}), NoRedirect())
15    with opener.open(req, timeout=10) as response:
16        raw = response.read(1048577)
17    if len(raw)>1048576:
18        raise ValueError("oversized response")
19    data=json.loads(raw)
20    if data.get("ok") is not True:
21        raise RuntimeError("receive unavailable")
22    address=data["result"]["address"]
23    if not isinstance(address,str) or not address.startswith("tb1q" if address_type=="segwit" else "tb1p"):
24        raise ValueError("unexpected address")
25    return address
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