@dvmkit/sdk 0.1.0-rc.3 → 0.1.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,16 @@
1
- import { L as LightningBackend, a as LightningPayment, b as LightningWalletInfo, C as CreatedInvoice, I as InvoiceStatus, A as AccumulatorPool, c as LockPubkey, d as AccumulatorQuerier, e as ConsumedCredentialStore } from '../credit-menu-DONAtGVf.js';
2
- export { f as AppEnv, g as AttestationPayload, B as BuilderIdentityKeypair, h as CheckMintHealthOptions, i as CreditFundingReport, F as FiatDenomination, j as FiatDenominationFailure, k as FundOnlyRequest, l as IncomingPaymentOpts, J as JobCancelledError, M as MintHealthCheckResult, m as MintHealthTracker, P as PAYMENT_PROOF_KEYS, n as PaymentErrorCode, o as PaymentErrorDetail, p as PaymentInfo, R as ReporterBannerOpts, q as ResolvedFx, r as RevenueBootCheckOpts, S as SDKServerOpts, s as ServerJob, t as ShortPayForfeit, T as TempoChannelReport, u as TempoObserverHealth, v as TempoSessionChannelMismatchError, U as UpfrontPaymentOpts, V as VerifiedIncomingPayment, w as VerifyIncomingSnapshot, X as X402BatchChannelObservation, x as X402FacilitatorHealth, y as X402SettlementEvidenceOutcome, z as X402SettlementRepair, D as X402SettlementRepairRefusal, E as X402SettlementRepaired, G as X402WedgedSettlement, H as X402WedgedSettlementPage, K as X402_BATCH_SETTLEMENT_MAINNET_NETWORK, N as abortJob, O as applyPaymentInfoToJob, Q as assertRevenueReporterReady, W as buildAttestation, Y as buildPaymentErrorResponse, Z as canSwap, _ as checkMintHealth, $ as clearAccumulatorForDvm, a0 as createDVMServer, a1 as creditDepositPayload, a2 as derivedFundCreditId, a3 as devModeSkipsPaymentVerification, a4 as fromJobRecord, a5 as fundedMicroFor, a6 as generateIdentity, a7 as hasPaymentProof, a8 as hashCapabilities, a9 as hashLockKey, aa as implicitCreditId, ab as initWalletAccumulatorTable, ac as insertAccumulatorRows, ad as isDerivedCreditId, ae as isTerminal, af as isYieldMessage, ag as issueUpfrontChallenges, ah as loadIdentitySecret, ai as lockPubkeyStoreToLockPubkey, aj as msatsToFiatMicro, ak as paymentErrorBody, al as pinAskFiat, am as priceFiatMicro, an as processIncomingPayment, ao as providerMessage, ap as repairX402ExactSettlementEffect, aq as resolveFxSnapshot, ar as resolvePriceFiat, as as revenueReporterBannerState, at as signAttestation, au as toCreditTerms, av as toJobRecord, ai as toLockPubkey, aw as unknownRouteNotFound, ax as verifyAttestation, ay as verifyIncomingPayment, az as verifyTempoSessionManagementCredential, aA as verifyUpfrontPayment, aB as writeIdentity, aC as x402RequiredUsdcMicro, aD as x402SettledShare } from '../credit-menu-DONAtGVf.js';
1
+ import { L as LightningBackend, a as LightningPayment, b as LightningWalletInfo, C as CreatedInvoice, I as InvoiceStatus, A as AccumulatorPool, c as LockPubkey, d as AccumulatorQuerier, e as ConsumedCredentialStore } from '../credit-menu-ClA1JyYW.js';
2
+ export { f as AppEnv, g as AttestationPayload, B as BuilderIdentityKeypair, h as CheckMintHealthOptions, i as CreditFundingReport, F as FiatDenomination, j as FiatDenominationFailure, k as FundOnlyRequest, l as IncomingPaymentOpts, J as JobCancelledError, M as MintHealthCheckResult, m as MintHealthTracker, P as PAYMENT_PROOF_KEYS, n as PaymentErrorCode, o as PaymentErrorDetail, p as PaymentInfo, R as ReporterBannerOpts, q as ResolvedFx, r as RevenueBootCheckOpts, S as SDKServerOpts, s as ServerJob, t as ShortPayForfeit, T as TempoChannelReport, u as TempoObserverHealth, v as TempoSessionChannelMismatchError, U as UpfrontPaymentOpts, V as VerifiedIncomingPayment, w as VerifyIncomingSnapshot, X as X402BatchChannelObservation, x as X402FacilitatorHealth, y as X402SettlementEvidenceOutcome, z as X402SettlementRepair, D as X402SettlementRepairRefusal, E as X402SettlementRepaired, G as X402WedgedSettlement, H as X402WedgedSettlementPage, K as X402_BATCH_SETTLEMENT_MAINNET_NETWORK, N as abortJob, O as applyPaymentInfoToJob, Q as assertRevenueReporterReady, W as buildAttestation, Y as buildPaymentErrorResponse, Z as canSwap, _ as checkMintHealth, $ as clearAccumulatorForDvm, a0 as createDVMServer, a1 as creditDepositPayload, a2 as derivedFundCreditId, a3 as devModeSkipsPaymentVerification, a4 as fromJobRecord, a5 as fundedMicroFor, a6 as generateIdentity, a7 as hasPaymentProof, a8 as hashCapabilities, a9 as hashLockKey, aa as implicitCreditId, ab as initWalletAccumulatorTable, ac as insertAccumulatorRows, ad as isDerivedCreditId, ae as isTerminal, af as isYieldMessage, ag as issueUpfrontChallenges, ah as loadIdentitySecret, ai as lockPubkeyStoreToLockPubkey, aj as msatsToFiatMicro, ak as paymentErrorBody, al as pinAskFiat, am as priceFiatMicro, an as processIncomingPayment, ao as providerMessage, ap as repairX402ExactSettlementEffect, aq as resolveFxSnapshot, ar as resolvePriceFiat, as as revenueReporterBannerState, at as signAttestation, au as toCreditTerms, av as toJobRecord, ai as toLockPubkey, aw as unknownRouteNotFound, ax as verifyAttestation, ay as verifyIncomingPayment, az as verifyTempoSessionManagementCredential, aA as verifyUpfrontPayment, aB as writeIdentity, aC as x402RequiredUsdcMicro, aD as x402SettledShare } from '../credit-menu-ClA1JyYW.js';
3
3
  import { ProofLike, MeltQuoteBolt11Response, Proof, Wallet, SerializedDLEQ, MintQuoteBolt11Response, MintPreview, OutputDataLike } from '@cashu/cashu-ts';
