Show / Hide Table of Contents

Interface ISettledPaymentStore

Records the transactions a facilitator has settled, so that the same signed payment cannot unlock a resource twice.

Namespace: Xrpl.X402.AspNetCore
Assembly: Xrpl.X402.AspNetCore.dll
Syntax
public interface ISettledPaymentStore
Remarks

A signed blob that has already been validated can be submitted again: the node answers tefPAST_SEQ or tefALREADY, and waiting on its hash finds the original tesSUCCESS. Without a record of what was settled, every presentation of the same PAYMENT-SIGNATURE would look like a fresh payment.

A hash must be kept until a ledger past its LastLedgerSequence is validated; after that LedgerSettlingFacilitator refuses the blob as expired before it reaches the store. An implementation backed by a time-based TTL must make the TTL cover that many ledgers.

The default InMemorySettledPaymentStore lives in one process. A deployment that runs several instances behind a load balancer must share one store between them (a database or a distributed cache with an atomic insert-if-absent), or a payment settled by one instance can be replayed against another.

A store is keyed by ledger index, so it serves one network: instances settling on mainnet and on testnet need separate stores, or the higher ledger indexes of one network prune the claims of the other while their windows are open. Instances sharing a store should read the validated ledger from nodes in step: an InMemorySettledPaymentStore-style pruning by validatedLedgerIndex can drop a claim while an instance on a node lagging by more than the retention margin still accepts the blob as unexpired.

Methods

| Edit this page View Source

ReleaseAsync(string, CancellationToken)

Drops a claim whose settlement did not succeed, so the payer can present the same blob again.

Declaration
ValueTask ReleaseAsync(string transactionHash, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string transactionHash

Hash passed to TryReserveAsync(string, uint, uint, CancellationToken).

CancellationToken cancellationToken

Cancels the operation.

Returns
Type Description
ValueTask
| Edit this page View Source

TryReserveAsync(string, uint, uint, CancellationToken)

Atomically claims transactionHash for settlement.

Declaration
ValueTask<bool> TryReserveAsync(string transactionHash, uint lastLedgerSequence, uint validatedLedgerIndex, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string transactionHash

Hash of the signed transaction, uppercase hex.

uint lastLedgerSequence

The transaction's LastLedgerSequence: the claim must be kept at least until a later ledger is validated.

uint validatedLedgerIndex

The latest validated ledger the facilitator saw; claims whose window ended well before it may be dropped.

CancellationToken cancellationToken

Cancels the operation.

Returns
Type Description
ValueTask<bool>

true when the hash was not claimed and now is; false when it is already claimed, whether settled or still being settled.

Remarks

An implementation that throws must leave the hash unclaimed. The facilitator cannot release a claim it was not told it holds - releasing it could drop a concurrent caller's claim and admit the blob twice - so a claim written before an exception (a cancelled request, a reply that timed out) refuses the blob as duplicate_payment until the store prunes it.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX