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

Designing Bitcoin Invoice Abstractions

permalink THAMER
#bitcoin#payments#sdk#software-engineering#wab

Research status: Theoretical SDK design. Examples are illustrative and have not been built or tested against the live engine.

Invoice versus watch

An invoice is a commercial record describing what a customer owes. A WAB watch is an engine observation mechanism. An SDK may link them, but should not imply that the engine manages products, taxes, customer accounts or legal invoices. The invoice owns the expected amount, currency, network, expiration policy and fulfillment reference. The watch supplies an address and an observation identifier according to the documented contract.

Conceptual TypeScript model

type Invoice = {
  id: string;
  expectedSat: bigint;
  net: "test" | "main";
  address: string;
  watchId: string;
  expiresAt: string;
};

This is a proposed application model. Serialize bigint explicitly at persistence boundaries; use a validated numeric conversion only where the actual API requires it. Do not pass this entire object to WATCH CREATE. Keep invoice IDs unique within the merchant namespace and persist the returned address before exposing it to the buyer.

Payment presentation

An application may construct a BIP21-style on-chain payment URI from a validated address and exact BTC amount. Convert satoshis using integer arithmetic, never floating-point rounding. This is not a BOLT11 Lightning invoice. A payment link or QR code must not contain BTC KEY, internal credentials or recovery material. A browser should receive only the payment instructions it needs.

Exceptions

Underpayment, overpayment, multiple transfers and payments after expiration require explicit merchant policies. Do not assume the watch aggregates multiple transfers unless verified. A refund is a new SEND intent with independent authorization; the input address of a transaction is not automatically a safe refund destination. Do not reuse an expired invoice for another order merely because its address remains valid.

Acceptance plan

Test exact amount formatting, duplicate invoice creation, late observations and mismatched networks. On Testnet, compare the invoice's expected amount against the actual recipient output rather than the sender's requested amount. Verify that repeated observations cannot trigger repeated delivery.

Primary reference

https://thamer.org/api

Related reading in this series

https://thamer.org/docs/wab-sdk-designing-bitcoin-sdk
https://thamer.org/docs/wab-sdk-api-engine-application-boundaries
https://thamer.org/docs/wab-sdk-wallet-identity-management
https://thamer.org/docs/wab-sdk-cross-language-interfaces
https://thamer.org/docs/wab-sdk-typed-json-contracts
https://thamer.org/docs/wab-sdk-authentication-credential-management
https://thamer.org/docs/wab-sdk-wallet-creation-restoration
https://thamer.org/docs/wab-sdk-receive-address-interfaces
https://thamer.org/docs/wab-sdk-balance-utxo-management
https://thamer.org/docs/wab-sdk-transaction-execution
https://thamer.org/docs/wab-sdk-idempotency-retry-strategies
https://thamer.org/docs/wab-sdk-wallet-recovery-local-lifecycle
https://thamer.org/docs/wab-sdk-payment-sdk-design
https://thamer.org/docs/wab-sdk-watch-payment-monitoring
https://thamer.org/docs/wab-sdk-confirmation-settlement-states
https://thamer.org/docs/wab-sdk-immutable-fee-policy
https://thamer.org/docs/wab-sdk-payment-reconciliation

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