@me2em/core
    Preparing search index...

    Interface PaymentAdapter

    A wallet adapter that can also execute and verify payments (Документ 2 v1.2 §5). Knowledge of attestations is deliberately kept out of pay: the buyer link is verifyWalletBinding on the app side, execution control is verifyPayment on the recipient side.

    interface PaymentAdapter {
        chain: string;
        resolveWallet(
            entity: WalletEntityRef,
            opts?: { seed?: Uint8Array; index?: number },
        ): Promise<WalletDescriptor>;
        isValidAddress(address: string): boolean;
        nextIndex?(usedPaths: string[]): number;
        pay(from: WalletDescriptor, request: PaymentRequest): Promise<string>;
        verifyPayment(
            txRef: string,
            request: PaymentRequest,
        ): Promise<PaymentResult>;
        verifyWalletBinding?(
            wallet: WalletDescriptor,
            entity: WalletEntityRef,
            attestation: Attestation,
        ): Promise<boolean>;
    }

    Hierarchy (View Summary)

    Index
    chain: string

    Exact CAIP-2 chain this adapter handles — also its registry key.

    • Optional: chain-scoped index allocation from used derivation paths (v1.2 §2.2). The adapter parses its own path formats; an empty input — or an input that is empty after filtering to the adapter's own paths — yields 0; otherwise max(indexes) + 1 (holes are never reused); paths the adapter cannot parse are ignored, never thrown on. Callers filter paths by subjectWalletChain before handing them over. core performs NO fallback when the method is absent — index allocation is caller responsibility.

      Parameters

      • usedPaths: string[]

      Returns number

    • Programmatically spends from a wallet the adapter CONTROLS (derived or imported keys). from is non-null. External wallets (browser extensions) do not go through pay — they follow the chain-specific request-URL flow. On success txRef is non-empty; on failure pay throws (v1.2 §5.1).

      Parameters

      Returns Promise<string>

    • Idempotent pure read of the chain state for a confirmed transaction (v1.2 §5.3): repeating the call with the same txRef yields the same result. The normative check order and failure reasons are pinned by v1.2 §5.4 (NOT_FOUND → REFERENCE_MISMATCH → EXPIRED → REPLAYED → WRONG_RECIPIENT → UNDERPAID → success). Chain-level REPLAYED is detected by the adapter; order-level deduplication stays with the application.

      Parameters

      Returns Promise<PaymentResult>