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

stage22-receive-address.py

TEXT FILE

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

Download / RawBack to folder
Python · 27 lines
1import json
2import os
3import urllib.request
4
5class NoRedirect(urllib.request.HTTPRedirectHandler):
6    def redirect_request(self, *args, **kwargs):
7        raise ValueError("redirect refused")
8
9def receive(opener=None):
10    if opener is None:
11        opener = urllib.request.build_opener(urllib.request.ProxyHandler({}), NoRedirect()).open
12    key = os.environ['BTC_KEY']
13    req = urllib.request.Request('http://127.0.0.1:7070/api/v5/btc/wallet/receive', data=b'{"net":"test","type":"segwit"}', headers={'X-BTC-KEY':key,'Content-Type':'application/json'}, method='POST')
14    with opener(req, timeout=5) as response:
15        raw = response.read(65537)
16    if len(raw)>65536: raise ValueError('oversized response')
17    data=json.loads(raw)
18    if data.get('ok') is not True: raise ValueError('receive failed')
19    address=data['result']['address']
20    if not isinstance(address,str) or not address.startswith('tb1q'): raise ValueError('unexpected address')
21    return address
22
23if __name__=='__main__':
24    import io
25    from unittest.mock import patch
26    with patch.dict(os.environ, {'BTC_KEY':'synthetic'}):
27        assert receive(lambda req,timeout: io.BytesIO(b'{"ok":true,"result":{"address":"tb1qfixture"}}'))=='tb1qfixture'
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