import { type DenomPublic } from "./blind.js"; import { denomId as formatDenomId, type Keyset } from "./denom.js"; import { type BlindedTarget, type Derived } from "./refresh.js"; import { type ContractTerms } from "./terms.js"; /** SHA-384 output width: §6.1's `commitmentDigest` and §6.6's `h_C`. */ export declare const COMMITMENT_DIGEST_LEN = 48; /** keccak256 output width: the on-chain `bytes32` `commitmentHash`. */ export declare const COMMITMENT_HASH_LEN = 32; /** * κ, the cut-and-choose parameter (§12). `γ` is drawn from `{0 … κ-1}` and * the soundness bound the refresh construction rests on is `1/κ`. Matches * `px402_registry::KAPPA`. */ export declare const KAPPA = 3; /** * The EIP-712 type string `PX402Reserve.WITHDRAW_TYPEHASH` hashes, character * for character identical to the constant in `contracts/src/PX402Reserve.sol` * and to the issuer's `WITHDRAW_TYPEHASH_PREIMAGE`. One character out of * place produces a digest the contract will never agree with, and the issuer * would reject every honest wallet. */ export declare const WITHDRAW_TYPEHASH_STRING = "WithdrawAuthorize(address reserveAddr,uint256 amount,bytes32 commitmentHash,uint64 nonce,uint64 deadline)"; /** * Domain-separation tag for the melt-reserve owner authorization (§6.4.1). * * The third of the three tags a coin key's signatures carry — the others are * `px402/v1/deposit-permission` (§6.3, `spend.ts`) and `px402/v1/refresh-link` * (§6.6, `refresh.ts`). Without distinct tags a signature produced for one * purpose could be presented as another; here that would mean a captured * deposit permission locking a coin's residual into a melt session. */ export declare const MELT_RESERVE_CONTEXT: Uint8Array; /** * §6.1's `commitmentDigest`: SHA-384 over the withdraw items, in the * **wallet's own index order** (§6.12), 48 bytes. * * ```text * commitmentDigest = SHA-384( concat over items in wallet index order of: * be32(len(denomId)) ‖ denomId ‖ pad(z, L_denom) ) * ``` * * Nothing sorts. An earlier revision of §6.1 called for a lexicographic * `denomId` sort, which is actively wrong — `denomId` is `usdc--`, * so sorting decimal numbers as strings places the largest denomination * second — and `vectors/withdraw.json` pins both the conforming digest and the * one that sort produces, so a "restored" sort fails loudly. * * `L` comes from each item's denomination **key**, never from the byte length * of `z`: `z` is uniform mod `N`, so about 1 value in 256 has a leading zero * byte that a minimal-length encoding would drop, and wallet and issuer would * then disagree on ~0.4% of withdrawals. The encoding is shared verbatim with * §6.6's `h_C` (`refresh.encodeBlindedItems`) so the two cannot drift. */ export declare function withdrawCommitmentDigest(items: readonly BlindedTarget[]): Uint8Array; /** * §6.12's `commitmentHash`: `keccak256(commitmentDigest)`, the 32-byte * on-chain word. * * This is the value in `pendingDebits`, in the `WithdrawAuthorized` event, in * the EIP-712 `WithdrawAuthorize` struct the reserve owner signs, and in the * issuance-root leaf `keccak(withdrawId ‖ commitmentHash ‖ H(σ_blind batch))`. * * **The 48-byte input length is enforced, not assumed.** The two failure * modes §6.12 calls out are truncating the digest to 32 bytes and keccaking * the items directly, and both begin with this function being handed * something that is not a SHA-384 digest — most plausibly a value that has * already been through keccak once. Rejecting a 32-byte input turns that into * an immediate throw instead of a coin nobody can verify. */ export declare function withdrawCommitmentHash(commitmentDigest: Uint8Array): Uint8Array; /** * `withdrawId = keccak256(abi.encode(reserveAddr, nonce))`, matching the * contract's `withdrawIdOf` and the issuer's `withdraw_id_of`. * * `abi.encode`, not `abi.encodePacked`: two full 32-byte words, the address * right-aligned in the first and the `uint256` nonce in the second. The * wallet does not get to name this value — the issuer recomputes it and * rejects a request whose copy disagrees, because it is the key * `commitIssuanceRoot` finalizes against. */ export declare function withdrawIdOf(reserveAddr: Uint8Array, nonce: bigint): Uint8Array; /** The `WithdrawAuthorize` struct's fields, as the reserve owner signs them. */ export interface WithdrawAuthorize { /** The wallet's own reserve address (§5.2.1), 20 bytes. */ readonly reserveAddr: Uint8Array; /** `Σ value(denomId)` over the items, in USDC base units. */ readonly amount: bigint; /** The **48-byte** SHA-384 digest. It is hashed to 32 bytes inside. */ readonly commitmentDigest: Uint8Array; readonly nonce: bigint; readonly deadline: bigint; } /** * The EIP-712 digest `PX402Reserve.withdrawAuthorize` recomputes on-chain: * `keccak256("\x19\x01" ‖ domainSeparator ‖ structHash)`. * * `domainSeparator` is read from the deployed contract rather than rebuilt * from a configured chain id — the issuer does the same, which is what makes * "the issuer accepted it" and "the contract will accept it" the same * statement. Unlike `contractTermsHash` (§6.3, deliberately domain-free) this * digest **is** signed, so it carries the full `\x19\x01` prefix and is bound * to one chain and one contract. */ export declare function withdrawAuthorizeDigest(domainSeparator: Uint8Array, a: WithdrawAuthorize): Uint8Array; /** * The 20-byte EVM address of a seed-derived reserve key: the low 20 bytes of * `keccak256` over the uncompressed public key with its `0x04` tag removed. */ export declare function reserveAddressFrom(reserveKey: Uint8Array): Uint8Array; /** * Sign a 32-byte EIP-712 digest with a reserve key, in the 65-byte * `r ‖ s ‖ v` layout `ecrecover` takes, `v ∈ {27, 28}`. * * **Low-`s` is required, not merely conventional.** OpenZeppelin's * `ECDSA.recover` rejects the malleated high-`s` copy (§5.2.2) and the issuer * checks for it before paying gas, so a high-`s` signature is a withdrawal * that costs the issuer a rejected request and the wallet a failed refill. * `@noble/curves` produces low-`s` for secp256k1 by default; this asserts it * rather than trusting the default to survive a version bump. */ export declare function signWithdrawAuthorize(reserveKey: Uint8Array, digest: Uint8Array): Uint8Array; /** * §6.4.1's melt-reserve owner authorization message: * * ```text * "px402/v1/melt-reserve" ‖ C⁰_p(32) ‖ be32(attempt) ‖ h_C(48) ‖ be64(residual) * ``` * * Every field is fixed-width, so none carries a length prefix (§6.12). `γ` is * **not** in it and must not be: an earlier revision left `γ` uncovered while * an implementation carried it as a request field, which let a wallet name * its own challenge and obtain a signature on the unrevealed row with * probability 1 instead of 1/κ. * * "Permissionless" writes mean anyone may *relay* a melt reserve; only the * coin's owner may *authorize* one. Without this signature, anyone who had * merely observed `⟨C⁰_p, σ⁰⟩` — every facilitator and merchant the coin was * ever shown to — could permanently destroy its residual, since §6.6 no * longer restores a locked residual on expiry. */ export declare function meltAuthorizationMessage(coinPub: Uint8Array, attempt: number, commitmentHash: Uint8Array, residual: bigint): Uint8Array; /** * A usable coin: `⟨denomId, c_s, C_p, σ⟩` plus the key and face value needed * to spend it. * * `secret` is the bearer instrument — whoever reads it spends the coin. `key` * travels with the coin because `L = bitlen(N)/8` is needed for every * encoding `σ` appears in, and resolving it by position in some array is the * mis-pairing §6.6 warns about. */ export interface IssuedCoin { readonly denomId: string; readonly key: DenomPublic; readonly valueBaseUnits: bigint; /** `c_s`: the Ed25519 secret. Secret material. */ readonly secret: Uint8Array; /** `C_p`: the Ed25519 public key, 32 bytes. */ readonly pub: Uint8Array; /** `σ`: the unblinded denomination signature, exactly `L` bytes. */ readonly sigma: Uint8Array; } /** * One planned withdraw item: the coin's secret, and the blinding factor and * blinded message derived alongside it. * * Held rather than persisted — every field is a pure function of * `(seed, reserveAddr, counter)`, which is what makes §6.10 recovery possible * and what makes a re-`POST` of an interrupted withdrawal idempotent. */ export interface WithdrawItem { readonly denomId: string; /** `c_s(i)`. */ readonly coinSecret: Uint8Array; /** `r(i)`, the seeded blinding factor. */ readonly r: bigint; /** `z(i) = Blind(pk_denom, C_p(i); r(i))`, as an integer. */ readonly blinded: bigint; } /** Inputs to {@link planWithdraw}. */ export interface WithdrawPlan { readonly seed: Uint8Array; readonly reserveAddr: Uint8Array; readonly keyset: Keyset; /** The wallet's lifetime-monotonic coin counter at the start of this batch. */ readonly startCounter: bigint; /** One denomination id per coin, in the order the wallet wants them hashed. */ readonly denomIds: readonly string[]; } /** * Derive §6.1 step 1 for a whole withdrawal: one coin secret, blinding factor * and blinded message per requested denomination. * * # The counter must never repeat (§6.13) * * `r` is a function of the blinding ikm **alone** — `N` is not bound into the * derivation — so two coin indices reaching the same ikm reuse `r` under the * same issuer key, which is a silent unlinkability failure nothing downstream * can detect. `(seed, reserveAddr)` are constant across a reserve's whole * history, so the counter is the only thing separating one blinding from * another. This function advances it once per item and the caller must not * reuse a `startCounter` across withdrawals. * * Coin public keys are validated before they are blinded: an issuance path * must refuse to have a small-order or non-canonical key signed into a coin. */ export declare function planWithdraw(plan: WithdrawPlan): WithdrawItem[]; /** The subset of `fetch` this client uses. Injectable so tests need no server. */ export type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise; /** * How a retryable failure is retried. * * `attempts` counts total attempts, not extra ones: `1` disables retrying. * `sleep` is injectable so a test suite does not spend real seconds proving * that a 409 is retried. */ export interface RetryOptions { readonly attempts: number; /** Delay before the attempt numbered `attempt` (1-based, so `attempt = 2` is the first retry). */ readonly delayMs: (attempt: number) => number; readonly sleep: (ms: number) => Promise; } /** Constructor options for {@link IssuerClient}. */ export interface IssuerClientOptions { readonly baseUrl: string; /** * The registry's base URL (§6.4.1). Optional because most of this client's * surface — `/keys`, `/withdraw`, `/melt-reserve`, `/melt-reveal` — is * served by the issuer alone. Only {@link IssuerClient.meltAttempt} needs * it: `GET /melt-attempt/:C_p` is served exclusively by `px402-registry`, * never by the issuer, and calling it without a configured `registryUrl` * throws rather than guessing at `baseUrl`. */ readonly registryUrl?: string; readonly fetch?: FetchLike; readonly retry?: Partial; } /** * What an issuer says it can still do with one epoch's keyset (K1), as its * `GET /keys` labels it. **Advisory**: a wallet checks every keyset against * `keysets(epochId)` on the reserve itself and never takes a label as * evidence of a commitment. * * - `current` -- the newest committed epoch: withdrawals and change land in it. * - `signing-retired` -- an older committed epoch inside its spend window: * its coins spend and melt, nothing new is signed under it. * - `melt-only` -- past its spend window, inside its refresh window: its * coins can only be melted, into the current epoch. * - `expired` -- past its refresh window: its coins are dead (listed so an * verifier can read the log). * - `pending` -- a new epoch's keyset not yet committed: never used. */ export type KeysetStatus = "current" | "signing-retired" | "melt-only" | "expired" | "pending"; /** One keyset an issuer serves, its id recomputed here, and its label. */ export interface ServedKeyset { readonly keyset: Keyset; /** `keccak256(canonicalBytes(keyset))`, recomputed -- never the served one. */ readonly keysetId: Uint8Array; readonly status: KeysetStatus; } /** The keyset an issuer serves, with the id this SDK recomputed from it. */ export interface IssuerKeys { /** * The top-level keyset of `GET /keys`: the one the issuer withdraws under * (`current`), or -- with none current -- its newest. */ readonly keyset: Keyset; /** * `keccak256(canonicalBytes(keyset))`, 32 bytes. * * Recomputed here, never taken from the response. The wallet's mandatory * check is that this value is the one `commitKeyset` wrote on-chain (§4); * comparing an id the issuer merely asserted against the chain would prove * nothing about the keys it served alongside it. */ readonly keysetId: Uint8Array; /** {@link keyset}'s label; `current` from an issuer that predates K1. */ readonly status: KeysetStatus; /** * Every epoch the issuer lists, oldest first, each id recomputed (K1). An * issuer that predates the list serves one keyset, and this holds it alone. */ readonly keysets: readonly ServedKeyset[]; /** * Whether the issuer listed its epochs (K1). When it did, an epoch it does * not list is one it no longer holds: it cannot melt that epoch's coins. */ readonly listed: boolean; } /** Arguments to {@link IssuerClient.withdraw}. */ export interface WithdrawParams { readonly keyset: Keyset; readonly items: readonly WithdrawItem[]; readonly reserveAddr: Uint8Array; readonly nonce: bigint; readonly deadline: bigint; /** Read from the deployed reserve contract, 32 bytes. */ readonly domainSeparator: Uint8Array; /** Signs the EIP-712 digest with the reserve key. Kept as a callback so the SDK need not hold it. */ readonly sign: (digest: Uint8Array) => Uint8Array | Promise; } /** One denomination a melt session targets. */ export interface MeltTarget { readonly denomId: string; readonly key: DenomPublic; readonly valueBaseUnits: bigint; } /** Arguments to {@link IssuerClient.melt}. */ export interface MeltParams { /** The keyset the change is minted under: the targets' (K1: the newest committed epoch). */ readonly keyset: Keyset; /** * The keyset the melted coin was issued under, when it is not * {@link keyset} (K1: a coin of an older epoch melts into change of the * newest). Defaults to {@link keyset}. */ readonly coinKeyset?: Keyset; /** `c⁰_s`, the melted coin's secret. */ readonly coinSecret: Uint8Array; /** `denomId⁰`. */ readonly denomId: string; /** `σ⁰`, exactly `L` bytes. */ readonly sigma: Uint8Array; /** `v_r`, the coin's remaining value. Checked by the registry against its own ledger. */ readonly residual: bigint; /** From `registry.meltAttempt(C⁰_p)`; 0-based, and incremented only by the issuer (§6.6). */ readonly attempt: number; /** `{D_j}` in index order. `Σ value(D_j)` must equal `residual`. */ readonly targetDenomIds: readonly string[]; readonly kappa?: number; /** Unix seconds, for reporting `expiresAt` only. Never used to decide whether a session lapsed. */ readonly now?: () => number; } /** * A live melt session: the challenge the authority chose, and the whole grid * the wallet derived to answer it. * * Every field except `gamma`, `expiresAt`, `committed` and `fresh` is a pure * function of `(coinSecret, attempt, targets)`, which is what makes crash * recovery work: re-run {@link IssuerClient.melt} from the seed and the same * session comes back, `gamma` included. */ export interface MeltSession { readonly coinPub: Uint8Array; readonly attempt: number; /** * The row the wallet must **not** reveal. Derived by the session authority * under a secret it alone holds (§6.4.1) — never supplied or predicted by * this client, and range-checked to `0 ≤ γ < κ` before it is used. */ readonly gamma: number; readonly kappa: number; readonly residual: bigint; /** * When the authority stops holding *unconfirmed* session state. **Not a * refund timer**: expiry does not restore the residual and never yields a * fresh `γ` (§6.6). */ readonly expiresAt: number; readonly committed: boolean; /** False when this call re-requested an existing session — the crash-recovery path. */ readonly fresh: boolean; /** `h_C`, 48 bytes. */ readonly commitHash: Uint8Array; readonly targets: readonly MeltTarget[]; /** `s_i` for `i = 0 … κ-1`. Secret for `i = γ`. */ readonly seeds: readonly Uint8Array[]; /** `T_i` for `i = 0 … κ-1`. */ readonly tPubs: readonly Uint8Array[]; /** The κ × |targets| grid, `i` outer and `j` inner, both 0-based and ascending. */ readonly grid: readonly (readonly Derived[])[]; } /** * A client for one issuer, and optionally the registry it delegates one * route to. * * # Endpoints * * `GET /keys`, `POST /withdraw`, `POST /melt-reserve` and `POST /melt-reveal` * are all served by the issuer (`crates/px402-issuer`) and go to `baseUrl`. * * `GET /melt-attempt/:C_p` is the one exception: §6.4.1 lists it under the * **registry's** API, and `px402-registry` is the only service that serves * it — the issuer's own surface is `/keys`, `/withdraw`, `/melt-reserve`, * `/melt`, `/melt-reveal`, `/log` and `/admin/*`, with no `/melt-attempt` * route at all. {@link IssuerClient.meltAttempt} therefore needs a second * base URL, {@link IssuerClientOptions.registryUrl}; without one it throws * rather than sending the request to a service that cannot answer it. */ export declare class IssuerClient { private readonly baseUrl; private readonly registryUrl; private readonly fetchImpl; private readonly retry; constructor(options: IssuerClientOptions); private url; /** * One request, with §6.5's dispositions applied. * * The loop retries exactly what `errors.ts` marks retryable — 409 whose * condition can still clear, 500 issuer faults, transport failures — and * nothing else. A 410 leaves on the first attempt, because its answer is * recoup (§6.9) and a retry loop around it is an infinite one. * * `base` defaults to the issuer; {@link meltAttempt} is the only caller * that passes {@link IssuerClientOptions.registryUrl} instead. */ private request; private post; /** * `GET /keys` (§4): the epoch's denomination ladder and windows. * * The served `keyset_id` is **verified, not trusted**: this recomputes * `keccak256(canonicalBytes(keyset))` from the fields it was given and * rejects a response whose asserted id is not that value. An issuer able to * serve two byte encodings of "the same" keyset, both with ids that * verify, could tag victims by which encoding they received. * * The caller still owes the on-chain comparison this check only makes * meaningful: a keyset whose id is not in `commitKeyset` must not be * withdrawn under (§4). */ keys(): Promise; /** * `POST /withdraw` (§6.1 steps 2–7): submit blinded coins, receive the * blind signatures, unblind and verify them. * * Ordering the issuer guarantees and this relies on: signatures are neither * returned nor published until the covering issuance root is confirmed, so * a signature arriving here implies a finalized debit that * `reclaimPending` can no longer undo. * * Every returned signature goes through `finalize`, which unblinds **and * verifies** (RFC 9474 §4.4 steps 5–6). Skipping the verification stores * whatever a faulty or malicious issuer returned as a coin and discovers at * spend time that it is worthless — after the money is gone. * * Idempotent: re-posting the same `commitmentDigest` returns the same * signatures and never re-debits, so an interrupted withdrawal is finished * by replaying the identical plan. */ withdraw(params: WithdrawParams): Promise; /** * `GET /melt-attempt/:C_p` (§6.4.1): the coin's current melt attempt. * * **Registry-only.** §6.4.1 lists this route under the registry's API — * `px402-registry` serves it and `px402-issuer` does not — so this call * goes to {@link IssuerClientOptions.registryUrl}, never to `baseUrl`. A * client constructed without a `registryUrl` throws here rather than * sending the request to a service with no such route: guessing `baseUrl` * produced a bare HTTP 404 that read as a transport failure instead of a * configuration one. * * 0-based, and it increments **only when the registry authorizes it** — * after a refund credits the coin (§6.7) — never on wallet request. A * wallet restored from seed reads it back here rather than remembering it, * which is the whole of what it needs to recompute an interrupted session. */ meltAttempt(coinPub: Uint8Array): Promise; /** * `POST /melt-reserve` (§6.6 Commit, §6.4.1): derive the κ × |targets| grid, * commit to it, and receive the challenge `γ`. * * # What is derived, and what is received * * Everything sent is a pure function of `(c⁰_s, attempt, targets)`: * `s_i`, `T_i`, `x_i`, the new coin secrets, the blinding factors, the * blinded messages, `h_C`, and the owner authorization over * `⟨C⁰_p, attempt, h_C, residual⟩`. Nothing is stored and nothing is random. * * `γ` is the one value that comes the other way. It is derived by the * session authority under a challenge secret only that service holds, so * the wallet cannot place its dishonest row where the challenge will not * land. **This client never sends a `gamma` field**, and a peer that * accepts one is nonconforming (§6.4.1: "Any implementation that accepts γ * on the wire MUST reject the request"). * * # Re-requesting is the crash-recovery path, not a retry for a new γ * * A melt reserve does not lapse on a timer. `MELT_TTL` bounds unconfirmed * session state only: an expired session restores nothing and re-rolls * nothing, and a second *differing* `h_C` for the same `⟨C⁰_p, attempt⟩` is * rejected outright — the first commitment stands. Calling this again after * a crash therefore returns the identical `γ`, which is exactly what a * wallet holding only its seed needs. */ melt(params: MeltParams): Promise; /** * `POST /melt-reveal` (§6.6 Reveal): open every row but `γ`, and hand over * row `γ`'s transfer key and blinded messages under a linking signature. * * The seeds for `i ≠ γ` let the issuer recompute those rows in full and * check them against `h_C`; row `γ` stays closed, and its blinded messages * are what get signed. `γ` is not sent as a field — it is the index the * seed map omits, and the issuer already knows it because it chose it. * * `s_L` binds `⟨C⁰_p, T_γ, {(denomId_j, m(γ,j))}⟩` with the denomination * and its blinded message **interleaved pairwise**, so a reveal cannot * re-point a committed `m` at a richer denomination. * * The returned signatures are unblinded with the grid's own `r(γ,j)` and * verified before they are returned as coins. */ reveal(session: MeltSession, coinSecret: Uint8Array): Promise; /** * One page of the issuer's public transparency log, `GET /log?from=` (§8): * every issuance and melt record it ever published, in `seq` order, from * `from` (1 is the start). * * Public and unauthenticated, and **read whole** by recovery: a caller that * reads every page names nothing of its own. Never ask the issuer about * one coin; see `recover.ts` on why the lookup is keyed on `z`. */ logPage(from: bigint): Promise; /** * The registry's `spentTotal(C_p)`, `GET /spent/:C_p` (§6.4.1): how much of * one coin's value is spent, committed or melted, right now. A refund never * lowers it; {@link coinSpent} reads the credit beside it. * * **This names the coin to the registry, from this caller's network * address.** Route the client's `fetch` through a proxy you control. */ spentTotal(coinPub: Uint8Array): Promise; /** * `GET /spent/:C_p` whole (§6.4.1): the coin's spent total and the refund * credit a melt has not yet collected. What is left to melt is * `face − spent + refundCredit`, the residual the registry locks. * * **This names the coin to the registry, from this caller's network * address.** Recovery needs it because the registry's public `/log` lists a * spend only once a spend root covering it is committed, hours later on a * production snapshot interval, so a coin spent since then would read as * unspent. Route the client's `fetch` through a proxy you control. */ coinSpent(coinPub: Uint8Array): Promise; /** * `POST /disputes { contract_terms }` for a bridge payment (v3 §26.7): the * payer's own dispute, with **no `payto_sig`** -- the preimage is the * credential, and only the wallet, the facilitator and the signing relayer * hold it. The issuer revokes a relayer's record when the payment's * `payoutNonce` was never used, and answers `PAYOUT_NOT_RECORDED` when no * relayer recorded at all. * * One attempt, and every status comes back as a {@link ServiceAnswer}: the * codes are the wallet's recourse schedule (`PAYOUT_OBSERVED`, * `DISPUTE_TOO_EARLY` with `not_before`, …), not errors to retry here. * Throws {@link PX402TransportError} only when nothing answered. * * This shows the issuer the payment's preimage -- `payTo` included -- from * this caller's network address, which it also sees at withdrawals: route * the client's `fetch` through a proxy you control. */ disputeBridgePayment(terms: ContractTerms): Promise; /** * `POST {registry}/bridge/cancel-request { contract_terms_hash }` (v3 §26.8 * step 7): asks the registry to cancel a bridge payment no relayer recorded, * without the facilitator's secret. The first request starts §20.2's * fallback clock -- the cancel opens `PAYOUT_DEADLINE` later -- so a payer * whose facilitator never refunds is refunded anyway. One attempt, answered * like {@link disputeBridgePayment}. * * The registry gets the **hash**, never the preimage: a preimage carries * `payTo`, and §6.4 is unconditional that the registry never learns one. * The registry answers only for a payment it holds as a bridge payment, * and `{ refunded: true }` once the coins are back. * * **Registry-only**, like {@link meltAttempt}: without a `registryUrl` it * throws rather than guessing. */ requestBridgeCancel(terms: ContractTerms): Promise; /** One POST, its answer whatever the status; a transport failure is {@link PX402TransportError}. */ private answer; } /** * A service's answer to one request, whatever its status: what the bridge * recourse (v3 §26.8 step 7) branches on. */ export interface ServiceAnswer { readonly status: number; /** The body's error code (`error`), when it named one. */ readonly error: string | undefined; /** `not_before`, unix seconds on the chain's clock, when the body carried one. */ readonly notBefore: number | undefined; /** The JSON body, when it was an object. Untrusted. */ readonly body: Record | undefined; } /** * The registry's books on one coin, `GET /spent/:C_p` (§6.4.1), as * {@link IssuerClient.coinSpent} reads them. Base units. */ export interface CoinSpent { /** `spentTotal(C_p)`: every committed spend and melted residual. A refund never lowers it (§6.7). */ readonly spent: bigint; /** * Refunded value a melt has not yet collected (§6.7), at most `spent`. A * melt is its only way back: the coin itself is never offered again (§7). * `0n` from a registry that does not report it. */ readonly refundCredit: bigint; } /** One entry of the issuer's public log (§8), as {@link IssuerClient.logPage} reads it. */ export interface IssuerLogEntry { /** `"issuance"`, `"melt"`, `"redemption"`, … — readers skip kinds they do not know. */ readonly kind: string; /** Unix seconds the issuer published the record. */ readonly createdAt: number; /** The record, as served. Untrusted: every reader checks what it uses. */ readonly payload: Record; } /** One page of `GET /log`. */ export interface IssuerLogPage { readonly entries: readonly IssuerLogEntry[]; /** The `seq` to ask for next, or `undefined` when this page reached the end. */ readonly next: bigint | undefined; /** * `log_size`: how many entries the log held when the page was served, for * a progress display. `undefined` when the issuer sent none, or one that is * not a number; nothing else reads it. */ readonly logSize?: bigint | undefined; } /** * A keyset as JSON, in exactly the shape the issuer's `GET /keys` serves one * (§6.14: every `u64` a decimal string, hex bare but for `keyset_id`). * * For keeping the wallet's own copy of a keyset (K1): `px402.recover` reads * every epoch the issuer still serves, and one it no longer serves -- an * issuer that lost an epoch's database -- only from a copy the caller kept * and passes back as `keysets`. Public data; nothing secret is in it. */ export declare function keysetToJson(keyset: Keyset): Record; /** * The inverse of {@link keysetToJson}, refusing a document whose `keyset_id` * is not the id of the keyset it holds. A keyset read back this way is no * more trusted than one an issuer serves: `px402.open` and `px402.recover` * check it against the chain (§4) like any other. */ export declare function keysetFromJson(json: unknown): Keyset; /** Re-exported so callers can format a denomination id without importing two modules. */ export { formatDenomId as denomIdFor };