@dvmkit/sdk 0.1.2-rc.7 → 0.1.4-rc.7
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 +121 -8
- package/dist/chunk-BIFLRKMO.js +87 -0
- package/dist/chunk-BQ2NMWKE.js +160 -0
- package/dist/{chunk-LDTWX7JW.js → chunk-BTZY7VPH.js} +13 -1
- package/dist/{chunk-FJDCFHW5.js → chunk-C6JHBLMW.js} +3 -81
- package/dist/{chunk-EXHBXA4U.js → chunk-DBCLBYHP.js} +13 -1
- package/dist/chunk-E4EVGPDX.js +391 -0
- package/dist/chunk-EDDYHZ6W.js +1010 -0
- package/dist/{chunk-2ABMGUDS.js → chunk-EVBK675R.js} +88 -10
- package/dist/{chunk-P4RUVDU7.js → chunk-H2MEFVH6.js} +12 -141
- package/dist/chunk-KXZUCCEY.js +142 -0
- package/dist/{chunk-LWUR4CGG.js → chunk-MLRCSJYX.js} +11 -3
- package/dist/{chunk-N4VTG3KH.js → chunk-QK3VJNCK.js} +930 -3011
- package/dist/chunk-RW5LP57K.js +44 -0
- package/dist/{chunk-6JZIX5WW.js → chunk-SSSZUVWM.js} +178 -8
- package/dist/{chunk-TKA6ZP4M.js → chunk-U6M3ATSG.js} +56 -426
- package/dist/chunk-VRQDX5P4.js +1742 -0
- package/dist/{chunk-JGGI65I3.js → chunk-Z4BNLUZF.js} +1 -150
- package/dist/{credit-ledger-ED6JXKVD.js → credit-ledger-2DFQHNLB.js} +2 -2
- package/dist/{credit-menu-BM4qCD5U.d.ts → credit-menu-C1ezIFlJ.d.ts} +1699 -1941
- package/dist/{fx-C-liI3oY.d.ts → fx-C6dl2LVI.d.ts} +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +8 -4
- package/dist/internal/caller.d.ts +10441 -0
- package/dist/internal/caller.js +10078 -0
- package/dist/internal/index.d.ts +2 -10816
- package/dist/internal/index.js +2 -10130
- package/dist/internal/server.d.ts +404 -0
- package/dist/internal/server.js +202 -0
- package/dist/job-store-DHnW4Cg_.d.ts +591 -0
- package/dist/lightning-backend-Ci1nogk_.d.ts +367 -0
- package/dist/{memory-credit-ledger-XJ5VQEVP.js → memory-credit-ledger-OP24Z2KO.js} +3 -3
- package/dist/{postgres-job-store-J5F4GUWU.js → postgres-job-store-3RAXMNSY.js} +1 -1
- package/dist/{revenue-reporter-JIKUPXOK.js → revenue-reporter-ASZ7SHHH.js} +1 -1
- package/dist/server/index.d.ts +41 -11
- package/dist/server/index.js +93 -69
- package/dist/{job-store-C53VQ5uu.d.ts → step-cache-BLPZNizw.d.ts} +176 -585
- package/dist/{tempo-session-store-DALMRIWN.js → tempo-session-store-2JNOKJGX.js} +2 -2
- package/dist/testing/index.d.ts +25 -3
- package/dist/testing/index.js +36 -3
- package/dist/{usd-gLcJB1ps.d.ts → usd-BgOfZlk6.d.ts} +1 -1
- package/dist/wallet-CJC8lwxx.d.ts +29 -0
- package/dist/{x402-FTG2GRAQ.js → x402-T2C5MX3T.js} +6 -3
- package/package.json +11 -5
- package/dist/{chunk-RU7SXHLO.js → chunk-UP2F5RRT.js} +3 -3
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { W as JsonValue } from './step-cache-BLPZNizw.js';
|
|
2
|
+
|
|
3
|
+
declare const lockPubkeyBrand: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* NUT-11 P2PK lock pubkey, lowercase-by-construction. Hex-encoded compressed
|
|
6
|
+
* secp256k1 pubkey (66 chars starting with `02` / `03`), normalised via
|
|
7
|
+
* `toLockPubkey`. The brand exists so any in-memory site that compares
|
|
8
|
+
* lock-pubkeys against each other — receive matching, monitor orphan/retired
|
|
9
|
+
* lookups, melt-pending keypair maps — gets a compile-time guarantee that
|
|
10
|
+
* both sides have been normalised. Raw strings off the wire or out of the DB
|
|
11
|
+
* must pass through `toLockPubkey` before they're treated as one.
|
|
12
|
+
*/
|
|
13
|
+
type LockPubkey = string & {
|
|
14
|
+
readonly [lockPubkeyBrand]: never;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Brand a raw lock-pubkey string. Trims surrounding whitespace and lowercases
|
|
18
|
+
* the hex so equality is structural. Idempotent on values that are already
|
|
19
|
+
* lowercase. Does not validate the curve point — assertions about hex shape
|
|
20
|
+
* live at the wire-validation layer (e.g. the `/admin/cashu/rotate-lock-pubkey`
|
|
21
|
+
* regex in `admin-cashu.ts`).
|
|
22
|
+
*/
|
|
23
|
+
declare function toLockPubkey(raw: string): LockPubkey;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Canonical deploy-time attestation payload (internal-review). One signature serves
|
|
27
|
+
* both auth-on-deploy and the `/v1/info#builder` attestation — the bytes the
|
|
28
|
+
* builder signs are the canonical JSON of this object. Making a field required
|
|
29
|
+
* also requires the coordinated fleet-before-caller release note in
|
|
30
|
+
* `public compatibility guide`.
|
|
31
|
+
*/
|
|
32
|
+
interface AttestationPayload {
|
|
33
|
+
/** Immutable platform or self-hosted DVM identifier this attestation applies to. */
|
|
34
|
+
dvm_id: string;
|
|
35
|
+
/** DVM slug the attestation applies to (must match the deploy request's slug). */
|
|
36
|
+
slug: string;
|
|
37
|
+
/** sha256(`canonicaliseForSigning(capabilities)`) hex. Binds the attestation
|
|
38
|
+
* to the capability shape declared at deploy time. */
|
|
39
|
+
capabilities_hash: string;
|
|
40
|
+
/** Builder identity x-only secp256k1 pubkey, hex (32 bytes / 64 chars). */
|
|
41
|
+
builder_pubkey: string;
|
|
42
|
+
/**
|
|
43
|
+
* Per-DVM receipt-signing x-only pubkey, hex (internal-review). Binds the key the
|
|
44
|
+
* deployed DVM signs job receipts with to the cold builder identity: the
|
|
45
|
+
* builder signs this payload, so a receipt verifying under
|
|
46
|
+
* `receipt_pubkey` inherits the builder's authority.
|
|
47
|
+
*
|
|
48
|
+
* Optional: attestations signed before receipts shipped omit it and still
|
|
49
|
+
* verify byte-for-byte (canonical JSON drops absent keys), and deploy paths
|
|
50
|
+
* that can't provision the matching secret leave it unset rather than
|
|
51
|
+
* attesting a key the running process doesn't hold.
|
|
52
|
+
*/
|
|
53
|
+
receipt_pubkey?: string;
|
|
54
|
+
/** Unix seconds at which the attestation was signed. */
|
|
55
|
+
deployed_at: number;
|
|
56
|
+
}
|
|
57
|
+
/** Result of {@link generateIdentity}: hex pubkey + hex secret. */
|
|
58
|
+
interface BuilderIdentityKeypair {
|
|
59
|
+
/** secp256k1 BIP-340 x-only pubkey, 32 bytes hex (64 chars). */
|
|
60
|
+
pubkey: string;
|
|
61
|
+
/** secp256k1 secret, 32 bytes hex (64 chars). */
|
|
62
|
+
secret: string;
|
|
63
|
+
}
|
|
64
|
+
/** Generate a fresh BIP-340 Schnorr keypair for builder identity. */
|
|
65
|
+
declare function generateIdentity(): BuilderIdentityKeypair;
|
|
66
|
+
/**
|
|
67
|
+
* Read the builder identity secret from `~/.dvmkit/builder.key`. Returns
|
|
68
|
+
* `null` when absent so callers can surface an `identity_required` error.
|
|
69
|
+
*
|
|
70
|
+
* `writeIdentity` persists the key `0o600`, but a destination mode survives
|
|
71
|
+
* `cp`/`scp`/git-checkout intact only by luck — those can land it `0o644`,
|
|
72
|
+
* leaving the signing key world-readable on a multi-user box. On POSIX we
|
|
73
|
+
* detect loose group/other bits, warn, and best-effort re-tighten to `0o600`
|
|
74
|
+
* (same self-heal posture as `writeIdentity`) rather than throw — a hard
|
|
75
|
+
* failure would brick a CLI whose key got widened in transit.
|
|
76
|
+
*/
|
|
77
|
+
declare function loadIdentitySecret(): string | null;
|
|
78
|
+
/**
|
|
79
|
+
* Persist a builder identity keypair: pubkey into `~/.dvmkit/builder.json`
|
|
80
|
+
* (top-level), secret into `~/.dvmkit/builder.key` (mode 0600 on POSIX).
|
|
81
|
+
* Atomic tmp+rename on the secret file so a crash mid-write never leaves a
|
|
82
|
+
* truncated key on disk — a torn write here is unrecoverable; the operator
|
|
83
|
+
* loses the ability to re-sign attestations for every DVM under this key.
|
|
84
|
+
*
|
|
85
|
+
* Refuses to overwrite when an identity already exists unless `force` is
|
|
86
|
+
* passed; the force path warns that any DVMs deployed under the old key
|
|
87
|
+
* need to be re-deployed to refresh their attestations.
|
|
88
|
+
*/
|
|
89
|
+
declare function writeIdentity(keypair: BuilderIdentityKeypair, opts?: {
|
|
90
|
+
force?: boolean;
|
|
91
|
+
}): void;
|
|
92
|
+
/**
|
|
93
|
+
* Compute the canonical `capabilities_hash` (sha256-hex of canonical JSON)
|
|
94
|
+
* for the supplied capabilities block. Shared between the CLI signer and any
|
|
95
|
+
* future verifier so both compute identical bytes.
|
|
96
|
+
*/
|
|
97
|
+
declare function hashCapabilities(capabilities: JsonValue): string;
|
|
98
|
+
/**
|
|
99
|
+
* Assemble the deploy-time attestation payload (internal-review). `deployedAt`
|
|
100
|
+
* defaults to the current Unix second; tests can pin it for reproducibility.
|
|
101
|
+
*/
|
|
102
|
+
declare function buildAttestation(args: {
|
|
103
|
+
dvmId: string;
|
|
104
|
+
slug: string;
|
|
105
|
+
capabilities: JsonValue;
|
|
106
|
+
builderPubkey: string;
|
|
107
|
+
/** Receipt-signing pubkey to attest (internal-review). Omitted when the deploy path
|
|
108
|
+
* can't provision the matching `DVMKIT_RECEIPT_KEY`. */
|
|
109
|
+
receiptPubkey?: string;
|
|
110
|
+
deployedAt?: number;
|
|
111
|
+
}): AttestationPayload;
|
|
112
|
+
/**
|
|
113
|
+
* Sign an attestation payload with the builder identity secret. Returns the
|
|
114
|
+
* 64-byte Schnorr signature as hex. The canonical bytes are produced via the
|
|
115
|
+
* same `canonicaliseForSigning` the verifier uses — both sides hash identical
|
|
116
|
+
* input regardless of object key order.
|
|
117
|
+
*/
|
|
118
|
+
declare function signAttestation(payload: AttestationPayload, secretHex: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* Verify a deploy-time attestation. Returns `true` iff the signature is a
|
|
121
|
+
* valid BIP-340 Schnorr signature of `canonicaliseForSigning(payload)` under
|
|
122
|
+
* `pubkeyHex`. Independent of the platform binding — callers (the deploy
|
|
123
|
+
* route, `/v1/info` clients) cross-check the pubkey against their trust root.
|
|
124
|
+
*/
|
|
125
|
+
declare function verifyAttestation(payload: AttestationPayload, signatureHex: string, pubkeyHex: string): boolean;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Per-method amount limits a mint advertises on its NUT-4 / NUT-5 bolt11/sat
|
|
129
|
+
* entry (internal-review). Both values are in the method's own unit — `sat` here,
|
|
130
|
+
* never msats.
|
|
131
|
+
*
|
|
132
|
+
* `null` means the mint advertised nothing in that direction, which reads as
|
|
133
|
+
* unbounded. A mint saying nothing is not a mint saying zero, so silence never
|
|
134
|
+
* narrows what we'll attempt — same defensive posture as the absent-`disabled`
|
|
135
|
+
* rule in {@link canMintBolt11Sat}.
|
|
136
|
+
*/
|
|
137
|
+
interface MintAmountBounds {
|
|
138
|
+
/** Smallest amount the mint will quote, or `null` when unadvertised. */
|
|
139
|
+
minSats: number | null;
|
|
140
|
+
/** Largest amount the mint will quote, or `null` when unadvertised. */
|
|
141
|
+
maxSats: number | null;
|
|
142
|
+
}
|
|
143
|
+
/** Error categories returned when a mint health probe fails. */
|
|
144
|
+
type HealthErrorCode = "timeout" | "http_error" | "network" | "parse_error" | "missing_fields";
|
|
145
|
+
/** Outcome of a single health probe against one mint. */
|
|
146
|
+
interface MintHealthCheckResult {
|
|
147
|
+
/** Mint URL exactly as passed in (not normalised). */
|
|
148
|
+
mintUrl: string;
|
|
149
|
+
/** True iff `/v1/info` returned 200, parsed as JSON, and had `pubkey` + `version`. */
|
|
150
|
+
ok: boolean;
|
|
151
|
+
/** Wall-clock duration of the successful (or final failed) attempt in ms. */
|
|
152
|
+
latencyMs: number;
|
|
153
|
+
/** NUT-06 mint pubkey when present. */
|
|
154
|
+
pubkey?: string;
|
|
155
|
+
/** NUT-06 mint version string (e.g. "Nutshell/0.20.0") when present. */
|
|
156
|
+
version?: string;
|
|
157
|
+
/** Sorted list of NUT keys the mint declares support for. */
|
|
158
|
+
supportedNuts?: string[];
|
|
159
|
+
/** Subset of `DEFAULT_REQUIRED_NUTS` the mint does not declare. Empty array when fully supported. */
|
|
160
|
+
missingRequiredNuts?: string[];
|
|
161
|
+
/** True when the mint advertises NUT-04 with method `bolt11` and unit `sat`. */
|
|
162
|
+
bolt11SatMintSupported?: boolean;
|
|
163
|
+
/** True when the mint advertises NUT-05 with method `bolt11` and unit `sat`. */
|
|
164
|
+
bolt11SatMeltSupported?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* True when the mint can currently *issue* — NUT-04 advertises bolt11/sat and
|
|
167
|
+
* is not switched off (`disabled: true`). Distinct from
|
|
168
|
+
* {@link bolt11SatMintSupported}, which only asks whether the method exists:
|
|
169
|
+
* a mint in melt-only recovery keeps advertising the method and turns the
|
|
170
|
+
* flag on. Consulted when picking a funding default (internal-review).
|
|
171
|
+
*/
|
|
172
|
+
mintingEnabled?: boolean;
|
|
173
|
+
/** Same question for NUT-05 (melt) — whether the mint can currently pay out. */
|
|
174
|
+
meltingEnabled?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* True when the mint can currently serve `/v1/swap` — see {@link canSwap} for
|
|
177
|
+
* why an unadvertised NUT-3 reads as `true`. This is what a per-call spend
|
|
178
|
+
* needs, so a `false` here is the reason a spend routes around this mint
|
|
179
|
+
* (internal-review).
|
|
180
|
+
*/
|
|
181
|
+
swapEnabled?: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Amount limits the mint advertises for issuing (NUT-04 bolt11/sat), in sats
|
|
184
|
+
* (internal-review). Consulted when picking a funding default and when refusing an
|
|
185
|
+
* amount locally, so a fund outside the range never opens a Lightning quote.
|
|
186
|
+
*/
|
|
187
|
+
mintAmountBounds?: MintAmountBounds;
|
|
188
|
+
/** The NUT-05 twin — limits on a single payout, which `dvm wallet cash-out` sizes against. */
|
|
189
|
+
meltAmountBounds?: MintAmountBounds;
|
|
190
|
+
/**
|
|
191
|
+
* True when the mint passes the full {@link assertNutSupport} gate — every
|
|
192
|
+
* required NUT present (not `supported: false`) and bolt11/sat on NUT-4 +
|
|
193
|
+
* NUT-5. The runtime `MintHealthTracker` treats a mint as healthy only when
|
|
194
|
+
* this is true, reproducing the boot-time NUT gate post-`listen` (internal-review).
|
|
195
|
+
*/
|
|
196
|
+
nutCompliant?: boolean;
|
|
197
|
+
/** Raw `nuts` object from the `/v1/info` response. Used by `assertNutSupport`. */
|
|
198
|
+
nutsRaw?: Record<string, unknown>;
|
|
199
|
+
/** Populated when `ok` is false. */
|
|
200
|
+
error?: {
|
|
201
|
+
code: HealthErrorCode;
|
|
202
|
+
message: string;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/** Tunables for `checkMintHealth`. */
|
|
206
|
+
interface CheckMintHealthOptions {
|
|
207
|
+
/** Per-attempt timeout in ms. Default: 5000. */
|
|
208
|
+
timeoutMs?: number;
|
|
209
|
+
/** Total attempts including the first. Default: 3. */
|
|
210
|
+
retries?: number;
|
|
211
|
+
/** Inter-attempt backoff schedule in ms. Default: [200, 500, 1000]. */
|
|
212
|
+
backoffMs?: number[];
|
|
213
|
+
/** Injected `fetch` for tests. Default: global fetch. */
|
|
214
|
+
fetchImpl?: typeof fetch;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Probe a Cashu mint's `/v1/info` endpoint with timeout + retries, and
|
|
218
|
+
* report whether it serves the NUT-04 + NUT-05 capabilities first-party DVMs
|
|
219
|
+
* depend on. Never throws — failures are returned as `{ ok: false, error }`.
|
|
220
|
+
*/
|
|
221
|
+
declare function checkMintHealth(mintUrl: string, opts?: CheckMintHealthOptions): Promise<MintHealthCheckResult>;
|
|
222
|
+
/**
|
|
223
|
+
* Whether the mint can currently serve `/v1/swap` — the operation every
|
|
224
|
+
* per-call Cashu payment depends on (internal-review).
|
|
225
|
+
*
|
|
226
|
+
* **An absent NUT-3 means yes.** Swap is a baseline mint operation and healthy
|
|
227
|
+
* mints do not enumerate it — neither coinos nor lnvoltz advertises a `"3"` key
|
|
228
|
+
* (see `public design rationale`).
|
|
229
|
+
* Reading silence as "incapable" would rule out every working mint.
|
|
230
|
+
*
|
|
231
|
+
* A mint that has *switched swaps off* does say so: a mint in melt-only
|
|
232
|
+
* recovery publishes a `"3"` entry flagged `disabled` / `supported: false`
|
|
233
|
+
* alongside its live NUT-5. Both spellings are honoured because this is the
|
|
234
|
+
* only signal distinguishing "can't swap" from "swap failed for some other
|
|
235
|
+
* reason", and it costs nothing to accept either.
|
|
236
|
+
*
|
|
237
|
+
* Never a boot-time gate — like {@link canMintBolt11Sat}, this informs mint
|
|
238
|
+
* *selection* only, so a mint that can still melt stays loadable for cash-out.
|
|
239
|
+
*/
|
|
240
|
+
declare function canSwap(nuts: Record<string, unknown>): boolean;
|
|
241
|
+
/** Whether `sats` falls inside a mint's advertised limits, and which end it broke. */
|
|
242
|
+
type AmountBoundsVerdict = "ok" | "below_min" | "above_max";
|
|
243
|
+
/**
|
|
244
|
+
* Judge one amount against one direction's limits. The single predicate both
|
|
245
|
+
* `dvm wallet fund` (mint selection, pre-quote refusal) and
|
|
246
|
+
* `dvm wallet cash-out` (per-leg sizing) ask, so the two commands can't drift
|
|
247
|
+
* on what "out of range" means.
|
|
248
|
+
*/
|
|
249
|
+
declare function amountBoundsVerdict(sats: number, bounds?: MintAmountBounds): AmountBoundsVerdict;
|
|
250
|
+
/**
|
|
251
|
+
* Assert that a mint's NUT-06 `nuts` object advertises all required capabilities.
|
|
252
|
+
* Two-phase check:
|
|
253
|
+
* 1. Dict-level — each NUT in `requiredNuts` must be present and not have
|
|
254
|
+
* `supported: false`. Throws naming the missing NUT numbers and mint URL.
|
|
255
|
+
* 2. Method-level — NUT-4 and NUT-5 must each advertise a `bolt11`/`sat`
|
|
256
|
+
* entry in their `methods` array (covers NUT-23). Throws naming the
|
|
257
|
+
* missing method.
|
|
258
|
+
*/
|
|
259
|
+
declare function assertNutSupport(mintUrl: string, nuts: Record<string, unknown>, requiredNuts?: readonly number[]): void;
|
|
260
|
+
|
|
261
|
+
/** A Lightning invoice created by the backend. */
|
|
262
|
+
interface CreatedInvoice {
|
|
263
|
+
/** BOLT11 payment request string. */
|
|
264
|
+
bolt11: string;
|
|
265
|
+
/** Payment hash (hex) — primary key for looking up settlement. */
|
|
266
|
+
paymentHash: string;
|
|
267
|
+
/** Amount in millisatoshis. */
|
|
268
|
+
amountMsats: number;
|
|
269
|
+
/** Unix milliseconds when the invoice expires. */
|
|
270
|
+
expiresAt: number;
|
|
271
|
+
}
|
|
272
|
+
/** Result of looking up an invoice's settlement status. */
|
|
273
|
+
interface InvoiceStatus {
|
|
274
|
+
/** True once the invoice has been paid and preimage is known. */
|
|
275
|
+
settled: boolean;
|
|
276
|
+
/** Preimage (hex) — present only after settlement. */
|
|
277
|
+
preimage?: string;
|
|
278
|
+
/** Unix milliseconds when the invoice settled (if settled). */
|
|
279
|
+
settledAt?: number;
|
|
280
|
+
/** Unix milliseconds when the invoice expires. */
|
|
281
|
+
expiresAt?: number;
|
|
282
|
+
}
|
|
283
|
+
/** How a payment reached a settled state — see `payInvoiceReconciling`. */
|
|
284
|
+
type LightningPayOutcome = "paid" | "reconciled" | "republished";
|
|
285
|
+
/** Settled payment plus the audit trail of how it got there. */
|
|
286
|
+
interface LightningPayment {
|
|
287
|
+
/** Payment preimage (hex) — proof the invoice was paid. */
|
|
288
|
+
preimage: string;
|
|
289
|
+
/** Routing fee reported by the wallet, in millisatoshis. Absent means unknown. */
|
|
290
|
+
feesPaidMsats?: number;
|
|
291
|
+
/** Whether the wallet answered directly, or the outcome had to be reconciled. */
|
|
292
|
+
outcome: LightningPayOutcome;
|
|
293
|
+
}
|
|
294
|
+
/** Bounds for a read-only wallet transaction snapshot. */
|
|
295
|
+
interface LightningTransactionListOptions {
|
|
296
|
+
/** Include transactions created at or after this Unix timestamp (seconds). */
|
|
297
|
+
from?: number;
|
|
298
|
+
/** Maximum number of transactions the wallet may return. */
|
|
299
|
+
limit?: number;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Credential-safe transaction evidence used to account for a wallet debit.
|
|
303
|
+
*
|
|
304
|
+
* Invoice, payment hash and preimage are deliberately replaced by digests or
|
|
305
|
+
* omitted. `fingerprint` identifies the complete reduced row; `invoiceHash`
|
|
306
|
+
* lets a caller bind an outgoing row to the invoice it just paid.
|
|
307
|
+
*/
|
|
308
|
+
interface LightningTransactionSnapshot {
|
|
309
|
+
fingerprint: string;
|
|
310
|
+
invoiceHash?: string;
|
|
311
|
+
type: "incoming" | "outgoing";
|
|
312
|
+
amountMsats: number;
|
|
313
|
+
/** Wallet-reported routing fee. Absent when the wallet omitted it. */
|
|
314
|
+
feesPaidMsats?: number;
|
|
315
|
+
createdAt: number;
|
|
316
|
+
settledAt?: number;
|
|
317
|
+
}
|
|
318
|
+
/** What a backend can tell us about the wallet behind it. */
|
|
319
|
+
interface LightningWalletInfo {
|
|
320
|
+
/** Human-readable wallet name (e.g. "Alby Hub"). */
|
|
321
|
+
alias?: string;
|
|
322
|
+
/** Operations the wallet supports (e.g. `pay_invoice`, `lookup_invoice`). */
|
|
323
|
+
methods: string[];
|
|
324
|
+
/**
|
|
325
|
+
* Budget fields the wallet volunteered, if any.
|
|
326
|
+
*
|
|
327
|
+
* No rail behind this interface is required to expose a connection's
|
|
328
|
+
* spending cap, and NWC — today's only implementation — has no method that
|
|
329
|
+
* returns one. Present it when a wallet offers it, never infer it.
|
|
330
|
+
*/
|
|
331
|
+
walletReportedBudget?: Record<string, unknown>;
|
|
332
|
+
}
|
|
333
|
+
/** Abstraction over Lightning wallet backends (NWC, future). */
|
|
334
|
+
interface LightningBackend {
|
|
335
|
+
/**
|
|
336
|
+
* Pay a bolt11 invoice exactly once. Returns the preimage on success.
|
|
337
|
+
*
|
|
338
|
+
* Implementations must never re-send a payment on an unknown outcome without
|
|
339
|
+
* first reconciling against the wallet — the rails behind this interface have
|
|
340
|
+
* no idempotency key, so a blind retry is a second payment.
|
|
341
|
+
*
|
|
342
|
+
* `amountMsats` is passed when known (callers always have it from the
|
|
343
|
+
* provider's payment-request). Backends that don't need it may ignore the
|
|
344
|
+
* param.
|
|
345
|
+
*/
|
|
346
|
+
payInvoice(bolt11: string, amountMsats?: number): Promise<LightningPayment>;
|
|
347
|
+
/** Get wallet balance in millisatoshis. */
|
|
348
|
+
getBalance(): Promise<number>;
|
|
349
|
+
/** Get wallet info (name, supported methods, any volunteered budget fields). */
|
|
350
|
+
getInfo(): Promise<LightningWalletInfo>;
|
|
351
|
+
/** Create a new incoming invoice for the given amount and description. */
|
|
352
|
+
createInvoice(params: {
|
|
353
|
+
amountMsats: number;
|
|
354
|
+
description?: string;
|
|
355
|
+
expirySeconds?: number;
|
|
356
|
+
}): Promise<CreatedInvoice>;
|
|
357
|
+
/** Look up an invoice's settlement status by payment hash. */
|
|
358
|
+
lookupInvoice(paymentHash: string): Promise<InvoiceStatus>;
|
|
359
|
+
/**
|
|
360
|
+
* Return a bounded, credential-safe transaction snapshot when supported.
|
|
361
|
+
* Optional so existing backends remain source-compatible; without it an
|
|
362
|
+
* exact total wallet debit cannot be attributed.
|
|
363
|
+
*/
|
|
364
|
+
listTransactions?(options: LightningTransactionListOptions): Promise<LightningTransactionSnapshot[]>;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export { type AttestationPayload as A, type BuilderIdentityKeypair as B, type CreatedInvoice as C, type InvoiceStatus as I, type LightningTransactionListOptions as L, type MintAmountBounds as M, type LightningTransactionSnapshot as a, type LightningBackend as b, type LightningPayment as c, type LightningWalletInfo as d, type MintHealthCheckResult as e, type CheckMintHealthOptions as f, type LockPubkey as g, amountBoundsVerdict as h, assertNutSupport as i, buildAttestation as j, canSwap as k, checkMintHealth as l, generateIdentity as m, hashCapabilities as n, loadIdentitySecret as o, signAttestation as s, toLockPubkey as t, verifyAttestation as v, writeIdentity as w };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MemoryCreditLedger
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-C3MTFLC6.js";
|
|
3
|
+
} from "./chunk-DBCLBYHP.js";
|
|
4
|
+
import "./chunk-MLRCSJYX.js";
|
|
6
5
|
import "./chunk-S3XAHZQY.js";
|
|
6
|
+
import "./chunk-C3MTFLC6.js";
|
|
7
7
|
export {
|
|
8
8
|
MemoryCreditLedger
|
|
9
9
|
};
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { ab as CashuMode, bK as CreditDrainEnqueue, R as ResolvedCreditConfig, bL as DVMAuthScheme, z as SignedRequestDomain, bM as CreditLedgerLike, bN as X402RefundSettlementGate, bO as CreditSnapshot, bP as DrawResult, bQ as X402SettlementStatus, bR as X402UnresolvedRefund, bS as GrownDrawResult, bT as DrawResolution, bU as FundingRecord, X as FundingReceipt, bV as CreditInvoiceRecord, bW as InvoiceSettlement, bX as BlockedInvoiceCursor, bY as InvoiceReconciliation, bZ as InvoiceWriteOff, b_ as DrawRecord, b$ as StalePendingDrawCursor, c0 as TempoCreditLossEvidence, c1 as CreditLedgerQuerier, c2 as TempoCreditLoss, c3 as X402CreditLossEvidence, c4 as X402CreditLoss, c5 as DrainMethod, c6 as DrainRequestResult, c7 as BitcoinDepositLiability, bo as FundingLot, c8 as CreditDrainRecord, c9 as ChannelDrainCursor, ca as DrainWriteOff, cb as DrainReleaseResult, cc as DrainFulfilment, cd as DrainTransitionResult, Y as JobReceipt, a1 as Message, K as KVStore, F as SignedRequestReplayStore, Z as ZodLike, a as DVMDescriptor } from '../step-cache-BLPZNizw.js';
|
|
2
|
+
export { ce as CLIENT_COMPATIBILITY_HEADERS, d as CanonicalEnvelope, cf as ClientCompatibility, cg as ClientCompatibilityEnv, ch as ClientCompatibilityGate, ci as ClientCompatibilityRequirement, cj as ClientSemVer, e as CreateSignedRequestVerifierOpts, ck as CreditFundingBasis, cl as CreditInvoiceStatus, cm as CreditLedger, cn as CreditLedgerError, co as CreditLedgerErrorCode, cp as CreditLedgerErrorDetails, cq as CreditLedgerPool, cr as CreditStatus, cs as DRAIN_DELIVERY_RESERVE_SATS, ct as DVM_PROTOCOL_VERSION, cu as DrainConflictReason, cv as DrawRailValue, cw as DrawStatus, cx as JobCostReportPayload, cy as PostgresX402ChannelStorage, cz as ReplayStoreBackend, cA as RevenueSkippedNoRailPayload, cB as RevenueSkippedNoRailReason, w as SIGNED_REQUEST_AUTH_ID, x as SIGNED_REQUEST_STATEMENT_VERSION, cC as Secp256k1AuthOpts, y as SignedRequestAudience, B as SignedRequestError, E as SignedRequestFailure, G as SignedRequestSignOpts, H as SignedRequestStatementHeader, M as SignedRequestVerifier, cD as X402ChannelStorageOpts, cE as X402RelayLockHolder, cF as X402RelaySubmissionLock, cG as X402RelaySubmissionLockError, cH as allocateDrawValue, cI as clientCompatibilityAttributes, cJ as clientCompatibilityMiddleware, cK as clientUpgradeRequired, N as createSignedRequestVerifier, cL as parseClientCapabilities, cM as parseClientCompatibility, cN as parseDvmClient, cO as parseProtocolVersion, cP as requireClientCompatibility, cQ as secp256k1Auth, cR as signedRequestInput, T as signedRequestStatementHeader } from '../step-cache-BLPZNizw.js';
|
|
3
3
|
import { Pool } from 'pg';
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
4
|
+
import { ak as CreditMenu, b as AppEnv, U as UpfrontPaymentOpts, h as PaymentInfo, al as ReceiptIssuer, am as LightningReceive, an as TempoSettlementReadiness, ao as DVMHostOpts } from '../credit-menu-C1ezIFlJ.js';
|
|
5
|
+
export { ap as BuildCreditMenuArgs, aq as BuilderIdentity, ar as CREDIT_ENVELOPE_KEYS, C as ConsumedCredentialStore, as as CreateX402BatchSettlementServerOpts, at as CreditEnvelope, au as CreditEnvelopeError, av as CreditFundCommitment, aw as CreditTerms, ax as DEFAULT_INVOICE_TTL_SECONDS, ay as DVMHost, az as JobManager, aA as JobManagerOpts, aB as LightningReceiveConfig, aC as MIN_INVOICE_TTL_SECONDS, aD as MemoryConsumedCredentialStore, aE as MemoryConsumedCredentialStoreOpts, aF as MemoryProcessedPaymentStore, aG as MemoryX402ExactSettlementStore, aH as MountOpts, aI as OwnerDisplay, aJ as PlatformReporterOpts, aK as PostgresProcessedPaymentStore, aL as PostgresX402ExactSettlementStore, aM as PriceFiat, aN as ProcessedPaymentQuerier, aO as ProcessedPaymentRail, aP as ProcessedPaymentRecord, aQ as ProcessedPaymentReplayError, aR as ProcessedPaymentStore, aS as X402BatchAcceptance, aT as X402BatchFunding, aU as X402BatchRefusal, aV as X402BatchSettlementServer, aW as X402ExactAcceptance, aX as X402ExactIntentConflictError, aY as X402ExactSettlementAttempt, aZ as X402ExactSettlementChainEvidence, a_ as X402ExactSettlementEffect, a$ as X402ExactSettlementEvidenceMissingError, b0 as X402ExactSettlementEvidenceReader, b1 as X402ExactSettlementIntent, b2 as X402ExactSettlementNotReadyError, b3 as X402ExactSettlementServer, b4 as X402ExactSettlementServerOpts, b5 as X402ExactSettlementStatus, b6 as X402ExactSettlementStore, b7 as X402SettlementChainEvidence, b8 as X402SettlementEvidenceReader, b9 as X402SettlementSubmissionError, ba as X402_BATCH_AUTO_SETTLEMENT, bb as X402_BATCH_MIN_WITHDRAW_DELAY_SECONDS, bc as X402_BATCH_SETTLEMENT_NETWORK, bd as attachCreditMenu, be as buildCreditMenu, bf as createDVMHost, bg as createX402BatchSettlementServer, bh as creditEnvelopeIgnoreFields, bi as drawSettlementRef, bj as extractCreditEnvelope, bk as fundingCommitment, bl as selectPrimaryCredit, bm as stripCreditEnvelope, bn as toCreditView } from '../credit-menu-C1ezIFlJ.js';
|
|
6
6
|
import { Context } from 'hono';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import { F as FxFetcher } from '../fx-
|
|
8
|
+
import { F as FxFetcher } from '../fx-C6dl2LVI.js';
|
|
9
|
+
import { c as StreamableJobStore, R as ReceiptIssuingStore, J as JobRecord, d as RequestIdClaim, e as RequestIdClaimResult, f as JobRetentionCursor, O as OutgoingMessage, A as AppendOutgoingOptions, P as PaymentCreditDelta, V as VerifyAndCreditResult, g as JobCounters } from '../job-store-DHnW4Cg_.js';
|
|
10
|
+
export { a as JobStatus, b as JobStore, h as isStreamableJobStore } from '../job-store-DHnW4Cg_.js';
|
|
9
11
|
export { P as PinnedFetch, S as SSRFError, a as SSRFGuardOpts, b as SSRFReason, c as SSRFResolver, d as assertSafeUrl, e as createPinnedFetch } from '../ssrf-DbFkpDv0.js';
|
|
10
|
-
import '@cashu/cashu-ts';
|
|
11
12
|
import 'mppx';
|
|
12
13
|
import '@x402/core/server';
|
|
13
14
|
import '@x402/evm/batch-settlement/server';
|
|
14
15
|
import 'viem';
|
|
15
16
|
import '@x402/core/types';
|
|
17
|
+
import '../lightning-backend-Ci1nogk_.js';
|
|
18
|
+
import '@cashu/cashu-ts';
|
|
16
19
|
|
|
17
20
|
/** Lifetime of a per-call implicit credit before the ledger refuses new draws. */
|
|
18
21
|
declare const IMPLICIT_CREDIT_TTL_MS: number;
|
|
19
22
|
|
|
20
|
-
/** Cashu accumulator opts resolved from environment variables. */
|
|
23
|
+
/** Builder-lock and Cashu accumulator opts resolved from environment variables. */
|
|
21
24
|
interface ResolvedCashuOpts {
|
|
22
25
|
cashuMode: CashuMode | undefined;
|
|
23
26
|
lockPubkey: string | undefined;
|
|
@@ -27,10 +30,11 @@ interface ResolvedCashuOpts {
|
|
|
27
30
|
canonicalDvmId: string | undefined;
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
|
-
* Resolves
|
|
31
|
-
* tables when
|
|
32
|
-
* call createDVMServer directly (cast,
|
|
33
|
-
* the
|
|
33
|
+
* Resolves the builder-lock and Cashu accumulator opts from environment
|
|
34
|
+
* variables, initializing DB tables when their prerequisites are met.
|
|
35
|
+
* Extracted from serve() so DVMs that call createDVMServer directly (cast,
|
|
36
|
+
* scrape) can wire Cashu and the builder admin surface without using the
|
|
37
|
+
* serve() wrapper (internal-review).
|
|
34
38
|
*
|
|
35
39
|
* @param pool - existing Postgres pool to reuse; pass undefined when no DB is available
|
|
36
40
|
* @param cashuModeHint - programmatic override for cashu mode (serve()'s opts.cashuMode)
|
|
@@ -327,6 +331,7 @@ declare class MemoryCreditLedger implements CreditLedgerLike {
|
|
|
327
331
|
drawId: string;
|
|
328
332
|
}): Promise<DrawRecord | undefined>;
|
|
329
333
|
getDrawByJobId(jobId: string): Promise<DrawRecord | undefined>;
|
|
334
|
+
listDrawsByJobId(jobId: string): Promise<DrawRecord[]>;
|
|
330
335
|
listPendingDraws(creditId: string): Promise<DrawRecord[]>;
|
|
331
336
|
listStalePendingDraws(args: {
|
|
332
337
|
createdBeforeMs: number;
|
|
@@ -445,7 +450,32 @@ declare class PostgresJobStore implements StreamableJobStore, ReceiptIssuingStor
|
|
|
445
450
|
private acquireRequestIdClaim;
|
|
446
451
|
releaseRequestIdClaim(claim: RequestIdClaim): Promise<void>;
|
|
447
452
|
save(record: JobRecord): Promise<void>;
|
|
453
|
+
/** Persist a job while retaining its mount identity for cost-report recovery. */
|
|
454
|
+
saveForDvm(record: JobRecord, dvmId: string): Promise<void>;
|
|
455
|
+
private saveRecord;
|
|
456
|
+
/**
|
|
457
|
+
* Read terminal zero-revenue jobs whose latest declared-cost revision has
|
|
458
|
+
* not yet reached the durable reporter outbox.
|
|
459
|
+
*/
|
|
460
|
+
listUnreportedTerminalCosts(args: {
|
|
461
|
+
dvmId: string;
|
|
462
|
+
limit: number;
|
|
463
|
+
afterJobId?: string;
|
|
464
|
+
}): Promise<JobRecord[]>;
|
|
465
|
+
/** Mark one revision only after its report has reached durable enqueue. */
|
|
466
|
+
markTerminalCostReported(jobId: string, costRevision: number): Promise<boolean>;
|
|
448
467
|
delete(id: string): Promise<void>;
|
|
468
|
+
listJobsForRetention(args: {
|
|
469
|
+
lastActivityBeforeMs: number;
|
|
470
|
+
limit: number;
|
|
471
|
+
capabilities: string[] | null;
|
|
472
|
+
after?: JobRetentionCursor;
|
|
473
|
+
}): Promise<JobRecord[]>;
|
|
474
|
+
redactJob(args: {
|
|
475
|
+
jobId: string;
|
|
476
|
+
expectedLastActivityAt: number;
|
|
477
|
+
redactedAt: number;
|
|
478
|
+
}): Promise<boolean>;
|
|
449
479
|
claimReceiptSeq(jobId: string): Promise<number>;
|
|
450
480
|
saveReceipt(jobId: string, receipt: JobReceipt): Promise<JobReceipt | undefined>;
|
|
451
481
|
appendOutgoing(jobId: string, message: OutgoingMessage, opts?: AppendOutgoingOptions): Promise<number>;
|