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

main.rs

TEXT FILE

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

Download / RawBack to folder
Rust · 29 lines
1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3#[derive(Serialize)]
4#[serde(rename_all="lowercase")]
5enum AddressType { Segwit, Taproot }
6#[derive(Serialize)]
7struct Query { net: &'static str, #[serde(rename="type")] kind: AddressType }
8#[derive(Deserialize)]
9struct Envelope { ok: bool, result: Option<Value> }
10fn utxos(key: &str, kind: AddressType) -> Result<Value, Box<dyn std::error::Error>> {
11    use std::io::Read;
12    if key.is_empty() { return Err("missing key".into()); }
13    let client = reqwest::blocking::Client::builder().no_proxy()
14        .redirect(reqwest::redirect::Policy::none())
15        .timeout(std::time::Duration::from_secs(10)).build()?;
16    let response = client.post("http://127.0.0.1:7070/api/v5/btc/wallet/utxos")
17        .header("X-BTC-KEY", key).json(&Query{net:"test",kind}).send()?;
18    if !response.status().is_success() { return Err("HTTP failure".into()); }
19    let mut bytes=Vec::new(); response.take(1_048_577).read_to_end(&mut bytes)?;
20    if bytes.len()>1_048_576 { return Err("oversized response".into()); }
21    let e: Envelope=serde_json::from_slice(&bytes)?;
22    if !e.ok { return Err("engine rejected query".into()); }
23    e.result.ok_or_else(|| "missing result".into())
24}
25fn main() {
26    let outcome=std::env::var("WAB_BTC_KEY").ok().and_then(|key|utxos(&key,AddressType::Segwit).ok());
27    if outcome.is_none(){ eprintln!("UTXO query unavailable"); std::process::exit(1); }
28    println!("UTXO response received");
29}
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