import { type LightningStack } from "./_paid-stack.js";
type FetchFn = typeof globalThis.fetch;
export declare const RUN402_MPP_LIGHTNING_PROFILE = "run402-mpp-lightning-charge-draft00-safety-v1";
/** A single Run402 charge above this is refused before paying (the spec's conservative USD ceiling in sats). */
export declare const LIGHTNING_MAX_DEBIT_SATS = 250000;
/** Bounded: the gateway credits a charge it cannot fulfil after three recovery cycles, well inside this. */
export declare const POST_SETTLEMENT_RETRY_LIMIT = 6;
export interface PostSettlementRetry {
    code: string;
    delayMs: number;
}
/**
 * The paid retry's answer, when it is one of the gateway's retryable
 * post-settlement states from the origin that was asked: the code and how
 * long to wait before repeating the identical request. Null for everything
 * else, including a terminal 409 and any answer from another origin.
 */
export declare function readPostSettlementRetry(response: Response, url: string): Promise<PostSettlementRetry | null>;
export interface LightningWalletLike {
    getBudgetSats(): Promise<{
        usedSats: number;
        totalSats: number | null;
    } | null>;
    getBalanceSats(): Promise<number>;
    payInvoice(bolt11: string): Promise<{
        preimage: string;
    }>;
    lookupInvoice(paymentHash: string): Promise<{
        state: string | null;
        preimage: string | null;
    } | null>;
}
export interface LightningFetchOptions {
    pairingUri: string;
    /** The x402 buyer to use when the seller offers no Lightning challenge. */
    fallback: () => Promise<FetchFn | null>;
    baseFetch?: FetchFn;
    wallet?: LightningWalletLike;
    stack?: () => Promise<LightningStack>;
    /** Called with the payment hash of each paid challenge (never the preimage). */
    onPaid?: (paymentHash: string) => void;
    /** The wait between post-settlement retries; tests pass an instant one. */
    sleep?: (ms: number) => Promise<void>;
}
export declare class LightningPaymentError extends Error {
    readonly code: string;
    readonly details: Record<string, unknown>;
    constructor(code: string, message: string, details?: Record<string, unknown>);
}
interface LightningChallenge {
    header: string;
    invoice: string;
    paymentHash: string;
    amountSats: number;
    expires: string | null;
}
/** The `WWW-Authenticate: Payment …` challenge for lightning/charge, or null. */
export declare function readLightningChallenge(response: Response, stack: LightningStack): LightningChallenge | null;
/**
 * Only a POST to a charged surface gets the Lightning negotiation headers
 * and a default Idempotency-Key. Every other request is left byte-for-byte
 * alone: an Idempotency-Key on an ordinary write (a room message, a project
 * provision) would turn a deliberate repeat into a replay.
 */
export declare function isLightningChargedRequest(input: RequestInfo | URL, init: RequestInit | undefined): boolean;
export declare function createLightningFetch(options: LightningFetchOptions): FetchFn;
export {};
//# sourceMappingURL=lightning-paid-fetch.d.ts.map