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

example.py

TEXT FILE

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

Download / RawBack to folder
Python · 31 lines
1import json
2import os
3from urllib.request import Request, build_opener, ProxyHandler, HTTPRedirectHandler
4
5class NoRedirect(HTTPRedirectHandler):
6    def redirect_request(self, *args, **kwargs):
7        raise ValueError("Redirect refused")
8
9def balance():
10    req = Request("http://127.0.0.1:7070/api/v5/btc/wallet/balance",
11                  data=b'{"net":"test","type":"segwit"}',
12                  headers={"Content-Type":"application/json", "X-BTC-KEY":os.environ["BTC_KEY"]}, method="POST")
13    with build_opener(ProxyHandler({}), NoRedirect()).open(req, timeout=15) as response:
14        raw = response.read(1048577)
15    if len(raw) > 1048576:
16        raise ValueError("Response too large")
17    obj = json.loads(raw)
18    if obj.get("ok") is not True:
19        raise ValueError("Engine rejected request")
20    sats = obj["result"]["balance_sat"]
21    if type(sats) is not int or sats < 0:
22        raise ValueError("Invalid balance")
23    return {"net":"test", "type":"segwit", "balance_sat":sats}
24
25def run(event):
26    if event != {"topic":"bitcoin/balance"}:
27        raise ValueError("Unexpected topic")
28    return {"topic":"bitcoin/observation", "payload":balance()}
29
30if __name__ == "__main__":
31    print(json.dumps(run({'topic': 'bitcoin/balance'})))
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