@dvmkit/sdk 0.2.0-rc.9 → 0.3.0-rc.10

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.
Files changed (58) hide show
  1. package/README.md +2 -0
  2. package/dist/{chunk-V7EVFLAK.js → chunk-2D75MNNG.js} +154 -523
  3. package/dist/{chunk-BIFLRKMO.js → chunk-2KGG5ORW.js} +1 -1
  4. package/dist/{chunk-PCUQZDZA.js → chunk-4VHTKNOR.js} +635 -321
  5. package/dist/{chunk-5URG56JJ.js → chunk-A4CM2BD3.js} +18 -2
  6. package/dist/{chunk-FT6HTUM4.js → chunk-AJNFXR7J.js} +1 -1
  7. package/dist/{chunk-S3XAHZQY.js → chunk-COYKJRMM.js} +24 -3
  8. package/dist/{chunk-UP2F5RRT.js → chunk-D7YQYLLM.js} +1 -4
  9. package/dist/{chunk-OMIQMMME.js → chunk-FPOLJRBF.js} +3 -3
  10. package/dist/{chunk-QP53RWAD.js → chunk-HHTL3ZFT.js} +9 -6
  11. package/dist/{chunk-JDT5LCJC.js → chunk-MD3H3BF7.js} +1 -1
  12. package/dist/{chunk-KSQEFVFJ.js → chunk-MMCE7XSR.js} +1 -1
  13. package/dist/{chunk-MRAGS5VP.js → chunk-N5B66UOS.js} +4 -16
  14. package/dist/{chunk-2ATUAUAO.js → chunk-O6D72KYA.js} +2 -2
  15. package/dist/{chunk-KXCKFIJI.js → chunk-QX52F6IB.js} +1 -1
  16. package/dist/{chunk-PHHAYRQV.js → chunk-U5VNEALI.js} +23 -10
  17. package/dist/{chunk-JLXYOV4Y.js → chunk-V5ZRATJH.js} +1 -1
  18. package/dist/{chunk-6GRIKOFB.js → chunk-VA7GT6C6.js} +5 -16
  19. package/dist/{chunk-O2X2CCKH.js → chunk-VIVXB4CD.js} +1 -1
  20. package/dist/{chunk-L67WTZX2.js → chunk-XMDQOXHO.js} +10 -33
  21. package/dist/{chunk-QT4ONTST.js → chunk-XRLKGCAW.js} +1 -1
  22. package/dist/{chunk-KMZXTBLA.js → chunk-XZ7LW4S5.js} +0 -1
  23. package/dist/{chunk-XQXJKJ3P.js → chunk-YO56VCTQ.js} +0 -4
  24. package/dist/{credit-ledger-5ZEJRI46.js → credit-ledger-MHA652TV.js} +2 -2
  25. package/dist/{credit-menu-D4Gcdgc4.d.ts → credit-menu-0-UtJ3hh.d.ts} +179 -533
  26. package/dist/{fx-B0SLBe5x.d.ts → fx-DhyT1Cjh.d.ts} +1 -1
  27. package/dist/index.d.ts +5 -17
  28. package/dist/internal/caller.d.ts +109 -698
  29. package/dist/internal/caller.js +10 -12
  30. package/dist/internal/server.d.ts +17 -42
  31. package/dist/internal/server.js +16 -15
  32. package/dist/{job-store-B2uZvga4.d.ts → job-store-D3CcZp_g.d.ts} +6 -10
  33. package/dist/{lightning-backend-CQBnQgsT.d.ts → lightning-backend-BhsyrBLa.d.ts} +1 -15
  34. package/dist/{memory-credit-ledger-ZOH6C3N4.js → memory-credit-ledger-BYBATRN3.js} +3 -3
  35. package/dist/{mpp-secret-state-WNAQQ6K4.js → mpp-secret-state-B5GCILVH.js} +1 -1
  36. package/dist/{mpp-setup-IOJBF7DB.js → mpp-setup-MPP3ST5X.js} +1 -1
  37. package/dist/{payout-reporter-5PIRYFVQ.js → payout-reporter-KEMUXEUO.js} +2 -2
  38. package/dist/{postgres-consumed-credential-store-ISRHBMOU.js → postgres-consumed-credential-store-6N2V5MJN.js} +1 -1
  39. package/dist/postgres-job-store-VE2JRUEC.js +7 -0
  40. package/dist/postgres-kv-store-DXGTKXLU.js +7 -0
  41. package/dist/{postgres-replay-store-IZFLTTAC.js → postgres-replay-store-ZF4JNZOW.js} +2 -2
  42. package/dist/{processed-payment-store-FIDI3RNH.js → processed-payment-store-GKMAWOM3.js} +2 -2
  43. package/dist/revenue-reporter-O75BGYFK.js +7 -0
  44. package/dist/server/index.d.ts +37 -140
  45. package/dist/server/index.js +64 -127
  46. package/dist/{step-cache-CXg7ziML.d.ts → step-cache-v2yhyhSZ.d.ts} +359 -1112
  47. package/dist/{tempo-charge-store-76TDAF34.js → tempo-charge-store-SDTUNTKA.js} +2 -2
  48. package/dist/{tempo-lifecycle-DXM7QXJQ.js → tempo-lifecycle-G5SB4HFC.js} +4 -4
  49. package/dist/{tempo-session-store-2JNOKJGX.js → tempo-session-store-WF3VZXNF.js} +2 -2
  50. package/dist/{tempo-wallet-O67H5M4N.js → tempo-wallet-ZFNUDFVO.js} +1 -1
  51. package/dist/testing/index.d.ts +2 -2
  52. package/dist/testing/index.js +2 -2
  53. package/dist/{usd-BNDg1715.d.ts → usd-Cu9G6xv2.d.ts} +1 -1
  54. package/dist/{x402-7S2EFINY.js → x402-CI6PSHNO.js} +4 -4
  55. package/package.json +2 -2
  56. package/dist/postgres-job-store-OGQ6IT4U.js +0 -7
  57. package/dist/postgres-kv-store-D5E2EZ24.js +0 -7
  58. package/dist/revenue-reporter-NNCNRY4C.js +0 -7
