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 Payment Agents: Matching Invoice Settlement Evidence

permalink THAMER
#ai-agents#bitcoin#commerce#wab-engine

Bitcoin Payment Agents: Matching Invoice Settlement Evidence

Research question

Reconciliation must match a specific output rather than a wallet balance or transaction ID alone.

Architecture and trust boundary

Separate the model, business ledger, operator authorization and local wallet executor. The model may propose an action but cannot establish financial evidence or grant itself permission. Keep BTC KEY out of prompts, browser contexts and business logs. A restricted tool does not turn the underlying credential into a restricted key.

Source implementation

Python · 13 lines
1def matches(invoice, output, min_confirmations):
2    sat = output.get('amount_sat')
3    conf = output.get('confirmations')
4    return (type(sat) is int and sat > 0 and sat == invoice['expected_sat']
5            and output.get('net') == invoice['net']
6            and output.get('script_pubkey') == invoice['script_pubkey']
7            and type(conf) is int and conf >= min_confirmations > 0)
8
9if __name__ == '__main__':
10    inv = {'expected_sat':900,'net':'test','script_pubkey':'fixture'}
11    out = {'amount_sat':900,'net':'test','script_pubkey':'fixture','confirmations':2}
12    assert matches(inv,out,2)
13    assert not matches(inv,dict(out,confirmations=0),2)

Integration with WAB ENGINE

The local executor can request Testnet SegWit balance using POST /api/v5/btc/wallet/balance with X-BTC-KEY and JSON body {"net":"test","type":"segwit"}. A balance is not settlement evidence. Any future SEND must bind authorization to the exact intent, use persistent idempotency and preserve the wallet's signed birth fee law. Treat the sender total and recipient net amount as distinct accounting values under the applicable inclusive fee law; never assume they are equal. No SEND is implemented here.

Limitations and failure handling

The output must come from a trusted chain observer and include a unique outpoint in the durable ledger. This predicate does not validate chain membership, prevent reuse across invoices, or handle reorganizations. Fixture scripts are not real Bitcoin scripts.

The included assertions exercise synthetic inputs only. No live engine, model or blockchain connection was tested. Fail closed on ambiguous financial state; investigate before retrying writes.

References

  • https://thamer.org/api
  • https://thamer.org/engine
  • https://developer.bitcoin.org/devguide/transactions.html

These links are reference pointers, not a claim of current external documentation verification.

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