4
- import { X as JsonValue, B as SignedRequestDomain, M as SignedRequestStatementHeader, Y as FundingReceipt, _ as JobReceipt$1, z as SignedRequestAudience, $ as PaymentRequired, a0 as X402Version, a1 as MppxCredential, a2 as Message, a3 as MessageType, a4 as MppxChallenge, a5 as X402_BATCH_SETTLEMENT_SCHEME, a6 as X402_EXACT_SCHEME, C as Currency, a7 as X402Wallet, a8 as X402Config, a9 as X402ExactVersionSupport, aa as X402Receipt, L as Logger$1, ab as TransactionalPayoutHook, ac as CashuMeltCompleted, K as KVStore } from '../job-store-m2pYmvbr.js';
5
- export { ad as BuildPaymentRequirementsOpts, ae as CapabilityDescriptor, af as CashuMode, ag as CreditDepositPayload, ah as DrainReceipt, ai as DrainReceiptEvent, aj as ExactEvmPayload, ak as ExactEvmPayloadAuthorization, al as FundingLot, am as FundingMethod, an as LotDebit, ao as LotDepletion, ap as MppxServer, aq as NON_CHANNEL_BITCOIN_RAILS, ar as NonChannelBitcoinRail, as as OutgoingMessage, at as PaymentPayload, au as PaymentPayloadV1, av as PaymentPayloadV2, aw as PaymentRequiredV2, ax as PaymentRequirements, ay as PaymentRequirementsV1, az as PaymentRequirementsV2, aA as PayoutReporter, aB as PostgresTempoSessionStore, aC as RAIL_REFUNDABLE, aD as ReceiptCredit, aE as ReceiptOutcome, aF as ReceiptPayment, aG as ResourceInfo, aH as RevenueReporter, aI as SIGNED_ENVELOPE_FIELDS, aJ as SIGNED_ENVELOPE_TYPES, aK as SettleResponse, aL as StaleJobReapable, aM as StepCache, aN as StepRecord, aO as UnsignedDrainReceipt, aP as UnsignedFundingReceipt, aQ as UnsignedJobReceipt, aR as VerifyResponse, aS as X402ResponseBody, aT as X402SelfRelayRpcFailureReason, aU as X402TrackedChannel, aV as X402_DEFAULT_NETWORK, aW as X402_V1_VERSION, aX as X402_VERSION, aY as _testing, aZ as buildPaymentRequiredV2, a_ as buildPaymentRequirements, a$ as caip2ToX402Network, b0 as canonicaliseForSigning, b1 as canonicalize, b2 as chainIdFromCaip2, b3 as computeResultHash, b4 as createDefaultReplayStore, b5 as decodePayment, b6 as decodePaymentRequiredHeader, b7 as depleteLots, b8 as encodePayment, b9 as encodePaymentRequiredHeader, ba as encodeSettleResponseHeader, bb as exactEvmAuthorization, bc as fifoOrder, bd as inKindDrawMsats, be as isArtifactMessage, bf as isDrainReceipt, bg as isFundingReceipt, bh as isInKindDepletion, bi as isNonChannelBitcoinRail, bj as isPaymentRequestMessage, bk as isSignedJobReceipt, bl as isStaleJobReapable, bm as lotOwedSats, bn as netOwedSats, bo as paymentRequiredV2FromV1, bp as settleWithFacilitator, bq as signDrainReceipt, br as signFundingReceipt, bs as signReceipt, bt as usdcContractByCaip2, bu as usdcContractFor, bv as usdcDomainNameFor, bw as usdcDomainVersionFor, bx as verifyDrainReceipt, by as verifyFundingReceipt, bz as verifyReceipt, bA as verifyWithFacilitator, bB as wrapMppx, bC as x402NetworkToCaip2 } from '../job-store-m2pYmvbr.js';
4
+ import { X as JsonValue, B as SignedRequestDomain, M as SignedRequestStatementHeader, Y as FundingReceipt, _ as JobReceipt$1, z as SignedRequestAudience, $ as PaymentRequired, a0 as X402Version, a1 as MppxCredential, a2 as Message, a3 as MessageType, a4 as MppxChallenge, a5 as X402_BATCH_SETTLEMENT_SCHEME, a6 as X402_EXACT_SCHEME, C as Currency, a7 as X402Wallet, a8 as X402Config, a9 as X402ExactVersionSupport, aa as X402Receipt, L as Logger$1, ab as TransactionalPayoutHook, ac as CashuMeltCompleted, K as KVStore } from '../job-store-DxFqDPYq.js';
5
+ export { ad as BuildPaymentRequirementsOpts, ae as CapabilityDescriptor, af as CashuMode, ag as CreditDepositPayload, ah as DrainReceipt, ai as DrainReceiptEvent, aj as ExactEvmPayload, ak as ExactEvmPayloadAuthorization, al as FundingLot, am as FundingMethod, an as LotDebit, ao as LotDepletion, ap as MppxServer, aq as NON_CHANNEL_BITCOIN_RAILS, ar as NonChannelBitcoinRail, as as OutgoingMessage, at as PaymentPayload, au as PaymentPayloadV1, av as PaymentPayloadV2, aw as PaymentRequiredV2, ax as PaymentRequirements, ay as PaymentRequirementsV1, az as PaymentRequirementsV2, aA as PayoutReporter, aB as PostgresTempoSessionStore, aC as RAIL_REFUNDABLE, aD as ReceiptCredit, aE as ReceiptOutcome, aF as ReceiptPayment, aG as ResourceInfo, aH as RevenueReporter, aI as SIGNED_ENVELOPE_FIELDS, aJ as SIGNED_ENVELOPE_TYPES, aK as SettleResponse, aL as StaleJobReapable, aM as StepCache, aN as StepRecord, aO as UnsignedDrainReceipt, aP as UnsignedFundingReceipt, aQ as UnsignedJobReceipt, aR as VerifyResponse, aS as X402ResponseBody, aT as X402SelfRelayRpcFailureReason, aU as X402TrackedChannel, aV as X402_DEFAULT_NETWORK, aW as X402_V1_VERSION, aX as X402_VERSION, aY as _testing, aZ as buildPaymentRequiredV2, a_ as buildPaymentRequirements, a$ as caip2ToX402Network, b0 as canonicaliseForSigning, b1 as canonicalize, b2 as chainIdFromCaip2, b3 as computeResultHash, b4 as createDefaultReplayStore, b5 as decodePayment, b6 as decodePaymentRequiredHeader, b7 as depleteLots, b8 as encodePayment, b9 as encodePaymentRequiredHeader, ba as encodeSettleResponseHeader, bb as exactEvmAuthorization, bc as fifoOrder, bd as inKindDrawMsats, be as isArtifactMessage, bf as isDrainReceipt, bg as isFundingReceipt, bh as isInKindDepletion, bi as isNonChannelBitcoinRail, bj as isPaymentRequestMessage, bk as isPromptMessage, bl as isSignedJobReceipt, bm as isStaleJobReapable, bn as lotOwedSats, bo as netOwedSats, bp as paymentRequiredV2FromV1, bq as settleWithFacilitator, br as signDrainReceipt, bs as signFundingReceipt, bt as signReceipt, bu as usdcContractByCaip2, bv as usdcContractFor, bw as usdcDomainNameFor, bx as usdcDomainVersionFor, by as verifyDrainReceipt, bz as verifyFundingReceipt, bA as verifyReceipt, bB as verifyWithFacilitator, bC as wrapMppx, bD as x402NetworkToCaip2 } from '../job-store-DxFqDPYq.js';
6
6
  import { SimplePool } from 'nostr-tools/pool';
7
7
  import { Session } from 'mppx/tempo';
8
8
  import { Pool } from 'pg';
9
9
  export { Pool } from 'pg';
10
10
  import { PaymentRequired as PaymentRequired$1 } from '@x402/core/types';
11
11
  import { ClientChannelStorage, BatchSettlementClientContext, BatchSettlementEvmScheme } from '@x402/evm/batch-settlement/client';
12
- export { e as FX_CACHE_TTL_MS, g as FX_RETRY_COUNT, w as warmFxSnapshot } from '../fx-Bq4cvn16.js';
13
- export { c as InvalidUsdPriceError, p as parseUsdPrice } from '../usd-DjVAPMlf.js';
12
+ export { e as FX_CACHE_TTL_MS, g as FX_RETRY_COUNT, w as warmFxSnapshot } from '../fx-ptKVFOwq.js';
13
+ export { c as InvalidUsdPriceError, p as parseUsdPrice } from '../usd-Cha_j80I.js';
14
14
  import { Hono } from 'hono';
15
15
  import { Env, BlankSchema } from 'hono/types';
16
16
  import { Store } from 'mppx';
@@ -103,7 +103,46 @@ interface BudgetLedger {
103
103
  }
104
104
  /** Load the persisted ledger. Returns an empty ledger if the file is missing or corrupt. */
105
105
  declare function loadLedger(): BudgetLedger;
