Bitcoin Subscription Billing: Deterministic Billing Periods
Bitcoin Subscription Billing: Deterministic Billing Periods
Generate stable invoice identities for fixed UTC billing periods.
Design and trust boundary
A recurring invoice is not recurring spending authorization. This example uses fixed 30-day periods, not calendar months. Persist the quoted price and terms per invoice; cancellation stops future invoices but does not erase historical obligations.
Independent reference implementation
1import hashlib
2import json
3
4def invoice_id(subscription, start, now):
5 if type(start) is not int or type(now) is not int or now < start:
6 raise ValueError('invalid time')
7 period = (now-start)//(30*86400)
8 payload = json.dumps([subscription,start,period],separators=(',',':'))
9 return hashlib.sha256(payload.encode()).hexdigest()
10
11assert invoice_id('s1',0,1) == invoice_id('s1',0,86400)
12assert invoice_id('s1',0,1) != invoice_id('s1',0,30*86400)
13assert invoice_id('s1',0,1) != invoice_id('s2',0,1)Operational boundaries
Run with Python 3. Assertions use synthetic data only. No wallet credentials, SEND or live API calls are included. Preserve the WAB Engine API and immutable signed fee law. Amounts are integer satoshis. Production use requires authenticated inputs, durable state and independent authorization. This is a proposed application pattern, not a production financial system.
Related research
https://thamer.org/learn/bitcoin-for-ai-agents-open-integration-guide
https://thamer.org/api