@@ -55,7 +55,7 @@ import {
55
55
  withIdentitiesLock,
56
56
  withTempoChannelLock,
57
57
  withholdsTempoCreditSession
58
- } from "../chunk-OMIQMMME.js";
58
+ } from "../chunk-FPOLJRBF.js";
59
59
  import {
60
60
  TEMPO_CHAIN_ID,
61
61
  TEMPO_MODERATO_CHAIN_ID,
@@ -71,7 +71,7 @@ import {
71
71
  tempoTokenReference,
72
72
  tempoWrongAssetHint,
73
73
  tryResolveTempoAsset
74
- } from "../chunk-O2X2CCKH.js";
74
+ } from "../chunk-VIVXB4CD.js";
75
75
  import {
76
76
  DvmX402ChannelStorage,
77
77
  X402_EXACT_AUTHORIZATION_TTL_SECONDS,
@@ -116,7 +116,7 @@ import {
116
116
  x402PendingStale,
117
117
  x402PendingUnsettled,
118
118
  x402WrongAssetHint
119
- } from "../chunk-2ATUAUAO.js";
119
+ } from "../chunk-O6D72KYA.js";
120
120
  import {
121
121
  RAIL_FLAGS,
122
122
  SUPPORTED_PROTOCOL_VERSION,
@@ -163,7 +163,7 @@ import {
163
163
  setOutputTraceId,
164
164
  settleDrainEvidence,
165
165
  withinAdvertisedTolerance
166
- } from "../chunk-KSQEFVFJ.js";
166
+ } from "../chunk-MMCE7XSR.js";
167
167
  import {
168
168
  CREDIT_POSTURES,
169
169
  FEEDBACK_POSTURES,
@@ -289,7 +289,7 @@ import {
289
289
  withWalletLock,
290
290
  writeAgentMnemonic,
291
291
  writeIdentity
292
- } from "../chunk-KXCKFIJI.js";
292
+ } from "../chunk-QX52F6IB.js";
293
293
  import {
294
294
  X402_BATCH_SETTLEMENT_SCHEME,
295
295
  X402_DEFAULT_FACILITATOR,
@@ -343,7 +343,7 @@ import {
343
343
  parseBudget,
344
344
  usdToMsats,
345
345
  usdcToMsats
346
- } from "../chunk-5URG56JJ.js";
346
+ } from "../chunk-A4CM2BD3.js";
347
347
  import {
348
348
  AGENT_MNEMONIC_FILE,
349
349
  BTC_RATE_FILE,
@@ -398,7 +398,7 @@ import {
398
398
  randomTraceId,
399
399
  setEmitter,
400
400
  withTraceContext
401
- } from "../chunk-XQXJKJ3P.js";
401
+ } from "../chunk-YO56VCTQ.js";
402
402
  import "../chunk-66HGCPBU.js";
