Transaction Idempotency and Safe SDK Retry Strategies
Research status: Theoretical SDK design. Examples are illustrative and have not been built or tested against the live engine.
Why retry policy belongs to each operation
HTTP failures do not reliably indicate whether a remote state change occurred. A read-only observation may be repeated under a bounded policy; a SEND requires a stable operation identity and the documented idempotency contract. Do not confuse a response request_id with a client-supplied idempotency identifier without verifying their relationship in the API reference.
Proposed durable journal
def execute(intent, journal, adapter):
record = journal.reserve(intent) # atomic, durable
if not record.is_new:
return record.observed_outcome
try:
outcome = adapter.send(intent, record.operation_id)
except TransportUncertain:
journal.mark_unresolved(record.operation_id)
return None
journal.record_outcome(record.operation_id, outcome)
return outcomeThe names are conceptual. A real implementation must handle crashes between dispatch and recording, concurrent reservations and failures to persist outcomes. Bind an identifier to the immutable intent, including wallet, network, destination and amount. Reject attempts to reuse it for different content.
Reconciliation and limits
A journal entry left in dispatching state after a crash is unresolved. If a transaction ID is available, query the documented transaction status. If not, follow the verified engine replay contract or request operator review. Do not assume that matching an address and amount uniquely identifies a payment. Retry with the same identifier only when documented semantics and retention make it safe. A new identifier represents a new authorized intent, even for the same destination.
Acceptance plan
Use a fake transport to simulate failure before dispatch, lost response after execution, malformed JSON, process crash and concurrent duplicate calls. Then conduct a controlled Testnet replay test using the documented mechanism and verify transaction evidence and wallet state. A repeated HTTP response alone is insufficient proof of no duplicate spend. Do not claim exactly-once execution across arbitrary failures or engine resets.
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-wallet-recovery-local-lifecycle
