Use a shared lease for mutually exclusive Algorand refund attempts

Two differently signed payment attempts can carry different transaction IDs for the same refund. A common lease lets the ledger reject a competing transaction from the same sender within the protected rounds.

Generate one lease per business operation

Store the 32-byte lease beside the refund record and reuse it for allowed alternatives. Include the sender in your database identity. A lease set by account A cannot exclude a transaction sent by account B. Leave unrelated refunds on separate leases.

import hashlib

lease = hashlib.sha256(b"merchant-17:refund:order-402").digest()
assert len(lease) == 32

Align the last valid rounds

Give competing attempts the same last-valid round. If one confirms, its sender/lease pair remains locked through that last-valid round. A second attempt valid beyond that boundary could execute after the lock expires. After expiry, reconcile confirmed transactions before authorizing another refund. A lease provides no permanent deduplication.

Sources