403
403
  import {
404
404
  redactUrl,
@@ -6318,9 +6318,7 @@ function createScheme(wallet, depositMicro, network = wallet.network, recordedSa
6318
6318
  const scheme = new BatchSettlementEvmScheme(signer, {
6319
6319
  storage,
6320
6320
  salt,
6321
- // The credit policy has already sized this purchase. Depositing the
6322
- // policy amount gives the channel exactly that runway, never upstream's
6323
- // generic 5x request multiplier.
6321
+ // Use at least the policy amount and upstream minimum, rather than its 5x default.
6324
6322
  depositStrategy: ({ minimumDepositAmount }) => (BigInt(minimumDepositAmount) > BigInt(depositMicro) ? BigInt(minimumDepositAmount) : BigInt(depositMicro)).toString(),
6325
6323
  ...url ? { rpcUrl: url } : {}
6326
6324
  });
@@ -9397,7 +9395,7 @@ async function probeX402(x402, timeoutMs) {
9397
9395
  let network;
9398
9396
  let address;
9399
9397
  try {
9400
- const { loadX402Wallet: loadX402Wallet2, getX402Balance: getX402Balance2, ensureAddress: ensureAddress2, usdcContractByCaip2: usdcContractByCaip22 } = await import("../x402-7S2EFINY.js");
9398
+ const { loadX402Wallet: loadX402Wallet2, getX402Balance: getX402Balance2, ensureAddress: ensureAddress2, usdcContractByCaip2: usdcContractByCaip22 } = await import("../x402-CI6PSHNO.js");
9401
9399
  const wallet = loadX402Wallet2();
9402
9400
  if (!wallet) {
9403
9401
  const storedKey = x402.privateKey;
@@ -9449,7 +9447,7 @@ async function probeMpp(mpp, timeoutMs) {
9449
9447
  if (!mpp) return null;
9450
9448
  if (mpp.method === "tempo") {
9451
9449
  try {
9452
- const { connectedTempoAccount: connectedTempoAccount2, getTempoUsdcBalance: getTempoUsdcBalance2, resolveTempoNetwork: resolveTempoNetwork2 } = await import("../tempo-wallet-O67H5M4N.js");
9450
+ const { connectedTempoAccount: connectedTempoAccount2, getTempoUsdcBalance: getTempoUsdcBalance2, resolveTempoNetwork: resolveTempoNetwork2 } = await import("../tempo-wallet-ZFNUDFVO.js");
9453
9451
  const account = await connectedTempoAccount2();
9454
9452
  if (!account) {
9455
9453
  return {
@@ -1,27 +1,25 @@
1
1
  import { FacilitatorConfig } from '@x402/core/server';
2
- import { aj as PaymentPayload, ap as PaymentRequirementsV1, aq as PaymentRequirementsV2, aE as X402Config, av as SettleResponse, aC as VerifyResponse, bi as X402ExactVersionSupport, bj as X402Receipt, bk as TransactionalPayoutHook, bl as CashuMeltCompleted } from '../step-cache-CXg7ziML.js';
3
- export { bm as CreditDepositPayload, bn as CreditDrainPayload, bo as FundingLot, bp as LotDebit, bq as LotDepletion, br as MppxServer, bs as NON_CHANNEL_BITCOIN_RAILS, bt as NonChannelBitcoinRail, bu as PayoutReporter, bv as PostgresTempoSessionStore, bw as RevenueReporter, bx as SIGNED_ENVELOPE_FIELDS, by as SIGNED_ENVELOPE_TYPES, bz as X402TrackedChannel, bA as _testing, bB as createDefaultReplayStore, bC as depleteLots, bD as fifoOrder, bE as inKindDrawMsats, bF as isInKindDepletion, bG as isNonChannelBitcoinRail, bH as lotOwedSats, bI as netOwedSats, bJ as wrapMppx } from '../step-cache-CXg7ziML.js';
2
+ import { aj as PaymentPayload, ap as PaymentRequirementsV1, aq as PaymentRequirementsV2, aE as X402Config, av as SettleResponse, aC as VerifyResponse, bi as X402ExactVersionSupport, bj as X402Receipt, bk as TransactionalPayoutHook, bl as CashuMeltCompleted } from '../step-cache-v2yhyhSZ.js';
3
+ export { bm as CreditDepositPayload, bn as CreditDrainPayload, bo as FundingLot, bp as LotDebit, bq as LotDepletion, br as MppxServer, bs as NON_CHANNEL_BITCOIN_RAILS, bt as NonChannelBitcoinRail, bu as PayoutReporter, bv as PostgresTempoSessionStore, bw as RevenueReporter, bx as SIGNED_ENVELOPE_FIELDS, by as SIGNED_ENVELOPE_TYPES, bz as X402TrackedChannel, bA as _testing, bB as createDefaultReplayStore, bC as depleteLots, bD as fifoOrder, bE as inKindDrawMsats, bF as isInKindDepletion, bG as isNonChannelBitcoinRail, bH as lotOwedSats, bI as netOwedSats, bJ as wrapMppx } from '../step-cache-v2yhyhSZ.js';
4
4
  import { Hono } from 'hono';
5
5
  import { Env, BlankSchema } from 'hono/types';
6
6
  import { Pool } from 'pg';
7
7
  export { Pool } from 'pg';
8
8
  import { g as getWallet } from '../wallet-Dwjs5n_M.js';
9
- import { A as AccumulatorPool, a as AccumulatorQuerier, C as ConsumedCredentialStore } from '../credit-menu-D4Gcdgc4.js';
10
- export { b as AppEnv, c as CreditFundingReport, F as FiatDenomination, d as FiatDenominationFailure, e as FundOnlyRequest, I as IncomingPaymentOpts, J as JobCancelledError, M as MintHealthTracker, P as PAYMENT_PROOF_KEYS, f as PaymentErrorCode, g as PaymentErrorDetail, h as PaymentInfo, R as ReporterBannerOpts, i as ResolvedFx, j as RevenueBootCheckOpts, S as SDKServerOpts, k as ServerJob, l as ShortPayForfeit, T as TempoChannelReport, m as TempoObserverHealth, n as TempoSessionChannelMismatchError, U as UpfrontPaymentOpts, V as VerifiedIncomingPayment, o as VerifyIncomingSnapshot, X as X402BatchChannelObservation, p as X402FacilitatorHealth, q as X402SettlementEvidenceOutcome, r as X402SettlementRepair, s as X402SettlementRepairRefusal, t as X402SettlementRepaired, u as X402WedgedSettlement, v as X402WedgedSettlementPage, w as X402_BATCH_SETTLEMENT_MAINNET_NETWORK, x as abortJob, y as applyPaymentInfoToJob, z as assertRevenueReporterReady, B as buildPaymentErrorResponse, D as clearAccumulatorForDvm, E as createDVMServer, G as creditDepositPayload, H as derivedFundCreditId, K as devModeSkipsPaymentVerification, L as fromJobRecord, N as fundedMicroFor, O as hasPaymentProof, Q as hashLockKey, W as implicitCreditId, Y as initWalletAccumulatorTable, Z as insertAccumulatorRows, _ as isDerivedCreditId, $ as isTerminal, a0 as isYieldMessage, a1 as issueUpfrontChallenges, a2 as msatsToFiatMicro, a3 as paymentErrorBody, a4 as pinAskFiat, a5 as priceFiatMicro, a6 as processIncomingPayment, a7 as providerMessage, a8 as repairX402ExactSettlementEffect, a9 as resolveFxSnapshot, aa as resolvePriceFiat, ab as revenueReporterBannerState, ac as toCreditTerms, ad as toJobRecord, ae as unknownRouteNotFound, af as verifyIncomingPayment, ag as verifyTempoSessionManagementCredential, ah as verifyUpfrontPayment, ai as x402RequiredUsdcMicro, aj as x402SettledShare } from '../credit-menu-D4Gcdgc4.js';
11
- import { g as LockPubkey } from '../lightning-backend-CQBnQgsT.js';
12
- export { t as lockPubkeyStoreToLockPubkey } from '../lightning-backend-CQBnQgsT.js';
13
- export { O as OutgoingMessage, S as StaleJobReapable, i as isStaleJobReapable } from '../job-store-B2uZvga4.js';
9
+ import { A as AccumulatorPool, a as AccumulatorQuerier, C as ConsumedCredentialStore } from '../credit-menu-0-UtJ3hh.js';
10
+ export { b as AppEnv, c as CreditFundingReport, F as FiatDenomination, d as FiatDenominationFailure, e as FundOnlyRequest, I as IncomingPaymentOpts, J as JobCancelledError, M as MintHealthTracker, P as PAYMENT_PROOF_KEYS, f as PaymentErrorCode, g as PaymentErrorDetail, h as PaymentInfo, R as ReporterBannerOpts, i as ResolvedFx, j as RevenueBootCheckOpts, S as SDKServerOpts, k as ServerJob, l as ShortPayForfeit, T as TempoChannelReport, m as TempoObserverHealth, n as TempoSessionChannelMismatchError, U as UpfrontPaymentOpts, V as VerifiedIncomingPayment, o as VerifyIncomingSnapshot, X as X402BatchChannelObservation, p as X402FacilitatorHealth, q as X402SettlementEvidenceOutcome, r as X402SettlementRepair, s as X402SettlementRepairRefusal, t as X402SettlementRepaired, u as X402WedgedSettlement, v as X402WedgedSettlementPage, w as X402_BATCH_SETTLEMENT_MAINNET_NETWORK, x as abortJob, y as applyPaymentInfoToJob, z as assertRevenueReporterReady, B as buildPaymentErrorResponse, D as clearAccumulatorForDvm, E as createDVMServer, G as creditDepositPayload, H as derivedFundCreditId, K as devModeSkipsPaymentVerification, L as fromJobRecord, N as fundedMicroFor, O as hasPaymentProof, Q as hashLockKey, W as implicitCreditId, Y as initWalletAccumulatorTable, Z as insertAccumulatorRows, _ as isDerivedCreditId, $ as isTerminal, a0 as isYieldMessage, a1 as issueUpfrontChallenges, a2 as msatsToFiatMicro, a3 as paymentErrorBody, a4 as pinAskFiat, a5 as priceFiatMicro, a6 as processIncomingPayment, a7 as providerMessage, a8 as repairX402ExactSettlementEffect, a9 as resolveFxSnapshot, aa as resolvePriceFiat, ab as revenueReporterBannerState, ac as toCreditTerms, ad as toJobRecord, ae as unknownRouteNotFound, af as verifyIncomingPayment, ag as verifyTempoSessionManagementCredential, ah as verifyUpfrontPayment, ai as x402RequiredUsdcMicro, aj as x402SettledShare } from '../credit-menu-0-UtJ3hh.js';
11
+ import { g as LockPubkey } from '../lightning-backend-BhsyrBLa.js';
12
+ export { t as lockPubkeyStoreToLockPubkey } from '../lightning-backend-BhsyrBLa.js';
13
+ export { O as OutgoingMessage, S as StaleJobReapable, i as isStaleJobReapable } from '../job-store-D3CcZp_g.js';
14
14
  import { Store } from 'mppx';
15
15
  import { z } from 'zod';
16
16
  import '@x402/evm/batch-settlement/server';
17
17
  import 'viem';
18
18
  import '@x402/core/types';
19
19
  import '@cashu/cashu-ts';
20
- import '../fx-B0SLBe5x.js';
20
+ import '../fx-DhyT1Cjh.js';
21
21
 
22
- /** POST a verify request to the configured facilitator. */
23
22
  declare function verifyWithFacilitator(payload: PaymentPayload, requirements: PaymentRequirementsV1 | PaymentRequirementsV2, config?: Pick<X402Config, "facilitator" | "facilitatorAuth">, createAuthHeaders?: FacilitatorConfig["createAuthHeaders"] | undefined): Promise<VerifyResponse>;
24
- /** POST a settlement request to the configured facilitator. */
25
23
  declare function settleWithFacilitator(payload: PaymentPayload, requirements: PaymentRequirementsV1 | PaymentRequirementsV2, config?: Pick<X402Config, "facilitator" | "facilitatorAuth">, createAuthHeaders?: FacilitatorConfig["createAuthHeaders"] | undefined): Promise<SettleResponse>;
26
24
 
27
25
  /**
@@ -93,9 +91,9 @@ declare function initLockPubkeyTable(db: LockPubkeyPool): Promise<void>;
93
91
  * batches and the receive path keeps accepting in-flight tokens locked to
94
92
  * them.
95
93
  *
96
- * `ON CONFLICT DO NOTHING` must remain even under the boot lock: callers on
97
- * one pool share its acquisition, so concurrent seeds can both pass the
98
- * `WHERE NOT EXISTS` check before either insert commits.
94
+ * `ON CONFLICT DO NOTHING` protects concurrent seeds invoked reentrantly from
95
+ * one guarded callback. Nested calls bypass the queue to avoid deadlock, so
96
+ * both inserts can pass `WHERE NOT EXISTS` before either commits.
99
97
  */
100
98
  declare function seedLockPubkeyState(db: LockPubkeyPool, dvmId: string, pubkey: string, now?: number): Promise<void>;
101
99
  /**
@@ -136,7 +134,6 @@ declare const DEFAULT_LOCK_PUBKEY_GRACE_SECONDS = 86400;
136
134
  declare function activePubkeySet(state: LockPubkeyState): LockPubkey[];
137
135
 
138
136
  interface InstallAdminCashuRoutesOpts {
139
- /** Pool against the SDK's accumulator DB. */
140
137
  db: Pool;
141
138
  /** Identifier of this DVM — bound into every signed admin challenge. */
142
139
  dvmId: string;
@@ -151,25 +148,15 @@ interface InstallAdminCashuRoutesOpts {
151
148
  graceSeconds: number;
152
149
  /** Replay-protection store keyed by nonce. */
153
150
  nonceStore: ConsumedCredentialStore;
154
- /**
155
- * Runs inside the transaction that marks the rows melted: the
156
- * proofs are SPENT and the Lightning payment reached the builder, so the
157
- * melt is a landed payout, and its report commits with the mark or not at
158
- * all. `enqueue` throwing rolls the mark back and fails the call — the CLI's
159
- * recovery re-posts `mark-melted` on its next run, where a melt marked with
160
- * no row would understate paid-out forever. `committed` runs after.
161
- */
151
+ /** Runs after mint checkstate reports the proofs SPENT, inside the transaction that
152
+ * records the caller-reported melt audit and marks rows melted. Enqueue failure
153
+ * rolls the mark back for recovery; committed runs only after commit. */
162
154
  onMelted?: TransactionalPayoutHook<CashuMeltCompleted>;
163
155
  /** Override for cashu-ts wallet construction (tests). */
164
156
  walletProvider?: typeof getWallet;
165
157
  /** Override for the current time (tests). Returns ms since epoch. */
166
158
  now?: () => number;
167
159
  }
168
- /**
169
- * Register the four admin endpoints on the supplied Hono app. Idempotent at
170
- * the call site — `app.ts` only invokes this when accumulator config is
171
- * complete (`cashuMode === "p2pk-accumulator"`, `db`, `dvmId`, `lockPubkey`).
172
- */
173
160
  declare function installAdminCashuRoutes<E extends Env = Env, S extends BlankSchema = BlankSchema>(app: Hono<E, S>, opts: InstallAdminCashuRoutesOpts): void;
174
161
  /**
175
162
  * Convenience constructor for the in-memory nonce store — exported so callers
@@ -311,27 +298,15 @@ declare class PostgresTempoChargeStore implements Store.AtomicStore {
311
298
  init(): Promise<void>;
312
299
  /** Read one stored value, or `null` when absent — mppx's miss sentinel. */
313
300
  get(key: string): Promise<unknown>;
314
- /** Replace one stored value. */
315
301
  put(key: string, value: unknown): Promise<void>;
316
302
  /** Delete one stored value — mppx's compensating release on a failed broadcast. */
317
303
  delete(key: string): Promise<void>;
318
304
  /**
319
- * Atomic read-modify-write, linearized across every machine sharing the pool.
320
- *
321
- * The advisory lock is taken before the row lock because a key's *first*
322
- * write is the one that matters here: `FOR UPDATE` locks nothing when no row
323
- * exists, so two machines marking one hash for the first time would both read
324
- * `null` and both believe they won.
325
- *
326
- * Replay keys are unique per credential, so they never contend. The contended
327
- * key is the fee-sponsor budget — one per `(chain, sponsor)`, read-modified
328
- * several times per sponsored charge — and serializing it across machines is
329
- * the point of sharing the store at all. The critical section is a SELECT and
330
- * an upsert, so a queue of waiters clears in tens of milliseconds; a pooled
331
- * connection is held for exactly that long and never across a chain call.
305
+ * Advisory locking covers the absent-row first write before the row lock.
306
+ * Both competing presentations of one credential and the shared sponsor
307
+ * budget need this serialization. The transaction contains no chain call.
332
308
  */
333
309
  update<result>(key: string, fn: (current: unknown) => Store.Change<unknown, result>): Promise<result>;
334
- /** The boot DDL itself — always runs under {@link withSdkInitLock}. */
335
310
  private createTables;
336
311
  private maybeSweep;
337
312
  }
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  PostgresTempoSessionStore
3
- } from "../chunk-UP2F5RRT.js";
3
+ } from "../chunk-D7YQYLLM.js";
4
4
  import {
5
5
  verifyX402Payment
6
- } from "../chunk-BIFLRKMO.js";
6
+ } from "../chunk-2KGG5ORW.js";
7
7
  import {
8
8
  RevenueReporter
9
- } from "../chunk-6GRIKOFB.js";
9
+ } from "../chunk-VA7GT6C6.js";
10
10
  import {
11
11
  PayoutReporter
12
- } from "../chunk-L67WTZX2.js";
12
+ } from "../chunk-XMDQOXHO.js";
13
13
  import {
14
14
  PostgresTempoChargeStore
15
- } from "../chunk-MRAGS5VP.js";
15
+ } from "../chunk-N5B66UOS.js";
16
16
  import "../chunk-YG7G4DPZ.js";
17
17
  import {
18
18
  DEFAULT_LOCK_PUBKEY_GRACE_SECONDS,
@@ -65,13 +65,14 @@ import {
65
65
  verifyUpfrontPayment,
66
66
  x402RequiredUsdcMicro,
67
67
  x402SettledShare
68
- } from "../chunk-PCUQZDZA.js";
69
- import "../chunk-QT4ONTST.js";
68
+ } from "../chunk-4VHTKNOR.js";
69
+ import "../chunk-XRLKGCAW.js";
70
70
  import {
71
71
  settleWithFacilitator,
72
72
  verifyWithFacilitator
73
73
  } from "../chunk-BQ2NMWKE.js";
74
- import "../chunk-PHHAYRQV.js";
74
+ import "../chunk-U5VNEALI.js";
75
+ import "../chunk-HHTL3ZFT.js";
75
76
  import {
76
77
  SIGNED_ENVELOPE_FIELDS,
77
78
  SIGNED_ENVELOPE_TYPES,
@@ -88,15 +89,15 @@ import {
88
89
  isYieldMessage,
89
90
  providerMessage,
90
91
  toJobRecord
91
- } from "../chunk-JDT5LCJC.js";
92
+ } from "../chunk-MD3H3BF7.js";
92
93
  import {
93
94
  toLockPubkey
94
- } from "../chunk-KXCKFIJI.js";
95
+ } from "../chunk-QX52F6IB.js";
95
96
  import "../chunk-Z4BNLUZF.js";
96
- import "../chunk-5URG56JJ.js";
97
+ import "../chunk-A4CM2BD3.js";
97
98
  import "../chunk-MKI6OVW4.js";
98
99
  import "../chunk-KXZUCCEY.js";
99
- import "../chunk-XQXJKJ3P.js";
100
+ import "../chunk-YO56VCTQ.js";
100
101
  import "../chunk-66HGCPBU.js";
101
102
  import "../chunk-FUJ36YDV.js";
102
103
  import "../chunk-4A2RAKCW.js";
@@ -110,13 +111,13 @@ import {
110
111
  isNonChannelBitcoinRail,
111
112
  lotOwedSats,
112
113
  netOwedSats
113
- } from "../chunk-V7EVFLAK.js";
114
- import "../chunk-S3XAHZQY.js";
114
+ } from "../chunk-2D75MNNG.js";
115
+ import "../chunk-COYKJRMM.js";
115
116
  import "../chunk-C3MTFLC6.js";
116
117
  import {
117
118
  _testing,
118
119
  wrapMppx
119
- } from "../chunk-KMZXTBLA.js";
120
+ } from "../chunk-XZ7LW4S5.js";
120
121
  export {
121
122
  DEFAULT_LOCK_PUBKEY_GRACE_SECONDS,
122
123
  JobCancelledError,
@@ -1,9 +1,7 @@
1
1
  import { ProofLike } from '@cashu/cashu-ts';
2
- import { a1 as Message, ah as FundingMethod, X as FundingReceipt, bO as CreditSnapshot, Y as JobReceipt, ax as StepRecord, a2 as MessageType } from './step-cache-CXg7ziML.js';
2
+ import { a1 as Message, ah as FundingMethod, X as FundingReceipt, bO as CreditSnapshot, Y as JobReceipt, ax as StepRecord, a2 as MessageType } from './step-cache-v2yhyhSZ.js';
3
3
 
4
- /** Job status values that can be persisted. */
5
4
  type JobStatus = "processing" | "completed" | "failed" | "awaiting-input" | "cancelled" | "working";
6
- /** Serializable snapshot of a job's persistent state. */
7
5
  interface JobRecord {
8
6
  id: string;
9
7
  tags: string[];
@@ -73,7 +71,7 @@ interface JobRecord {
73
71
  seq: number;
74
72
  paidMsats: number;
75
73
  paymentMint?: string;
76
- /** Rail of the most recent successful credit (cashu / x402 / mpp). */
74
+ /** Rail of the most recent successful credit (cashu / x402 / tempo). */
77
75
  paymentRail?: FundingMethod;
78
76
  /**
79
77
  * Settlement reference threaded into the platform revenue ledger
@@ -85,11 +83,13 @@ interface JobRecord {
85
83
  paymentTxHash?: string;
86
84
  /** Chain transaction returned to callers recovering x402 or Tempo acceptance. */
87
85
  paymentTransactionHash?: string;
88
- /** Rail-native upfront amount (sats or USDC microunits). */
86
+ /**
87
+ * Accumulated same-rail stablecoin micro-units for Tempo/x402; resets when the rail changes.
88
+ * Cashu revenue uses paidMsats.
89
+ */
89
90
  nativeAmount?: number;
90
91
  /** Native asset tag paired with `nativeAmount`. */
91
92
  nativeAsset?: "sats" | "usdc" | "usdc.e" | "usd-cents";
92
- /** Cashu flow discriminator written into `revenue_events.metadata.cashu_flow`. */
93
93
  cashuFlow?: "p2pk_accumulator";
94
94
  /**
95
95
  * What this job cost the **builder** to serve, in 1e-6 of
@@ -325,9 +325,7 @@ interface RequestIdClaimResult {
325
325
  /** True when the durable identity binding existed before this lock acquisition. */
326
326
  replayed: boolean;
327
327
  }
328
- /** Persistent backing store for job records. */
329
328
  interface JobStore {
330
- /** Retrieve a job record by ID. Returns undefined if not found. */
331
329
  get(id: string): Promise<JobRecord | undefined>;
332
330
  /**
333
331
  * Retrieve the job a settlement reference paid for. On the cashu
@@ -357,7 +355,6 @@ interface JobStore {
357
355
  * durable caller/fingerprint/job binding remains retained.
358
356
  */
359
357
  releaseRequestIdClaim?(claim: RequestIdClaim): Promise<void>;
360
- /** Upsert a job record. */
361
358
  save(record: JobRecord): Promise<void>;
362
359
  delete(id: string): Promise<void>;
363
360
  }
@@ -596,7 +593,6 @@ interface StaleJobReapable {
596
593
  /** See {@link StreamableJobStore.cancelStaleJob}. */
597
594
  cancelStaleJob(jobId: string, expectedActivityBefore: number, reason: string, terminalStatus: "failed" | "cancelled"): Promise<boolean>;
598
595
  }
599
- /** Runtime type guard for StaleJobReapable. */
600
596
  declare function isStaleJobReapable(store: JobStore): store is JobStore & StaleJobReapable;
601
597
 
602
598
  export { type AppendOutgoingOptions as A, type JobRecord as J, type OutgoingMessage as O, type PaymentCreditDelta as P, type ReceiptIssuingStore as R, type StaleJobReapable as S, type TopUpCapUnenforcedReason as T, type VerifyAndCreditResult as V, type JobStatus as a, type JobStore as b, type StreamableJobStore as c, type RequestIdClaim as d, type RequestIdClaimResult as e, type JobRetentionCursor as f, type JobCounters as g, isStreamableJobStore as h, isStaleJobReapable as i };
@@ -1,4 +1,4 @@
1
- import { W as JsonValue } from './step-cache-CXg7ziML.js';
1
+ import { W as JsonValue } from './step-cache-v2yhyhSZ.js';
2
2
 
3
3
  declare const lockPubkeyBrand: unique symbol;
4
4
  /**
@@ -136,9 +136,7 @@ interface MintAmountBounds {
136
136
  /** Largest amount the mint will quote, or `null` when unadvertised. */
137
137
  maxSats: number | null;
138
138
  }
139
- /** Error categories returned when a mint health probe fails. */
140
139
  type HealthErrorCode = "timeout" | "http_error" | "network" | "parse_error" | "missing_fields";
141
- /** Outcome of a single health probe against one mint. */
142
140
  interface MintHealthCheckResult {
143
141
  /** Mint URL exactly as passed in (not normalised). */
144
142
  mintUrl: string;
@@ -146,9 +144,7 @@ interface MintHealthCheckResult {
146
144
  ok: boolean;
147
145
  /** Wall-clock duration of the successful (or final failed) attempt in ms. */
148
146
  latencyMs: number;
149
- /** NUT-06 mint pubkey when present. */
150
147
  pubkey?: string;
151
- /** NUT-06 mint version string (e.g. "Nutshell/0.20.0") when present. */
152
148
  version?: string;
153
149
  /** Sorted list of NUT keys the mint declares support for. */
154
150
  supportedNuts?: string[];
@@ -251,9 +247,7 @@ declare function amountBoundsVerdict(sats: number, bounds?: MintAmountBounds): A
251
247
  */
252
248
  declare function assertNutSupport(mintUrl: string, nuts: Record<string, unknown>, requiredNuts?: readonly number[]): void;
253
249
 
254
- /** A Lightning invoice created by the backend. */
255
250
  interface CreatedInvoice {
256
- /** BOLT11 payment request string. */
257
251
  bolt11: string;
258
252
  /** Payment hash (hex) — primary key for looking up settlement. */
259
253
  paymentHash: string;
@@ -274,7 +268,6 @@ interface InvoiceStatus {
274
268
  }
275
269
  /** How a payment reached a settled state — see `payInvoiceReconciling`. */
276
270
  type LightningPayOutcome = "paid" | "reconciled" | "republished";
277
- /** Settled payment plus the audit trail of how it got there. */
278
271
  interface LightningPayment {
279
272
  /** Payment preimage (hex) — proof the invoice was paid. */
280
273
  preimage: string;
@@ -283,7 +276,6 @@ interface LightningPayment {
283
276
  /** Whether the wallet answered directly, or the outcome had to be reconciled. */
284
277
  outcome: LightningPayOutcome;
285
278
  }
286
- /** Bounds for a read-only wallet transaction snapshot. */
287
279
  interface LightningTransactionListOptions {
288
280
  /** Include transactions created at or after this Unix timestamp (seconds). */
289
281
  from?: number;
@@ -307,9 +299,7 @@ interface LightningTransactionSnapshot {
307
299
  createdAt: number;
308
300
  settledAt?: number;
309
301
  }
310
- /** What a backend can tell us about the wallet behind it. */
311
302
  interface LightningWalletInfo {
312
- /** Human-readable wallet name (e.g. "Alby Hub"). */
313
303
  alias?: string;
314
304
  /** Operations the wallet supports (e.g. `pay_invoice`, `lookup_invoice`). */
315
305
  methods: string[];
@@ -322,7 +312,6 @@ interface LightningWalletInfo {
322
312
  */
323
313
  walletReportedBudget?: Record<string, unknown>;
324
314
  }
325
- /** Abstraction over Lightning wallet backends (NWC, future). */
326
315
  interface LightningBackend {
327
316
  /**
328
317
  * Pay a bolt11 invoice exactly once. Returns the preimage on success.
@@ -338,15 +327,12 @@ interface LightningBackend {
338
327
  payInvoice(bolt11: string, amountMsats?: number): Promise<LightningPayment>;
339
328
  /** Get wallet balance in millisatoshis. */
340
329
  getBalance(): Promise<number>;
341
- /** Get wallet info (name, supported methods, any volunteered budget fields). */
342
330
  getInfo(): Promise<LightningWalletInfo>;
343
- /** Create a new incoming invoice for the given amount and description. */
344
331
  createInvoice(params: {
345
332
  amountMsats: number;
346
333
  description?: string;
347
334
  expirySeconds?: number;
348
335
  }): Promise<CreatedInvoice>;
349
- /** Look up an invoice's settlement status by payment hash. */
350
336
  lookupInvoice(paymentHash: string): Promise<InvoiceStatus>;
351
337
  /**
352
338
  * Return a bounded, credential-safe transaction snapshot when supported.
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  MemoryCreditLedger
3
- } from "./chunk-PHHAYRQV.js";
4
- import "./chunk-V7EVFLAK.js";
5
- import "./chunk-S3XAHZQY.js";
3
+ } from "./chunk-U5VNEALI.js";
4
+ import "./chunk-2D75MNNG.js";
5
+ import "./chunk-COYKJRMM.js";
6
6
  import "./chunk-C3MTFLC6.js";
7
7
  export {
8
8
  MemoryCreditLedger
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withSdkInitLock
3
- } from "./chunk-S3XAHZQY.js";
3
+ } from "./chunk-COYKJRMM.js";
4
4
 
5
5
  // src/sdk/server/mpp-secret-state.ts
6
6
  var DEFAULT_ROTATION_WINDOW_MS = 5 * 60 * 1e3;
@@ -17,7 +17,7 @@ import {
17
17
  parseMppMethodsAllowlist,
18
18
  resolveTempoNetwork,
19
19
  wrapMppx
20
- } from "./chunk-KMZXTBLA.js";
20
+ } from "./chunk-XZ7LW4S5.js";
21
21
  export {
22
22
  MPPX_HMAC_MISMATCH_REASON,
23
23
  TEMPO_MAINNET_CHAIN_ID,
@@ -3,8 +3,8 @@ import {
3
3
  PAYOUT_SNAPSHOT_INTERVAL_MS,
4
4
  PayoutReporter,
5
5
  PostgresX402BatchStore
6
- } from "./chunk-L67WTZX2.js";
7
- import "./chunk-S3XAHZQY.js";
6
+ } from "./chunk-XMDQOXHO.js";
7
+ import "./chunk-COYKJRMM.js";
8
8
  export {
9
9
  MemoryX402BatchStore,
10
10
  PAYOUT_SNAPSHOT_INTERVAL_MS,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withSdkInitLock
3
- } from "./chunk-S3XAHZQY.js";
3
+ } from "./chunk-COYKJRMM.js";
4
4
 
5
5
  // src/sdk/server/postgres-consumed-credential-store.ts
6
6
  var DEFAULT_TABLE_NAME = "consumed_credentials";
@@ -0,0 +1,7 @@
1
+ import {
2
+ PostgresJobStore
3
+ } from "./chunk-HHTL3ZFT.js";
4
+ import "./chunk-COYKJRMM.js";
5
+ export {
6
+ PostgresJobStore
7
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ PostgresKVStore
3
+ } from "./chunk-V5ZRATJH.js";
4
+ import "./chunk-COYKJRMM.js";
5
+ export {
6
+ PostgresKVStore
7
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PostgresReplayStore
3
- } from "./chunk-FT6HTUM4.js";
4
- import "./chunk-S3XAHZQY.js";
3
+ } from "./chunk-AJNFXR7J.js";
4
+ import "./chunk-COYKJRMM.js";
5
5
  export {
6
6
  PostgresReplayStore
7
7
  };
@@ -2,8 +2,8 @@ import {
2
2
  MemoryProcessedPaymentStore,
3
3
  PostgresProcessedPaymentStore,
4
4
  ProcessedPaymentReplayError
5
- } from "./chunk-QT4ONTST.js";
6
- import "./chunk-S3XAHZQY.js";
5
+ } from "./chunk-XRLKGCAW.js";
6
+ import "./chunk-COYKJRMM.js";
7
7
  export {
8
8
  MemoryProcessedPaymentStore,
9
9
  PostgresProcessedPaymentStore,
@@ -0,0 +1,7 @@
1
+ import {
2
+ RevenueReporter
3
+ } from "./chunk-VA7GT6C6.js";
4
+ import "./chunk-COYKJRMM.js";
5
+ export {
6
+ RevenueReporter
7
+ };