/** * H3-DAC + x402 Hybrid Payment Protocol * * Features: * - Per-datagram micropayments (QUIC/HTTP3) * - x402 header compatibility * - Streaming byte-metered payments * - ZK batch settlement * - E2E encryption (x25519 ECDH) * - Reputation-based discounts */ import { ethers } from 'ethers'; import { OGChainClient } from '../chain/0g'; import { SecurityManager } from '../crypto/security'; export interface DatagramPayment { escrowId: string; payer: string; payee: string; amount: string; nonce: number; datagramHash: string; timestamp: number; } export interface StreamingSession { sessionId: string; payer: string; payee: string; bytesDelivered: number; totalCost: string; payments: DatagramPayment[]; active: boolean; } export interface BatchSettlement { proofHash: string; escrowIds: string[]; totalAmount: string; datagramCount: number; zkProof?: Uint8Array; } export interface RelayerReputation { address: string; bond: string; authorized: boolean; reputationScore: number; totalSettled: string; failedCount: number; discountPercentage: number; } export declare class H3DACPaymentV2 { private chainClient; private security; private escrowAddress?; private tokenAddress?; private escrowContract?; private tokenContract?; private sessions; private pendingBatches; private sharedSecrets; constructor(chainClient: OGChainClient, security: SecurityManager, escrowAddress?: string | undefined, tokenAddress?: string | undefined); /** * Initialize contracts */ init(escrowAddress: string, tokenAddress: string): Promise; /** * Create x402-compatible payment header * Format: Payment: escrowId=,amount=,nonce=,hash= */ createX402Header(payment: DatagramPayment): string; /** * Parse x402 Payment header */ parseX402Header(header: string): Partial; /** * Lock payment for single datagram (x402 compatible) */ lockDatagramPayment(payee: string, amount: string, datagramPayload: Uint8Array, nonce?: number): Promise; /** * Release payment (called by relay after delivery) */ releaseDatagramPayment(escrowId: string, bytesDelivered: number): Promise; /** * Start streaming session (multiple datagrams, single settlement) */ startStreamingSession(sessionId: string, payee: string, estimatedBytes: number, costPerByte: string): Promise; /** * Add datagram to streaming session */ addDatagramToSession(sessionId: string, datagramPayload: Uint8Array, costPerDatagram: string): Promise; /** * Close streaming session with batch settlement */ closeStreamingSession(sessionId: string, generateZKProof?: boolean): Promise; /** * Get relayer reputation info */ getRelayerReputation(relayerAddress: string): Promise; /** * Establish x25519 shared secret for session encryption */ establishSharedSecret(sessionId: string, peerPublicKey: Uint8Array): Promise; /** * Encrypt datagram with session secret */ encryptDatagram(sessionId: string, payload: Uint8Array): Uint8Array; /** * Decrypt datagram with session secret */ decryptDatagram(sessionId: string, encrypted: Uint8Array): Uint8Array; /** * Calculate cost savings with reputation discount */ calculateDiscountedCost(relayerAddress: string, baseCost: string): Promise<{ originalCost: string; discount: string; finalCost: string; }>; getSession(sessionId: string): StreamingSession | undefined; getPendingBatch(proofHash: string): BatchSettlement | undefined; getAllSessions(): StreamingSession[]; } //# sourceMappingURL=h3-dac-v2.d.ts.map