106
+ interface RecordSpendOptions {
107
+ msats: number;
108
+ principalMsats?: number;
109
+ routingFeeMsats?: number | null;
110
+ walletDebitMsats?: number | null;
111
+ btcRate: number;
112
+ /** Outflow kind. Defaults to `job`. */
113
+ kind?: BudgetSpendKind;
114
+ jobId: string;
115
+ providerEndpoint: string;
116
+ /** Optional short context label — see {@link BudgetLedgerEntry.label}. */
117
+ label?: string;
118
+ /** Set to `"provider"` when {@link label} is provider-supplied free text. */
119
+ labelSource?: "provider";
120
+ now?: Date;
121
+ }
122
+ /** Append a confirmed spend to the ledger. */
123
+ declare function recordSpend(opts: RecordSpendOptions): void;
124
+ /**
125
+ * Enforce the global budget caps before a planned spend.
126
+ * - If any cap is set, resolves the BTC/USD rate, runs the check, and throws `DvmError("budget_exceeded")` on overflow.
127
+ * - If no cap is set, attempts a best-effort rate resolution for ledger recording (tolerates failure).
128
+ *
129
+ * A rate-provider outage degrades to the last-known cached rate on both branches
130
+ * (internal-review) — a stale rate still enforces caps roughly right, where a hard failure
131
+ * blocked every spend on the branch every default install takes. With caps set and
132
+ * *no* rate at all, `resolveBtcUsdRate` throws `DvmError("rate_unavailable")` and the
133
+ * spend is blocked: an unpriceable spend can't be cap-checked, and recording it as $0
134
+ * would corrupt future cap enforcement.
135
+ *
136
+ * Returns the resolved BTC/USD rate to thread into the post-payment `recordSpend` call so the
137
+ * pre-check and the debit use a single rate.
138
+ */
139
+ declare function enforceGlobalBudget(opts: {
140
+ plannedMsats: number;
141
+ btcRate?: number;
142
+ }): Promise<number>;
106
143
 
144
+ /** Stable response code for unavailable database-backed admin signer state. */
145
+ declare const ADMIN_STATE_UNAVAILABLE = "admin_state_unavailable";
107
146
  /**
108
147
  * Build the canonical 32-byte challenge that an `Authorization: P2PK …`
109
148
  * admin header is signed over. Bind `method || path || dvm_id` so a `GET`
@@ -118,6 +157,35 @@ declare function buildAdminChallenge(args: {
118
157
  nonceHex: string;
119
158
  unixSeconds: number | string;
120
159
  }): Uint8Array;
160
+ /** Parsed components of an `Authorization: P2PK <nonce>.<unix>.<sig>` header. */
161
+ interface AdminAuthHeader {
162
+ /** Full header value, ready to drop into `Authorization`. */
163
+ header: string;
164
+ /** 16-byte hex nonce — exposed so callers/tests can introspect it. */
165
+ nonceHex: string;
166
+ /** Request timestamp in unix seconds — exposed for the same reason. */
167
+ unixSeconds: number;
168
+ }
169
+ /**
170
+ * Build a signed `Authorization: P2PK <nonce>.<unix>.<sig>` header for a
171
+ * dvmkit admin request. The CLI calls this once per request; the
172
+ * `nonceHex` + `unixSeconds` are returned so tests can replay them through
173
+ * `buildAdminChallenge` to verify the signed payload.
174
+ *
175
+ * The privkey must be the per-DVM lock privkey derived via
176
+ * `deriveBuilderLockKeypair` — the same key the DVM advertises on
177
+ * `/v1/info.cashu.lock_pubkeys[0]`.
178
+ */
179
+ declare function buildAdminAuthHeader(args: {
180
+ method: string;
181
+ path: string;
182
+ dvmId: string;
183
+ privkeyHex: string;
184
+ /** Test seam — defaults to `Date.now`. */
185
+ now?: () => number;
186
+ /** Test seam — defaults to `crypto.randomBytes(16)`. */
187
+ randomNonce?: () => Uint8Array;
188
+ }): AdminAuthHeader;
121
189
 
122
190
  /**
123
191
  * Derived per-DVM builder lock keypair. Both halves are hex; the privkey is 32
@@ -380,6 +448,8 @@ declare class DvmError extends Error {
380
448
  }
381
449
  /** Identify provider-authored prose present on one or more remote error objects. */
382
450
  declare function providerProseSources(...sources: (Partial<Record<DvmErrorProseField, unknown>> | undefined)[]): DvmErrorProseSources | undefined;
451
+ /** Detect fetch AbortError / TimeoutError — the two names browsers and Node use for signal-aborted requests. */
452
+ declare function isAbortError(err: unknown): boolean;
383
453
  /** Return the first safe Node/undici transport code found on an error or its causes. */
384
454
  declare function transportErrorCode(err: unknown): string | undefined;
385
455
 
@@ -2744,6 +2814,84 @@ interface DvmLocated {
2744
2814
  */
2745
2815
  attestedBuilderPubkey?: string;
2746
2816
  }
2817
+ /**
2818
+ * The unretired drain requested against one specific credit, if any.
2819
+ *
2820
+ * Strict on the stamp: an entry belonging to another credit — or to no credit
2821
+ * we can name (written before the stamp existed) — is not this credit's drain,
2822
+ * and re-posting its id here would open a fresh drain server-side rather than
2823
+ * poll the one that is owed (internal-review).
2824
+ */
2825
+ declare function pendingDrainFor(record: StoredCredit | undefined, creditId: string): PendingDrain | undefined;
2826
+ /**
2827
+ * Load the record for one credit, or undefined when none is tracked.
2828
+ *
2829
+ * Locked despite reading like a lookup: learning a new `dvmId` or hostname
2830
+ * alias rewrites the file (internal-review), and so does the legacy-duplicate
2831
+ * collapse inside {@link loadStore}.
2832
+ */
2833
+ declare function loadCredit(endpoint: string, callerPubkey: string, identity?: AttestedDvmIdentity): StoredCredit | undefined;
2834
+ /**
2835
+ * Ensure a record exists for a credit whose fund leg was just accepted on
2836
+ * `/v1/job` (fund-and-draw, internal-review). The exact credited amount is the
2837
+ * server's call (pro-rata at its fx), so the record is marked
2838
+ * {@link StoredCredit.provisional} until the countersigned receipt or a
2839
+ * fund/balance response adopts the real figures.
2840
+ */
2841
+ declare function ensureProvisionalCredit(args: {
2842
+ endpoint: string;
2843
+ identity?: AttestedDvmIdentity;
2844
+ callerPubkey: string;
2845
+ creditId: string;
2846
+ currency: string;
2847
+ targetMicro: number;
2848
+ menu?: CreditMenu;
2849
+ now?: number;
2850
+ }): void;
2851
+ /**
2852
+ * Adopt the x402 binding a refusal named onto the tracked credit.
2853
+ *
2854
+ * The heal half of the pin: the local record is a copy of a server-side fact,
2855
+ * so the server's own word replaces it rather than the other way round, and one
2856
+ * refusal is enough — the next refill routes over the named instrument instead
2857
+ * of signing into the same answer again.
2858
+ *
2859
+ * A heal that actually moves the instrument drops the recorded chain with it
2860
+ * (internal-review), unless the caller also supplies the chain resolved from the
2861
+ * refusal's channel id. Supplying that verified chain also fills or corrects a
2862
+ * channel instrument that was already recorded — the instrument being equal
2863
+ * must not make the newly learned half of its binding a no-op (internal-review).
2864
+ */
2865
+ declare function recordCreditX402Instrument(endpoint: string, callerPubkey: string, creditId: string, instrument: X402CreditInstrument, identity?: AttestedDvmIdentity,
2866
+ /** Channel chain learned from the channel store, when the refusal names one. */
2867
+ channelNetwork?: string): void;
2868
+ /**
2869
+ * Persist a drain request so a re-invoked drain polls the same id.
2870
+ *
2871
+ * Keyed on the drain's whole `(drainId, creditId)` identity: re-recording the
2872
+ * same drain refreshes it, and anything else is appended. Deliberately not
2873
+ * keyed on the credit alone — an entry may be the only local pointer to a
2874
+ * parked payout, and replacing drain A with drain B because they share a
2875
+ * credit would drop exactly the evidence this store exists to keep.
2876
+ *
2877
+ * Callers own the shape readers lean on. {@link pendingDrainFor} takes the
2878
+ * first entry stamped for a credit, so `dvm credit drain` refuses a
2879
+ * `--drain-id` that would leave a credit holding two; a second entry can then
2880
+ * only arrive by hand-editing, and the older one is what polls.
2881
+ */
2882
+ declare function recordPendingDrain(endpoint: string, callerPubkey: string, drain: PendingDrain, identity?: AttestedDvmIdentity): void;
2883
+ /**
2884
+ * Retire one drain, once it is fulfilled (or once the server has said it never
2885
+ * existed).
2886
+ *
2887
+ * Matched on the drain's own `(drainId, creditId)` identity rather than on the
2888
+ * record's current credit: reclaiming a drain stranded on a previous credit
2889
+ * must retire exactly that entry and leave the tracked credit's own drain — and
2890
+ * its projection — untouched. Matching the id alone would also work for every
2891
+ * entry this CLI writes, but an unstamped legacy entry can only be named this
2892
+ * way, and it needs a retirement path too.
2893
+ */
2894
+ declare function clearPendingDrain(endpoint: string, callerPubkey: string, drain: Pick<PendingDrain, "drainId" | "creditId">, identity?: AttestedDvmIdentity): void;
2747
2895
 
