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

Bitcoin Agent Rolling Spending Windows

permalink THAMER
#ai-agents#bitcoin#python#spending-policy

Bitcoin Agent Rolling Spending Windows

Design and trust boundary

Count settled debits within the rolling interval and all unresolved reservations regardless of age. An uncertain broadcast must never disappear merely because a window elapsed. Use trusted timestamps and serialize reservation with the decision.

Independent reference implementation

Python · 10 lines
1"""Offline educational example; no wallet calls."""
2def available(now, window, ceiling, settled, pending):
3    if any(type(x) is not int or x <= 0 for x in (window, ceiling)):
4        raise ValueError("invalid policy")
5    if any(type(t) is not int or t > now or type(a) is not int or a <= 0 for t,a in settled) or any(type(a) is not int or a <= 0 for a in pending):
6        raise ValueError("invalid ledger")
7    return max(0, ceiling - sum(a for t,a in settled if now-window < t <= now) - sum(pending))
8
9assert available(100, 20, 1000, [(80, 200), (81, 300)], [400]) == 300
10assert available(1000, 20, 1000, [], [400]) == 600

Operational boundaries

All amounts are integer satoshis. This offline example assumes trusted policy inputs and does not authenticate a caller or execute SEND. Production requires durable state, exact intent binding, stable idempotency and reconciliation of uncertain broadcasts. The external policy must not modify the immutable wallet fee law.

Related research

https://thamer.org/learn/bitcoin-for-ai-agents-open-integration-guide

https://thamer.org/api

Questions & Answers

Explore all questions →

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