Payment Confirmation and Settlement State Machines
Research status: Theoretical SDK design. Examples are illustrative and have not been built or tested against the live engine.
Separate evidence from decisions
An SDK should distinguish observed payment, confirmation count and business acceptance. These are related but not identical. A transaction can be observed before inclusion in a block; a reorganization can change its confirmation state. A merchant can choose a confirmation threshold, but the SDK must not label any fixed threshold as absolute finality.
Conceptual state projection
def project(evidence, expected_sat, min_confirmations):
if evidence is None or not evidence.current:
return "UNKNOWN"
if not evidence.matches_destination:
return "REVIEW"
if evidence.output_sat < expected_sat:
return "UNDERPAID"
if evidence.confirmations < min_confirmations:
return "OBSERVED"
return "ELIGIBLE_FOR_ACCEPTANCE"These are proposed application states, not WAB status values. The example assumes one verified matching output and a valid nonnegative confirmation count. Aggregation, conflicting transactions and reorganization handling need additional logic. Preserve raw engine evidence separately from the projection.
Reorganization and fulfillment
Keep an append-only observation history and record the policy used when a decision was made. A later observation may invalidate an earlier confirmation assessment. Do not silently undo a delivered product; instead create a review event and follow the merchant's incident policy. A failed status query is uncertainty, not a reorganization. Distinguish stale evidence from contradictory evidence.
Transaction identity alone does not prove payment of a particular invoice. Verify network, destination and output amount; where necessary use an independent trusted Bitcoin view. Replacement transactions can change transaction identity, so avoid treating an unconfirmed txid as a permanent settlement key.
Acceptance plan
Exercise zero confirmations, threshold crossing, lost connectivity, conflicting evidence and a simulated reorganization using fixtures. In live Testnet tests record actual confirmation transitions without forcing a network reorganization. Test exactly-once application fulfillment using durable unique constraints, without claiming exactly-once network execution.
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-invoice-abstractions
https://thamer.org/docs/wab-sdk-immutable-fee-policy
https://thamer.org/docs/wab-sdk-payment-reconciliation
