@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
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { L as LightningTransactionListOptions, a as LightningTransactionSnapshot, b as LightningBackend, c as LightningPayment, d as LightningWalletInfo, C as CreatedInvoice, I as InvoiceStatus, M as MintAmountBounds, e as MintHealthCheckResult } from '../lightning-backend-
|
|
2
|
-
export { A as AttestationPayload, B as BuilderIdentityKeypair, f as CheckMintHealthOptions, g as LockPubkey, h as amountBoundsVerdict, i as assertNutSupport, j as buildAttestation, k as canSwap, l as checkMintHealth, m as generateIdentity, n as hashCapabilities, o as loadIdentitySecret, s as signAttestation, t as toLockPubkey, v as verifyAttestation, w as writeIdentity } from '../lightning-backend-
|
|
1
|
+
import { L as LightningTransactionListOptions, a as LightningTransactionSnapshot, b as LightningBackend, c as LightningPayment, d as LightningWalletInfo, C as CreatedInvoice, I as InvoiceStatus, M as MintAmountBounds, e as MintHealthCheckResult } from '../lightning-backend-BhsyrBLa.js';
|
|
2
|
+
export { A as AttestationPayload, B as BuilderIdentityKeypair, f as CheckMintHealthOptions, g as LockPubkey, h as amountBoundsVerdict, i as assertNutSupport, j as buildAttestation, k as canSwap, l as checkMintHealth, m as generateIdentity, n as hashCapabilities, o as loadIdentitySecret, s as signAttestation, t as toLockPubkey, v as verifyAttestation, w as writeIdentity } from '../lightning-backend-BhsyrBLa.js';
|
|
3
3
|
import { ProofLike, MeltQuoteBolt11Response, Proof, Wallet, SerializedDLEQ, MintQuoteBolt11Response, MintQuoteState, MintPreview, OutputDataLike, CounterSource, CounterRange } from '@cashu/cashu-ts';
|
|
4
4
|
export { g as getWallet } from '../wallet-Dwjs5n_M.js';
|
|
5
|
-
import { W as JsonValue, z as SignedRequestDomain, H as SignedRequestStatementHeader, X as FundingReceipt, Y as JobReceipt$1, y as SignedRequestAudience, _ as PaymentRequired, $ as X402Version, a0 as MppxCredential, a1 as Message, a2 as MessageType, a3 as MppxChallenge, a4 as X402_BATCH_SETTLEMENT_SCHEME, a5 as X402_EXACT_SCHEME, a6 as ReceiptCredit, C as Currency, a7 as X402Wallet, L as Logger$1, K as KVStore, a8 as ResourceInfo } from '../step-cache-
|
|
6
|
-
export { a9 as BuildPaymentRequirementsOpts, aa as CapabilityDescriptor, ab as CashuMode, ac as CompleteContent, ad as DrainReceipt, ae as DrainReceiptEvent, af as ExactEvmPayload, ag as ExactEvmPayloadAuthorization, ah as FundingMethod, ai as MessageFrom, aj as PaymentPayload, ak as PaymentPayloadV1, al as PaymentPayloadV2, am as PaymentRequestContent, an as PaymentRequiredV2, ao as PaymentRequirements, ap as PaymentRequirementsV1, aq as PaymentRequirementsV2, ar as PromptContent, as as RAIL_REFUNDABLE, at as ReceiptOutcome, au as ReceiptPayment, av as SettleResponse, aw as StepCache, ax as StepRecord, ay as TextContent, az as UnsignedDrainReceipt, aA as UnsignedFundingReceipt, aB as UnsignedJobReceipt, aC as VerifyResponse, aD as WorkingContent, aE as X402Config, aF as X402ResponseBody, aG as X402SelfRelayRpcFailureReason, aH as X402_DEFAULT_NETWORK, aI as X402_V1_VERSION, aJ as X402_VERSION, aK as buildPaymentRequiredV2, aL as buildPaymentRequirements, aM as caip2ToX402Network, aN as canonicalRequestPath, aO as canonicaliseForSigning, aP as canonicalize, aQ as chainIdFromCaip2, aR as computeResultHash, aS as decodePayment, aT as decodePaymentRequiredHeader, aU as encodePayment, aV as encodePaymentRequiredHeader, aW as encodeSettleResponseHeader, aX as exactEvmAuthorization, aY as isArtifactMessage, aZ as isCancelMessage, a_ as isCompleteMessage, a$ as isDrainReceipt, b0 as isFundingReceipt, b1 as isPaymentRequestMessage, b2 as isPromptMessage, b3 as isSignedJobReceipt, b4 as isTextMessage, b5 as isWorkingMessage, b6 as paymentRequiredV2FromV1, b7 as signDrainReceipt, b8 as signFundingReceipt, b9 as signReceipt, ba as usdcContractByCaip2, bb as usdcContractFor, bc as usdcDomainNameFor, bd as usdcDomainVersionFor, be as verifyDrainReceipt, bf as verifyFundingReceipt, bg as verifyReceipt, bh as x402NetworkToCaip2 } from '../step-cache-
|
|
5
|
+
import { W as JsonValue, z as SignedRequestDomain, H as SignedRequestStatementHeader, X as FundingReceipt, Y as JobReceipt$1, y as SignedRequestAudience, _ as PaymentRequired, $ as X402Version, a0 as MppxCredential, a1 as Message, a2 as MessageType, a3 as MppxChallenge, a4 as X402_BATCH_SETTLEMENT_SCHEME, a5 as X402_EXACT_SCHEME, a6 as ReceiptCredit, C as Currency, a7 as X402Wallet, L as Logger$1, K as KVStore, a8 as ResourceInfo } from '../step-cache-v2yhyhSZ.js';
|
|
6
|
+
export { a9 as BuildPaymentRequirementsOpts, aa as CapabilityDescriptor, ab as CashuMode, ac as CompleteContent, ad as DrainReceipt, ae as DrainReceiptEvent, af as ExactEvmPayload, ag as ExactEvmPayloadAuthorization, ah as FundingMethod, ai as MessageFrom, aj as PaymentPayload, ak as PaymentPayloadV1, al as PaymentPayloadV2, am as PaymentRequestContent, an as PaymentRequiredV2, ao as PaymentRequirements, ap as PaymentRequirementsV1, aq as PaymentRequirementsV2, ar as PromptContent, as as RAIL_REFUNDABLE, at as ReceiptOutcome, au as ReceiptPayment, av as SettleResponse, aw as StepCache, ax as StepRecord, ay as TextContent, az as UnsignedDrainReceipt, aA as UnsignedFundingReceipt, aB as UnsignedJobReceipt, aC as VerifyResponse, aD as WorkingContent, aE as X402Config, aF as X402ResponseBody, aG as X402SelfRelayRpcFailureReason, aH as X402_DEFAULT_NETWORK, aI as X402_V1_VERSION, aJ as X402_VERSION, aK as buildPaymentRequiredV2, aL as buildPaymentRequirements, aM as caip2ToX402Network, aN as canonicalRequestPath, aO as canonicaliseForSigning, aP as canonicalize, aQ as chainIdFromCaip2, aR as computeResultHash, aS as decodePayment, aT as decodePaymentRequiredHeader, aU as encodePayment, aV as encodePaymentRequiredHeader, aW as encodeSettleResponseHeader, aX as exactEvmAuthorization, aY as isArtifactMessage, aZ as isCancelMessage, a_ as isCompleteMessage, a$ as isDrainReceipt, b0 as isFundingReceipt, b1 as isPaymentRequestMessage, b2 as isPromptMessage, b3 as isSignedJobReceipt, b4 as isTextMessage, b5 as isWorkingMessage, b6 as paymentRequiredV2FromV1, b7 as signDrainReceipt, b8 as signFundingReceipt, b9 as signReceipt, ba as usdcContractByCaip2, bb as usdcContractFor, bc as usdcDomainNameFor, bd as usdcDomainVersionFor, be as verifyDrainReceipt, bf as verifyFundingReceipt, bg as verifyReceipt, bh as x402NetworkToCaip2 } from '../step-cache-v2yhyhSZ.js';
|
|
7
7
|
import { SimplePool } from 'nostr-tools/pool';
|
|
8
8
|
import { Session } from 'mppx/tempo';
|
|
9
9
|
import { Pool } from 'pg';
|
|
10
10
|
import { PaymentRequired as PaymentRequired$1 } from '@x402/core/types';
|
|
11
11
|
import { ClientChannelStorage, BatchSettlementClientContext, BatchSettlementEvmScheme } from '@x402/evm/batch-settlement/client';
|
|
12
|
-
export { e as FX_CACHE_TTL_MS, g as FX_RETRY_COUNT, w as warmFxSnapshot } from '../fx-
|
|
13
|
-
export { c as InvalidUsdPriceError, p as parseUsdPrice } from '../usd-
|
|
12
|
+
export { e as FX_CACHE_TTL_MS, g as FX_RETRY_COUNT, w as warmFxSnapshot } from '../fx-DhyT1Cjh.js';
|
|
13
|
+
export { c as InvalidUsdPriceError, p as parseUsdPrice } from '../usd-Cu9G6xv2.js';
|
|
14
14
|
import 'hono';
|
|
15
15
|
import 'mppx';
|
|
16
16
|
import '@x402/core/server';
|
|
@@ -25,19 +25,12 @@ declare const CAPABILITY_NAME_RE: RegExp;
|
|
|
25
25
|
declare const X402_DEFAULT_FACILITATOR = "https://x402.org/facilitator";
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* despite the file's historical location.
|
|
32
|
-
*
|
|
33
|
-
* `pubkeyHex` is the x-only (32-byte) public key in hex; `signatureHex` is
|
|
34
|
-
* the 64-byte signature in hex.
|
|
35
|
-
* Returns `false` on any failure (bad encoding, wrong length, invalid
|
|
36
|
-
* signature) so callers can map a single boolean to `auth_error`.
|
|
28
|
+
* BIP-340 verification over canonical JSON, with a 32-byte x-only public key
|
|
29
|
+
* and a 64-byte signature, both hex-encoded. Bad wire encoding or failed crypto
|
|
30
|
+
* verification returns false; unsupported payload serialization can throw.
|
|
37
31
|
*/
|
|
38
32
|
declare function verifyCanonicalSignedRequest(payload: JsonValue, signatureHex: string, pubkeyHex: string): boolean;
|
|
39
33
|
|
|
40
|
-
/** Time window for a global spending cap. */
|
|
41
34
|
type BudgetWindow = "daily" | "weekly" | "monthly";
|
|
42
35
|
/** User-configured fiat caps. Any subset may be set. */
|
|
43
36
|
interface BudgetCaps {
|
|
@@ -61,10 +54,7 @@ type BudgetSpendKind = "job" | "float_fund" | "credit_fund";
|
|
|
61
54
|
interface BudgetLedgerEntry {
|
|
62
55
|
/** Unix timestamp (ms) when the payment was confirmed. */
|
|
63
56
|
timestamp: number;
|
|
64
|
-
/**
|
|
65
|
-
* Outflow kind. Absent on entries written before which were all
|
|
66
|
-
* job spends — {@link entryKind} normalises that.
|
|
67
|
-
*/
|
|
57
|
+
/** Missing kind denotes a legacy job spend; entryKind supplies that default. */
|
|
68
58
|
kind?: BudgetSpendKind;
|
|
69
59
|
/** Job ID the payment belongs to. For `float_fund`, the funding reference (e.g. a mint quote id). */
|
|
70
60
|
jobId: string;
|
|
@@ -87,10 +77,8 @@ interface BudgetLedgerEntry {
|
|
|
87
77
|
/** USD equivalent at spend time. */
|
|
88
78
|
usd: number;
|
|
89
79
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* `payment-request` spends it's the provider's stated reason. Optional — old
|
|
93
|
-
* entries recorded before lack it and render fine without it.
|
|
80
|
+
* Human context for wallet history: CLI-authored for upfront payments,
|
|
81
|
+
* provider-supplied for mid-job payment requests. Optional on legacy entries.
|
|
94
82
|
*/
|
|
95
83
|
label?: string;
|
|
96
84
|
/**
|
|
@@ -101,12 +89,10 @@ interface BudgetLedgerEntry {
|
|
|
101
89
|
*/
|
|
102
90
|
labelSource?: "provider";
|
|
103
91
|
}
|
|
104
|
-
/** Persisted budget file shape. */
|
|
105
92
|
interface BudgetLedger {
|
|
106
93
|
caps: BudgetCaps;
|
|
107
94
|
entries: BudgetLedgerEntry[];
|
|
108
95
|
}
|
|
109
|
-
/** Spend inside a window, split by what the money was for. */
|
|
110
96
|
interface BudgetSpendBreakdown {
|
|
111
97
|
/** Total USD spent in the window — the number caps are checked against. */
|
|
112
98
|
totalUsd: number;
|
|
@@ -144,7 +130,6 @@ interface RecordSpendOptions {
|
|
|
144
130
|
labelSource?: "provider";
|
|
145
131
|
now?: Date;
|
|
146
132
|
}
|
|
147
|
-
/** Append a confirmed spend to the ledger. */
|
|
148
133
|
declare function recordSpend(opts: RecordSpendOptions): void;
|
|
149
134
|
/**
|
|
150
135
|
* Enforce the global budget caps before a planned spend.
|
|
@@ -165,7 +150,6 @@ declare function enforceGlobalBudget(opts: {
|
|
|
165
150
|
plannedMsats: number;
|
|
166
151
|
btcRate?: number;
|
|
167
152
|
}): Promise<number>;
|
|
168
|
-
/** Snapshot of current spending vs caps for `dvm budget status`. */
|
|
169
153
|
declare function statusSnapshot(now?: Date): {
|
|
170
154
|
caps: BudgetCaps;
|
|
171
155
|
windows: {
|
|
@@ -197,9 +181,7 @@ declare function buildAdminChallenge(args: {
|
|
|
197
181
|
nonceHex: string;
|
|
198
182
|
unixSeconds: number | string;
|
|
199
183
|
}): Uint8Array;
|
|
200
|
-
/** Parsed components of an `Authorization: P2PK <nonce>.<unix>.<sig>` header. */
|
|
201
184
|
interface AdminAuthHeader {
|
|
202
|
-
/** Full header value, ready to drop into `Authorization`. */
|
|
203
185
|
header: string;
|
|
204
186
|
/** 16-byte hex nonce — exposed so callers/tests can introspect it. */
|
|
205
187
|
nonceHex: string;
|
|
@@ -313,26 +295,9 @@ declare function getInputFeesForProofs(mintUrl: string, proofs: Pick<Proof, "id"
|
|
|
313
295
|
*/
|
|
314
296
|
declare function fetchMeltQuote(mintUrl: string, bolt11: string): Promise<MeltQuoteInfo>;
|
|
315
297
|
|
|
316
|
-
/**
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
* Anything that picks proofs has to know a swap's input requirement *before*
|
|
321
|
-
* it hands cashu-ts the proofs — that's what selection is. cashu-ts has no
|
|
322
|
-
* side-effect-free oracle for it (`Wallet.prepareSwapToSend` mints blinded
|
|
323
|
-
* outputs and reserves NUT-13 counters), so this module reconstructs the
|
|
324
|
-
* requirement from the public primitives the library uses internally:
|
|
325
|
-
* `Wallet.getFeesForProofs`, `Wallet.getFeesForKeyset` and `splitAmount`.
|
|
326
|
-
* Keeping that reconstruction in one file is the point — the bug this
|
|
327
|
-
* replaces was a hand-rolled `ceil(N * input_fee_ppk / 1000)` in the agent
|
|
328
|
-
* wallet's selector drifting from the library that does the swap.
|
|
329
|
-
*
|
|
330
|
-
* It lives here rather than under `wallet-agent/` because the same
|
|
331
|
-
* arithmetic prices both sides of the protocol: the caller's spend selection
|
|
332
|
-
* (`wallet-agent/spend.ts`, `release.ts`) and the builder's drain-park batch
|
|
333
|
-
* selection (`commands/builder/drain-service.ts`), which is where the same bug
|
|
334
|
-
* class was found a second time.
|
|
335
|
-
*/
|
|
298
|
+
/** Selection needs a reserve before swapping. prepareSwapToSend has side effects
|
|
299
|
+
* (blinded outputs and counter reservations), so price it through cashu-ts fee
|
|
300
|
+
* primitives shared by caller and builder proof selection. */
|
|
336
301
|
|
|
337
302
|
/**
|
|
338
303
|
* Sats a `wallet.ops.send(amountSats, …).includeFees(true)` swap consumes on
|
|
@@ -341,9 +306,7 @@ declare function fetchMeltQuote(mintUrl: string, bolt11: string): Promise<MeltQu
|
|
|
341
306
|
* Selection is done when `sum(inputs) >= amountSats + reserve(inputs)`.
|
|
342
307
|
*/
|
|
343
308
|
type SwapSendReserve = (inputs: ProofRef[]) => number;
|
|
344
|
-
/** The one field of a proof the fee helpers read: its keyset id. */
|
|
345
309
|
interface ProofRef {
|
|
346
|
-
/** Keyset id the proof was issued against. */
|
|
347
310
|
id: string;
|
|
348
311
|
}
|
|
349
312
|
/**
|
|
@@ -595,7 +558,6 @@ type Rail = "cashu_p2pk" | "tempo" | "x402";
|
|
|
595
558
|
* `cashu` maps to the P2PK agent-wallet rail.
|
|
596
559
|
*/
|
|
597
560
|
type RailFlag = "cashu" | "tempo" | "x402";
|
|
598
|
-
/** Recognise the user-facing rail flag values accepted on the CLI. */
|
|
599
561
|
declare const RAIL_FLAGS: readonly RailFlag[];
|
|
600
562
|
|
|
601
563
|
interface Config {
|
|
@@ -995,7 +957,6 @@ interface NwcTransaction {
|
|
|
995
957
|
/** Unix seconds when the invoice settled (null/undefined means unpaid). */
|
|
996
958
|
settledAt?: number;
|
|
997
959
|
}
|
|
998
|
-
/** Error from an NWC operation (invalid URI, timeout, wallet rejection, etc.). */
|
|
999
960
|
declare class NwcError extends Error {
|
|
1000
961
|
code: string;
|
|
1001
962
|
/**
|
|
@@ -1016,7 +977,6 @@ declare class NwcError extends Error {
|
|
|
1016
977
|
*/
|
|
1017
978
|
method?: string | undefined);
|
|
1018
979
|
}
|
|
1019
|
-
/** Per-request transport tunables. */
|
|
1020
980
|
interface NwcRequestOptions {
|
|
1021
981
|
/** Reuse an existing pool instead of opening (and closing) a fresh one. */
|
|
1022
982
|
pool?: SimplePool;
|
|
@@ -1079,7 +1039,6 @@ declare function parseNwcUri(uri: string): NwcConnection;
|
|
|
1079
1039
|
declare function payInvoiceReconciling(conn: NwcConnection, bolt11: string, opts?: PayInvoiceReconcilingOptions): Promise<PayInvoiceOutcome>;
|
|
1080
1040
|
/** Get wallet balance in millisatoshis. */
|
|
1081
1041
|
declare function getBalance(conn: NwcConnection, opts?: NwcRequestOptions): Promise<number>;
|
|
1082
|
-
/** Get wallet metadata (alias, supported methods, any volunteered budget fields). */
|
|
1083
1042
|
declare function getInfo(conn: NwcConnection, opts?: NwcRequestOptions): Promise<WalletInfo>;
|
|
1084
1043
|
/**
|
|
1085
1044
|
* Create a Lightning invoice on the remote wallet.
|
|
@@ -1579,11 +1538,9 @@ declare function receiptFailureDetail(reason: ReceiptInvalidReason): string;
|
|
|
1579
1538
|
type ReceiptParseError = "shape_invalid";
|
|
1580
1539
|
/** The highest protocol version this client supports. */
|
|
1581
1540
|
declare const SUPPORTED_PROTOCOL_VERSION = 1;
|
|
1582
|
-
/** Reference to a DVM provider — identified by its HTTPS endpoint URL. */
|
|
1583
1541
|
interface ProviderRef {
|
|
1584
1542
|
endpoint: string;
|
|
1585
1543
|
}
|
|
1586
|
-
/** Universal job envelope — transport-agnostic representation of a job request. */
|
|
1587
1544
|
interface JobEnvelope {
|
|
1588
1545
|
/**
|
|
1589
1546
|
* Capability name on the target DVM. Set by callers that already
|
|
@@ -1601,7 +1558,6 @@ interface JobEnvelope {
|
|
|
1601
1558
|
/** Max bid in millisatoshis */
|
|
1602
1559
|
bidMsats?: number;
|
|
1603
1560
|
}
|
|
1604
|
-
/** Payment token attached to a job submission. */
|
|
1605
1561
|
interface Payment {
|
|
1606
1562
|
/** Cashu token (for X-Cashu header) */
|
|
1607
1563
|
cashuToken?: string;
|
|
@@ -1617,13 +1573,8 @@ interface Payment {
|
|
|
1617
1573
|
cashuRequestId?: string;
|
|
1618
1574
|
}
|
|
1619
1575
|
/**
|
|
1620
|
-
*
|
|
1621
|
-
*
|
|
1622
|
-
* `upfront` is the protocol-enforced fiat commitment. `priceMsats` is the
|
|
1623
|
-
* client's local advisory sats estimate — derived via `fetchBtcUsdRate` from
|
|
1624
|
-
* `upfront.amount × current fx` at transport-read time. Binding sats settles
|
|
1625
|
-
* at the `/v1/job` 402 handshake; this field is for display + budget
|
|
1626
|
-
* comparison only.
|
|
1576
|
+
* upfront is the binding fiat commitment. priceMsats is advisory; the 402
|
|
1577
|
+
* handshake supplies the actual settlement amount.
|
|
1627
1578
|
*/
|
|
1628
1579
|
interface Quote {
|
|
1629
1580
|
/**
|
|
@@ -1673,15 +1624,9 @@ interface Quote {
|
|
|
1673
1624
|
/** Quote expiration (unix seconds). */
|
|
1674
1625
|
expiresAt?: number;
|
|
1675
1626
|
/**
|
|
1676
|
-
*
|
|
1677
|
-
*
|
|
1678
|
-
*
|
|
1679
|
-
* commit to the accumulator at receive time, Tempo and x402 are final
|
|
1680
|
-
* settlement. It is **not** the answer to "does a failed job cost me money":
|
|
1681
|
-
* since the behavior was introduced a failed job releases its draw and never debits, and whether
|
|
1682
|
-
* the caller can reach that released value is told by {@link Quote.credit}
|
|
1683
|
-
* `refundable` is omitted by legacy providers, in which case
|
|
1684
|
-
* this field stays undefined.
|
|
1627
|
+
* Rail refundability is separate from failed-job cost: failure releases the
|
|
1628
|
+
* pending credit draw, while the credit menu states whether its value can be
|
|
1629
|
+
* reclaimed. Legacy providers omit refundable.
|
|
1685
1630
|
*/
|
|
1686
1631
|
payment?: {
|
|
1687
1632
|
methods: string[];
|
|
@@ -1787,7 +1732,6 @@ declare function parseCreditMenu(raw: unknown): CreditMenu | undefined;
|
|
|
1787
1732
|
* there is no header for the caller to hang a proof on.
|
|
1788
1733
|
*/
|
|
1789
1734
|
interface LightningFundingOffer {
|
|
1790
|
-
/** The bolt11 to pay. */
|
|
1791
1735
|
invoice: string;
|
|
1792
1736
|
/** Payment hash, for reconciling against the wallet's own record. */
|
|
1793
1737
|
payment_hash: string;
|
|
@@ -1852,12 +1796,13 @@ interface DrainWire {
|
|
|
1852
1796
|
token?: string;
|
|
1853
1797
|
/** Structured settlement evidence for a non-cashu payout, once sent. */
|
|
1854
1798
|
sent?: Record<string, unknown>;
|
|
1855
|
-
/**
|
|
1799
|
+
/** Opaque receipt observations; consumers must shape-check and authenticate them. */
|
|
1856
1800
|
receipts: unknown[];
|
|
1857
1801
|
}
|
|
1858
|
-
/**
|
|
1802
|
+
/**
|
|
1803
|
+
* POST /v1/credit operation response.
|
|
1804
|
+
*/
|
|
1859
1805
|
interface CreditOpResult {
|
|
1860
|
-
/** Which op this answers. */
|
|
1861
1806
|
op: "fund" | "balance" | "drain";
|
|
1862
1807
|
/** Micro-units actually credited by a `fund` (pro-rata of the artifact's value). */
|
|
1863
1808
|
funded_micro?: number;
|
|
@@ -1873,7 +1818,6 @@ interface CreditOpResult {
|
|
|
1873
1818
|
* is on `credit.credit_id`, not the `credit_id` that was polled.
|
|
1874
1819
|
*/
|
|
1875
1820
|
reconciled?: boolean;
|
|
1876
|
-
/** The primary / affected credit. */
|
|
1877
1821
|
credit?: CreditWire;
|
|
1878
1822
|
/** Every credit this caller holds here (`balance` op; includes expired). */
|
|
1879
1823
|
credits?: CreditWire[];
|
|
@@ -1885,7 +1829,6 @@ interface CreditOpResult {
|
|
|
1885
1829
|
* treats it as no update and keeps whatever snapshot it already holds.
|
|
1886
1830
|
*/
|
|
1887
1831
|
menu?: CreditMenu;
|
|
1888
|
-
/** The drain record (`drain` op). */
|
|
1889
1832
|
drain?: DrainWire;
|
|
1890
1833
|
/** Relay-safe one-liner from the DVM (drain op). */
|
|
1891
1834
|
display?: string;
|
|
@@ -1909,7 +1852,6 @@ interface CreditOpResult {
|
|
|
1909
1852
|
* response; that one is a single block inside it.
|
|
1910
1853
|
*/
|
|
1911
1854
|
interface JobReceipt {
|
|
1912
|
-
/** Job ID (server-assigned) */
|
|
1913
1855
|
jobId: string;
|
|
1914
1856
|
status: "completed" | "processing" | "payment-required" | "failed" | "cancelled" | "awaiting-input";
|
|
1915
1857
|
/** Tempo settlement transaction from the validated `Payment-Receipt` header. */
|
|
@@ -1922,17 +1864,12 @@ interface JobReceipt {
|
|
|
1922
1864
|
artifactCount?: number;
|
|
1923
1865
|
/** Tells agents where the payload lives: `"summary"` when the summary string is the full payload; `"messages"` when artifacts hold the actual output. */
|
|
1924
1866
|
payloadIn?: "summary" | "messages";
|
|
1925
|
-
/** Quotes collected during submission */
|
|
1926
1867
|
quotes?: Quote[];
|
|
1927
1868
|
/** Estimated seconds until completion (for async jobs) */
|
|
1928
1869
|
estimatedSeconds?: number;
|
|
1929
1870
|
/**
|
|
1930
|
-
*
|
|
1931
|
-
*
|
|
1932
|
-
* dvmkit DVMs no longer send one — overpayment funds the caller's credit and
|
|
1933
|
-
* is drawn for the job, and deleted the server half. The reader
|
|
1934
|
-
* stays because the header is still NUT-24, a third-party DVM may send it,
|
|
1935
|
-
* and a token nobody claims is money on the floor.
|
|
1871
|
+
* Third-party/legacy X-Cashu-Change token. Current SDK overpayment funds
|
|
1872
|
+
* the caller's credit; transports retain this token for compatible recovery.
|
|
1936
1873
|
*/
|
|
1937
1874
|
cashuChange?: string;
|
|
1938
1875
|
/**
|
|
@@ -1968,19 +1905,16 @@ interface JobReceipt {
|
|
|
1968
1905
|
fundedMicro?: number;
|
|
1969
1906
|
credit?: CreditWire;
|
|
1970
1907
|
}
|
|
1971
|
-
/** Options controlling how submit() waits for results. */
|
|
1972
1908
|
interface SubmitOptions {
|
|
1973
1909
|
/** Wait for result in ms. 0 = fire-and-forget. Default 30000. */
|
|
1974
1910
|
timeoutMs?: number;
|
|
1975
1911
|
}
|
|
1976
|
-
/** Options controlling how status() polls/subscribes. */
|
|
1977
1912
|
interface StatusOptions {
|
|
1978
1913
|
/** How long to subscribe/poll in ms. Default 5000. */
|
|
1979
1914
|
timeoutMs?: number;
|
|
1980
1915
|
/** opaque per-job token issued at create-time; sent as `X-Job-Token`. */
|
|
1981
1916
|
jobToken?: string;
|
|
1982
1917
|
}
|
|
1983
|
-
/** Options controlling how getMessages() polls/subscribes. */
|
|
1984
1918
|
interface MessagePollOptions {
|
|
1985
1919
|
/** How long to poll/subscribe in ms. */
|
|
1986
1920
|
timeoutMs?: number;
|
|
@@ -2005,12 +1939,8 @@ interface JobStatus {
|
|
|
2005
1939
|
payloadIn?: "summary" | "messages";
|
|
2006
1940
|
message?: string;
|
|
2007
1941
|
/**
|
|
2008
|
-
*
|
|
2009
|
-
*
|
|
2010
|
-
* dvmkit DVMs no longer send one — overpayment funds the caller's credit and
|
|
2011
|
-
* is drawn for the job, and deleted the server half. The reader
|
|
2012
|
-
* stays because the header is still NUT-24, a third-party DVM may send it,
|
|
2013
|
-
* and a token nobody claims is money on the floor.
|
|
1942
|
+
* Third-party/legacy X-Cashu-Change token. Current SDK overpayment funds
|
|
1943
|
+
* the caller's credit; transports retain this token for compatible recovery.
|
|
2014
1944
|
*/
|
|
2015
1945
|
cashuChange?: string;
|
|
2016
1946
|
/**
|
|
@@ -2462,11 +2392,8 @@ interface PendingTempoChargeFunding {
|
|
|
2462
2392
|
* around individual storage calls.
|
|
2463
2393
|
*/
|
|
2464
2394
|
declare function withTempoChannelLock<T>(operation: () => Promise<T>): Promise<T>;
|
|
2465
|
-
/** List the caller's currently remembered Tempo credit channels. */
|
|
2466
2395
|
declare function listTempoChannelAssociations(): TempoChannelAssociation[];
|
|
2467
|
-
/** Find the channel bound to one DVM credit and caller identity. */
|
|
2468
2396
|
declare function loadTempoChannelAssociation(endpoint: string, callerPubkey: string, creditId: string): TempoChannelAssociation | undefined;
|
|
2469
|
-
/** Load the full mppx entry associated with one DVM credit. */
|
|
2470
2397
|
declare function loadTempoChannelEntry(association: TempoChannelAssociation): Promise<ChannelEntry | undefined>;
|
|
2471
2398
|
/**
|
|
2472
2399
|
* The wallets a recorded channel's descriptor authorizes over its collateral.
|
|
@@ -2491,17 +2418,8 @@ interface TempoChannelController {
|
|
|
2491
2418
|
*/
|
|
2492
2419
|
declare function loadTempoChannelController(association: TempoChannelAssociation): Promise<TempoChannelController | undefined>;
|
|
2493
2420
|
/**
|
|
2494
|
-
*
|
|
2495
|
-
*
|
|
2496
|
-
* Both roles count. The payer is who the escrow refunds, and the authorized
|
|
2497
|
-
* signer is who can still commit that deposit — dropping either key changes
|
|
2498
|
-
* what the channel can do, so either one is reason enough to keep refusing.
|
|
2499
|
-
*
|
|
2500
|
-
* A record whose descriptor is already gone reads as controlled: ownership is
|
|
2501
|
-
* then unknowable, and guessing "stranger" would let a key be replaced over a
|
|
2502
|
-
* channel it may well own. A machine with no Tempo key configured controls
|
|
2503
|
-
* nothing, which is the opposite default and for the same reason — no key here
|
|
2504
|
-
* can sign for that channel, so nothing here is worth protecting.
|
|
2421
|
+
* Either payer or delegated signer controls the channel. Unknown ownership is
|
|
2422
|
+
* treated as controlled; with a known controller, an absent address does not match.
|
|
2505
2423
|
*/
|
|
2506
2424
|
declare function tempoChannelControlledBy(controller: TempoChannelController | undefined, address: string | undefined): boolean;
|
|
2507
2425
|
/** Every charge funding a sweep could still resume, optionally scoped to one DVM identity. */
|
|
@@ -2511,19 +2429,7 @@ declare function listResumableTempoChargeFundings(filter?: {
|
|
|
2511
2429
|
now?: number;
|
|
2512
2430
|
}): PendingTempoChargeFunding[];
|
|
2513
2431
|
|
|
2514
|
-
/**
|
|
2515
|
-
* The naming contract every stablecoin rail shares.
|
|
2516
|
-
*
|
|
2517
|
-
* A rail settles in exactly one token contract, and the caller-side balance
|
|
2518
|
-
* read queries exactly that contract — so a wallet funded with the wrong dollar
|
|
2519
|
-
* is indistinguishable from an unfunded one unless every surface that prints a
|
|
2520
|
-
* balance can name the asset the rail actually accepts. Each rail resolves that
|
|
2521
|
-
* name once, in its own module, and returns this shape; print sites carry no
|
|
2522
|
-
* literals.
|
|
2523
|
-
*
|
|
2524
|
-
* Deliberately type-only and dependency-free: it is imported by both the
|
|
2525
|
-
* caller-side CLI and the `src/lib/x402/` modules the SDK server shares.
|
|
2526
|
-
*/
|
|
2432
|
+
/** Dependency-free display names for the token selected by a stablecoin rail. */
|
|
2527
2433
|
interface RailAsset {
|
|
2528
2434
|
/** Token contract the rail settles in. */
|
|
2529
2435
|
address: `0x${string}`;
|
|
@@ -2535,7 +2441,6 @@ interface RailAsset {
|
|
|
2535
2441
|
unit: string;
|
|
2536
2442
|
}
|
|
2537
2443
|
|
|
2538
|
-
/** Where a resolved RPC URL came from. */
|
|
2539
2444
|
type RpcSource = "override" | "bundled";
|
|
2540
2445
|
/**
|
|
2541
2446
|
* A resolved RPC URL and the source that supplied it.
|
|
@@ -2569,19 +2474,10 @@ declare function resolveRpcOverride(envValue: string | undefined, bundled?: stri
|
|
|
2569
2474
|
declare function resolveRpcHttpTransportOptions(source: RpcSource, envValue: string | undefined): RpcHttpTransportOptions | undefined;
|
|
2570
2475
|
|
|
2571
2476
|
/**
|
|
2572
|
-
*
|
|
2573
|
-
*
|
|
2574
|
-
* `tempo.charge` signs a per-call EIP-712-style authorization with that key
|
|
2575
|
-
* for every 402 challenge. The on-chain USDC balance at the derived address
|
|
2576
|
-
* is the practical spending limit.
|
|
2577
|
-
*
|
|
2578
|
-
* Persistence reuses the existing `config.tempo` shape (set by
|
|
2579
|
-
* `dvm wallet tempo-connect --api-key 0x...`) so both the import-existing
|
|
2580
|
-
* path and the new generate-fresh path (`dvm wallet fund $X --rail tempo`)
|
|
2581
|
-
* write the same JSON. Older records without `network` resolve to mainnet.
|
|
2477
|
+
* Imported and generated keys share `config.tempo`. Records without a network
|
|
2478
|
+
* retain the mainnet default. Balance reads target the configured token.
|
|
2582
2479
|
*/
|
|
2583
2480
|
|
|
2584
|
-
/** A locally-persisted Tempo (EVM) account. */
|
|
2585
2481
|
interface TempoAccount {
|
|
2586
2482
|
/** Lowercase 0x-prefixed 40-char EVM address derived from {@link privateKey}. */
|
|
2587
2483
|
address: `0x${string}`;
|
|
@@ -2590,24 +2486,14 @@ interface TempoAccount {
|
|
|
2590
2486
|
/** Network this key is configured to spend on. */
|
|
2591
2487
|
network?: TempoNetwork;
|
|
2592
2488
|
}
|
|
2593
|
-
/** Supported Tempo wallet networks. */
|
|
2594
2489
|
type TempoNetwork = "mainnet" | "moderato";
|
|
2595
2490
|
/**
|
|
2596
|
-
*
|
|
2597
|
-
*
|
|
2598
|
-
* The endpoint the read went to is carried **only** in redacted form
|
|
2599
|
-
* ({@link rpcUrlRedacted}), never in the clear. A caller's
|
|
2600
|
-
* `DVM_TEMPO_RPC_URL` usually holds a provider API key in its path, and
|
|
2601
|
-
* this object is one JSON spread away from caller-visible output — which is
|
|
2602
|
-
* why removed the raw field outright. needs the endpoint on
|
|
2603
|
-
* the success path (a read against the wrong one returns a believable `$0.00`
|
|
2604
|
-
* that nothing else distinguishes from an unfunded wallet), so it comes back
|
|
2605
|
-
* pre-redacted: there is no clear value here for a future consumer to leak.
|
|
2491
|
+
* Carries the queried endpoint only in redacted form, including on success:
|
|
2492
|
+
* provider URLs may contain credentials and consumers may expose this object.
|
|
2606
2493
|
*/
|
|
2607
2494
|
interface TempoBalance {
|
|
2608
|
-
/** Account whose USDC balance was queried. */
|
|
2609
2495
|
address: `0x${string}`;
|
|
2610
|
-
/** Raw
|
|
2496
|
+
/** Raw configured-token balance, in base units (6 decimals). */
|
|
2611
2497
|
rawBaseUnits: bigint;
|
|
2612
2498
|
/** Balance in USDC (`rawBaseUnits / 10^6`, returned as a number for display). */
|
|
2613
2499
|
usdc: number;
|
|
@@ -2625,13 +2511,10 @@ interface TempoBalance {
|
|
|
2625
2511
|
/** Wall-clock ms when the balance was fetched. */
|
|
2626
2512
|
fetchedAtMs: number;
|
|
2627
2513
|
}
|
|
2628
|
-
/** Tempo mainnet chain id. */
|
|
2629
2514
|
declare const TEMPO_CHAIN_ID = 4217;
|
|
2630
|
-
/** Tempo Moderato chain id. */
|
|
2631
2515
|
declare const TEMPO_MODERATO_CHAIN_ID = 42431;
|
|
2632
2516
|
/** Default pathUSD token on Tempo Moderato. */
|
|
2633
2517
|
declare const TEMPO_PATH_USD_MODERATO: "0x20c0000000000000000000000000000000000000";
|
|
2634
|
-
/** Public Tempo Moderato RPC. */
|
|
2635
2518
|
declare const TEMPO_MODERATO_RPC: "https://rpc.moderato.tempo.xyz";
|
|
2636
2519
|
/** Stable chain, RPC, and default-token identity for a persisted Tempo network. */
|
|
2637
2520
|
declare function resolveTempoNetwork(network?: TempoNetwork): {
|
|
@@ -2640,19 +2523,6 @@ declare function resolveTempoNetwork(network?: TempoNetwork): {
|
|
|
2640
2523
|
rpcUrl: string;
|
|
2641
2524
|
defaultToken: `0x${string}`;
|
|
2642
2525
|
};
|
|
2643
|
-
/**
|
|
2644
|
-
* The single asset the Tempo rail settles in, resolved from the environment.
|
|
2645
|
-
*
|
|
2646
|
-
* Tempo carries more than one dollar-denominated stablecoin (USDC.e and USDT0
|
|
2647
|
-
* at minimum), but a DVM charges in exactly one contract and the caller-side
|
|
2648
|
-
* balance read queries exactly that contract. Every surface that names the
|
|
2649
|
-
* asset resolves it here so a caller running with `DVM_TEMPO_CURRENCY` set
|
|
2650
|
-
* never reads copy that contradicts the contract their wallet is actually
|
|
2651
|
-
* pointed at.
|
|
2652
|
-
*
|
|
2653
|
-
* Tempo needs no fields beyond the shared {@link RailAsset} contract. The
|
|
2654
|
-
* wallet's persisted network selects the default address before this resolves.
|
|
2655
|
-
*/
|
|
2656
2526
|
type TempoAsset = RailAsset;
|
|
2657
2527
|
/**
|
|
2658
2528
|
* Resolve the Tempo settlement asset from `DVM_TEMPO_CURRENCY`, falling
|
|
@@ -2738,14 +2608,9 @@ declare function generateTempoKey(opts?: {
|
|
|
2738
2608
|
* surface the address + a "balance not queried" hint in `--human` output.
|
|
2739
2609
|
*/
|
|
2740
2610
|
declare function getTempoUsdcBalance(account: TempoAccount): Promise<TempoBalance>;
|
|
2741
|
-
/** Derive the EVM address from a 0x-prefixed 32-byte hex private key. */
|
|
2742
2611
|
declare function deriveTempoAddress(privateKey: `0x${string}`): Promise<`0x${string}`>;
|
|
2743
2612
|
|
|
2744
|
-
/** Caller-side TIP-1034 session credentials and unilateral channel recovery. */
|
|
2745
|
-
|
|
2746
|
-
/** True when this caller can fund credit over either Tempo flavour. */
|
|
2747
2613
|
declare function offersTempoCreditFunding(menu: CreditMenu | undefined): boolean;
|
|
2748
|
-
/** Test seam for supplying the challenge's Tempo chain client. */
|
|
2749
2614
|
type TempoSessionClientResolver = NonNullable<NonNullable<Parameters<typeof Session.Client.session>[0]>["getClient"]>;
|
|
2750
2615
|
type TempoSessionMethod = ReturnType<typeof Session.Client.session>;
|
|
2751
2616
|
type TempoSessionChallenge = Parameters<TempoSessionMethod["createCredential"]>[0]["challenge"];
|
|
@@ -2759,7 +2624,6 @@ declare function tempoSessionChallenge(err: unknown): TempoSessionChallenge | un
|
|
|
2759
2624
|
* crash on a path whose whole job is refusing what the DVM asks for.
|
|
2760
2625
|
*/
|
|
2761
2626
|
declare function tempoSessionChallengeMicro(challenge: TempoSessionChallenge): number;
|
|
2762
|
-
/** Create the cooperative-close credential for a channel-backed credit drain. */
|
|
2763
2627
|
declare function createTempoCloseCredential(args: {
|
|
2764
2628
|
account: TempoAccount;
|
|
2765
2629
|
association: TempoChannelAssociation;
|
|
@@ -2843,9 +2707,7 @@ interface TempoChannelExitArgs {
|
|
|
2843
2707
|
* collateral an exit can still recover.
|
|
2844
2708
|
*/
|
|
2845
2709
|
abandon?: boolean;
|
|
2846
|
-
/** Test seam for the challenge chain client. */
|
|
2847
2710
|
client?: Parameters<typeof Session.Precompile.Chain.getChannelState>[0];
|
|
2848
|
-
/** Test seam for on-chain state transitions. */
|
|
2849
2711
|
chain?: TempoChannelExitChain;
|
|
2850
2712
|
}
|
|
2851
2713
|
/**
|
|
@@ -2874,13 +2736,12 @@ interface TempoChannelReconcileResult {
|
|
|
2874
2736
|
status: TempoChannelChainStatus;
|
|
2875
2737
|
/** Whether the local record is gone once this call returns. Only ever on `closed`. */
|
|
2876
2738
|
retired: boolean;
|
|
2877
|
-
/** The channel the verdict is about. */
|
|
2878
2739
|
channelId: string;
|
|
2879
2740
|
/** The escrow's deposit, falling back to the record's figure when unread. */
|
|
2880
2741
|
depositMicro: number;
|
|
2881
2742
|
/** What the escrow has already paid the DVM, zero when unread. */
|
|
2882
2743
|
settledMicro: number;
|
|
2883
|
-
/**
|
|
2744
|
+
/** Redacted read or local-retirement failure; the chain verdict can still be closed. */
|
|
2884
2745
|
error?: DvmError;
|
|
2885
2746
|
}
|
|
2886
2747
|
/**
|
|
@@ -2898,9 +2759,10 @@ interface TempoChannelReconcileResult {
|
|
|
2898
2759
|
* It broadcasts nothing: the chain seam is narrowed to `getChannelState`, and
|
|
2899
2760
|
* the retirement is a local file write. It also never throws — a drain that
|
|
2900
2761
|
* moved real money must not come back as an error because an RPC was down, and
|
|
2901
|
-
* a balance read must still report the rest of the wallet.
|
|
2902
|
-
*
|
|
2903
|
-
*
|
|
2762
|
+
* a balance read must still report the rest of the wallet. Failures are
|
|
2763
|
+
* redacted in the result. A read failure is `unreadable`; a local retirement
|
|
2764
|
+
* failure retains the chain's `closed` verdict and the record. Still-live
|
|
2765
|
+
* channels keep their recovery records.
|
|
2904
2766
|
*/
|
|
2905
2767
|
declare function reconcileTempoChannelOnChain(args: {
|
|
2906
2768
|
association: TempoChannelAssociation;
|
|
@@ -3318,19 +3180,7 @@ interface JobCompletion {
|
|
|
3318
3180
|
* a one-liner, not the payload, when the real output sits in artifact messages
|
|
3319
3181
|
*/
|
|
3320
3182
|
declare function buildCompletionHintFields(jobId: string, input: JobCompletion): Record<string, unknown>;
|
|
3321
|
-
/**
|
|
3322
|
-
* Pre-rendered hint string an agent can pass through verbatim to its user when
|
|
3323
|
-
* a job's payload lives in artifact messages rather than the `summary` field.
|
|
3324
|
-
* Pluralised when the count is known.
|
|
3325
|
-
*
|
|
3326
|
-
* The `--no-stream` is load-bearing, not decoration. A bare `dvm messages <id>`
|
|
3327
|
-
* reads from the job's stored cursor, and by the time this hint is rendered the
|
|
3328
|
-
* cursor is at the end of the log — so following it verbatim returned an **empty
|
|
3329
|
-
* batch**, which is the worst possible answer to "fetch the artifacts".
|
|
3330
|
-
* `--no-stream` replays a terminal job from seq 0 — that flag belongs to the
|
|
3331
|
-
* caller CLI, which lives in its own repository — which is what a caller asking
|
|
3332
|
-
* for the payload actually wants.
|
|
3333
|
-
*/
|
|
3183
|
+
/** `--no-stream` replays from seq 0: the stored cursor may already be past the artifacts. */
|
|
3334
3184
|
declare function nextStepHint(jobId: string, payloadIn: "summary" | "messages" | undefined, artifactCount: number | undefined): string | undefined;
|
|
3335
3185
|
/**
|
|
3336
3186
|
* Pick the terminal-outcome fields off a receipt or status response, dropping
|
|
@@ -3368,9 +3218,7 @@ declare function asProviderTextOpt(text: string | undefined): ProviderText | und
|
|
|
3368
3218
|
/** Render a ProviderText (or string) back to plain text — used by --human output paths. */
|
|
3369
3219
|
declare function providerTextToString(value: string | ProviderText): string;
|
|
3370
3220
|
|
|
3371
|
-
/** Tells the agent exactly what to do after a command returns. */
|
|
3372
3221
|
type NextAction = null | NextActionRespond | NextActionPay | NextActionApprove | NextActionPoll | NextActionRefund;
|
|
3373
|
-
/** Provider asked a question — agent should answer. */
|
|
3374
3222
|
interface NextActionRespond {
|
|
3375
3223
|
type: "respond";
|
|
3376
3224
|
job_id: string;
|
|
@@ -3381,7 +3229,6 @@ interface NextActionRespond {
|
|
|
3381
3229
|
/** CLI-owned guidance for the agent. */
|
|
3382
3230
|
hint: string;
|
|
3383
3231
|
}
|
|
3384
|
-
/** Payment requested above auto-pay threshold — agent should decide. */
|
|
3385
3232
|
interface NextActionPay {
|
|
3386
3233
|
type: "pay";
|
|
3387
3234
|
job_id: string;
|
|
@@ -3459,7 +3306,6 @@ declare function pollNextAction(jobId: string, hint?: string): NextActionPoll;
|
|
|
3459
3306
|
*/
|
|
3460
3307
|
declare function computeNextAction(jobId: string, messages: Message[]): NextAction;
|
|
3461
3308
|
|
|
3462
|
-
/** Persisted record of a submitted DVM job. */
|
|
3463
3309
|
interface JobRecord {
|
|
3464
3310
|
id: string;
|
|
3465
3311
|
endpoint: string;
|
|
@@ -3563,33 +3409,17 @@ interface JobRecord {
|
|
|
3563
3409
|
*/
|
|
3564
3410
|
builderAnchor?: ReceiptTrustAnchor;
|
|
3565
3411
|
}
|
|
3566
|
-
/** Reference to a received artifact, indexed in the job record. */
|
|
3567
3412
|
interface ArtifactRef {
|
|
3568
|
-
/** Sequence number of the artifact message. */
|
|
3569
3413
|
seq: number;
|
|
3570
|
-
/** Artifact name, if provided. */
|
|
3571
3414
|
name?: string;
|
|
3572
3415
|
mimeType?: string;
|
|
3573
3416
|
}
|
|
3574
3417
|
declare function saveJob(job: JobRecord): void;
|
|
3575
3418
|
/** Merge a partial update into an existing job record. No-op if job not found. */
|
|
3576
3419
|
declare function updateJob(id: string, update: Partial<Omit<JobRecord, "id">>): void;
|
|
3577
|
-
/**
|
|
3578
|
-
*
|
|
3579
|
-
* The only writer of a terminal `status` — routing every such write
|
|
3580
|
-
* through here keeps the invariant that a terminal record always carries its
|
|
3581
|
-
* `completion` snapshot, which is what lets `dvm status` replay the full
|
|
3582
|
-
* payload locally. Pass `{}` when the provider gave nothing to snapshot (e.g.
|
|
3583
|
-
* a caller-initiated cancel). No-op if the job is not found.
|
|
3584
|
-
*
|
|
3585
|
-
* Idempotent on `completedAt`: a job can be marked terminal more than once (a
|
|
3586
|
-
* `dvm status --messages` re-read, or the first read of a record that predates
|
|
3587
|
-
* the snapshot), and the job finished when it first finished — re-stamping would
|
|
3588
|
-
* drift the recorded time forward and skew `avgLatencyMs` in local provider
|
|
3589
|
-
* history.
|
|
3590
|
-
*/
|
|
3420
|
+
/** Persist status and completion together for offline replay. Empty completion is allowed.
|
|
3421
|
+
* Repeated terminal updates preserve the original completedAt. Missing jobs are unchanged. */
|
|
3591
3422
|
declare function markJobTerminal(id: string, status: TerminalJobStatus, completion: JobCompletion, extra?: Partial<Omit<JobRecord, "id" | "status" | "completedAt" | "completion">>): void;
|
|
3592
|
-
/** Load a single job record by ID, or null if not found. */
|
|
3593
3423
|
declare function loadJob(id: string): JobRecord | null;
|
|
3594
3424
|
/** Load all job records. Returns [] on missing/corrupt file. */
|
|
3595
3425
|
declare function loadAllJobs(): JobRecord[];
|
|
@@ -5003,15 +4833,10 @@ declare function fetchCoinGeckoSpot(opts?: CoinGeckoFetchOptions): Promise<CoinG
|
|
|
5003
4833
|
*/
|
|
5004
4834
|
declare function fetchCoinGeckoBtcUsd(opts?: CoinGeckoFetchOptions): Promise<CoinGeckoBtcSpot>;
|
|
5005
4835
|
|
|
5006
|
-
/** Parsed components of a Lightning address (user@domain). */
|
|
5007
4836
|
interface LnAddressParts {
|
|
5008
4837
|
user: string;
|
|
5009
4838
|
domain: string;
|
|
5010
4839
|
}
|
|
5011
|
-
/**
|
|
5012
|
-
* Parse a Lightning address into user and domain components.
|
|
5013
|
-
* Validates the format is `user@domain` with reasonable constraints.
|
|
5014
|
-
*/
|
|
5015
4840
|
declare function parseLnAddress(address: string): LnAddressParts;
|
|
5016
4841
|
/**
|
|
5017
4842
|
* Resolve a payee identifier to the LNURL-pay metadata URL to GET.
|
|
@@ -5026,14 +4851,6 @@ declare function parseLnAddress(address: string): LnAddressParts;
|
|
|
5026
4851
|
* here rather than at an unrelated HTTP error later.
|
|
5027
4852
|
*/
|
|
5028
4853
|
declare function resolveLnurlPayMetadataUrl(target: string): string;
|
|
5029
|
-
/**
|
|
5030
|
-
* Fetch a bolt11 invoice from a Lightning address or `lnurl1…` string via the
|
|
5031
|
-
* LNURL-pay protocol.
|
|
5032
|
-
*
|
|
5033
|
-
* 1. GET the metadata URL ({@link resolveLnurlPayMetadataUrl}) for pay params
|
|
5034
|
-
* 2. Validate amount is within [minSendable, maxSendable]
|
|
5035
|
-
* 3. GET `{callback}?amount={amountMsats}` for the bolt11 invoice
|
|
5036
|
-
*/
|
|
5037
4854
|
declare function fetchLnurlPayInvoice(lnAddress: string, amountMsats: number): Promise<string>;
|
|
5038
4855
|
/**
|
|
5039
4856
|
* Validate a Lightning address (or `lnurl1…` string) by probing its LNURL-pay
|
|
@@ -5049,38 +4866,10 @@ declare function validateLnAddress(address: string): Promise<void>;
|
|
|
5049
4866
|
* Returned by {@link createMonotonicClock}.
|
|
5050
4867
|
*/
|
|
5051
4868
|
type MonotonicNowMs = () => number;
|
|
5052
|
-
/**
|
|
5053
|
-
* A
|
|
5054
|
-
*
|
|
5055
|
-
*
|
|
5056
|
-
* correcting a drifted host, the recurring CI-runner step behind * — is ignored until the wall catches up, while a legitimate forward
|
|
5057
|
-
* jump re-anchors immediately.
|
|
5058
|
-
*
|
|
5059
|
-
* The anchor is taken when the clock is created, so a sweeper that was already
|
|
5060
|
-
* running when the clock stepped is covered; one started afterwards has no way
|
|
5061
|
-
* to know, and simply trusts the clock it was born with.
|
|
5062
|
-
*
|
|
5063
|
-
* **One implementation, held by everything that needs it.** Two copies of this
|
|
5064
|
-
* would drift on exactly the reasoning that is hard to re-derive — the anchor
|
|
5065
|
-
* ordering, the re-anchor on the un-floored value, why the return is floored.
|
|
5066
|
-
* `JobManager` (the SDK stale-job sweep, the orphan-draw sweep and the
|
|
5067
|
-
* reactivation grace) and `IsolateJobReaper` (the isolate-tier mirror of that
|
|
5068
|
-
* sweep) each hold one.
|
|
5069
|
-
*
|
|
5070
|
-
* **What it costs is the reader's to weigh, and it is not the same everywhere.**
|
|
5071
|
-
* While the guard is compensating a step of `S`, a cutoff read off it is eager
|
|
5072
|
-
* by up to `S`. On the orphan-draw sweep that is the safe direction
|
|
5073
|
-
* outright: holds younger than `orphanDrawAgeMs` become candidates, but the
|
|
5074
|
-
* sweep still refuses any draw whose job row exists and isn't terminal, so the
|
|
5075
|
-
* eagerness only reaches draws inside the millisecond-scale window between the
|
|
5076
|
-
* ledger commit and `persistJob` — the window that age gate widens away from.
|
|
5077
|
-
* Blindness, the alternative, strands a caller's money with no signal at all.
|
|
5078
|
-
* On a stale-job watchdog it force-*fails* a job that may well be alive, so
|
|
5079
|
-
* both sweeps reading this for a watchdog cutoff clamp how far they lean on
|
|
5080
|
-
* it; see `JobManager#staleSweepCompensationCapMs` and
|
|
5081
|
-
* `IsolateJobReaper#compensationCapMs` for where each arm's cap
|
|
5082
|
-
* comes from, and why they differ.
|
|
5083
|
-
*/
|
|
4869
|
+
/** Wall-clock epoch ms projected forward by performance.now() after a backward step.
|
|
4870
|
+
* A forward step re-anchors immediately; the anchor starts at construction.
|
|
4871
|
+
* During compensation a cutoff can be eager by the backward-step size, so watchdog
|
|
4872
|
+
* callers must cap compensation separately. Results are floored to integer milliseconds. */
|
|
5084
4873
|
declare function createMonotonicClock(): MonotonicNowMs;
|
|
5085
4874
|
|
|
5086
4875
|
/** NWC-backed implementation of LightningBackend. */
|
|
@@ -5109,26 +4898,11 @@ declare const X402_EXACT_AUTHORIZATION_TTL_SECONDS = 600;
|
|
|
5109
4898
|
declare const X402_REFUSAL_TRANSACTION_DISCOVERY_WINDOW_MS: number;
|
|
5110
4899
|
|
|
5111
4900
|
/**
|
|
5112
|
-
*
|
|
5113
|
-
*
|
|
5114
|
-
*
|
|
5115
|
-
* caller CLI, which lives in its own repository.
|
|
5116
|
-
*
|
|
5117
|
-
* The credential is a structured `Credential.Credential` — an EIP-712-style
|
|
5118
|
-
* signature over the challenge plus mppx metadata. mppx's
|
|
5119
|
-
* `tempo.charge({ account }).createCredential({ challenge, context })`
|
|
5120
|
-
* performs the signing; this wrapper just plumbs it through the open-union
|
|
5121
|
-
* Challenge type and the `viem`/`mppx` dynamic imports so consumers don't
|
|
5122
|
-
* carry the dependency surface directly.
|
|
5123
|
-
*
|
|
5124
|
-
* The DVM authors the amount, so this is also where the caller refuses one it
|
|
5125
|
-
* never agreed to. Every Tempo signing path in the CLI goes through here —
|
|
5126
|
-
* credit funding, upfront per-call, mid-job top-up — which is why the ceiling
|
|
5127
|
-
* lives at this choke point rather than in each leg, exactly as
|
|
5128
|
-
* x402's lives inside `tryX402Payment`.
|
|
4901
|
+
* Refuse an advertised charge above the caller's tolerance before handing it
|
|
4902
|
+
* to mppx for signing. Nonzero pull charges sign a Tempo transaction; zero
|
|
4903
|
+
* charges sign a typed proof and push mode returns a transaction hash.
|
|
5129
4904
|
*/
|
|
5130
4905
|
|
|
5131
|
-
/** Inputs to {@link buildTempoCredential}. */
|
|
5132
4906
|
interface BuildTempoCredentialArgs {
|
|
5133
4907
|
/** mppx challenges from the DVM (one per advertised method/intent). */
|
|
5134
4908
|
challenges: readonly MppxChallenge[];
|
|
@@ -5330,20 +5104,10 @@ declare function computeSmartDenominations(amountSats: number, opts?: SmartDenom
|
|
|
5330
5104
|
declare const WALLET_VERSION: 9;
|
|
5331
5105
|
/** Cap on the number of recent-spends entries persisted to the wallet. */
|
|
5332
5106
|
declare const RECENT_SPENDS_CAP = 10;
|
|
5333
|
-
/**
|
|
5334
|
-
* Default Cashu mint for the agent wallet. Used when
|
|
5335
|
-
* `wallet.mints` is empty. May 8 mint matrix selected Coinos as the alpha
|
|
5336
|
-
* default; runtime can fall back across the configured mint list.
|
|
5337
|
-
*/
|
|
5107
|
+
/** Used when wallet.mints is empty; configured alternatives remain available. */
|
|
5338
5108
|
declare const DEFAULT_AGENT_MINT_URL: "https://mint.coinos.io";
|
|
5339
|
-
/**
|
|
5340
|
-
* A Cashu proof persisted in the agent wallet, tagged with the issuing mint
|
|
5341
|
-
* and the lock pubkey it's locked to. Schema v2 widens the v1 shape (a
|
|
5342
|
-
* bare ProofLike) so multi-mint balance views in don't have to
|
|
5343
|
-
* back-fill mint information.
|
|
5344
|
-
*/
|
|
5109
|
+
/** Persisted proof with issuing mint and independent NUT-11 lock authority. */
|
|
5345
5110
|
interface AgentProof {
|
|
5346
|
-
/** Mint URL that issued this proof. */
|
|
5347
5111
|
mint: string;
|
|
5348
5112
|
/** Per-proof secret string (NUT-00 / NUT-11 envelope). */
|
|
5349
5113
|
secret: string;
|
|
@@ -5351,7 +5115,6 @@ interface AgentProof {
|
|
|
5351
5115
|
C: string;
|
|
5352
5116
|
/** Denomination, in sats. */
|
|
5353
5117
|
amount: number;
|
|
5354
|
-
/** Keyset ID under which the proof was issued. */
|
|
5355
5118
|
id: string;
|
|
5356
5119
|
/** Optional NUT-12 proof, including the blinding factor needed by enforcing mints. */
|
|
5357
5120
|
dleq?: SerializedDLEQ;
|
|
@@ -5363,12 +5126,8 @@ interface AgentProof {
|
|
|
5363
5126
|
* appears on outputs from `dvm wallet release --output unlocked`.
|
|
5364
5127
|
*/
|
|
5365
5128
|
locked_to_pubkey: string | null;
|
|
5366
|
-
/**
|
|
5367
|
-
*
|
|
5368
|
-
* to a DVM and reverted (or removed on success) once the response lands.
|
|
5369
|
-
* Stale `in_flight` proofs older than `in_flight_until_ms` are returned
|
|
5370
|
-
* to the spendable pool by the next wallet-touching command.
|
|
5371
|
-
*/
|
|
5129
|
+
/** Stale in_flight proofs become sweep candidates, except those committed to
|
|
5130
|
+
* pending melts or prepared swaps, whose outcomes require mint evidence. */
|
|
5372
5131
|
status: "valid" | "in_flight";
|
|
5373
5132
|
/**
|
|
5374
5133
|
* Wall-clock millis at which an `in_flight` proof becomes eligible for
|
|
@@ -5406,9 +5165,7 @@ interface AgentProof {
|
|
|
5406
5165
|
interface AgentRecentSpend {
|
|
5407
5166
|
/** UUIDv4 used as the per-call replay key (`X-Cashu-Request-Id`). */
|
|
5408
5167
|
request_id: string;
|
|
5409
|
-
/** HTTPS endpoint of the DVM the spend was sent to. */
|
|
5410
5168
|
dvm_endpoint: string;
|
|
5411
|
-
/** Mint URL the spent proofs were issued at. */
|
|
5412
5169
|
mint: string;
|
|
5413
5170
|
/** Total spend amount, in sats. */
|
|
5414
5171
|
amount_sats: number;
|
|
@@ -5457,7 +5214,6 @@ interface PendingMintMintingState {
|
|
|
5457
5214
|
* cleared once those outputs have been signed and persisted as proofs.
|
|
5458
5215
|
*/
|
|
5459
5216
|
interface PendingMint {
|
|
5460
|
-
/** Mint URL the quote was requested at. */
|
|
5461
5217
|
mint: string;
|
|
5462
5218
|
/** Quote ID returned by the mint; passed to `checkMintQuoteBolt11`. */
|
|
5463
5219
|
quote_id: string;
|
|
@@ -5752,7 +5508,7 @@ interface AgentWallet {
|
|
|
5752
5508
|
mnemonic_fingerprint: string | null;
|
|
5753
5509
|
/** Cashu mint URLs the wallet trusts, in selection order. */
|
|
5754
5510
|
mints: string[];
|
|
5755
|
-
/** Locally
|
|
5511
|
+
/** Locally held proofs, with each proof recording its own lock authority. */
|
|
5756
5512
|
proofs: AgentProof[];
|
|
5757
5513
|
/**
|
|
5758
5514
|
* NUT-13 deterministic-secret counters per `(mint_url, keyset_id)`
|
|
@@ -5789,31 +5545,10 @@ interface AgentWallet {
|
|
|
5789
5545
|
/** ISO-8601 wallet creation timestamp. */
|
|
5790
5546
|
created_at: string;
|
|
5791
5547
|
}
|
|
5792
|
-
/**
|
|
5793
|
-
*
|
|
5794
|
-
*
|
|
5795
|
-
*
|
|
5796
|
-
* the fund flow and is expected to be empty); fresh recent_spends,
|
|
5797
|
-
* pending_submissions, nut13_counters; `mnemonic_fingerprint: null`.
|
|
5798
|
-
* - v2 → v9: preserves all v2 fields, adds empty recent_spends,
|
|
5799
|
-
* pending_submissions, nut13_counters.
|
|
5800
|
-
* - v3 → v9: renames recovery_pubkey/recovery_privkey → lock_pubkey/lock_privkey;
|
|
5801
|
-
* adds empty pending_submissions, nut13_counters.
|
|
5802
|
-
* - v4 → v9: adds empty pending_submissions, nut13_counters
|
|
5803
|
-
* - v5 → v9: adds empty nut13_counters and a null mnemonic_fingerprint
|
|
5804
|
-
* A v5 wallet inherits NUT-13 inactive — `getWallet` will
|
|
5805
|
-
* stay in degraded mode until the user runs `dvm wallet restore
|
|
5806
|
-
* <mnemonic>` to re-attach the sibling `~/.dvm/wallet.mnemonic`.
|
|
5807
|
-
* - v6 → v9: pass-through for the v7 step. Existing proofs are
|
|
5808
|
-
* free-balance, so `reserved_for` and `t_expire` remain unset;
|
|
5809
|
-
* `dvm wallet reserve` populates them on new pre-fund proofs.
|
|
5810
|
-
* - v7 → v9: adds empty pending_melts. No wallet predating the
|
|
5811
|
-
* cash-out verb can have a melt in flight, so an empty list is exact.
|
|
5812
|
-
* - v8 → v9: preserves pending mints without `expires_at`; the recovery sweep
|
|
5813
|
-
* applies its bounded legacy fallback to those entries.
|
|
5814
|
-
* Throws `DvmError("wallet_unknown_version", ...)` for files written by a
|
|
5815
|
-
* newer CLI so we never silently corrupt a future schema by treating it as v9.
|
|
5816
|
-
*/
|
|
5548
|
+
/** Missing files return null; earlier supported schemas migrate in memory to v9.
|
|
5549
|
+
* Populated v1 legacy state is refused. Wallets without a bound mnemonic stay
|
|
5550
|
+
* NUT-13 inactive; old pending mints retain missing expiry for recovery fallback.
|
|
5551
|
+
* Unknown versions fail instead of being interpreted as the current schema. */
|
|
5817
5552
|
declare function loadAgentWallet(): AgentWallet | null;
|
|
5818
5553
|
/**
|
|
5819
5554
|
* Atomically write the wallet to `~/.dvm/wallet.json` with mode 0600. The
|
|
@@ -5965,16 +5700,7 @@ declare function prepareP2PKMint(cashuWallet: Wallet, sats: number, quote: MintQ
|
|
|
5965
5700
|
*/
|
|
5966
5701
|
declare function maxKeysetDenomination(cashuWallet: Wallet): number | undefined;
|
|
5967
5702
|
|
|
5968
|
-
/**
|
|
5969
|
-
* Single source of truth for mint inventory across `dvm wallet show`,
|
|
5970
|
-
* `dvm wallet mint-list`, and `dvm wallet mint-health`. All three
|
|
5971
|
-
* commands historically disagreed: `mint-add` wrote to `config.cashuMints`
|
|
5972
|
-
* while `wallet show` read from `wallet.mints` via `effectiveMints()`, which
|
|
5973
|
-
* silently injected {@link DEFAULT_AGENT_MINT_URL} as a fallback. This
|
|
5974
|
-
* module makes `wallet.mints` the canonical store and surfaces the implicit
|
|
5975
|
-
* default as a labeled `source: "default"` entry rather than conflating it
|
|
5976
|
-
* with explicit configuration.
|
|
5977
|
-
*/
|
|
5703
|
+
/** `wallet.mints` is canonical; the implicit default is labeled separately from configuration. */
|
|
5978
5704
|
|
|
5979
5705
|
/**
|
|
5980
5706
|
* Where an entry in the wallet's displayed mint inventory came from. Shared
|
|
@@ -5994,9 +5720,7 @@ declare function maxKeysetDenomination(cashuWallet: Wallet): number | undefined;
|
|
|
5994
5720
|
* callers that probe arbitrary URLs against the wallet's configured list.
|
|
5995
5721
|
*/
|
|
5996
5722
|
type MintSource = "configured" | "default" | "proofs" | "pending" | "ad_hoc";
|
|
5997
|
-
/** A single entry in the wallet's displayed mint inventory. */
|
|
5998
5723
|
interface MintInventoryEntry {
|
|
5999
|
-
/** Mint URL. */
|
|
6000
5724
|
url: string;
|
|
6001
5725
|
/** Why this URL appears in the inventory — see {@link MintSource}. */
|
|
6002
5726
|
source: MintSource;
|
|
@@ -6076,11 +5800,9 @@ type SelectError = {
|
|
|
6076
5800
|
message: string;
|
|
6077
5801
|
hint: string;
|
|
6078
5802
|
};
|
|
6079
|
-
/** Successful per-mint selection. */
|
|
6080
5803
|
interface SelectionResult {
|
|
6081
5804
|
/** The chosen proofs, in the order they should be sent to the DVM. */
|
|
6082
5805
|
selected: AgentProof[];
|
|
6083
|
-
/** The mint URL all selected proofs are issued at. */
|
|
6084
5806
|
mint: string;
|
|
6085
5807
|
/** Sum of `selected[].amount`, in sats. Equals `amountSats + the swap's reserve` or more — overshoot returns as `keep` change. */
|
|
6086
5808
|
totalSats: number;
|
|
@@ -6159,7 +5881,6 @@ declare function coveringMintsForSpend(args: {
|
|
|
6159
5881
|
interface CashuSubmissionBinding {
|
|
6160
5882
|
/** Immutable DVM identity resolved from the live descriptor. */
|
|
6161
5883
|
dvmId: string;
|
|
6162
|
-
/** Capability dispatched by the request. */
|
|
6163
5884
|
capability: string;
|
|
6164
5885
|
/** Exact unsigned `/v1/job` payload persisted for same-request recovery. */
|
|
6165
5886
|
requestBody: Record<string, unknown>;
|
|
@@ -6326,8 +6047,6 @@ declare const X402_BATCH_CHANNEL_ABI: readonly [{
|
|
|
6326
6047
|
}];
|
|
6327
6048
|
}];
|
|
6328
6049
|
|
|
6329
|
-
/** Durable caller-side storage for reusable x402 batch-settlement channels. */
|
|
6330
|
-
|
|
6331
6050
|
/** Immutable channel configuration needed by the unilateral withdrawal verbs. */
|
|
6332
6051
|
interface StoredX402ChannelConfig {
|
|
6333
6052
|
payer: `0x${string}`;
|
|
@@ -6367,7 +6086,8 @@ interface PendingX402Funding {
|
|
|
6367
6086
|
* payer put its name to, and a deposit's authorized value can exceed the funded amount
|
|
6368
6087
|
* so both are journalled from the payload at signing time
|
|
6369
6088
|
* rather than recomputed from the request. Optional because entries written
|
|
6370
|
-
* before this field existed are still on disk;
|
|
6089
|
+
* before this field existed are still on disk; reservation consumers must
|
|
6090
|
+
* handle missing or unreadable authority conservatively.
|
|
6371
6091
|
*/
|
|
6372
6092
|
maxClaimableMicro?: string;
|
|
6373
6093
|
/** ERC-3009 value on a deposit payload; absent on a voucher-only payload. */
|
|
@@ -6375,7 +6095,7 @@ interface PendingX402Funding {
|
|
|
6375
6095
|
/** Unix seconds after which a deposit authorization can no longer be submitted. */
|
|
6376
6096
|
authorizationValidBefore?: string;
|
|
6377
6097
|
/**
|
|
6378
|
-
*
|
|
6098
|
+
* A recorded terminal refusal, excluded from verbatim resumption. Marked
|
|
6379
6099
|
* rather than deleted, because the entry carries two signed things with
|
|
6380
6100
|
* different lifetimes and only one of them dies on a clock: the
|
|
6381
6101
|
* ERC-3009 deposit authorization, dead at `authorizationValidBefore`, and the
|
|
@@ -6478,12 +6198,9 @@ declare function listResumableX402ExactFundings(filter?: {
|
|
|
6478
6198
|
*/
|
|
6479
6199
|
declare function clearPendingX402ExactFunding(pending: PendingX402ExactFunding): void;
|
|
6480
6200
|
/**
|
|
6481
|
-
*
|
|
6482
|
-
*
|
|
6483
|
-
*
|
|
6484
|
-
* `x402-clear-pending` will retire without `--force`. Never a gate: nothing
|
|
6485
|
-
* refuses on age, because a signed authorization is exactly as claimable at 25
|
|
6486
|
-
* hours as at 25 minutes.
|
|
6201
|
+
* Age at which an active unacknowledged voucher is reported as abandoned and
|
|
6202
|
+
* may be retired without force. Age alone does not revoke its signed authority.
|
|
6203
|
+
* Retired deposits have a separate authorization-expiry gate.
|
|
6487
6204
|
*/
|
|
6488
6205
|
declare const X402_PENDING_STALE_MS: number;
|
|
6489
6206
|
/** Whether an entry has gone long enough unacknowledged to read as abandoned. */
|
|
@@ -6624,7 +6341,6 @@ declare function acknowledgeX402ChannelOwner(owner: Pick<StoredX402ChannelMetada
|
|
|
6624
6341
|
declare function listX402Channels(filter?: {
|
|
6625
6342
|
payer?: string;
|
|
6626
6343
|
}): StoredX402ChannelMetadata[];
|
|
6627
|
-
/** Find a channel by id, or by the DVM credit it backs. */
|
|
6628
6344
|
declare function findX402Channel(args: {
|
|
6629
6345
|
channelId?: string;
|
|
6630
6346
|
endpoint?: string;
|
|
@@ -6734,22 +6450,19 @@ declare function x402ReservationRelease(journalled: PendingX402Funding[]): {
|
|
|
6734
6450
|
retriable: boolean;
|
|
6735
6451
|
};
|
|
6736
6452
|
|
|
6737
|
-
/** Caller-side x402 batch-settlement signing, recovery, and cooperative refund. */
|
|
6738
|
-
|
|
6739
6453
|
/** Signed payment, the channel it advances, and what its signature covers. */
|
|
6740
6454
|
interface X402BatchPayment extends X402VoucherFacts {
|
|
6741
6455
|
paymentHeader: string;
|
|
6742
6456
|
channelId: `0x${string}`;
|
|
6743
6457
|
scheme: BatchSettlementEvmScheme;
|
|
6744
6458
|
}
|
|
6745
|
-
/** Build one deposit or cumulative voucher from a server challenge. */
|
|
6746
6459
|
declare function createX402BatchPayment(args: {
|
|
6747
6460
|
wallet: X402Wallet;
|
|
6748
6461
|
paymentRequired: PaymentRequired$1;
|
|
6749
6462
|
endpoint: string;
|
|
6750
6463
|
callerPubkey: string;
|
|
6751
6464
|
creditId: string;
|
|
6752
|
-
/**
|
|
6465
|
+
/** Deposit policy in token micro-units, raised to upstream's required minimum. */
|
|
6753
6466
|
depositMicro: number;
|
|
6754
6467
|
}): Promise<X402BatchPayment>;
|
|
6755
6468
|
/**
|
|
@@ -6789,41 +6502,17 @@ interface X402ChannelReconciliation {
|
|
|
6789
6502
|
/** What the contract says has already been claimed out of it. */
|
|
6790
6503
|
totalClaimedMicro: string;
|
|
6791
6504
|
/**
|
|
6792
|
-
*
|
|
6793
|
-
*
|
|
6794
|
-
*
|
|
6795
|
-
* ever added to the stored balance in the first place, and the chain figure
|
|
6796
|
-
* replaces the whole projection rather than reversing anything entry by
|
|
6797
|
-
* entry — so these ids say which journal the repair was taken beside, not
|
|
6798
|
-
* what it subtracted.
|
|
6799
|
-
*
|
|
6800
|
-
* At least one of them is provably lapsed and unconsumed. One, not all:
|
|
6801
|
-
* `channels()` answers for the entire channel, so the probe stops at the
|
|
6802
|
-
* first proof and the rest carry no claim about their own deadlines or
|
|
6803
|
-
* nonces, including ones still inside their validity window.
|
|
6505
|
+
* Refused candidate IDs associated with replacing the whole-channel projection,
|
|
6506
|
+
* not individually subtracted amounts. Only one is necessarily proven expired
|
|
6507
|
+
* and unused; the remaining authorizations may still be live.
|
|
6804
6508
|
*/
|
|
6805
6509
|
fundIds: string[];
|
|
6806
6510
|
}
|
|
6807
6511
|
/**
|
|
6808
|
-
*
|
|
6809
|
-
* its
|
|
6810
|
-
*
|
|
6811
|
-
*
|
|
6812
|
-
* every money decision on this rail already reads the chain: the stored figure
|
|
6813
|
-
* is a running local sum with no audit trail, so subtracting from it would
|
|
6814
|
-
* produce a second guess rather than an answer. Overwriting it with what the
|
|
6815
|
-
* contract holds is the only move that ends with the projection *equal* to
|
|
6816
|
-
* chain rather than merely less wrong.
|
|
6817
|
-
*
|
|
6818
|
-
* The proof is {@link canReplaceExpiredX402Deposit}'s, unchanged: the
|
|
6819
|
-
* authorization is past its deadline and its nonce was never consumed, so the
|
|
6820
|
-
* deposit can no longer land and never did. Without it the read would be a
|
|
6821
|
-
* race — a deposit still in flight reads as absent one block before it settles,
|
|
6822
|
-
* and writing that back would push the projection *below* chain.
|
|
6823
|
-
*
|
|
6824
|
-
* `chargedCumulativeAmount` is deliberately untouched. It is the base the next
|
|
6825
|
-
* voucher signs from, and lowering it to a figure the DVM has already exceeded
|
|
6826
|
-
* is how a caller signs a cumulative cap that reads as a replay.
|
|
6512
|
+
* Replace the channel projection from `channels()` only after a refused deposit
|
|
6513
|
+
* is expired and its nonce proven unused. Subtracting a local deposit would
|
|
6514
|
+
* not establish chain truth; reading while it can still land races submission.
|
|
6515
|
+
* Keep the authorized cumulative cursor, which the DVM may already have used.
|
|
6827
6516
|
*/
|
|
6828
6517
|
declare function reconcileRefusedX402Deposits(args: {
|
|
6829
6518
|
wallet: X402Wallet;
|
|
@@ -6859,18 +6548,14 @@ interface X402RefundOutcome {
|
|
|
6859
6548
|
* while returning the DVM's credit result to the CLI.
|
|
6860
6549
|
*/
|
|
6861
6550
|
declare function refundX402BatchChannel(args: X402RefundArgs): Promise<X402RefundOutcome>;
|
|
6862
|
-
/** What the drain needs to find the channel it is closing, and to close it. */
|
|
6863
6551
|
interface X402RefundArgs {
|
|
6864
6552
|
wallet: X402Wallet;
|
|
6865
6553
|
endpoint: string;
|
|
6866
|
-
/** Caller identity the channel was recorded under, half of the metadata key. */
|
|
6867
6554
|
callerPubkey: string;
|
|
6868
|
-
/** DVM credit the channel backs — the other half. */
|
|
6869
6555
|
creditId: string;
|
|
6870
6556
|
depositMicro: number;
|
|
6871
6557
|
post: (paymentHeader?: string) => Promise<CreditOpResult>;
|
|
6872
6558
|
}
|
|
6873
|
-
/** Read a decoded x402 challenge attached by the HTTPS transport. */
|
|
6874
6559
|
declare function x402RequiredFromError(err: DvmError): PaymentRequired$1 | undefined;
|
|
6875
6560
|
/**
|
|
6876
6561
|
* Assert that a DVM challenge still derives the channel recorded for this
|
|
@@ -6884,7 +6569,6 @@ declare function assertX402RequirementDescribesChannel(args: {
|
|
|
6884
6569
|
depositMicro: number;
|
|
6885
6570
|
}): void;
|
|
6886
6571
|
|
|
6887
|
-
/** x402 private-key environment variables understood by the shared validator. */
|
|
6888
6572
|
declare const X402_SELF_RELAY_KEY = "DVMKIT_X402_SELF_RELAY_KEY";
|
|
6889
6573
|
declare const X402_RECEIVER_AUTHORIZER_KEY = "DVMKIT_X402_RECEIVER_AUTHORIZER_KEY";
|
|
6890
6574
|
declare const X402_BATCH_SETTLEMENT_KEY = "DVMKIT_X402_BATCH_SETTLEMENT";
|
|
@@ -6894,7 +6578,6 @@ interface X402DerivedAddresses {
|
|
|
6894
6578
|
relay?: `0x${string}`;
|
|
6895
6579
|
authorizer?: `0x${string}`;
|
|
6896
6580
|
}
|
|
6897
|
-
/** Options for validating a complete environment or a write-only environment patch. */
|
|
6898
6581
|
interface X402EnvValidationOptions {
|
|
6899
6582
|
/** Require a key-rotation patch to carry every value needed for proof. */
|
|
6900
6583
|
requireCompleteBundle?: boolean;
|
|
@@ -6905,15 +6588,12 @@ interface X402EnvValidationOptions {
|
|
|
6905
6588
|
}
|
|
6906
6589
|
/** Safe validation failure which names variables and public addresses, never private values. */
|
|
6907
6590
|
declare class X402EnvValidationError extends Error {
|
|
6908
|
-
/** Machine-readable validation code. */
|
|
6909
6591
|
readonly code: string;
|
|
6910
6592
|
/** Environment variable whose value or dependency failed validation. */
|
|
6911
6593
|
readonly variable: string;
|
|
6912
6594
|
/** Expected public address, when the failure was an address mismatch. */
|
|
6913
6595
|
readonly expectedAddress?: string | undefined;
|
|
6914
|
-
constructor(
|
|
6915
|
-
/** Machine-readable validation code. */
|
|
6916
|
-
code: string,
|
|
6596
|
+
constructor(code: string,
|
|
6917
6597
|
/** Environment variable whose value or dependency failed validation. */
|
|
6918
6598
|
variable: string, message: string,
|
|
6919
6599
|
/** Expected public address, when the failure was an address mismatch. */
|
|
@@ -6928,23 +6608,11 @@ declare class X402EnvValidationError extends Error {
|
|
|
6928
6608
|
*/
|
|
6929
6609
|
declare function validateX402Env(env: Record<string, string | undefined>, opts?: X402EnvValidationOptions): X402DerivedAddresses;
|
|
6930
6610
|
|
|
6931
|
-
/**
|
|
6932
|
-
* The chains the x402 rail settles on — one row each, and the only place a
|
|
6933
|
-
* chain is described.
|
|
6934
|
-
*
|
|
6935
|
-
* This file exists because the rail used to describe a chain in four places: a
|
|
6936
|
-
* contract map and two EIP-712 domain maps in `spec.ts`, a viem chain-loader
|
|
6937
|
-
* map in `wallet.ts`, and a label/confusable pair in `asset.ts`. They drifted —
|
|
6938
|
-
* the loader map carried two chains, the contract map six — so `--network`
|
|
6939
|
-
* accepted five chains the balance read then threw on, and a funded Polygon
|
|
6940
|
-
* wallet reported as unreachable. A row here is the whole description of a
|
|
6941
|
-
* chain; a chain the rail can't do everything for doesn't get one.
|
|
6942
|
-
*/
|
|
6943
6611
|
/** Everything the x402 rail needs to know about one settlement chain. */
|
|
6944
6612
|
interface X402Network {
|
|
6945
6613
|
/** CAIP-2 chain id — the form the caller wallet and DVM configs are written in. */
|
|
6946
6614
|
caip2: string;
|
|
6947
|
-
/**
|
|
6615
|
+
/** Legacy v1 network slug; v2 uses CAIP-2. */
|
|
6948
6616
|
slug: string;
|
|
6949
6617
|
/** Human name for copy ("Base"). */
|
|
6950
6618
|
label: string;
|
|
@@ -6969,27 +6637,9 @@ interface X402Network {
|
|
|
6969
6637
|
* test pins it against viem so the two can't drift.
|
|
6970
6638
|
*/
|
|
6971
6639
|
nativeGas: string;
|
|
6972
|
-
/**
|
|
6973
|
-
* Ticker of the dollar most often confused for the native one here, or null
|
|
6974
|
-
* where there isn't a well-known one.
|
|
6975
|
-
*
|
|
6976
|
-
* Every mainnet listed predates Circle issuing natively on it, so each
|
|
6977
|
-
* carries a widely-held bridged dollar from that era: USDbC on Base, USDC.e
|
|
6978
|
-
* on Polygon (the PoS-bridge dollar) and on Avalanche (the Avalanche-bridge
|
|
6979
|
-
* dollar). All three still appear in wallet and exchange menus, and none is
|
|
6980
|
-
* spendable here. Testnets are null — nobody holds a bridged testnet dollar
|
|
6981
|
-
* by accident.
|
|
6982
|
-
*/
|
|
6640
|
+
/** Bridged token commonly confused with native USDC, or null if unnamed. */
|
|
6983
6641
|
confusable: string | null;
|
|
6984
6642
|
}
|
|
6985
|
-
/**
|
|
6986
|
-
* Every chain the rail supports end to end: a USDC contract to settle against,
|
|
6987
|
-
* an EIP-712 domain to sign with, and a viem chain to read the balance on.
|
|
6988
|
-
*
|
|
6989
|
-
* Adding a row is the whole job of adding a chain. Dropping one of the three
|
|
6990
|
-
* facts is what this table exists to prevent, and `networks.test.ts` fails a
|
|
6991
|
-
* row whose `viemChain` doesn't resolve to a chain with the matching id.
|
|
6992
|
-
*/
|
|
6993
6643
|
declare const X402_NETWORKS: readonly X402Network[];
|
|
6994
6644
|
/** Look up a chain by CAIP-2 id (`eip155:8453`). Undefined when unsupported. */
|
|
6995
6645
|
declare function x402NetworkByCaip2(caip2: string): X402Network | undefined;
|
|
@@ -7020,33 +6670,8 @@ declare function x402SupportedNetworksHint(): string;
|
|
|
7020
6670
|
|
|
7021
6671
|
declare function loadX402Wallet(): X402Wallet | null;
|
|
7022
6672
|
declare function ensureAddress(wallet: X402Wallet): Promise<X402Wallet>;
|
|
7023
|
-
/**
|
|
7024
|
-
* The payer address the configured x402 key pays as, or `null` when no usable
|
|
7025
|
-
* key is configured.
|
|
7026
|
-
*
|
|
7027
|
-
* A purely local read, and the x402 twin of `connectedTempoAccount`: every
|
|
7028
|
-
* channel record names the payer that opened it, so "is this channel this
|
|
7029
|
-
* wallet's" is answerable with no chain call and no network at all, which is
|
|
7030
|
-
* what lets `dvm doctor` answer it under `--no-network`.
|
|
7031
|
-
*
|
|
7032
|
-
* A key too malformed to derive an address from reads as no key, exactly as its
|
|
7033
|
-
* Tempo twin does. It is the one answer that can't mislead here: the reporting
|
|
7034
|
-
* surfaces say "nothing on this machine can withdraw these channels", which is
|
|
7035
|
-
* true of an unusable key, and the shape of the key itself is `dvm doctor`'s
|
|
7036
|
-
* `config_x402_shape` row to report rather than this one's.
|
|
7037
|
-
*/
|
|
6673
|
+
/** Local ownership read; returns null for an absent or unusable configured key. */
|
|
7038
6674
|
declare function connectedX402Payer(): Promise<string | null>;
|
|
7039
|
-
/**
|
|
7040
|
-
* Mint a fresh EVM private key for the x402 rail.
|
|
7041
|
-
*
|
|
7042
|
-
* The caller shouldn't have to manufacture and transport a 32-byte secret to
|
|
7043
|
-
* get onto a rail — `dvm wallet x402-connect` with no key source calls this,
|
|
7044
|
-
* exactly as `dvm wallet tempo-connect` calls `generateTempoKey`. viem's
|
|
7045
|
-
* generator is the one implementation; it reads from the platform CSPRNG.
|
|
7046
|
-
*
|
|
7047
|
-
* The key goes straight into `saveX402Wallet` and is never returned to an
|
|
7048
|
-
* output surface — only the address derived from it is.
|
|
7049
|
-
*/
|
|
7050
6675
|
declare function generateX402PrivateKey(): Promise<`0x${string}`>;
|
|
7051
6676
|
/** What `saveX402Wallet` persisted — the derived address and the chain it resolved to. */
|
|
7052
6677
|
interface X402ConnectedWallet {
|
|
@@ -7574,22 +7199,12 @@ declare function railLabelAtSentenceStart(label: string): string;
|
|
|
7574
7199
|
/** Quote one argument for safe copy/paste into a POSIX shell command. */
|
|
7575
7200
|
declare function shellQuoteArg(value: string): string;
|
|
7576
7201
|
|
|
7577
|
-
/**
|
|
7578
|
-
* Verify a BIP-340 Schnorr signature against a 32-byte challenge and a
|
|
7579
|
-
* compressed (33-byte, `02`/`03` prefix) or x-only (32-byte) public key.
|
|
7580
|
-
* Compressed inputs have their parity byte dropped — BIP-340 keys are
|
|
7581
|
-
* x-only — and the y-coordinate is recomputed inside cashu-ts when
|
|
7582
|
-
* needed.
|
|
7583
|
-
*/
|
|
7202
|
+
/** BIP-340 verification accepts compressed or x-only public keys; compressed parity bytes are dropped. */
|
|
7584
7203
|
declare function verifyChallenge(pubkeyHex: string, challenge: Uint8Array, sigHex: string): boolean;
|
|
7585
7204
|
|
|
7586
7205
|
/**
|
|
7587
|
-
*
|
|
7588
|
-
*
|
|
7589
|
-
* Defaults to `~/.dvm`. The `DVM_CONFIG_DIR` env override lets an operator
|
|
7590
|
-
* run a parallel state tree (e.g. `DVM_CONFIG_DIR=~/.dvm-test`) without
|
|
7591
|
-
* touching their real wallet. Resolved once at import time;
|
|
7592
|
-
* setting the env after the process boots has no effect.
|
|
7206
|
+
* Caller state defaults to ~/.dvm; DVM_CONFIG_DIR redirects it at import time.
|
|
7207
|
+
* Builder state is independently redirected, so the two identities stay separate.
|
|
7593
7208
|
*/
|
|
7594
7209
|
declare const CONFIG_DIR: string;
|
|
7595
7210
|
declare const CONFIG_FILE: string;
|
|
@@ -7663,10 +7278,8 @@ declare const FEEDBACK_NUDGES_FILE: string;
|
|
|
7663
7278
|
declare const RECOVERY_MNEMONIC_FILE: string;
|
|
7664
7279
|
declare const WALLET_FILE: string;
|
|
7665
7280
|
/**
|
|
7666
|
-
*
|
|
7667
|
-
*
|
|
7668
|
-
* principles design note; only its `mnemonic_fingerprint` lives on the
|
|
7669
|
-
* wallet record. Mirrors the builder pattern at {@link BUILDER_MNEMONIC_FILE}.
|
|
7281
|
+
* Agent BIP-39 mnemonic, mode 0600. Kept outside wallet.json so resetting
|
|
7282
|
+
* proof state does not discard the recovery identity.
|
|
7670
7283
|
*/
|
|
7671
7284
|
declare const AGENT_MNEMONIC_FILE: string;
|
|
7672
7285
|
/**
|
|
@@ -8017,7 +7630,6 @@ declare function redactUrl(url: string): string;
|
|
|
8017
7630
|
*/
|
|
8018
7631
|
declare function redactUrlsInText(text: string): string;
|
|
8019
7632
|
|
|
8020
|
-
/** Outcome of a {@link writeAgentMnemonic} call. */
|
|
8021
7633
|
interface WriteAgentMnemonicResult {
|
|
8022
7634
|
/**
|
|
8023
7635
|
* Path of the timestamped 0600 copy of the mnemonic that was replaced, or
|
|
@@ -8192,11 +7804,8 @@ interface CashOutMintOptions {
|
|
|
8192
7804
|
declare function cashOutFromMint(opts: CashOutMintOptions): Promise<CashOutMintOutcome>;
|
|
8193
7805
|
declare function spendableAt(proofs: AgentProof[], mintUrl: string): AgentProof[];
|
|
8194
7806
|
|
|
8195
|
-
/** Return value from {@link sweepStaleInFlight}. */
|
|
8196
7807
|
interface InFlightSweepResult {
|
|
8197
|
-
/** New wallet object with stale `in_flight` proofs reverted. */
|
|
8198
7808
|
wallet: AgentWallet;
|
|
8199
|
-
/** Number of proofs swept back to `valid`. */
|
|
8200
7809
|
reverted: number;
|
|
8201
7810
|
}
|
|
8202
7811
|
/**
|
|
@@ -8218,7 +7827,6 @@ interface InFlightSweepResult {
|
|
|
8218
7827
|
*/
|
|
8219
7828
|
declare function sweepStaleInFlight(wallet: AgentWallet, nowMs: number): InFlightSweepResult;
|
|
8220
7829
|
|
|
8221
|
-
/** Regex for a 32-byte secp256k1 private key in lowercase or mixed-case hex. */
|
|
8222
7830
|
declare const PRIVKEY_HEX_RE: RegExp;
|
|
8223
7831
|
/**
|
|
8224
7832
|
* Derive the compressed secp256k1 public key from a hex-encoded private key.
|
|
@@ -8256,9 +7864,7 @@ declare function formatLocktime(seconds: number): string;
|
|
|
8256
7864
|
|
|
8257
7865
|
/** Why the selector replaced the preferred funding mint. */
|
|
8258
7866
|
type FundFallbackKind = "health" | "capability" | "bounds" | null;
|
|
8259
|
-
/** Details of a preferred mint replaced by a configured alternative. */
|
|
8260
7867
|
interface FundMintFallback {
|
|
8261
|
-
/** Mint the caller would otherwise have used. */
|
|
8262
7868
|
preferred: string;
|
|
8263
7869
|
/** Configured mint selected for this amount. */
|
|
8264
7870
|
selected: string;
|
|
@@ -8266,7 +7872,6 @@ interface FundMintFallback {
|
|
|
8266
7872
|
reason: string;
|
|
8267
7873
|
}
|
|
8268
7874
|
interface FundMintSelection {
|
|
8269
|
-
/** Mint URL the caller should use for the fund operation. */
|
|
8270
7875
|
url: string;
|
|
8271
7876
|
/** Category of fallback, or `null` when the preferred mint was selected. */
|
|
8272
7877
|
fallbackKind: FundFallbackKind;
|
|
@@ -8275,7 +7880,6 @@ interface FundMintSelection {
|
|
|
8275
7880
|
/** Present when an alternative replaced the preferred mint. */
|
|
8276
7881
|
fallback?: FundMintFallback;
|
|
8277
7882
|
}
|
|
8278
|
-
/** Inputs for {@link resolveFundMint}. */
|
|
8279
7883
|
interface ResolveFundMintOptions {
|
|
8280
7884
|
/** Mint selected by the caller or wallet configuration. */
|
|
8281
7885
|
preferred: string;
|
|
@@ -8297,7 +7901,6 @@ interface ResolveFundMintOptions {
|
|
|
8297
7901
|
* manual fund flow has always exposed.
|
|
8298
7902
|
*/
|
|
8299
7903
|
declare function resolveFundMint(args: ResolveFundMintOptions): Promise<FundMintSelection>;
|
|
8300
|
-
/** Format advertised issuance bounds for caller-facing explanations. */
|
|
8301
7904
|
declare function describeMintBounds(bounds: MintAmountBounds | undefined): string;
|
|
8302
7905
|
|
|
8303
7906
|
/** The agent master keypair derived from a BIP-39 mnemonic. Both halves are hex. */
|
|
@@ -8307,7 +7910,6 @@ interface AgentMasterKeypair {
|
|
|
8307
7910
|
/** 33-byte compressed secp256k1 public key, lowercase hex (66 chars). */
|
|
8308
7911
|
pubkey: string;
|
|
8309
7912
|
}
|
|
8310
|
-
/** Structured result of validating a candidate BIP-39 mnemonic. */
|
|
8311
7913
|
type MnemonicValidationResult = {
|
|
8312
7914
|
ok: true;
|
|
8313
7915
|
} | {
|
|
@@ -8325,13 +7927,7 @@ type MnemonicValidationResult = {
|
|
|
8325
7927
|
};
|
|
8326
7928
|
/** Generate a fresh 12-word BIP-39 mnemonic for a new agent wallet. */
|
|
8327
7929
|
declare function generateAgentMnemonic(): string;
|
|
8328
|
-
/**
|
|
8329
|
-
* Derive the agent master keypair from a BIP-39 mnemonic at `m/1789'/1'`.
|
|
8330
|
-
*
|
|
8331
|
-
* The privkey is the wallet's signing identity (what we store today as
|
|
8332
|
-
* `lock_privkey` in `~/.dvm/wallet.json`). The mnemonic itself is never
|
|
8333
|
-
* persisted — the user is responsible for backing it up out-of-band.
|
|
8334
|
-
*/
|
|
7930
|
+
/** The wallet signing identity at `m/1789'/1'`; persistence is handled separately. */
|
|
8335
7931
|
declare function deriveAgentMasterKeypair(mnemonic: string): AgentMasterKeypair;
|
|
8336
7932
|
/**
|
|
8337
7933
|
* Validate a candidate mnemonic and report which check failed, so the CLI can
|
|
@@ -8432,41 +8028,15 @@ interface ToAgentProofTags {
|
|
|
8432
8028
|
/** Convert a cashu-ts proof into the lossless agent-wallet disk shape. */
|
|
8433
8029
|
declare function toAgentProof(proof: Proof, mintUrl: string, lockedTo: string | null, tags?: ToAgentProofTags): AgentProof;
|
|
8434
8030
|
|
|
8435
|
-
/**
|
|
8436
|
-
* Claim an external Cashu token into the agent wallet. This is the
|
|
8437
|
-
* single supported path for taking an inbound token (a refund/change token a
|
|
8438
|
-
* DVM delivered, or a token handed over out-of-band) into spendable agent-
|
|
8439
|
-
* wallet balance — it replaces the deleted legacy `dvm wallet deposit --token`
|
|
8440
|
-
* plain-Cashu rail.
|
|
8441
|
-
*
|
|
8442
|
-
* The incoming swap is signed with the agent's master private key when a
|
|
8443
|
-
* NUT-11 P2PK lock's currently-required witness set includes the agent's
|
|
8444
|
-
* master pubkey, and its outputs are
|
|
8445
|
-
* **re-locked to that same** `lock_pubkey`. Plain proofs and expired P2PK locks
|
|
8446
|
-
* without a refund path pass the preflight: plain secrets are not NUT-11, and
|
|
8447
|
-
* cashu-ts reports no currently-required witness for the latter. An expired
|
|
8448
|
-
* lock with a refund path still exposes expected refund witnesses and is
|
|
8449
|
-
* checked against the agent's master key. This input-lock check is separate
|
|
8450
|
-
* from the wallet's `reserved_for` bookkeeping used by spend selection.
|
|
8451
|
-
*
|
|
8452
|
-
* A token P2PK-locked to a third party (one whose currently-required witness
|
|
8453
|
-
* pubkey the agent doesn't hold) is rejected up-front with `cashu_not_claimable`
|
|
8454
|
-
* rather than attempted-and-lost — a token locked to the agent's own key is
|
|
8455
|
-
* claimable (the agent signs the witness).
|
|
8456
|
-
*/
|
|
8457
|
-
|
|
8458
8031
|
interface ReceiveResult {
|
|
8459
|
-
/** Mint the token was claimed against. */
|
|
8460
8032
|
mintUrl: string;
|
|
8461
8033
|
/** Total sats claimed into spendable balance. */
|
|
8462
8034
|
claimedSats: number;
|
|
8463
|
-
/** Number of proofs persisted. */
|
|
8464
8035
|
proofCount: number;
|
|
8465
8036
|
}
|
|
8466
8037
|
interface ReceiveOptions {
|
|
8467
8038
|
/** Override `getWallet` for tests. */
|
|
8468
8039
|
getWalletForMint?: (mintUrl: string) => Promise<Wallet>;
|
|
8469
|
-
/** `Date.now` override for tests (locktime-expiry check). */
|
|
8470
8040
|
now?: () => number;
|
|
8471
8041
|
}
|
|
8472
8042
|
/**
|
|
@@ -9112,19 +8682,7 @@ declare function abandonPendingSubmission(args: {
|
|
|
9112
8682
|
requestId: string;
|
|
9113
8683
|
}): Promise<void>;
|
|
9114
8684
|
|
|
9115
|
-
/**
|
|
9116
|
-
* Shared prose for a rail's status, so `dvm doctor` and `dvm wallet balance`
|
|
9117
|
-
* describe the same failure with the same words.
|
|
9118
|
-
*
|
|
9119
|
-
* The probe layer (`wallet-probe.ts`) stays data-only; this is the rendering
|
|
9120
|
-
* half — what to call a rail, and what to say when one is configured but the
|
|
9121
|
-
* balance couldn't be read.
|
|
9122
|
-
*
|
|
9123
|
-
* The channel-exit refusals in `payment-rails/tempo-session.ts` render their
|
|
9124
|
-
* key-import advice from here too. Same reason, one surface wider:
|
|
9125
|
-
* a caller meets that advice from doctor, from a balance row and from a failed
|
|
9126
|
-
* exit, and three copies of it drifted onto two different import routes.
|
|
9127
|
-
*/
|
|
8685
|
+
/** Rendering stays separate from data-only probes; status and recovery hints share this vocabulary. */
|
|
9128
8686
|
|
|
9129
8687
|
/**
|
|
9130
8688
|
* ` via <endpoint>` for a balance a rail read over RPC, else `""`.
|
|
@@ -9140,24 +8698,9 @@ declare function rpcEndpointSuffix(rail: RailProbe): string;
|
|
|
9140
8698
|
* for a rail that read no endpoint.
|
|
9141
8699
|
*/
|
|
9142
8700
|
declare function rpcEndpointLine(rail: RailProbe): string | null;
|
|
9143
|
-
/**
|
|
9144
|
-
* The one-line diagnosis for a rail that is configured but wasn't reachable.
|
|
9145
|
-
*
|
|
9146
|
-
* "Not reachable" is the honest summary of an RPC that didn't answer, and a
|
|
9147
|
-
* wrong one for a wallet pinned to a chain this rail was never able to serve:
|
|
9148
|
-
* nothing is down, and no amount of retrying or reinstalling viem will change
|
|
9149
|
-
* the answer. The probe distinguishes them, so the copy does too.
|
|
9150
|
-
*/
|
|
8701
|
+
/** Unsupported chains need configuration changes rather than an unreachable-RPC diagnosis. */
|
|
9151
8702
|
declare function unreachableRailDisplay(rail: RailProbe): string;
|
|
9152
|
-
/**
|
|
9153
|
-
* The diagnosis line for an NWC connection the wallet *answered* and rejected,
|
|
9154
|
-
* or null for any other failure.
|
|
9155
|
-
*
|
|
9156
|
-
* "Not reachable" is wrong twice over here: the wallet is up and talking, and
|
|
9157
|
-
* the two rejections it can send want opposite things done about them. A
|
|
9158
|
-
* revoked connection has to be recreated; a restricted one exists, works, and
|
|
9159
|
-
* needs a permission or a higher cap — recreating that one reproduces it.
|
|
9160
|
-
*/
|
|
8703
|
+
/** Revoked connections need replacement; restricted connections need permission or budget changes. */
|
|
9161
8704
|
declare function nwcRejectionDisplay(rail: RailProbe): string | null;
|
|
9162
8705
|
/**
|
|
9163
8706
|
* The remedy for an unreachable rail. A probe that diagnosed the failure
|
|
@@ -9166,52 +8709,15 @@ declare function nwcRejectionDisplay(rail: RailProbe): string | null;
|
|
|
9166
8709
|
*/
|
|
9167
8710
|
declare function unreachableRailHint(rail: RailProbe): string;
|
|
9168
8711
|
/**
|
|
9169
|
-
*
|
|
9170
|
-
*
|
|
9171
|
-
*
|
|
9172
|
-
* Written once because six hints across `dvm doctor`, `dvm wallet balance` and
|
|
9173
|
-
* the channel-exit path each carried their own copy, and all six named
|
|
9174
|
-
* `--api-key <key>` — a flag whose value lands in shell history, `ps`,
|
|
9175
|
-
* `/proc/<pid>/cmdline` and any agent transcript that reads a command line back
|
|
9176
|
-
* Every one of them fires with real collateral locked behind a key
|
|
9177
|
-
* this machine no longer holds, which is the worst moment to teach that route.
|
|
9178
|
-
* Named routes only: `DVM_TEMPO_KEY` and `--key-file` mirror what the x402 twin
|
|
9179
|
-
* publishes, so a caller crossing rails reads one shape.
|
|
9180
|
-
*
|
|
9181
|
-
* `replacingConnectedKey` is a liveness question, not a stylistic one. A hint
|
|
9182
|
-
* that is safe but names a command the current state refuses has only traded
|
|
9183
|
-
* one defect for another, and `tempo-connect` refuses to import over
|
|
9184
|
-
* a wallet already configured without `--force`. Both sides judge "configured"
|
|
9185
|
-
* with the same secp256k1 scalar validator — `tempoAccountFromConfig` for the
|
|
9186
|
-
* connected account, `walletMppConnect` for the guard — so "a key is connected"
|
|
9187
|
-
* and "the import needs `--force`" are the same fact, and the caller passes it
|
|
9188
|
-
* exactly when they have one.
|
|
8712
|
+
* Key-import hints use a file or environment variable rather than a positional spending key.
|
|
8713
|
+
* Replacing an already connected key requires --force so the suggested command can run.
|
|
9189
8714
|
*/
|
|
9190
8715
|
declare function tempoKeyImportRoutes(opts: {
|
|
9191
8716
|
replacingConnectedKey: boolean;
|
|
9192
8717
|
}): string;
|
|
9193
|
-
/**
|
|
9194
|
-
* The whole hint for a chain-touching Tempo exit leg with no key to sign it.
|
|
9195
|
-
*
|
|
9196
|
-
* A constant rather than a sentence written twice: `advanceTempoChannelExit`
|
|
9197
|
-
* and `dvm wallet tempo-exit` refuse this same state one call apart, and their
|
|
9198
|
-
* two copies had already drifted — the caller's route was migrated off argv in
|
|
9199
|
-
* one and left on `--api-key` in the other. No `--force`, because
|
|
9200
|
-
* nothing reached this line with a key connected.
|
|
9201
|
-
*/
|
|
8718
|
+
/** With no connected key to replace, the exit recovery hint omits --force. */
|
|
9202
8719
|
declare const TEMPO_EXIT_KEY_MISSING_HINT: string;
|
|
9203
8720
|
|
|
9204
|
-
/**
|
|
9205
|
-
* Naming the dollar the x402 rail actually reads, so a wrong-asset or
|
|
9206
|
-
* wrong-chain balance stops reading as a plain `$0.00`.
|
|
9207
|
-
*
|
|
9208
|
-
* Mirrors the Tempo shape landed in `payment-rails/tempo-wallet.ts`
|
|
9209
|
-
* one resolver, one shared hint string, no copy literals at the
|
|
9210
|
-
* print sites — with the one structural difference that x402 is multi-network:
|
|
9211
|
-
* the settlement contract is a function of the wallet's configured chain, so
|
|
9212
|
-
* the copy has to name the network as well as the token.
|
|
9213
|
-
*/
|
|
9214
|
-
|
|
9215
8721
|
/** The USDC the x402 rail reads on one configured network. */
|
|
9216
8722
|
interface X402Asset extends RailAsset {
|
|
9217
8723
|
/** Human network name for copy ("Base"); the CAIP-2 id when we can't name it. */
|
|
@@ -9224,17 +8730,7 @@ interface X402Asset extends RailAsset {
|
|
|
9224
8730
|
*/
|
|
9225
8731
|
confusable: string | null;
|
|
9226
8732
|
}
|
|
9227
|
-
/**
|
|
9228
|
-
* Resolve the USDC the rail reads on `network`, defaulting to the same Base
|
|
9229
|
-
* chain id the wallet loader does.
|
|
9230
|
-
*
|
|
9231
|
-
* Returns null — rather than throwing, as `resolveTempoAsset` does on a bad
|
|
9232
|
-
* override — for a network outside the supported table. `--network` rejects
|
|
9233
|
-
* those at connect time, so the only way to reach this branch is a
|
|
9234
|
-
* config persisted before that validation existed; here it means "we have no
|
|
9235
|
-
* name to print", and a status surface must not abort over copy it merely
|
|
9236
|
-
* wanted.
|
|
9237
|
-
*/
|
|
8733
|
+
/** Returns null for unsupported networks so read-only naming can omit the asset. */
|
|
9238
8734
|
declare function resolveX402Asset(network?: string): X402Asset | null;
|
|
9239
8735
|
/**
|
|
9240
8736
|
* Why a funded-looking x402 wallet reads zero: the rail reads one contract on
|
|
@@ -9287,7 +8783,6 @@ interface X402ChannelRpc {
|
|
|
9287
8783
|
*/
|
|
9288
8784
|
declare function resolveX402ChannelRpc(channelNetwork: string, configuredNetwork: string, bundled: string | undefined): X402ChannelRpc;
|
|
9289
8785
|
|
|
9290
|
-
/** Inputs for `tryX402Payment`. */
|
|
9291
8786
|
interface X402PaymentRequest {
|
|
9292
8787
|
amountMsats: number;
|
|
9293
8788
|
/**
|
|
@@ -9300,7 +8795,6 @@ interface X402PaymentRequest {
|
|
|
9300
8795
|
payTo: string;
|
|
9301
8796
|
/** CAIP-2 chain id (`eip155:8453`). */
|
|
9302
8797
|
network: string;
|
|
9303
|
-
/** Asset ticker or contract address. Defaults to USDC for known networks. */
|
|
9304
8798
|
asset?: string;
|
|
9305
8799
|
/** Versioned challenge selected from `PAYMENT-REQUIRED` or the legacy 402 body. */
|
|
9306
8800
|
paymentRequired?: PaymentRequired;
|
|
@@ -9324,9 +8818,8 @@ interface X402PaymentRequest {
|
|
|
9324
8818
|
*/
|
|
9325
8819
|
btcRate?: number;
|
|
9326
8820
|
}
|
|
9327
|
-
/** Successfully-signed x402 payment header (base64 PaymentPayload). */
|
|
9328
8821
|
interface X402PaymentProof {
|
|
9329
|
-
/** Base64-encoded payment
|
|
8822
|
+
/** Base64-encoded payment payload for the selected protocol header. */
|
|
9330
8823
|
paymentHeader: string;
|
|
9331
8824
|
/** Protocol version that selects `PAYMENT-SIGNATURE` (v2) or `X-PAYMENT` (v1). */
|
|
9332
8825
|
x402Version: X402Version;
|
|
@@ -9338,70 +8831,21 @@ interface X402PaymentProof {
|
|
|
9338
8831
|
btcRate: number;
|
|
9339
8832
|
}
|
|
9340
8833
|
/**
|
|
9341
|
-
*
|
|
9342
|
-
*
|
|
9343
|
-
*
|
|
9344
|
-
*
|
|
9345
|
-
* Returns `null` to signal "fall through to the next rail" — preserves the
|
|
9346
|
-
* upstream responder's chained-fallback semantics for callers that hold
|
|
9347
|
-
* multiple wallets. Throws `DvmError("x402_build_failed", ...)` on any
|
|
9348
|
-
* unexpected failure (RPC, viem signing, malformed wallet) so the failure
|
|
9349
|
-
* surfaces with a stable code instead of a silent `null`; callers
|
|
9350
|
-
* that want soft fall-through should catch and continue.
|
|
9351
|
-
*
|
|
9352
|
-
* The server's advertised `requiredUsdcMicro` is authoritative for the signed
|
|
9353
|
-
* amount. The caller still resolves a BTC/USD rate to refuse an advertisement
|
|
9354
|
-
* more than 10% above its own conversion and to book the actual signed amount
|
|
9355
|
-
* in the msat-denominated ledger. The rate comes from `request.btcRate` when
|
|
9356
|
-
* the caller already resolved one, else from `resolveBtcUsdRate` — which serves
|
|
9357
|
-
* the last cached rate when CoinGecko is down.
|
|
9358
|
-
*
|
|
9359
|
-
* With no rate *anywhere* this rail simply can't quote a USDC amount, so it
|
|
9360
|
-
* soft-falls-through like any other unbuildable payload. Only an uncapped
|
|
9361
|
-
* caller reaches that state — `enforceGlobalBudget` hard-fails a capped one
|
|
9362
|
-
* upstream — and Lightning, ordered after x402, can still settle the spend the
|
|
9363
|
-
* ledger already agreed to let through. Tempo answers a missing rate the same
|
|
9364
|
-
* way x402 does, for the same reason: it prices in dollars too, so with no rate
|
|
9365
|
-
* there is nothing to check the DVM's advertisement against.
|
|
8834
|
+
* Signs the selected USDC amount and returns a v1 or v2 payment header. Refuses
|
|
8835
|
+
* malformed or excessive advertisements before signing. Unsupported networks
|
|
8836
|
+
* or an unavailable BTC/USD rate return null for rail fallback; build failures
|
|
8837
|
+
* have a typed error. A cached rate can price the ceiling and budget ledger.
|
|
9366
8838
|
*/
|
|
9367
8839
|
declare function tryX402Payment(request: X402PaymentRequest, wallet: X402Wallet): Promise<X402PaymentProof | null>;
|
|
9368
8840
|
|
|
9369
8841
|
/**
|
|
9370
|
-
*
|
|
9371
|
-
*
|
|
9372
|
-
*
|
|
9373
|
-
*
|
|
9374
|
-
* from the payer address, and the contract will only pay a withdrawal out to
|
|
9375
|
-
* the payer that opened it. So replacing `config.x402.privateKey` — or deleting
|
|
9376
|
-
* it — is not a settings change: any channel balance the old key still controls
|
|
9377
|
-
* becomes unreachable, behind a timed exit nobody holds the key for.
|
|
9378
|
-
*
|
|
9379
|
-
* The check is therefore fail-closed and grounded in chain state rather than in
|
|
9380
|
-
* what the local journal remembers. A cooperatively drained channel leaves its
|
|
9381
|
-
* metadata behind forever; refusing on metadata alone would make the caller's
|
|
9382
|
-
* first rotation impossible. Refusing only when the chain says the channel
|
|
9383
|
-
* still holds value — or that a timed withdrawal is mid-flight — is the line
|
|
9384
|
-
* that is both safe and eventually passable.
|
|
9385
|
-
*
|
|
9386
|
-
* The other half of the same protection — a signed voucher still waiting for
|
|
9387
|
-
* its acknowledgement — is journal state rather than chain state, and
|
|
9388
|
-
* already owns it in `wallet-x402.ts` alongside `x402-clear-pending`, the one
|
|
9389
|
-
* command that discards such a voucher on purpose. This module deliberately
|
|
9390
|
-
* doesn't second-guess it: chain state read a moment ago cannot speak for a
|
|
9391
|
-
* header that is still replayable, and one refusal is easier to act on.
|
|
9392
|
-
*
|
|
9393
|
-
* The same question read the other way round — given *this* channel, may the
|
|
9394
|
-
* currently connected wallet move it — is {@link assertX402ChannelPayer},
|
|
9395
|
-
* shared by both exits so a caller who reconnected reads one sentence rather
|
|
9396
|
-
* than two dialects of it. There is deliberately no chain twin of it: both
|
|
9397
|
-
* exits now follow the channel onto the chain it was opened on, so a re-pin
|
|
9398
|
-
* costs the caller nothing.
|
|
8842
|
+
* Key replacement and disconnect require chain proof that every owned channel
|
|
8843
|
+
* has neither collateral nor a pending withdrawal. Local metadata survives
|
|
8844
|
+
* drainage, so its presence alone cannot block key rotation. Pending signed
|
|
8845
|
+
* vouchers are guarded separately: a chain read cannot revoke their authority.
|
|
9399
8846
|
*
|
|
9400
|
-
*
|
|
9401
|
-
*
|
|
9402
|
-
* recorded channel. It shares this module's chain seam and inverts
|
|
9403
|
-
* only its posture on failure: a guard that cannot read refuses, a report that
|
|
9404
|
-
* cannot read says so and carries on.
|
|
8847
|
+
* Exits and reports follow each channel's recorded chain. Guards fail closed
|
|
8848
|
+
* when reads fail; reports retain the failure and continue with other rails.
|
|
9405
8849
|
*/
|
|
9406
8850
|
|
|
9407
8851
|
/** What the caller is about to do to the configured key — drives the remedy copy. */
|
|
@@ -9493,45 +8937,12 @@ interface X402ChannelClient {
|
|
|
9493
8937
|
}) => Promise<readonly [bigint, number | bigint] | bigint>;
|
|
9494
8938
|
}
|
|
9495
8939
|
/**
|
|
9496
|
-
* Report
|
|
9497
|
-
*
|
|
9498
|
-
*
|
|
9499
|
-
*
|
|
9500
|
-
*
|
|
9501
|
-
*
|
|
9502
|
-
* reach it has to say so and go on reporting the rest of the wallet, or one
|
|
9503
|
-
* unreachable chain hides every other rail the caller holds.
|
|
9504
|
-
*
|
|
9505
|
-
* The verdict rests on the contract's own views. `pendingWithdrawals` outranks
|
|
9506
|
-
* everything, because a timed exit in its delay window is the state a caller
|
|
9507
|
-
* has an unfinished action in. Otherwise escrow the contract still accounts for
|
|
9508
|
-
* is `open`. With none, the question is whether the contract has ever seen this
|
|
9509
|
-
* channel, and two counters answer it: `totalClaimed`, which nothing resets,
|
|
9510
|
-
* and `refundNonce`, which only ever increments. Either being non-zero makes it
|
|
9511
|
-
* `closed` — a channel that ran its course rather than one that never existed.
|
|
9512
|
-
*
|
|
9513
|
-
* One case defeats all of them, and the copy on an `unconfirmed` row is written
|
|
9514
|
-
* around it: a channel funded, never claimed, never refunded, and then emptied
|
|
9515
|
-
* through the timed exit. `finalizeWithdraw` sets `ws.amount = 0` and
|
|
9516
|
-
* `ws.initiatedAt = 0` and decrements `balance`, so every view reads zero and
|
|
9517
|
-
* the contract is genuinely indistinguishable from one that never held the
|
|
9518
|
-
* channel at all. `unconfirmed` therefore means "the contract holds nothing and
|
|
9519
|
-
* cannot say why", not "the deposit never landed", and the row must not assert
|
|
9520
|
-
* the second.
|
|
9521
|
-
*
|
|
9522
|
-
* The two verdicts where the contract's zero is an absence rather than a
|
|
9523
|
-
* balance — `unconfirmed`, and `unreadable` where it answered nothing at all —
|
|
9524
|
-
* fall back to the caller's own stored figure instead, exactly as the Tempo
|
|
9525
|
-
* rows do. That figure is the one taught the store to distrust, so a
|
|
9526
|
-
* row reporting it also reports {@link X402ChannelChainReport.balanceUnreconciledAt}
|
|
9527
|
-
* when it carries the stamp. Reporting an assumption as an observation in the
|
|
9528
|
-
* one case the chain cannot correct it is what that stamp exists to prevent.
|
|
9529
|
-
*
|
|
9530
|
-
* Broadcasts nothing: every chain call here is a `view`. A successful read
|
|
9531
|
-
* writes its authoritative balance and claimed total back to the local
|
|
9532
|
-
* projection; a failed read changes nothing. Unlike the Tempo twin there is no
|
|
9533
|
-
* retirement to perform — the x402 record is the only local copy of the
|
|
9534
|
-
* channel config a timed exit needs, and no chain state makes it safe to drop.
|
|
8940
|
+
* Report contract views without broadcasting. Successful views attempt to write
|
|
8941
|
+
* authoritative balance and claimed total locally; failed reads use available local
|
|
8942
|
+
* fallback figures and retain their unreconciled provenance stamp. For all-zero
|
|
8943
|
+
* views, refundNonce distinguishes a refunded channel when readable; otherwise
|
|
8944
|
+
* unconfirmed means the contract cannot establish its history. Keep config for
|
|
8945
|
+
* timed exits even after a terminal observation.
|
|
9535
8946
|
*/
|
|
9536
8947
|
declare function readX402ChannelOnChain(args: {
|
|
9537
8948
|
channel: StoredX402ChannelMetadata;
|