@dvmkit/sdk 0.2.0-rc.9 → 0.3.0-rc.9
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.
- package/README.md +2 -0
- package/dist/{chunk-V7EVFLAK.js → chunk-2D75MNNG.js} +154 -523
- package/dist/{chunk-BIFLRKMO.js → chunk-2KGG5ORW.js} +1 -1
- package/dist/{chunk-5URG56JJ.js → chunk-A4CM2BD3.js} +18 -2
- package/dist/{chunk-FT6HTUM4.js → chunk-AJNFXR7J.js} +1 -1
- package/dist/{chunk-S3XAHZQY.js → chunk-COYKJRMM.js} +24 -3
- package/dist/{chunk-UP2F5RRT.js → chunk-D7YQYLLM.js} +1 -4
- package/dist/{chunk-OMIQMMME.js → chunk-FPOLJRBF.js} +3 -3
- package/dist/{chunk-QP53RWAD.js → chunk-HHTL3ZFT.js} +9 -6
- package/dist/{chunk-PCUQZDZA.js → chunk-LTAIBLS2.js} +537 -321
- package/dist/{chunk-JDT5LCJC.js → chunk-MD3H3BF7.js} +1 -1
- package/dist/{chunk-KSQEFVFJ.js → chunk-MMCE7XSR.js} +1 -1
- package/dist/{chunk-MRAGS5VP.js → chunk-N5B66UOS.js} +4 -16
- package/dist/{chunk-2ATUAUAO.js → chunk-O6D72KYA.js} +2 -2
- package/dist/{chunk-KXCKFIJI.js → chunk-QX52F6IB.js} +1 -1
- package/dist/{chunk-PHHAYRQV.js → chunk-U5VNEALI.js} +23 -10
- package/dist/{chunk-JLXYOV4Y.js → chunk-V5ZRATJH.js} +1 -1
- package/dist/{chunk-6GRIKOFB.js → chunk-VA7GT6C6.js} +5 -16
- package/dist/{chunk-O2X2CCKH.js → chunk-VIVXB4CD.js} +1 -1
- package/dist/{chunk-L67WTZX2.js → chunk-XMDQOXHO.js} +10 -33
- package/dist/{chunk-QT4ONTST.js → chunk-XRLKGCAW.js} +1 -1
- package/dist/{chunk-KMZXTBLA.js → chunk-XZ7LW4S5.js} +0 -1
- package/dist/{chunk-XQXJKJ3P.js → chunk-YO56VCTQ.js} +0 -4
- package/dist/{credit-ledger-5ZEJRI46.js → credit-ledger-MHA652TV.js} +2 -2
- package/dist/{credit-menu-D4Gcdgc4.d.ts → credit-menu-BlCL7gZx.d.ts} +175 -533
- package/dist/{fx-B0SLBe5x.d.ts → fx-DhyT1Cjh.d.ts} +1 -1
- package/dist/index.d.ts +5 -17
- package/dist/internal/caller.d.ts +109 -698
- package/dist/internal/caller.js +10 -12
- package/dist/internal/server.d.ts +17 -42
- package/dist/internal/server.js +16 -15
- package/dist/{job-store-B2uZvga4.d.ts → job-store-D3CcZp_g.d.ts} +6 -10
- package/dist/{lightning-backend-CQBnQgsT.d.ts → lightning-backend-BhsyrBLa.d.ts} +1 -15
- package/dist/{memory-credit-ledger-ZOH6C3N4.js → memory-credit-ledger-BYBATRN3.js} +3 -3
- package/dist/{mpp-secret-state-WNAQQ6K4.js → mpp-secret-state-B5GCILVH.js} +1 -1
- package/dist/{mpp-setup-IOJBF7DB.js → mpp-setup-MPP3ST5X.js} +1 -1
- package/dist/{payout-reporter-5PIRYFVQ.js → payout-reporter-KEMUXEUO.js} +2 -2
- package/dist/{postgres-consumed-credential-store-ISRHBMOU.js → postgres-consumed-credential-store-6N2V5MJN.js} +1 -1
- package/dist/postgres-job-store-VE2JRUEC.js +7 -0
- package/dist/postgres-kv-store-DXGTKXLU.js +7 -0
- package/dist/{postgres-replay-store-IZFLTTAC.js → postgres-replay-store-ZF4JNZOW.js} +2 -2
- package/dist/{processed-payment-store-FIDI3RNH.js → processed-payment-store-GKMAWOM3.js} +2 -2
- package/dist/revenue-reporter-O75BGYFK.js +7 -0
- package/dist/server/index.d.ts +37 -140
- package/dist/server/index.js +64 -127
- package/dist/{step-cache-CXg7ziML.d.ts → step-cache-v2yhyhSZ.d.ts} +359 -1112
- package/dist/{tempo-charge-store-76TDAF34.js → tempo-charge-store-SDTUNTKA.js} +2 -2
- package/dist/{tempo-lifecycle-DXM7QXJQ.js → tempo-lifecycle-G5SB4HFC.js} +4 -4
- package/dist/{tempo-session-store-2JNOKJGX.js → tempo-session-store-WF3VZXNF.js} +2 -2
- package/dist/{tempo-wallet-O67H5M4N.js → tempo-wallet-ZFNUDFVO.js} +1 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +2 -2
- package/dist/{usd-BNDg1715.d.ts → usd-Cu9G6xv2.d.ts} +1 -1
- package/dist/{x402-7S2EFINY.js → x402-CI6PSHNO.js} +4 -4
- package/package.json +2 -2
- package/dist/postgres-job-store-OGQ6IT4U.js +0 -7
- package/dist/postgres-kv-store-D5E2EZ24.js +0 -7
- package/dist/revenue-reporter-NNCNRY4C.js +0 -7
package/dist/server/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PostgresReplayStore
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import {
|
|
5
|
-
PostgresJobStore
|
|
6
|
-
} from "../chunk-QP53RWAD.js";
|
|
3
|
+
} from "../chunk-AJNFXR7J.js";
|
|
7
4
|
import {
|
|
8
5
|
PostgresKVStore
|
|
9
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-V5ZRATJH.js";
|
|
10
7
|
import {
|
|
11
8
|
SSRFError,
|
|
12
9
|
assertSafeUrl,
|
|
@@ -74,20 +71,24 @@ import {
|
|
|
74
71
|
revenueReporterBannerState,
|
|
75
72
|
seedLockPubkeyState,
|
|
76
73
|
selectPrimaryCredit,
|
|
74
|
+
signHostingControl,
|
|
77
75
|
stripCreditEnvelope,
|
|
78
76
|
stripProtocolEnvelope,
|
|
79
77
|
toCreditView,
|
|
80
78
|
unknownRouteNotFound
|
|
81
|
-
} from "../chunk-
|
|
79
|
+
} from "../chunk-LTAIBLS2.js";
|
|
82
80
|
import {
|
|
83
81
|
MemoryProcessedPaymentStore,
|
|
84
82
|
PostgresProcessedPaymentStore,
|
|
85
83
|
ProcessedPaymentReplayError
|
|
86
|
-
} from "../chunk-
|
|
84
|
+
} from "../chunk-XRLKGCAW.js";
|
|
87
85
|
import "../chunk-BQ2NMWKE.js";
|
|
88
86
|
import {
|
|
89
87
|
MemoryCreditLedger
|
|
90
|
-
} from "../chunk-
|
|
88
|
+
} from "../chunk-U5VNEALI.js";
|
|
89
|
+
import {
|
|
90
|
+
PostgresJobStore
|
|
91
|
+
} from "../chunk-HHTL3ZFT.js";
|
|
91
92
|
import {
|
|
92
93
|
SignedRequestError,
|
|
93
94
|
createDefaultReplayStore,
|
|
@@ -96,12 +97,12 @@ import {
|
|
|
96
97
|
} from "../chunk-H2MEFVH6.js";
|
|
97
98
|
import {
|
|
98
99
|
isStreamableJobStore
|
|
99
|
-
} from "../chunk-
|
|
100
|
+
} from "../chunk-MD3H3BF7.js";
|
|
100
101
|
import {
|
|
101
102
|
generateEphemeralReceiptKey,
|
|
102
103
|
isTestMintUrl,
|
|
103
104
|
receiptPubkeyFromSecret
|
|
104
|
-
} from "../chunk-
|
|
105
|
+
} from "../chunk-QX52F6IB.js";
|
|
105
106
|
import {
|
|
106
107
|
X402_DEFAULT_FACILITATOR,
|
|
107
108
|
X402_DEFAULT_NETWORK,
|
|
@@ -110,7 +111,7 @@ import {
|
|
|
110
111
|
} from "../chunk-Z4BNLUZF.js";
|
|
111
112
|
import {
|
|
112
113
|
IMPLICIT_CREDIT_TTL_MS
|
|
113
|
-
} from "../chunk-
|
|
114
|
+
} from "../chunk-A4CM2BD3.js";
|
|
114
115
|
import {
|
|
115
116
|
resolveRpcOverride
|
|
116
117
|
} from "../chunk-MKI6OVW4.js";
|
|
@@ -121,7 +122,7 @@ import {
|
|
|
121
122
|
} from "../chunk-KXZUCCEY.js";
|
|
122
123
|
import {
|
|
123
124
|
initLoggers
|
|
124
|
-
} from "../chunk-
|
|
125
|
+
} from "../chunk-YO56VCTQ.js";
|
|
125
126
|
import "../chunk-66HGCPBU.js";
|
|
126
127
|
import "../chunk-FUJ36YDV.js";
|
|
127
128
|
import "../chunk-4A2RAKCW.js";
|
|
@@ -133,11 +134,11 @@ import {
|
|
|
133
134
|
PostgresX402ChannelStorage,
|
|
134
135
|
X402RelaySubmissionLockError,
|
|
135
136
|
allocateDrawValue
|
|
136
|
-
} from "../chunk-
|
|
137
|
+
} from "../chunk-2D75MNNG.js";
|
|
137
138
|
import {
|
|
138
139
|
SDK_INIT_ADVISORY_LOCK,
|
|
139
140
|
withSdkInitLock
|
|
140
|
-
} from "../chunk-
|
|
141
|
+
} from "../chunk-COYKJRMM.js";
|
|
141
142
|
import {
|
|
142
143
|
applyRetryToPool
|
|
143
144
|
} from "../chunk-C3MTFLC6.js";
|
|
@@ -147,7 +148,7 @@ import {
|
|
|
147
148
|
TEMPO_SETTLEMENT_DEFAULT_LOW_BALANCE_MICRO,
|
|
148
149
|
TempoSettlementReadiness,
|
|
149
150
|
resolveTempoNetwork
|
|
150
|
-
} from "../chunk-
|
|
151
|
+
} from "../chunk-XZ7LW4S5.js";
|
|
151
152
|
|
|
152
153
|
// src/sdk/server/cashu-env.ts
|
|
153
154
|
async function resolveCashuOptsFromEnv(env, pool, cashuModeHint) {
|
|
@@ -221,6 +222,7 @@ async function resolveCashuOptsFromEnv(env, pool, cashuModeHint) {
|
|
|
221
222
|
error: err instanceof Error ? err.message : String(err)
|
|
222
223
|
})
|
|
223
224
|
);
|
|
225
|
+
if (cashuMode === "p2pk-accumulator") throw err;
|
|
224
226
|
db = void 0;
|
|
225
227
|
}
|
|
226
228
|
}
|
|
@@ -320,7 +322,6 @@ var PlatformLightningRailHealth = class {
|
|
|
320
322
|
lastAttemptAtMs;
|
|
321
323
|
inFlight;
|
|
322
324
|
ceilingLoggedForMs;
|
|
323
|
-
/** Prime the signal during boot without making a menu request wait for it. */
|
|
324
325
|
async refresh() {
|
|
325
326
|
if (this.inFlight) return this.inFlight;
|
|
326
327
|
this.lastAttemptAtMs = this.now();
|
|
@@ -332,7 +333,6 @@ var PlatformLightningRailHealth = class {
|
|
|
332
333
|
this.inFlight = void 0;
|
|
333
334
|
}
|
|
334
335
|
}
|
|
335
|
-
/** Answer from cache and begin a non-blocking refresh once it is due. */
|
|
336
336
|
available() {
|
|
337
337
|
const nowMs = this.now();
|
|
338
338
|
if (this.lastAttemptAtMs === void 0 || nowMs - this.lastAttemptAtMs >= this.refreshTtlMs) {
|
|
@@ -463,16 +463,10 @@ var LightningReceive = class _LightningReceive {
|
|
|
463
463
|
permissionRefusal;
|
|
464
464
|
railHealth;
|
|
465
465
|
/**
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
* unreachable.** A wallet outage at boot must not stop a DVM whose other
|
|
471
|
-
* rails are fine — the menu simply omits `lightning` until a later probe
|
|
472
|
-
* succeeds. A connection that can spend, or one that can't state what it can
|
|
473
|
-
* do, is a different thing entirely: it is a standing money risk that no
|
|
474
|
-
* amount of retrying fixes, so it fails the boot loudly with the fix in the
|
|
475
|
-
* message.
|
|
466
|
+
* Return undefined when unconfigured. Permission/URI failures refuse construction with a
|
|
467
|
+
* corrective message; wallet transport failure constructs an unavailable receive leg so
|
|
468
|
+
* other rails can still boot. Recovery must validate method scope before advertising
|
|
469
|
+
* Lightning.
|
|
476
470
|
*/
|
|
477
471
|
static async create(config) {
|
|
478
472
|
const invoiceTtlSeconds = resolveInvoiceTtl(config.invoiceTtlSeconds);
|
|
@@ -528,26 +522,17 @@ var LightningReceive = class _LightningReceive {
|
|
|
528
522
|
);
|
|
529
523
|
}
|
|
530
524
|
/**
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
* Reads the cached observation and never blocks; a stale one kicks off a
|
|
534
|
-
* background refresh and answers with what we last knew. Advertising a rail
|
|
535
|
-
* whose wallet is down would hand the caller an option that 402s on use —
|
|
536
|
-
* the §4 posture is to drop it and let the sale survive on the others.
|
|
525
|
+
* Answer from cached wallet and optional rail-health observations without blocking. A stale
|
|
526
|
+
* wallet observation starts a background refresh.
|
|
537
527
|
*/
|
|
538
528
|
available() {
|
|
539
529
|
if (Date.now() - this.checkedAtMs > HEALTH_TTL_MS) void this.refresh();
|
|
540
530
|
return this.health === "healthy" && (this.railHealth?.available() ?? true);
|
|
541
531
|
}
|
|
542
532
|
/**
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
* signed body — that binding is the condition-3 commitment on this
|
|
547
|
-
* rail, and it is why no artifact hash rides the request: there is no
|
|
548
|
-
* caller-supplied artifact to hash. A re-poll returns the stored row rather
|
|
549
|
-
* than minting again; a second bolt11 for one `fund_id` would leave two
|
|
550
|
-
* payable invoices against a funding that can only be credited once.
|
|
533
|
+
* Return the stored invoice on retry: two payable bolt11s for one fund ID could charge
|
|
534
|
+
* twice while only one credits. Caller and amount are bound to the recorded credit/funding
|
|
535
|
+
* pair, without a caller-supplied artifact hash.
|
|
551
536
|
*/
|
|
552
537
|
async issue(ledger, args) {
|
|
553
538
|
const existing = await ledger.getInvoice({ creditId: args.creditId, fundId: args.fundId });
|
|
@@ -582,9 +567,8 @@ var LightningReceive = class _LightningReceive {
|
|
|
582
567
|
fundId: args.fundId,
|
|
583
568
|
callerPubkey: args.callerPubkey,
|
|
584
569
|
currency: args.currency,
|
|
585
|
-
//
|
|
586
|
-
//
|
|
587
|
-
// caller was quoted (the shape).
|
|
570
|
+
// Pin fiat and millisatoshi amounts at issue time; settlement does not reprice them
|
|
571
|
+
// after FX changes.
|
|
588
572
|
amountMicro: args.amountMicro,
|
|
589
573
|
amountMsats: created.amountMsats || args.amountMsats,
|
|
590
574
|
paymentHash: created.paymentHash,
|
|
@@ -593,24 +577,9 @@ var LightningReceive = class _LightningReceive {
|
|
|
593
577
|
});
|
|
594
578
|
}
|
|
595
579
|
/**
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
* `blocked` row implies payment — {@link applyOne} returns above the block
|
|
600
|
-
* classification when the lookup says unpaid — but that is *this fleet's
|
|
601
|
-
* belief, recorded possibly weeks ago*, and the verb it gates mints balance
|
|
602
|
-
* against it. One round trip turns the belief into a fact and recovers the
|
|
603
|
-
* true settlement instant for `settled_at`, which a blocked row never got to
|
|
604
|
-
* write.
|
|
605
|
-
*
|
|
606
|
-
* Unlike {@link settlePending} this **throws**: there is no request whose
|
|
607
|
-
* latency it protects, and crediting on an unverifiable wallet is exactly
|
|
608
|
-
* what it exists to prevent. `NOT_FOUND` is the one exception, and it is not
|
|
609
|
-
* an outage — it is the wallet saying it has never seen this hash, the same
|
|
610
|
-
* reading {@link applyOne} and the caller-side reconcile in `src/lib/nwc.ts`
|
|
611
|
-
* take. It comes back as `known: false` because the operator's repair for it
|
|
612
|
-
* ("you are pointed at a different wallet than the one that minted this")
|
|
613
|
-
* is not the repair for an unpaid invoice, and certainly not for a retry.
|
|
580
|
+
* Re-observe the wallet payment before an operator credits a blocked invoice and recover
|
|
581
|
+
* its settlement instant. Unlike settlePending, lookup failures throw. NOT_FOUND returns
|
|
582
|
+
* known:false, distinguishing the wrong wallet/unknown hash from an unpaid known invoice.
|
|
614
583
|
*/
|
|
615
584
|
async lookupSettlement(paymentHash) {
|
|
616
585
|
try {
|
|
@@ -627,23 +596,12 @@ var LightningReceive = class _LightningReceive {
|
|
|
627
596
|
}
|
|
628
597
|
}
|
|
629
598
|
/**
|
|
630
|
-
*
|
|
631
|
-
*
|
|
599
|
+
* Read pending invoices locally, then check at most MAX_SETTLE_CHECKS on bounded wallet
|
|
600
|
+
* deadlines. Log failures without throwing into the request.
|
|
632
601
|
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
* into the request**: a wallet failure here means the caller's balance is
|
|
637
|
-
* merely not updated yet, which the ordinary `insufficient_credit` path
|
|
638
|
-
* already states honestly.
|
|
639
|
-
*
|
|
640
|
-
* **Each invoice gets its own failure boundary.** The sweep window is a few
|
|
641
|
-
* rows wide, so a row that fails on its own terms — a `fund_id` the caller
|
|
642
|
-
* reused on another rail, a credit someone else opened first — must not take
|
|
643
|
-
* the rest of the pass down with it: the next invoice in the window may be
|
|
644
|
-
* the paid one, and it would never be looked up. Only a transport failure
|
|
645
|
-
* ends the pass early, because there the wallet itself is gone and the
|
|
646
|
-
* remaining lookups would just spend the caller's latency confirming it.
|
|
602
|
+
* An invoice-specific failure must not suppress payable siblings; wallet transport failure
|
|
603
|
+
* ends the pass. Deterministic refusals retire that row as blocked for operator repair,
|
|
604
|
+
* while transient failures remain pending.
|
|
647
605
|
*/
|
|
648
606
|
async settlePending(ledger, args) {
|
|
649
607
|
let pending;
|
|
@@ -683,13 +641,6 @@ var LightningReceive = class _LightningReceive {
|
|
|
683
641
|
}
|
|
684
642
|
return settled;
|
|
685
643
|
}
|
|
686
|
-
/**
|
|
687
|
-
* One invoice's settlement check. Returns the applied settlement, or
|
|
688
|
-
* `undefined` when nothing changed (still unpaid, or retired unpaid).
|
|
689
|
-
*
|
|
690
|
-
* Throws whatever the wallet or the ledger threw — classifying that is
|
|
691
|
-
* {@link retireOrLog}'s job, so this stays one invoice's happy path.
|
|
692
|
-
*/
|
|
693
644
|
async applyOne(ledger, backend, invoice, opts) {
|
|
694
645
|
let status;
|
|
695
646
|
try {
|
|
@@ -740,18 +691,9 @@ var LightningReceive = class _LightningReceive {
|
|
|
740
691
|
});
|
|
741
692
|
}
|
|
742
693
|
/**
|
|
743
|
-
*
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
* The split that matters is permanent-versus-transient, because it decides
|
|
747
|
-
* whether the row keeps a slot in the sweep window. A transient failure — the
|
|
748
|
-
* database blinked, the wallet answered oddly — leaves it `pending` and the
|
|
749
|
-
* caller's next request retries it. A **permanent** one means the ledger will
|
|
750
|
-
* refuse this invoice identically forever, so leaving it pending costs a
|
|
751
|
-
* `lookup_invoice` on every subsequent request and, at
|
|
752
|
-
* {@link MAX_SETTLE_CHECKS} of them, fills the window so a genuinely payable
|
|
753
|
-
* invoice behind them is never even looked up. Those get `blocked`, which
|
|
754
|
-
* drops them out of the sweep and hands the operator the payment hash.
|
|
694
|
+
* Retire a deterministic uncreditable payment as blocked so it no longer occupies the
|
|
695
|
+
* bounded sweep window. Transient failures stay pending for a later request; report the
|
|
696
|
+
* payment hash for operator repair.
|
|
755
697
|
*/
|
|
756
698
|
async retireOrLog(ledger, invoice, err) {
|
|
757
699
|
const reason = await this.blockingReason(ledger, invoice, err);
|
|
@@ -784,21 +726,10 @@ var LightningReceive = class _LightningReceive {
|
|
|
784
726
|
);
|
|
785
727
|
}
|
|
786
728
|
/**
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
* has already committed (a `credit_fundings` entry at this
|
|
792
|
-
* `(credit_id, fund_id)`, or a `credits` row whose owner, denomination or
|
|
793
|
-
* rail disagrees with the invoice), or the basis this module rebuilds
|
|
794
|
-
* identically from the invoice row on every pass. None of them is a race.
|
|
795
|
-
*
|
|
796
|
-
* `funding_replayed` is the one that needs a second read to classify.
|
|
797
|
-
* Usually it *is* benign — a concurrent check won the race and the money is
|
|
798
|
-
* credited either way — but the key is `(credit_id, fund_id)` and `fund_id`
|
|
799
|
-
* is **caller-chosen**: reuse it on cashu or x402 after this bolt11 was
|
|
800
|
-
* minted and the row that collided is a different payment entirely, so the
|
|
801
|
-
* sats this invoice received have nowhere to land.
|
|
729
|
+
* Classify funding_replayed by reading the existing funding’s rail. A Lightning row can
|
|
730
|
+
* represent a concurrent applied check; another rail at this caller-chosen key is a
|
|
731
|
+
* different payment, leaving the invoice’s sats uncredited. A failed diagnostic read
|
|
732
|
+
* remains transient, never a guessed permanent refusal.
|
|
802
733
|
*/
|
|
803
734
|
async blockingReason(ledger, invoice, err) {
|
|
804
735
|
if (!(err instanceof CreditLedgerError)) return void 0;
|
|
@@ -834,7 +765,6 @@ var LightningReceive = class _LightningReceive {
|
|
|
834
765
|
throw err;
|
|
835
766
|
}
|
|
836
767
|
}
|
|
837
|
-
/** Record activity without letting it promote an unvalidated connection. */
|
|
838
768
|
noteOperationOk() {
|
|
839
769
|
if (this.health !== "healthy") return;
|
|
840
770
|
this.checkedAtMs = Date.now();
|
|
@@ -1027,7 +957,6 @@ var PostgresTempoSettlementReadinessStore = class {
|
|
|
1027
957
|
address;
|
|
1028
958
|
token;
|
|
1029
959
|
now;
|
|
1030
|
-
/** Create the shared latch table under the SDK-wide boot migration lock. */
|
|
1031
960
|
async init() {
|
|
1032
961
|
await withSdkInitLock(this.pool, async () => {
|
|
1033
962
|
await this.pool.query(`
|
|
@@ -1170,6 +1099,12 @@ function createDVMHost(opts = {}) {
|
|
|
1170
1099
|
)
|
|
1171
1100
|
);
|
|
1172
1101
|
const envMaybe = env;
|
|
1102
|
+
const hostingSecret = envMaybe.DVMKIT_HOSTING_CONTROL_SECRET;
|
|
1103
|
+
const hostingScope = envMaybe.DVMKIT_HOSTING_CONTROL_SCOPE;
|
|
1104
|
+
if (!opts.hostingControl && Boolean(hostingSecret) !== Boolean(hostingScope)) {
|
|
1105
|
+
throw new Error("Hosting control requires both DVMKIT_HOSTING_CONTROL_SECRET and DVMKIT_HOSTING_CONTROL_SCOPE");
|
|
1106
|
+
}
|
|
1107
|
+
const hostingControl = opts.hostingControl ?? (hostingSecret && hostingScope ? { secret: hostingSecret, scope: hostingScope } : void 0);
|
|
1173
1108
|
const port = serveOpts?.port ?? opts.port ?? Number(envMaybe.PORT ?? "8080");
|
|
1174
1109
|
const bootStart = Date.now();
|
|
1175
1110
|
const phaseMarks = [];
|
|
@@ -1199,13 +1134,13 @@ function createDVMHost(opts = {}) {
|
|
|
1199
1134
|
});
|
|
1200
1135
|
applyRetryToPool(pool, "dvm-host");
|
|
1201
1136
|
pgPool = pool;
|
|
1202
|
-
const { PostgresJobStore: PostgresJobStore2 } = await import("../postgres-job-store-
|
|
1137
|
+
const { PostgresJobStore: PostgresJobStore2 } = await import("../postgres-job-store-VE2JRUEC.js");
|
|
1203
1138
|
const pgJobStore = new PostgresJobStore2(pool);
|
|
1204
1139
|
pendingInits.push(pgJobStore.init(), pgJobStore.initStreaming());
|
|
1205
1140
|
jobStore = pgJobStore;
|
|
1206
1141
|
pgStreamStore = pgJobStore;
|
|
1207
1142
|
if (!opts.store) {
|
|
1208
|
-
const { PostgresKVStore: PostgresKVStore2 } = await import("../postgres-kv-store-
|
|
1143
|
+
const { PostgresKVStore: PostgresKVStore2 } = await import("../postgres-kv-store-DXGTKXLU.js");
|
|
1209
1144
|
const pgKvStore = new PostgresKVStore2(pool);
|
|
1210
1145
|
pendingInits.push(pgKvStore.init());
|
|
1211
1146
|
store = pgKvStore;
|
|
@@ -1290,11 +1225,11 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
|
|
|
1290
1225
|
let tempoChargeBackend = "user-supplied";
|
|
1291
1226
|
const mppTempoRecipient = envMaybe.DVMKIT_TEMPO_RECIPIENT;
|
|
1292
1227
|
if (!mpp && mppTempoRecipient) {
|
|
1293
|
-
const { createMppFromOpts, createDualKeyMppxFromOpts, parseMppMethodsAllowlist } = await import("../mpp-setup-
|
|
1228
|
+
const { createMppFromOpts, createDualKeyMppxFromOpts, parseMppMethodsAllowlist } = await import("../mpp-setup-MPP3ST5X.js");
|
|
1294
1229
|
tempoChargeBackend = pgPool ? "postgres" : "memory";
|
|
1295
1230
|
let tempoCharge;
|
|
1296
1231
|
if (pgPool) {
|
|
1297
|
-
const { PostgresTempoChargeStore } = await import("../tempo-charge-store-
|
|
1232
|
+
const { PostgresTempoChargeStore } = await import("../tempo-charge-store-SDTUNTKA.js");
|
|
1298
1233
|
const chargeStore = new PostgresTempoChargeStore(pgPool);
|
|
1299
1234
|
pendingInits.push(chargeStore.init());
|
|
1300
1235
|
tempoCharge = { store: chargeStore };
|
|
@@ -1313,7 +1248,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
|
|
|
1313
1248
|
{ createPublicClient, createWalletClient, erc20Abi, http },
|
|
1314
1249
|
{ tempo: tempoMainnet, tempoModerato }
|
|
1315
1250
|
] = await Promise.all([
|
|
1316
|
-
import("../tempo-session-store-
|
|
1251
|
+
import("../tempo-session-store-WF3VZXNF.js"),
|
|
1317
1252
|
import("viem/accounts"),
|
|
1318
1253
|
import("viem"),
|
|
1319
1254
|
import("viem/chains")
|
|
@@ -1414,7 +1349,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
|
|
|
1414
1349
|
applyMppSecretRotation,
|
|
1415
1350
|
loadMppSecretState,
|
|
1416
1351
|
DEFAULT_ROTATION_WINDOW_MS
|
|
1417
|
-
} = await import("../mpp-secret-state-
|
|
1352
|
+
} = await import("../mpp-secret-state-B5GCILVH.js");
|
|
1418
1353
|
await initMppSecretStateTable(pgPool);
|
|
1419
1354
|
const rotation = await applyMppSecretRotation(
|
|
1420
1355
|
pgPool,
|
|
@@ -1454,7 +1389,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
|
|
|
1454
1389
|
assertReceiptIdentity(envMaybe, opts.builder, receiptKey, cashuOpts.dvmId, opts.devMode);
|
|
1455
1390
|
let sharedPgReplayStore;
|
|
1456
1391
|
if (pgPool) {
|
|
1457
|
-
const { PostgresReplayStore: PostgresReplayStore2 } = await import("../postgres-replay-store-
|
|
1392
|
+
const { PostgresReplayStore: PostgresReplayStore2 } = await import("../postgres-replay-store-ZF4JNZOW.js");
|
|
1458
1393
|
const store2 = new PostgresReplayStore2(pgPool);
|
|
1459
1394
|
pendingInits.push(store2.init());
|
|
1460
1395
|
sharedPgReplayStore = store2;
|
|
@@ -1482,24 +1417,24 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
|
|
|
1482
1417
|
}
|
|
1483
1418
|
let sharedPgConsumedStore;
|
|
1484
1419
|
if (pgPool) {
|
|
1485
|
-
const { PostgresConsumedCredentialStore } = await import("../postgres-consumed-credential-store-
|
|
1420
|
+
const { PostgresConsumedCredentialStore } = await import("../postgres-consumed-credential-store-6N2V5MJN.js");
|
|
1486
1421
|
const consumedStore = new PostgresConsumedCredentialStore(pgPool);
|
|
1487
1422
|
pendingInits.push(consumedStore.init());
|
|
1488
1423
|
sharedPgConsumedStore = consumedStore;
|
|
1489
1424
|
}
|
|
1490
1425
|
if (pgPool) {
|
|
1491
|
-
const { CreditLedger: CreditLedger2 } = await import("../credit-ledger-
|
|
1426
|
+
const { CreditLedger: CreditLedger2 } = await import("../credit-ledger-MHA652TV.js");
|
|
1492
1427
|
const pgLedger = new CreditLedger2(pgPool, tempoSessionStore);
|
|
1493
1428
|
pendingInits.push(pgLedger.init());
|
|
1494
1429
|
creditLedger = pgLedger;
|
|
1495
|
-
const { PostgresProcessedPaymentStore: PostgresProcessedPaymentStore2 } = await import("../processed-payment-store-
|
|
1430
|
+
const { PostgresProcessedPaymentStore: PostgresProcessedPaymentStore2 } = await import("../processed-payment-store-GKMAWOM3.js");
|
|
1496
1431
|
const pgProcessed = new PostgresProcessedPaymentStore2(pgPool);
|
|
1497
1432
|
pendingInits.push(pgProcessed.init());
|
|
1498
1433
|
processedPayments = pgProcessed;
|
|
1499
1434
|
} else {
|
|
1500
|
-
const { MemoryCreditLedger: MemoryCreditLedger2 } = await import("../memory-credit-ledger-
|
|
1435
|
+
const { MemoryCreditLedger: MemoryCreditLedger2 } = await import("../memory-credit-ledger-BYBATRN3.js");
|
|
1501
1436
|
creditLedger = disposableCashu?.ledger ?? new MemoryCreditLedger2();
|
|
1502
|
-
const { MemoryProcessedPaymentStore: MemoryProcessedPaymentStore2 } = await import("../processed-payment-store-
|
|
1437
|
+
const { MemoryProcessedPaymentStore: MemoryProcessedPaymentStore2 } = await import("../processed-payment-store-GKMAWOM3.js");
|
|
1503
1438
|
processedPayments = new MemoryProcessedPaymentStore2();
|
|
1504
1439
|
}
|
|
1505
1440
|
await Promise.all(pendingInits);
|
|
@@ -1619,7 +1554,8 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
|
|
|
1619
1554
|
lockPubkey: cashuOpts.lockPubkey,
|
|
1620
1555
|
lockPubkeyGraceSeconds: cashuOpts.lockPubkeyGraceSeconds,
|
|
1621
1556
|
canonicalDvmId: cashuOpts.canonicalDvmId,
|
|
1622
|
-
db: cashuOpts.db,
|
|
1557
|
+
db: hostingControl ? pgPool : cashuOpts.db,
|
|
1558
|
+
hostingControl,
|
|
1623
1559
|
dvmId: cashuOpts.dvmId,
|
|
1624
1560
|
failFast,
|
|
1625
1561
|
mintHealthTracker: opts.mintHealthTracker,
|
|
@@ -2188,6 +2124,7 @@ export {
|
|
|
2188
2124
|
secp256k1Auth,
|
|
2189
2125
|
selectPrimaryCredit,
|
|
2190
2126
|
serve,
|
|
2127
|
+
signHostingControl,
|
|
2191
2128
|
signedRequestInput,
|
|
2192
2129
|
signedRequestStatementHeader,
|
|
2193
2130
|
stripCreditEnvelope,
|