2748
2896
  /**
2749
2897
  * Durable, append-only store for the DVM-signed receipts this caller has
@@ -3151,6 +3299,11 @@ interface CoinGeckoSpot {
3151
3299
  usdc_usd: number;
3152
3300
  as_of: string;
3153
3301
  }
3302
+ /** Bitcoin-only spot snapshot. Counterpart to {@link CoinGeckoSpot}. */
3303
+ interface CoinGeckoBtcSpot {
3304
+ btc_usd: number;
3305
+ as_of: string;
3306
+ }
3154
3307
  /**
3155
3308
  * One raw call to CoinGecko's `simple/price` endpoint for **both** BTC and
3156
3309
  * USDC. No cache, no retry — callers wrap with their own. Use
@@ -3158,6 +3311,12 @@ interface CoinGeckoSpot {
3158
3311
  * variant throws if upstream returns a degraded `usd-coin.usd`.
3159
3312
  */
3160
3313
  declare function fetchCoinGeckoSpot(opts?: CoinGeckoFetchOptions): Promise<CoinGeckoSpot>;
3314
+ /**
3315
+ * One raw call to CoinGecko's `simple/price` endpoint for **BTC only**. No
3316
+ * cache, no retry. Hits the bitcoin-only URL by default — narrower upstream
3317
+ * surface, and a malformed `usd-coin.usd` cannot break this caller.
3318
+ */
3319
+ declare function fetchCoinGeckoBtcUsd(opts?: CoinGeckoFetchOptions): Promise<CoinGeckoBtcSpot>;
3161
3320
 
3162
3321
  /** Parsed components of a Lightning address (user@domain). */
3163
3322
  interface LnAddressParts {
@@ -5286,6 +5445,8 @@ declare function currentContext(service?: string): TraceContext;
5286
5445
  */
5287
5446
  declare function pinDimension(key: string, value: unknown): void;
5288
5447
 
5448
+ /** Postgres NOTIFY channel fired after each successful span batch INSERT. */
5449
+ declare const SPANS_INSERTED_CHANNEL = "spans_inserted";
5289
5450
  /**
5290
5451
  * Buffered span writer. Collects SpanRow objects in memory and flushes them
5291
5452
  * to a transport (direct DB or HTTP POST) on a timer or threshold.
@@ -5328,6 +5489,18 @@ declare class SpanWriter {
5328
5489
  */
5329
5490
  private truncateForSize;
5330
5491
  }
5492
+ /**
5493
+ * Build and execute a multi-row INSERT into observability.spans.
5494
+ * Accepts either typed SpanRow[] or loosely-typed Record<string, unknown>[]
5495
+ * (the HTTP ingestion endpoint validates fields before calling this).
5496
+ */
5497
+ declare function insertSpanBatch(pool: Pool, rows: readonly Record<string, unknown>[] | readonly SpanRow[]): Promise<void>;
5498
+ /** Direct Postgres INSERT transport for platform-api and router. */
5499
+ declare class DbTransport implements SpanTransport {
5500
+ private pool;
5501
+ constructor(pool: Pool);
5502
+ send(rows: SpanRow[]): Promise<void>;
5503
+ }
5331
5504
 
5332
5505
  /** Process-wide singleton loggers object, set by initLoggers(). */
5333
5506
  declare let loggers: Record<DatasetName, Logger>;
