Building Reliable Bitcoin Payment Reconciliation SDKs
Research status: Theoretical SDK design. Examples are illustrative and have not been built or tested against the live engine.
Reconciliation model
Reconciliation compares what an application expected to receive with what the Bitcoin evidence supports. It is not simply a balance query: a wallet balance may include unrelated deposits, change and pending activity. Keep invoice records, watch observations and transaction outputs as separate data sets. Use a stable wallet and network scope, and preserve evidence provenance and observation time.
Conceptual Python matching
def match_output(invoice, output):
if output.net != invoice.net:
return False
return (output.address == invoice.address
and output.amount_sat == invoice.expected_sat)This example matches a single exact output in a normalized model. It does not prove uniqueness, confirmation or ownership. Real reconciliation should use transaction ID and output index, validate destination scripts where appropriate, and prevent the same output from being credited to multiple invoices. Partial and multiple payments need explicit aggregation rules.
Evidence and reporting
Use WATCH observations and TX STATUS according to their documented contracts. If the engine response does not provide sufficient output detail, obtain it from an authorized trusted Bitcoin source rather than inventing fields. A report should distinguish matched, pending, underpaid, overpaid, unmatched and unknown records. Missing data is not zero revenue. Keep integer amounts and preserve the original source records for audit.
Durable accounting boundary
A specialized SDK may generate reconciliation reports, but the merchant ledger remains responsible for credits and corrections. Use atomic uniqueness constraints for output allocation and idempotent posting of accepted credits. Keep reorganization adjustments as explicit entries rather than deleting history. Avoid logging secrets or exposing unrelated wallet activity to customers.
Acceptance plan
Create fixtures for duplicate outputs, unrelated deposits, partial payments, stale status and unavailable sources. In a live Testnet experiment register a payment request, send a known payment from another wallet and compare the expected invoice amount with the observed output and later confirmation. Restart the reconciliation process and confirm that the same output cannot be credited twice. Publish redacted evidence and distinguish simulated failures from live observations.
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-confirmation-settlement-states
https://thamer.org/docs/wab-sdk-immutable-fee-policy