@@ -5742,4 +5915,60 @@ declare class MemoryKVStore implements KVStore {
5742
5915
  */
5743
5916
  declare function backupSecretFile(file: string, nextContent?: string): string | null;
5744
5917
 
5745
- export { AccumulatorPool, type AgentProof, type AgentWallet, type AmountLabelOptions, type AttestedDvmIdentity, type BuilderLockKeypair, CAPABILITY_NAME_RE, COINGECKO_SIMPLE_PRICE_URL, CREDIT_DRAIN_RAILS, CREDIT_FUNDING_MODES, CREDIT_FUND_RAILS, type CachedBtcRate, type CancelOptions, type CoinGeckoSpot, CreatedInvoice, type CreditDrainRail, type CreditFundOutcome, type CreditFundRail, type CreditFundStatus, type CreditFundingMode, type CreditMenu, type CreditOpResult, type CreditRailPick, type CreditRailReason, type CreditRailSource, type CreditTerms, type CreditWire, DEFAULT_LOCK_PUBKEY_GRACE_SECONDS, type DeliveredResult, type DescribeOptions, type DrainReceiptChecks, type DrainReceiptVerifyResult, type DrainWire, DvmError, DvmX402ChannelStorage, type FundCreditArgs, FundingReceipt, type FundingReceiptChecks, type FundingReceiptVerifyResult, InvoiceStatus, type JobEnvelope, type JobPolicy, JobReceipt$1 as JobReceipt, type JobStatus, JsonValue, LightningBackend, type LightningFundingOffer, LightningPayment, type LnAddressParts, LockPubkey, type LockPubkeyPool, type LockPubkeyState, type LockPubkeyStateLoader, LockPubkey as LockPubkeyStoreLockPubkey, type MeltQuoteInfo, MemoryKVStore, Message, type MessagePollOptions, MessageType, MppxCredential, NwcBackend, type NwcConnection, NwcError, type NwcRequestOptions, type NwcTransaction, type OutboundMessage, type PayInvoiceOutcome, type PayInvoiceReconcilingOptions, type PayInvoiceResult, type PayOutcome, type Payment, PaymentRequired, type PendingX402ExactFunding, type PendingX402Funding, PostgresTempoChargeStore, type ProviderInfo, type ProviderRef, type ProviderText, type Quote, RECENT_SPENDS_CAP, ROUTER_FEEDBACK_CLAIM_HEADER, ROUTER_FEEDBACK_CLAIM_TTL_MS, type RailFlag, type ReceiptChecks, type ReceiptInvalidReason, type ReceiptKeypair, type ReceiptParseError, type ReceiptTrustAnchor, type ReceiptVerification, type ReceiptVerifyResult, STABLECOIN_FUND_RAILS, SUPPORTED_PROTOCOL_VERSION, type SelectError, type SendMessageOptions, type SpanRow, type SpanTransport, type StatusOptions, type StoredX402ChannelConfig, type StoredX402ChannelMetadata, type StreamOptions, type StreamResult, type SubmitOptions, TEMPO_CHAIN_ID, TEMPO_CLOSE_DB_RECOVERY_BUDGET_MS, TEMPO_CLOSE_REQUESTED_TOPIC, type Transport, type JobReceipt as TransportJobReceipt, type V1InfoCapability, type V1InfoResponse, type VerifyJobReceiptArgs, type WalletInfo, type X402Balance, type X402BatchPayment, type X402ChannelReconciliation, X402Config, type X402ConnectedWallet, X402EnvValidationError, type X402Network, type X402RefundArgs, type X402RefundOutcome, type X402RepinnedWallet, type X402UnobservedBalanceProvenance, X402Version, X402_BATCH_CHANNEL_ABI, X402_BATCH_SETTLEMENT_KEY, X402_BATCH_SETTLEMENT_SCHEME, X402_DEFAULT_FACILITATOR, X402_EXACT_AUTHORIZATION_TTL_SECONDS, X402_EXACT_SCHEME, X402_NETWORKS, X402_PENDING_STALE_MS, X402_RECEIVER_AUTHORIZER_KEY, X402_REFUSAL_TRANSACTION_DISCOVERY_WINDOW_MS, X402_RPC_URL_KEY, X402_SELF_RELAY_KEY, acknowledgeReplayedX402Payment, acknowledgeX402ChannelOwner, activePubkeySet, applyRetryToPool, asProviderText, assertSupportedX402Network, assertValidBudget, assertX402RequirementDescribesChannel, attestedDvmIdentity, authenticatedBuilderPubkey, availableRails, backupSecretFile, buildAdminChallenge, buildTempoCredential, builderLockPath, canReplaceExpiredX402Deposit, cashuSubmissionBindingFingerprint, checkMeltQuoteState, checkReceiptAttestation, clearPendingX402ExactFunding, clearPendingX402Funding, computeSmartDenominations, connectedX402Payer, costAnchor, createAdminCashuNonceStore, createInstrumentedFetch, createMonotonicClock, createNoopLogger, createStdoutLogger, createX402BatchPayment, currentContext, deriveBuilderLockKeypair, deriveBuilderLockPubkey, deriveReceiptKeypair, deriveReceiptSecret, drainReceiptsDisplay, drainReceiptsHint, ensureAddress, epochMsToIso, fetchBtcUsdRate, fetchCoinGeckoSpot, fetchLnurlPayInvoice, fetchMeltQuote, findX402Channel, formatAmount, formatAmountBestEffort, formatPaymentAmount, formatSats, formatStaleness, formatUsd, formatUsdcMicrounits, fundCredit, fundingModeForTempoIntent, fundingModeForX402Flavour, generateEphemeralReceiptKey, generateX402PrivateKey, getBalance, getInfo, getInputFeesForProofs, getLastKnownBtcRate, getWallet, getX402Balance, hashedCanonicalDvmId, humanizeZodError, initLockPubkeyTable, initLoggers, installAdminCashuRoutes, isCreditFundRail, isCreditFundingMode, isStablecoinFundRail, issueRouterFeedbackClaim, jobCredentialGate, listPendingX402Fundings, listPendingX402FundingsForChannel, listResumableX402ExactFundings, listResumableX402Fundings, listTempoChannelAssociations, listX402Channels, loadAgentWallet, loadConfiguredMints, loadLedger, loadLockPubkeyState, loadResumableX402ExactFunding, loadResumableX402Funding, loadTempoChannelEntry, loadX402Wallet, loggers, lookupInvoice, makeInvoice, maxKeysetDenomination, missingDleqRecoveryDiagnostic, monetaryJson, msatsToUsd, msatsToUsdCents, msatsToUsdc, normalizeFeedbackEndpointHost, nwcDedupWindowMs, nwcTimeoutMs, offersX402CreditFunding, parseBudget, parseCreditMenu, parseCreditTerms, parseLnAddress, parseNwcUri, payInvoiceReconciling, pickCreditFundRail, pinDimension, planCreditForQuote, pollPendingCreditFundings, preferLightningFirst, prepareP2PKMint, processX402BatchCorrection, processX402BatchResponse, processX402BatchResponseForWallet, providerProseSources, providerTextToString, pruneRetired, randomTraceId, rateUnavailablePaymentError, receiptDisplay, receiptFailureDetail, receiptHint, receiptIssuedAtIso, receiptPubkeyFromSecret, reconcileRefusedX402Deposits, recordPendingX402ExactFunding, recordPendingX402Funding, recordX402ChannelMetadata, refundX402BatchChannel, removeX402Wallet, repinX402WalletNetwork, resolveLnurlPayMetadataUrl, resolveRpcHttpTransportOptions, resolveRpcOverride, restoreProofsFromOutputs, retirePendingX402Funding, rotateLockPubkey, saveAgentWallet, saveX402Wallet, seedLockPubkeyState, selectProofsForSpend, serializeOutputData, setEmitter, signDvmRequestData, signRequestData, signedRequestDomain, swapFeeForProofs, swapSendReserve, tempoCredentialAmountMicro, transportErrorCode, usdToMsats, usdcToMsats, validateLnAddress, validateX402Env, verifyCanonicalSignedRequest, verifyDrainReceiptChain, verifyFundingReceiptChain, verifyJobReceipt, verifyRouterFeedbackClaim, verifyX402Payment, weakestReceiptVerdict, withInitRetry, withNwcPool, withTraceContext, withWalletLock, withX402ChannelLock, x402ChannelBalanceUnreconciledAt, x402ExactFundingDead, x402NetworkByCaip2, x402NetworkBySlug, x402NetworkLabel, x402NetworkListForCopy, x402PendingBlockExpiresAt, x402PendingDepositExpiresAt, x402PendingFundingJson, x402PendingRetired, x402PendingStale, x402PendingUnsettled, x402RequiredFromError, x402SupportedNetworksHint, x402VoucherPendingRefusal };
5918
+ /**
5919
+ * The caller-facing rail vocabulary: one noun per rail, in three registers.
5920
+ *
5921
+ * `fundingRailLabel` is the table. `paymentRailLabel` and `probeRailLabel` are
5922
+ * registers of it rather than parallel copies, so a caller crossing between
5923
+ * `dvm wallet`, `dvm doctor`, `dvm quote`, `dvm pay` and `dvm credit` is told
5924
+ * about one thing per rail rather than three (internal-review).
5925
+ *
5926
+ * **Rail-choice menus are the one caller-facing surface that deliberately does
5927
+ * not read from here.** `dvm wallet setup`'s onramp titles and the NWC float
5928
+ * row beside them — both in the caller CLI, which lives in its own repository —
5929
+ * lead with the protocol name — `Cashu — Bitcoin / Lightning`, not
5930
+ * `ecash — Bitcoin / Lightning` — because at the moment of choosing, the
5931
+ * protocol name *is* the information: it's what identifies the row to someone
5932
+ * who already holds that money, and it's the literal `--rail` value they type
5933
+ * next. internal-review wrote that
5934
+ * carve-out into the payment-language rule — a caller meets protocol terms
5935
+ * "only when choosing a rail, troubleshooting, or managing custody and exits"
5936
+ * — and internal-review settled that the onramp titles fall under it.
5937
+ *
5938
+ * Those titles carry the plain language in their second half, after the dash:
5939
+ * `<protocol name> — <what the money is>`. Everything downstream of the choice
5940
+ * — a balance, a quote, a credit row, a diagnosis — glosses from this file.
5941
+ * `__tests__/rail-naming-contract.ts` holds both registers as literals, so
5942
+ * neither can drift into the other silently.
5943
+ */
5944
+
5945
+ /**
5946
+ * Human wording for every funding rail, exhaustive over the rail registry, so
5947
+ * adding a rail to `CREDIT_FUND_RAILS` is a compile error here by design.
5948
+ *
5949
+ * Rail keys are wire and config identifiers: `cashu`, `cashu_p2pk` and `tempo`
5950
+ * are protocol and locking-scheme names rather than things a human recognizes
5951
+ * owning. Prose that a human reads gets the gloss; the raw key stays in the
5952
+ * machine fields beside it.
5953
+ *
5954
+ * This is the single table every caller-facing surface reads (internal-review). The
5955
+ * twins below are registers of it, not parallel copies — `dvm wallet`,
5956
+ * `dvm doctor`, `dvm quote`, `dvm pay` and `dvm credit` all land on one noun
5957
+ * per rail, so a caller crossing between commands isn't told about three
5958
+ * different things.
5959
+ */
5960
+ declare function fundingRailLabel(rail: CreditFundRail): string;
5961
+
5962
+ /** Quote one argument for safe copy/paste into a POSIX shell command. */
5963
+ declare function shellQuoteArg(value: string): string;
5964
+
5965
+ /**
5966
+ * Verify a BIP-340 Schnorr signature against a 32-byte challenge and a
5967
+ * compressed (33-byte, `02`/`03` prefix) or x-only (32-byte) public key.
5968
+ * Compressed inputs have their parity byte dropped — BIP-340 keys are
5969
+ * x-only — and the y-coordinate is recomputed inside cashu-ts when
5970
+ * needed.
5971
+ */
5972
+ declare function verifyChallenge(pubkeyHex: string, challenge: Uint8Array, sigHex: string): boolean;
5973
+
5974
+ export { ADMIN_STATE_UNAVAILABLE, AccumulatorPool, type AgentProof, type AgentWallet, type AmountLabelOptions, type AttestedDvmIdentity, type BuilderLockKeypair, CAPABILITY_NAME_RE, COINGECKO_SIMPLE_PRICE_URL, CREDIT_DRAIN_RAILS, CREDIT_FUNDING_MODES, CREDIT_FUND_RAILS, type CachedBtcRate, type CancelOptions, type CoinGeckoBtcSpot, type CoinGeckoSpot, CreatedInvoice, type CreditDrainRail, type CreditFundOutcome, type CreditFundRail, type CreditFundStatus, type CreditFundingMode, type CreditMenu, type CreditOpResult, type CreditRailPick, type CreditRailReason, type CreditRailSource, type CreditTerms, type CreditWire, DEFAULT_LOCK_PUBKEY_GRACE_SECONDS, DbTransport, type DeliveredResult, type DescribeOptions, type DrainReceiptChecks, type DrainReceiptVerifyResult, type DrainWire, type DrawCeilingSource, type DrawSkip, DvmError, DvmX402ChannelStorage, type FundCreditArgs, FundingReceipt, type FundingReceiptChecks, type FundingReceiptVerifyResult, InvoiceStatus, type JobEnvelope, type JobPolicy, JobReceipt$1 as JobReceipt, type JobStatus, JsonValue, LightningBackend, type LightningFundingOffer, LightningPayment, LightningWalletInfo, type LnAddressParts, LockPubkey, type LockPubkeyPool, type LockPubkeyState, type LockPubkeyStateLoader, LockPubkey as LockPubkeyStoreLockPubkey, type MeltQuoteInfo, MemoryKVStore, Message, type MessagePollOptions, MessageType, MppxChallenge, MppxCredential, NwcBackend, type NwcConnection, NwcError, type NwcRequestOptions, type NwcTransaction, type OutboundMessage, type PayInvoiceOutcome, type PayInvoiceReconcilingOptions, type PayInvoiceResult, type PayOutcome, type Payment, PaymentRequired, type PendingX402ExactFunding, type PendingX402Funding, type PersistedOutputData, PostgresTempoChargeStore, type ProviderInfo, type ProviderRef, type ProviderText, type Quote, RECENT_SPENDS_CAP, ROUTER_FEEDBACK_CLAIM_HEADER, ROUTER_FEEDBACK_CLAIM_TTL_MS, type RailFlag, type ReceiptChecks, type ReceiptInvalidReason, type ReceiptKeypair, type ReceiptParseError, type ReceiptTrustAnchor, type ReceiptVerification, type ReceiptVerifyResult, SPANS_INSERTED_CHANNEL, STABLECOIN_FUND_RAILS, SUPPORTED_PROTOCOL_VERSION, type SelectError, type SendMessageOptions, type SpanRow, type SpanTransport, SpanWriter, type StatusOptions, type StoredCredit, type StoredX402ChannelConfig, type StoredX402ChannelMetadata, type StreamOptions, type StreamResult, type SubmitOptions, type SuppressedPurchase, TEMPO_CHAIN_ID, TEMPO_CLOSE_DB_RECOVERY_BUDGET_MS, TEMPO_CLOSE_REQUESTED_TOPIC, type Transport, type JobReceipt as TransportJobReceipt, type V1InfoCapability, type V1InfoResponse, type VerifyJobReceiptArgs, type WalletInfo, type X402Balance, type X402BatchPayment, type X402ChannelReconciliation, X402Config, type X402ConnectedWallet, type X402CreditFlavour, type X402CreditInstrument, X402EnvValidationError, type X402Network, type X402RefundArgs, type X402RefundOutcome, type X402RepinnedWallet, type X402UnobservedBalanceProvenance, X402Version, X402_BATCH_CHANNEL_ABI, X402_BATCH_SETTLEMENT_KEY, X402_BATCH_SETTLEMENT_SCHEME, X402_DEFAULT_FACILITATOR, X402_EXACT_AUTHORIZATION_TTL_SECONDS, X402_EXACT_SCHEME, X402_NETWORKS, X402_PENDING_STALE_MS, X402_RECEIVER_AUTHORIZER_KEY, X402_REFUSAL_TRANSACTION_DISCOVERY_WINDOW_MS, X402_RPC_URL_KEY, X402_SELF_RELAY_KEY, acknowledgeReplayedX402Payment, acknowledgeX402ChannelOwner, activePubkeySet, applyRetryToPool, asProviderText, assertSupportedX402Network, assertValidBudget, assertX402RequirementDescribesChannel, attestedDvmIdentity, authenticatedBuilderPubkey, availableRails, backupSecretFile, buildAdminAuthHeader, buildAdminChallenge, buildTempoCredential, builderLockPath, canReplaceExpiredX402Deposit, cashuSubmissionBindingFingerprint, checkMeltQuoteState, checkReceiptAttestation, clearPendingDrain, clearPendingX402ExactFunding, clearPendingX402Funding, computeSmartDenominations, connectedX402Payer, costAnchor, createAdminCashuNonceStore, createInstrumentedFetch, createMonotonicClock, createNoopLogger, createStdoutLogger, createX402BatchPayment, currentContext, deriveBuilderLockKeypair, deriveBuilderLockPubkey, deriveReceiptKeypair, deriveReceiptSecret, drainReceiptsDisplay, drainReceiptsHint, enforceGlobalBudget, ensureAddress, ensureProvisionalCredit, epochMsToIso, fetchBtcUsdRate, fetchCoinGeckoBtcUsd, fetchCoinGeckoSpot, fetchLnurlPayInvoice, fetchMeltQuote, findX402Channel, formatAmount, formatAmountBestEffort, formatPaymentAmount, formatSats, formatStaleness, formatUsd, formatUsdcMicrounits, fundCredit, fundingModeForTempoIntent, fundingModeForX402Flavour, fundingRailLabel, generateEphemeralReceiptKey, generateX402PrivateKey, getBalance, getInfo, getInputFeesForProofs, getLastKnownBtcRate, getWallet, getX402Balance, hashedCanonicalDvmId, humanizeZodError, initLockPubkeyTable, initLoggers, insertSpanBatch, installAdminCashuRoutes, isAbortError, isCreditFundRail, isCreditFundingMode, isStablecoinFundRail, issueRouterFeedbackClaim, jobCredentialGate, listPendingX402Fundings, listPendingX402FundingsForChannel, listResumableX402ExactFundings, listResumableX402Fundings, listTempoChannelAssociations, listX402Channels, loadAgentWallet, loadConfiguredMints, loadCredit, loadLedger, loadLockPubkeyState, loadResumableX402ExactFunding, loadResumableX402Funding, loadTempoChannelEntry, loadX402Wallet, loggers, lookupInvoice, makeInvoice, maxKeysetDenomination, missingDleqRecoveryDiagnostic, monetaryJson, msatsToUsd, msatsToUsdCents, msatsToUsdc, normalizeFeedbackEndpointHost, nwcDedupWindowMs, nwcTimeoutMs, offersX402CreditFunding, parseBudget, parseCreditMenu, parseCreditTerms, parseLnAddress, parseNwcUri, payInvoiceReconciling, pendingDrainFor, pickCreditFundRail, pinDimension, planCreditForQuote, pollPendingCreditFundings, preferLightningFirst, prepareP2PKMint, processX402BatchCorrection, processX402BatchResponse, processX402BatchResponseForWallet, providerProseSources, providerTextToString, pruneRetired, randomTraceId, rateUnavailablePaymentError, receiptDisplay, receiptFailureDetail, receiptHint, receiptIssuedAtIso, receiptPubkeyFromSecret, reconcileRefusedX402Deposits, recordCreditX402Instrument, recordPendingDrain, recordPendingX402ExactFunding, recordPendingX402Funding, recordSpend, recordX402ChannelMetadata, refundX402BatchChannel, removeX402Wallet, repinX402WalletNetwork, resolveLnurlPayMetadataUrl, resolveRpcHttpTransportOptions, resolveRpcOverride, restoreProofsFromOutputs, retirePendingX402Funding, rotateLockPubkey, saveAgentWallet, saveX402Wallet, seedLockPubkeyState, selectProofsForSpend, serializeOutputData, setEmitter, shellQuoteArg, signDvmRequestData, signRequestData, signedRequestDomain, swapFeeForProofs, swapSendReserve, tempoCredentialAmountMicro, transportErrorCode, usdToMsats, usdcToMsats, validateLnAddress, validateX402Env, verifyCanonicalSignedRequest, verifyChallenge, verifyDrainReceiptChain, verifyFundingReceiptChain, verifyJobReceipt, verifyRouterFeedbackClaim, verifyX402Payment, weakestReceiptVerdict, withInitRetry, withNwcPool, withTraceContext, withWalletLock, withX402ChannelLock, x402ChannelBalanceUnreconciledAt, x402ExactFundingDead, x402NetworkByCaip2, x402NetworkBySlug, x402NetworkLabel, x402NetworkListForCopy, x402PendingBlockExpiresAt, x402PendingDepositExpiresAt, x402PendingFundingJson, x402PendingRetired, x402PendingStale, x402PendingUnsettled, x402RequiredFromError, x402SupportedNetworksHint, x402VoucherPendingRefusal };
@@ -8,6 +8,7 @@ import {
8
8
  connectedTempoAccount,
9
9
  createTempoCreditSession,
10
10
  createTempoSessionPaymentFetch,
11
+ fundingRailLabel,
11
12
  listResumableTempoChargeFundings,
12
13
  listTempoChannelAssociations,
13
14
  loadResumableTempoChargeFunding,
@@ -18,6 +19,7 @@ import {
18
19
  offersTempoCreditSession,
19
20
  persistTempoOpenCredential,
20
21
  recordPendingTempoChargeFunding,
22
+ shellQuoteArg,
21
23
  tempoChargeCredentialSettleable,
22
24
  tempoSessionAssociationByKey,
23
25
  tempoSessionChallenge,
@@ -28,7 +30,7 @@ import {
28
30
  tempoSessionPriorCumulativeMicro,
29
31
  withTempoChannelLock,
30
32
  withholdsTempoCreditSession
31
- } from "../chunk-YD3TZNXV.js";
33
+ } from "../chunk-ZMZTZFRC.js";
32
34
  import {
33
35
  DvmX402ChannelStorage,
34
36
  X402_EXACT_AUTHORIZATION_TTL_SECONDS,
@@ -71,28 +73,33 @@ import {
71
73
  x402PendingRetired,
72
74
  x402PendingStale,
73
75
  x402PendingUnsettled
74
- } from "../chunk-RHP3BRTH.js";
76
+ } from "../chunk-AB3L6B52.js";
75
77
  import {
76
78
  SUPPORTED_PROTOCOL_VERSION,
79
+ clearPendingDrain,
77
80
  clearPendingFunding,
81
+ ensureProvisionalCredit,
78
82
  info,
79
83
  isCreditPosture,
80
84
  isValidEvmPrivateKey,
81
85
  listPendingFundings,
82
86
  loadConfig,
87
+ loadCredit,
83
88
  loadCreditX402Binding,
84
89
  loadPendingFunding,
85
90
  maxAdvertisedMicro,
86
91
  normalizeCreditEndpoint,
87
92
  parseCreditMenu,
88
93
  parseCreditTerms,
94
+ pendingDrainFor,
89
95
  progress,
90
96
  recordCreditX402Instrument,
91
97
  recordFundResponse,
98
+ recordPendingDrain,
92
99
  recordPendingFunding,
93
100
  updateConfig,
94
101
  withinAdvertisedTolerance
95
- } from "../chunk-FT7IM66W.js";
102
+ } from "../chunk-4KB3LTOS.js";
96
103
  import {
97
104
  RevenueReporter
98
105
  } from "../chunk-2ABMGUDS.js";
@@ -110,12 +117,16 @@ import {
110
117
  CAPABILITY_NAME_RE
111
118
  } from "../chunk-XYTSDAPH.js";
112
119
  import {
120
+ ADMIN_STATE_UNAVAILABLE,
113
121
  DEFAULT_LOCK_PUBKEY_GRACE_SECONDS,
122
+ DbTransport,
114
123
  MintHealthTracker,
115
124
  NwcBackend,
116
125
  NwcError,
117
126
  PAYMENT_PROOF_KEYS,
118
127
  RECENT_SPENDS_CAP,
128
+ SPANS_INSERTED_CHANNEL,
129
+ SpanWriter,
119
130
  TEMPO_CLOSE_DB_RECOVERY_BUDGET_MS,
120
131
  TEMPO_CLOSE_REQUESTED_TOPIC,
121
132
  TEMPO_SESSION_UPDATED_REASON,
@@ -134,6 +145,7 @@ import {
134
145
  attestedDvmIdentity,
135
146
  authenticatedBuilderPubkey,
136
147
  backupSecretFile,
148
+ buildAdminAuthHeader,
137
149
  buildAdminChallenge,
138
150
  buildAttestation,
139
151
  buildPaymentErrorResponse,
@@ -166,6 +178,7 @@ import {
166
178
  initLockPubkeyTable,
167
179
  initWalletAccumulatorTable,
168
180
  insertAccumulatorRows,
181
+ insertSpanBatch,
169
182
  installAdminCashuRoutes,
170
183
  isDerivedCreditId,
171
184
  isDrainReceipt,
@@ -212,6 +225,7 @@ import {
212
225
  unknownRouteNotFound,
213
226
  validateX402Env,
214
227
  verifyAttestation,
228
+ verifyChallenge,
215
229
  verifyDrainReceipt,
216
230
  verifyDrainReceiptChain,
217
231
  verifyFundingReceipt,
@@ -227,7 +241,7 @@ import {
227
241
  writeIdentity,
228
242
  x402RequiredUsdcMicro,
229
243
  x402SettledShare
230
- } from "../chunk-C2DC4FKR.js";
244
+ } from "../chunk-ATQIII6K.js";
231
245
  import {
232
246
  X402_BATCH_SETTLEMENT_SCHEME,
233
247
  X402_DEFAULT_FACILITATOR,
@@ -260,7 +274,7 @@ import {
260
274
  x402NetworkListForCopy,
261
275
  x402NetworkToCaip2,
262
276
  x402SupportedNetworksHint
263
- } from "../chunk-XY5Y5REG.js";
277
+ } from "../chunk-AAJNGQMC.js";
264
278
  import {
265
279
  BUDGET_FILE,
266
280
  COINGECKO_SIMPLE_PRICE_URL,
@@ -270,6 +284,7 @@ import {
270
284
  costAnchor,
271
285
  ensureConfigDir,
272
286
  fetchBtcUsdRate,
287
+ fetchCoinGeckoBtcUsd,
273
288
  fetchCoinGeckoSpot,
274
289
  formatAmount,
275
290
  formatAmountBestEffort,
@@ -279,6 +294,7 @@ import {
279
294
  formatUsd,
280
295
  formatUsdcMicrounits,
281
296
  getLastKnownBtcRate,
297
+ isAbortError,
282
298
  monetaryJson,
283
299
  msatsToUsd,
284
300
  msatsToUsdCents,
@@ -290,7 +306,7 @@ import {
290
306
  transportErrorCode,
291
307
  usdToMsats,
292
308
  usdcToMsats
293
- } from "../chunk-5SO7ZVOH.js";
309
+ } from "../chunk-F2L6KIMD.js";
294
310
  import "../chunk-EXHBXA4U.js";
295
311
  import {
296
312
  RAIL_REFUNDABLE,
@@ -6033,6 +6049,9 @@ function sleep(ms) {
6033
6049
  }
6034
6050
 
6035
6051
  // src/lib/messages/types.ts
6052
+ function isPromptMessage(msg) {
6053
+ return msg.type === "prompt";
6054
+ }
6036
6055
  function isArtifactMessage(msg) {
6037
6056
  return msg.type === "artifact";
6038
6057
  }
@@ -6048,12 +6067,14 @@ function providerTextToString(value) {
6048
6067
  return typeof value === "string" ? value : value.text;
6049
6068
  }
6050
6069
  export {
6070
+ ADMIN_STATE_UNAVAILABLE,
6051
6071
  CAPABILITY_NAME_RE,
6052
6072
  COINGECKO_SIMPLE_PRICE_URL,
6053
6073
  CREDIT_DRAIN_RAILS,
6054
6074
  CREDIT_FUNDING_MODES,
6055
6075
  CREDIT_FUND_RAILS,
6056
6076
  DEFAULT_LOCK_PUBKEY_GRACE_SECONDS,
6077
+ DbTransport,
6057
6078
  DvmError,
6058
6079
  DvmX402ChannelStorage,
6059
6080
  FX_CACHE_TTL_MS,
@@ -6076,8 +6097,10 @@ export {
6076
6097
  RevenueReporter,
6077
6098
  SIGNED_ENVELOPE_FIELDS,
6078
6099
  SIGNED_ENVELOPE_TYPES,
6100
+ SPANS_INSERTED_CHANNEL,
6079
6101
  STABLECOIN_FUND_RAILS,
6080
6102
  SUPPORTED_PROTOCOL_VERSION,
6103
+ SpanWriter,
6081
6104
  StepCache,
6082
6105
  TEMPO_CHAIN_ID,
6083
6106
  TEMPO_CLOSE_DB_RECOVERY_BUDGET_MS,
@@ -6117,6 +6140,7 @@ export {
6117
6140
  authenticatedBuilderPubkey,
6118
6141
  availableRails,
6119
6142
  backupSecretFile,
6143
+ buildAdminAuthHeader,
6120
6144
  buildAdminChallenge,
6121
6145
  buildAttestation,
6122
6146
  buildPaymentErrorResponse,
@@ -6135,6 +6159,7 @@ export {
6135
6159
  checkMintHealth,
6136
6160
  checkReceiptAttestation,
6137
6161
  clearAccumulatorForDvm,
6162
+ clearPendingDrain,
6138
6163
  clearPendingX402ExactFunding,
6139
6164
  clearPendingX402Funding,
6140
6165
  computeResultHash,
@@ -6165,10 +6190,13 @@ export {
6165
6190
  encodePayment,
6166
6191
  encodePaymentRequiredHeader,
6167
6192
  encodeSettleResponseHeader,
6193
+ enforceGlobalBudget,
6168
6194
  ensureAddress,
6195
+ ensureProvisionalCredit,
6169
6196
  epochMsToIso,
6170
6197
  exactEvmAuthorization,
6171
6198
  fetchBtcUsdRate,
6199
+ fetchCoinGeckoBtcUsd,
6172
6200
  fetchCoinGeckoSpot,
6173
6201
  fetchLnurlPayInvoice,
6174
6202
  fetchMeltQuote,
@@ -6186,6 +6214,7 @@ export {
6186
6214
  fundedMicroFor,
6187
6215
  fundingModeForTempoIntent,
6188
6216
  fundingModeForX402Flavour,
6217
+ fundingRailLabel,
6189
6218
  generateEphemeralReceiptKey,
6190
6219
  generateIdentity,
6191
6220
  generateX402PrivateKey,
@@ -6206,7 +6235,9 @@ export {
6206
6235
  initLoggers,
6207
6236
  initWalletAccumulatorTable,
6208
6237
  insertAccumulatorRows,
6238
+ insertSpanBatch,
6209
6239
  installAdminCashuRoutes,
6240
+ isAbortError,
6210
6241
  isArtifactMessage,
6211
6242
  isCreditFundRail,
6212
6243
  isCreditFundingMode,
@@ -6216,6 +6247,7 @@ export {
6216
6247
  isInKindDepletion,
6217
6248
  isNonChannelBitcoinRail,
6218
6249
  isPaymentRequestMessage,
6250
+ isPromptMessage,
6219
6251
  isSignedJobReceipt,
6220
6252
  isStablecoinFundRail,
6221
6253
  isStaleJobReapable,
@@ -6232,6 +6264,7 @@ export {
6232
6264
  listX402Channels,
6233
6265
  loadAgentWallet,
6234
6266
  loadConfiguredMints,
6267
+ loadCredit,
6235
6268
  loadIdentitySecret,
6236
6269
  loadLedger,
6237
6270
  loadLockPubkeyState,
@@ -6265,6 +6298,7 @@ export {
6265
6298
  payInvoiceReconciling,
6266
6299
  paymentErrorBody,
6267
6300
  paymentRequiredV2FromV1,
6301
+ pendingDrainFor,
6268
6302
  pickCreditFundRail,
6269
6303
  pinAskFiat,
6270
6304
  pinDimension,
@@ -6289,8 +6323,11 @@ export {
6289
6323
  receiptIssuedAtIso,
6290
6324
  receiptPubkeyFromSecret,
6291
6325
  reconcileRefusedX402Deposits,
6326
+ recordCreditX402Instrument,
6327
+ recordPendingDrain,
6292
6328
  recordPendingX402ExactFunding,
6293
6329
  recordPendingX402Funding,
6330
+ recordSpend,
6294
6331
  recordX402ChannelMetadata,
6295
6332
  refundX402BatchChannel,
6296
6333
  removeX402Wallet,
@@ -6312,6 +6349,7 @@ export {
6312
6349
  serializeOutputData,
6313
6350
  setEmitter,
6314
6351
  settleWithFacilitator,
6352
+ shellQuoteArg,
6315
6353
  signAttestation,
6316
6354
  signDrainReceipt,
6317
6355
  signDvmRequestData,
@@ -6337,6 +6375,7 @@ export {
6337
6375
  validateX402Env,
6338
6376
  verifyAttestation,
6339
6377
  verifyCanonicalSignedRequest,
6378
+ verifyChallenge,
6340
6379
  verifyDrainReceipt,
6341
6380
  verifyDrainReceiptChain,
6342
6381
  verifyFundingReceipt,