@dvmkit/dvm-cli 0.15.3 → 0.17.0
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/dist/{chunk-HXTASGHL.js → chunk-A2B7QDMS.js} +2 -2
- package/dist/{chunk-DZHEYRS2.js → chunk-DE7TEOUR.js} +3136 -2821
- package/dist/{chunk-57PXJ56K.js → chunk-DGA5EFKU.js} +354 -186
- package/dist/{chunk-2MCZ4QOK.js → chunk-ESQ6DCS3.js} +4 -4
- package/dist/{chunk-D5CGDS3V.js → chunk-IK7RI645.js} +2 -2
- package/dist/{chunk-HJ2JYBTT.js → chunk-OEWENVJ7.js} +5 -5
- package/dist/{chunk-F45ETHDP.js → chunk-R6FZT6S2.js} +14 -6
- package/dist/{chunk-I7ZBID4L.js → chunk-REIUNZQX.js} +2 -2
- package/dist/{chunk-YQJRKWNT.js → chunk-THTPKBZX.js} +24488 -22833
- package/dist/{chunk-UCCT5IKU.js → chunk-UFMAHF6T.js} +63 -1
- package/dist/{chunk-UWVMG4VG.js → chunk-VLD7OKSH.js} +6 -6
- package/dist/{chunk-EZL4IVCU.js → chunk-ZGBCVQF2.js} +3 -3
- package/dist/{client-NBC2IDA2.js → client-3JOMNAIQ.js} +6 -6
- package/dist/dvm.js +468 -217
- package/dist/{internal-O7IQD6EQ.js → internal-L362ZUWL.js} +5 -5
- package/dist/{lifecycle-MIJH3JE4.js → lifecycle-BH4OA5I3.js} +6 -6
- package/dist/{payout-reporter-Y6OW3FYD-K6MRWQXK.js → payout-reporter-F5LFV5W4-EJ7E5ALO.js} +2 -2
- package/dist/{pocket-refill-LCDXSC74.js → pocket-refill-5BEM22UM.js} +12 -12
- package/dist/{revenue-reporter-CIG2MEDN-ZXMO6NWG.js → revenue-reporter-2U55YH2I-EUB6PBRN.js} +2 -2
- package/dist/{tempo-lifecycle-FMBCHD2M.js → tempo-lifecycle-WGTX6MJR.js} +8 -8
- package/dist/{tempo-wallet-U3WBWIIH.js → tempo-wallet-OTB2YSWE.js} +7 -7
- package/dist/{wallet-Z3FDX43V.js → wallet-73EJBUSO.js} +7 -7
- package/dist/{x402-ARXZQ5BD-H6PNJYYT.js → x402-G6C4N2BN-TAJEBQGU.js} +2 -2
- package/package.json +3 -2
- package/skills/dvm/calling.md +3 -1
- package/skills/dvm/wallets.md +9 -1
package/dist/dvm.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
assertTempoWalletIdle,
|
|
6
6
|
findSigningIdentityByPubkey,
|
|
7
7
|
resolveSigningIdentity
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZGBCVQF2.js";
|
|
9
9
|
import {
|
|
10
10
|
CARD_MIN_MICRO,
|
|
11
11
|
DEFAULT_CREDIT_POSTURE,
|
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
computeNextAction,
|
|
44
44
|
correctPendingFundAmount,
|
|
45
45
|
createMessageAppendSession,
|
|
46
|
+
createPendingMintQuote,
|
|
46
47
|
declinedAskSeqs,
|
|
47
48
|
deriveAlias,
|
|
48
49
|
describeMintBounds,
|
|
@@ -67,6 +68,7 @@ import {
|
|
|
67
68
|
fundCredit,
|
|
68
69
|
fundTimeoutMs,
|
|
69
70
|
guidanceJobArg,
|
|
71
|
+
hasPendingAcceptedJobAccess,
|
|
70
72
|
hasUnknownUpfrontCredit,
|
|
71
73
|
hasUnknownUpfrontRail,
|
|
72
74
|
heldCashuSubmissionAsks,
|
|
@@ -180,6 +182,7 @@ import {
|
|
|
180
182
|
sweepPendingMints,
|
|
181
183
|
sweepStaleInFlight,
|
|
182
184
|
terminalSettlementFields,
|
|
185
|
+
terminalSettlementReport,
|
|
183
186
|
tierCapOverrides,
|
|
184
187
|
toCapture,
|
|
185
188
|
toFloatError,
|
|
@@ -192,39 +195,19 @@ import {
|
|
|
192
195
|
updateJob,
|
|
193
196
|
updateObservedJob,
|
|
194
197
|
walletHistory,
|
|
198
|
+
walletInvoiceFundingAdvice,
|
|
195
199
|
warnInvalidJobIdentityHeader,
|
|
196
200
|
withAcceptedUnresolved,
|
|
197
201
|
withIdentityRecovery,
|
|
198
202
|
withJobTokenRedaction,
|
|
199
203
|
withRequestResultRecovery
|
|
200
|
-
} from "./chunk-
|
|
204
|
+
} from "./chunk-DE7TEOUR.js";
|
|
201
205
|
import {
|
|
202
206
|
connectedTempoAccount,
|
|
203
207
|
generateTempoKey,
|
|
204
208
|
tempoBalanceCheckHint,
|
|
205
209
|
tempoWrongAssetHint
|
|
206
|
-
} from "./chunk-
|
|
207
|
-
import {
|
|
208
|
-
addOutputWarnings,
|
|
209
|
-
assertValidBudget,
|
|
210
|
-
costAnchor,
|
|
211
|
-
formatAmount,
|
|
212
|
-
formatAmountBestEffort,
|
|
213
|
-
formatPaymentAmount,
|
|
214
|
-
getOutputTraceId,
|
|
215
|
-
hasUnsavedJobState,
|
|
216
|
-
info,
|
|
217
|
-
json,
|
|
218
|
-
monetaryJson,
|
|
219
|
-
parseBudget,
|
|
220
|
-
raw,
|
|
221
|
-
resolveBtcUsdRate,
|
|
222
|
-
setOutputTraceId,
|
|
223
|
-
staleRateNotice,
|
|
224
|
-
tryResolveBtcUsdRate,
|
|
225
|
-
tryX402Payment,
|
|
226
|
-
withOutputWarnings
|
|
227
|
-
} from "./chunk-F45ETHDP.js";
|
|
210
|
+
} from "./chunk-OEWENVJ7.js";
|
|
228
211
|
import {
|
|
229
212
|
assertSupportedX402Network,
|
|
230
213
|
connectedX402Payer,
|
|
@@ -233,7 +216,7 @@ import {
|
|
|
233
216
|
repinX402WalletNetwork,
|
|
234
217
|
saveX402Wallet,
|
|
235
218
|
x402NetworkLabel
|
|
236
|
-
} from "./chunk-
|
|
219
|
+
} from "./chunk-VLD7OKSH.js";
|
|
237
220
|
import {
|
|
238
221
|
CREDIT_POSTURES,
|
|
239
222
|
FEEDBACK_POSTURES,
|
|
@@ -250,10 +233,31 @@ import {
|
|
|
250
233
|
retireConfigBackup,
|
|
251
234
|
rollbackConfig,
|
|
252
235
|
updateConfig
|
|
253
|
-
} from "./chunk-
|
|
236
|
+
} from "./chunk-ESQ6DCS3.js";
|
|
237
|
+
import {
|
|
238
|
+
addOutputWarnings,
|
|
239
|
+
assertValidBudget,
|
|
240
|
+
costAnchor,
|
|
241
|
+
formatAmount,
|
|
242
|
+
formatAmountBestEffort,
|
|
243
|
+
formatPaymentAmount,
|
|
244
|
+
getOutputTraceId,
|
|
245
|
+
hasUnsavedJobState,
|
|
246
|
+
info,
|
|
247
|
+
json,
|
|
248
|
+
monetaryJson,
|
|
249
|
+
parseBudget,
|
|
250
|
+
raw,
|
|
251
|
+
resolveBtcUsdRate,
|
|
252
|
+
setOutputTraceId,
|
|
253
|
+
staleRateNotice,
|
|
254
|
+
tryResolveBtcUsdRate,
|
|
255
|
+
tryX402Payment,
|
|
256
|
+
withOutputWarnings
|
|
257
|
+
} from "./chunk-R6FZT6S2.js";
|
|
254
258
|
import {
|
|
255
259
|
assertX402WalletIdle
|
|
256
|
-
} from "./chunk-
|
|
260
|
+
} from "./chunk-REIUNZQX.js";
|
|
257
261
|
import {
|
|
258
262
|
A,
|
|
259
263
|
AGENT_MNEMONIC_FILE,
|
|
@@ -313,6 +317,7 @@ import {
|
|
|
313
317
|
attestedDvmIdentity,
|
|
314
318
|
authenticatedBuilderPubkey,
|
|
315
319
|
base64,
|
|
320
|
+
bech32,
|
|
316
321
|
bindCashuTokenToSubmissionContext,
|
|
317
322
|
canonicalRequestPath,
|
|
318
323
|
cashuSubmissionBindingFingerprint,
|
|
@@ -492,7 +497,7 @@ import {
|
|
|
492
497
|
x402PendingUnsettled,
|
|
493
498
|
x402RequiredFromError,
|
|
494
499
|
x402ReservationRelease
|
|
495
|
-
} from "./chunk-
|
|
500
|
+
} from "./chunk-THTPKBZX.js";
|
|
496
501
|
import "./chunk-JBU7RKQ3.js";
|
|
497
502
|
import "./chunk-KDNFUDOG.js";
|
|
498
503
|
import "./chunk-IUTVV6N5.js";
|
|
@@ -778,11 +783,11 @@ import {
|
|
|
778
783
|
usdToMsats,
|
|
779
784
|
usdcToMsats,
|
|
780
785
|
x402NetworkByCaip2
|
|
781
|
-
} from "./chunk-
|
|
782
|
-
import "./chunk-
|
|
783
|
-
import "./chunk-
|
|
786
|
+
} from "./chunk-DGA5EFKU.js";
|
|
787
|
+
import "./chunk-A2B7QDMS.js";
|
|
788
|
+
import "./chunk-IK7RI645.js";
|
|
784
789
|
import "./chunk-R2DSAZBO.js";
|
|
785
|
-
import "./chunk-
|
|
790
|
+
import "./chunk-UFMAHF6T.js";
|
|
786
791
|
import {
|
|
787
792
|
privateKeyToAccount
|
|
788
793
|
} from "./chunk-EVQERRCP.js";
|
|
@@ -11444,6 +11449,11 @@ async function handlePaymentRequest(jobId, request2, policy, transport, provider
|
|
|
11444
11449
|
});
|
|
11445
11450
|
}
|
|
11446
11451
|
async function handleLockedPaymentRequest(jobId, request2, policy, transport, provider, opts) {
|
|
11452
|
+
if (hasPendingAcceptedJobAccess(jobId, provider.endpoint)) throw new DvmError(
|
|
11453
|
+
"local_job_state_unsaved",
|
|
11454
|
+
"Private recovery state must be folded before another payment can be sent.",
|
|
11455
|
+
"Run dvm status <job_id> --messages before paying; unresolved recovery records remain preserved."
|
|
11456
|
+
);
|
|
11447
11457
|
const approval = opts?.requestSeq === void 0 ? void 0 : {
|
|
11448
11458
|
requestSeq: opts.requestSeq,
|
|
11449
11459
|
approval: opts.approval ?? "auto"
|
|
@@ -11605,8 +11615,8 @@ async function handleLockedPaymentRequest(jobId, request2, policy, transport, pr
|
|
|
11605
11615
|
}
|
|
11606
11616
|
}
|
|
11607
11617
|
if ((opts?.rail === void 0 || opts.rail === "x402") && request2.x402) {
|
|
11608
|
-
const { loadX402Wallet: loadX402Wallet2 } = await import("./wallet-
|
|
11609
|
-
const { tryX402Payment: tryX402Payment2 } = await import("./client-
|
|
11618
|
+
const { loadX402Wallet: loadX402Wallet2 } = await import("./wallet-73EJBUSO.js");
|
|
11619
|
+
const { tryX402Payment: tryX402Payment2 } = await import("./client-3JOMNAIQ.js");
|
|
11610
11620
|
const wallet = loadX402Wallet2();
|
|
11611
11621
|
if (wallet) {
|
|
11612
11622
|
let proof;
|
|
@@ -14384,7 +14394,7 @@ async function settleCreditAfterJob(args) {
|
|
|
14384
14394
|
}
|
|
14385
14395
|
}
|
|
14386
14396
|
if (args.allowTopup !== false) {
|
|
14387
|
-
const refill = args.refillPocket ?? (await import("./pocket-refill-
|
|
14397
|
+
const refill = args.refillPocket ?? (await import("./pocket-refill-5BEM22UM.js")).refillPocketIfLow;
|
|
14388
14398
|
await refill({ human: args.human }).catch(() => void 0);
|
|
14389
14399
|
}
|
|
14390
14400
|
}
|
|
@@ -14842,8 +14852,10 @@ async function cancelWithAccess(jobId, opts, access) {
|
|
|
14842
14852
|
const endingDisplay = settlement ? cancelledDisplay(settlement) : receiptPending ? `Stopped. Its receipt is not available yet; \`dvm status ${guidanceJobArg(jobId)}\` shows what was charged once it is.` : void 0;
|
|
14843
14853
|
const display = [endingDisplay, artifacts.display].filter(Boolean).join(" ") || void 0;
|
|
14844
14854
|
const hint = settlementCurrencyHint(settlement, ref.endpoint);
|
|
14855
|
+
const { wallet_remaining } = await terminalSettlementReport(jobId, { status: "cancelled", persistLocalState: !access.endpointOverridden });
|
|
14845
14856
|
if (opts.human) {
|
|
14846
14857
|
info(`Job ${jobId}${identifier ? ` [${identifier}]` : ""} cancelled.`);
|
|
14858
|
+
if (wallet_remaining) info(wallet_remaining.display);
|
|
14847
14859
|
if (display) info(display);
|
|
14848
14860
|
if (hint) info(` ${hint}`);
|
|
14849
14861
|
} else {
|
|
@@ -14853,6 +14865,7 @@ async function cancelWithAccess(jobId, opts, access) {
|
|
|
14853
14865
|
status: "cancelled",
|
|
14854
14866
|
...opts.reason ? { reason: opts.reason } : {},
|
|
14855
14867
|
...settlement ? { settlement } : {},
|
|
14868
|
+
...wallet_remaining ? { wallet_remaining } : {},
|
|
14856
14869
|
...display ? { display } : {},
|
|
14857
14870
|
...artifacts.fields,
|
|
14858
14871
|
...hint ? { hint } : {},
|
|
@@ -14937,8 +14950,10 @@ async function declineWithAccess(jobId, opts, access) {
|
|
|
14937
14950
|
const endingDisplay = observed === void 0 ? `Decline sent, but the job's status could not be read. Check it with \`dvm status ${job}\`.` : settlement ? `Declined; the job has ended. ${settlement.display}` : `Declined; the job has ended. Its receipt is not available yet; \`dvm status ${job}\` shows the final charge once it is.`;
|
|
14938
14951
|
const display = [endingDisplay, artifacts.display].filter(Boolean).join(" ");
|
|
14939
14952
|
const hint = settlementCurrencyHint(settlement, ref.endpoint);
|
|
14953
|
+
const { wallet_remaining } = await terminalSettlementReport(jobId, { status: observed, persistLocalState: !access.endpointOverridden });
|
|
14940
14954
|
if (opts.human) {
|
|
14941
14955
|
info(`Job ${jobId}${identifier ? ` [${identifier}]` : ""}: ${display}`);
|
|
14956
|
+
if (wallet_remaining) info(wallet_remaining.display);
|
|
14942
14957
|
if (hint) info(` ${hint}`);
|
|
14943
14958
|
return;
|
|
14944
14959
|
}
|
|
@@ -14949,6 +14964,7 @@ async function declineWithAccess(jobId, opts, access) {
|
|
|
14949
14964
|
declined: true,
|
|
14950
14965
|
...opts.reason !== void 0 ? { reason: opts.reason } : {},
|
|
14951
14966
|
...settlement ? { settlement } : {},
|
|
14967
|
+
...wallet_remaining ? { wallet_remaining } : {},
|
|
14952
14968
|
display,
|
|
14953
14969
|
...artifacts.fields,
|
|
14954
14970
|
...hint ? { hint } : {},
|
|
@@ -15159,14 +15175,14 @@ async function confirmRollback(stored, preview, opts) {
|
|
|
15159
15175
|
async function withStrandingChecked(removing, commit) {
|
|
15160
15176
|
const leaving = new Set(removing.map((target) => target.split(".")[0]));
|
|
15161
15177
|
if (leaving.has("tempo")) {
|
|
15162
|
-
const { assertTempoWalletIdle: assertTempoWalletIdle2 } = await import("./tempo-lifecycle-
|
|
15178
|
+
const { assertTempoWalletIdle: assertTempoWalletIdle2 } = await import("./tempo-lifecycle-WGTX6MJR.js");
|
|
15163
15179
|
await assertTempoWalletIdle2("disconnect");
|
|
15164
15180
|
}
|
|
15165
15181
|
if (!leaving.has("x402")) return commit();
|
|
15166
|
-
const { withX402ChannelLock: withX402ChannelLock2, listPendingX402Fundings: listPendingX402Fundings2, x402PendingUnsettled: x402PendingUnsettled2 } = await import("./internal-
|
|
15167
|
-
const { assertX402WalletIdle: assertX402WalletIdle2 } = await import("./lifecycle-
|
|
15168
|
-
const { ensureAddress: ensureAddress2 } = await import("./internal-
|
|
15169
|
-
const { loadX402Wallet: loadX402Wallet2 } = await import("./wallet-
|
|
15182
|
+
const { withX402ChannelLock: withX402ChannelLock2, listPendingX402Fundings: listPendingX402Fundings2, x402PendingUnsettled: x402PendingUnsettled2 } = await import("./internal-L362ZUWL.js");
|
|
15183
|
+
const { assertX402WalletIdle: assertX402WalletIdle2 } = await import("./lifecycle-BH4OA5I3.js");
|
|
15184
|
+
const { ensureAddress: ensureAddress2 } = await import("./internal-L362ZUWL.js");
|
|
15185
|
+
const { loadX402Wallet: loadX402Wallet2 } = await import("./wallet-73EJBUSO.js");
|
|
15170
15186
|
return withX402ChannelLock2(async () => {
|
|
15171
15187
|
const unsettled = listPendingX402Fundings2().filter((entry) => x402PendingUnsettled2(entry));
|
|
15172
15188
|
if (unsettled.length > 0) {
|
|
@@ -19994,7 +20010,8 @@ async function runCreditFund(dvm, opts) {
|
|
|
19994
20010
|
menu,
|
|
19995
20011
|
providerInfo,
|
|
19996
20012
|
opts,
|
|
19997
|
-
config: config2
|
|
20013
|
+
config: config2,
|
|
20014
|
+
rail
|
|
19998
20015
|
});
|
|
19999
20016
|
}
|
|
20000
20017
|
const outcome = await fundCredit({
|
|
@@ -20036,6 +20053,7 @@ async function runCreditFund(dvm, opts) {
|
|
|
20036
20053
|
adopted ? `${baseHint ? `${baseHint} ` : ""}${adopted.advice}` : baseHint,
|
|
20037
20054
|
{
|
|
20038
20055
|
...err?.data ?? {},
|
|
20056
|
+
...outcome.walletFundCommand ? { wallet_fund_command: outcome.walletFundCommand } : {},
|
|
20039
20057
|
display: outcome.display,
|
|
20040
20058
|
endpoint,
|
|
20041
20059
|
credit_id: outcome.creditId,
|
|
@@ -20374,17 +20392,24 @@ async function enforceTrustTier(args) {
|
|
|
20374
20392
|
const capUsd = `$${formatUsd(cap2 / 1e6)}`;
|
|
20375
20393
|
const held = fundsTracked ? Math.max(args.stored?.remainingMicro ?? 0, 0) : 0;
|
|
20376
20394
|
const heldClause = held > 0 ? ` On top of the $${formatUsd(held / 1e6)} already on deposit, that would leave $${formatUsd(exposureMicro / 1e6)} here.` : "";
|
|
20395
|
+
const lightningMinimum = args.menu?.lightning_min_micro;
|
|
20396
|
+
const walletFunding = args.rail === "lightning" && lightningMinimum !== void 0 && lightningMinimum > cap2 ? {
|
|
20397
|
+
...walletInvoiceFundingAdvice(args.amountMicro),
|
|
20398
|
+
minimumUsd: `$${formatUsd(lightningMinimum / 1e6)}`
|
|
20399
|
+
} : void 0;
|
|
20400
|
+
const walletGuidance = walletFunding ? `Lightning top-ups here start at ${walletFunding.minimumUsd}, above the ${capUsd} this caller can load at the current trust tier. ${walletFunding.text} ` : "";
|
|
20377
20401
|
throw withHeadroom(
|
|
20378
20402
|
new DvmError(
|
|
20379
20403
|
"amount_exceeds_trust_tier",
|
|
20380
20404
|
`Funding ${amountUsd} at ${args.endpoint} would exceed this DVM's ${capUsd} trust-tier cap.`,
|
|
20381
|
-
`Nothing moved. Re-run with --over-trust to fund it anyway, or pre-grant every DVM signed by this builder with 'dvm credit trust ${args.endpoint} <builder-max|$amount>'. Or fund ${capUsd} or less.`,
|
|
20405
|
+
walletFunding ? `No money moved. ${walletGuidance}Re-run with --over-trust to fund credit over Lightning anyway, or pre-grant every DVM signed by this builder with 'dvm credit trust ${args.endpoint} <builder-max|$amount>'.` : `Nothing moved. Re-run with --over-trust to fund it anyway, or pre-grant every DVM signed by this builder with 'dvm credit trust ${args.endpoint} <builder-max|$amount>'. Or fund ${capUsd} or less.`,
|
|
20382
20406
|
{
|
|
20383
|
-
display: `This agent has only earned ${capUsd} of credit at ${args.endpoint} so far, and ${amountUsd} was asked for.${heldClause} No money moved. Loading more than the earned amount is allowed, but it has to be asked for explicitly \u2014 re-run with --over-trust, or pre-grant every DVM signed by this builder with 'dvm credit trust ${args.endpoint} <builder-max|$amount>'.`,
|
|
20407
|
+
display: `This agent has only earned ${capUsd} of credit at ${args.endpoint} so far, and ${amountUsd} was asked for.${heldClause} No money moved. ` + walletGuidance + `Loading more than the earned amount is allowed, but it has to be asked for explicitly \u2014 re-run with --over-trust, or pre-grant every DVM signed by this builder with 'dvm credit trust ${args.endpoint} <builder-max|$amount>'.`,
|
|
20384
20408
|
endpoint: args.endpoint,
|
|
20385
20409
|
amount_micro: args.amountMicro,
|
|
20386
20410
|
exposure_micro: exposureMicro,
|
|
20387
|
-
cap_micro: cap2
|
|
20411
|
+
cap_micro: cap2,
|
|
20412
|
+
...walletFunding ? { wallet_fund_command: walletFunding.command } : {}
|
|
20388
20413
|
}
|
|
20389
20414
|
),
|
|
20390
20415
|
headroom
|
|
@@ -21864,8 +21889,8 @@ async function probeX402(x402, timeoutMs) {
|
|
|
21864
21889
|
let network;
|
|
21865
21890
|
let address;
|
|
21866
21891
|
try {
|
|
21867
|
-
const { loadX402Wallet: loadX402Wallet2 } = await import("./wallet-
|
|
21868
|
-
const { getX402Balance, ensureAddress: ensureAddress2, usdcContractByCaip2 } = await import("./internal-
|
|
21892
|
+
const { loadX402Wallet: loadX402Wallet2 } = await import("./wallet-73EJBUSO.js");
|
|
21893
|
+
const { getX402Balance, ensureAddress: ensureAddress2, usdcContractByCaip2 } = await import("./internal-L362ZUWL.js");
|
|
21869
21894
|
const wallet = loadX402Wallet2();
|
|
21870
21895
|
if (!wallet) {
|
|
21871
21896
|
const storedKey = x402.privateKey;
|
|
@@ -21917,8 +21942,8 @@ async function probeMpp(mpp, timeoutMs) {
|
|
|
21917
21942
|
if (!mpp) return null;
|
|
21918
21943
|
if (mpp.method === "tempo") {
|
|
21919
21944
|
try {
|
|
21920
|
-
const { connectedTempoAccount: connectedTempoAccount2 } = await import("./tempo-wallet-
|
|
21921
|
-
const { getTempoUsdcBalance: getTempoUsdcBalance3, resolveTempoNetwork: resolveTempoNetwork2 } = await import("./internal-
|
|
21945
|
+
const { connectedTempoAccount: connectedTempoAccount2 } = await import("./tempo-wallet-OTB2YSWE.js");
|
|
21946
|
+
const { getTempoUsdcBalance: getTempoUsdcBalance3, resolveTempoNetwork: resolveTempoNetwork2 } = await import("./internal-L362ZUWL.js");
|
|
21922
21947
|
const account = await connectedTempoAccount2();
|
|
21923
21948
|
if (!account) {
|
|
21924
21949
|
return {
|
|
@@ -25655,7 +25680,7 @@ async function messagesWithAccess(jobId, opts, access) {
|
|
|
25655
25680
|
const content2 = jobContentFields(jobId, providerStatus2, opts.human);
|
|
25656
25681
|
const resolvedAction2 = await resolveNextAction2(nextAction, msgs, providerStatus2?.status);
|
|
25657
25682
|
const currency2 = access.endpointOverridden ? await providerCurrency({ receipt: providerStatus2?.receipt, status: providerStatus2, messages: msgs, transport, ref }) : void 0;
|
|
25658
|
-
const settlement2 = observedSettlementFields(jobId, providerStatus2, !access.endpointOverridden, currency2);
|
|
25683
|
+
const settlement2 = await observedSettlementFields(jobId, providerStatus2, !access.endpointOverridden, currency2);
|
|
25659
25684
|
transport.close();
|
|
25660
25685
|
if (opts.human) {
|
|
25661
25686
|
renderSettlementHuman(settlement2);
|
|
@@ -25724,7 +25749,7 @@ async function messagesWithAccess(jobId, opts, access) {
|
|
|
25724
25749
|
const resolvedAction = await resolveNextAction2(result.nextAction, result.messages, providerStatus?.status ?? result.providerStatus?.status);
|
|
25725
25750
|
const observed = providerStatus ?? result.providerStatus;
|
|
25726
25751
|
const currency = access.endpointOverridden ? await providerCurrency({ receipt: observed?.receipt, status: observed, messages: result.messages, transport, ref }) : void 0;
|
|
25727
|
-
const settlement = observedSettlementFields(jobId, observed, !access.endpointOverridden, currency);
|
|
25752
|
+
const settlement = await observedSettlementFields(jobId, observed, !access.endpointOverridden, currency);
|
|
25728
25753
|
transport.close();
|
|
25729
25754
|
if (opts.human) {
|
|
25730
25755
|
renderSettlementHuman(settlement);
|
|
@@ -25907,7 +25932,7 @@ async function messageWithAccess(jobId, text, opts, access) {
|
|
|
25907
25932
|
}
|
|
25908
25933
|
const content = jobContentFields(jobId, providerStatus, opts.human);
|
|
25909
25934
|
const currency = access.endpointOverridden ? await providerCurrency({ receipt: providerStatus?.receipt, status: providerStatus, messages: result.messages, transport, ref }) : void 0;
|
|
25910
|
-
const settlement = observedSettlementFields(jobId, providerStatus, !access.endpointOverridden, currency);
|
|
25935
|
+
const settlement = await observedSettlementFields(jobId, providerStatus, !access.endpointOverridden, currency);
|
|
25911
25936
|
transport.close();
|
|
25912
25937
|
if (opts.human) {
|
|
25913
25938
|
renderSettlementHuman(settlement);
|
|
@@ -26124,7 +26149,7 @@ async function payWithAccess(jobId, opts, access) {
|
|
|
26124
26149
|
});
|
|
26125
26150
|
}
|
|
26126
26151
|
const currency = access.endpointOverridden ? await providerCurrency({ receipt: providerStatus?.receipt, status: providerStatus, messages: streamResult.messages, transport, ref }) : void 0;
|
|
26127
|
-
const settlement = observedSettlementFields(jobId, providerStatus, !access.endpointOverridden, currency);
|
|
26152
|
+
const settlement = await observedSettlementFields(jobId, providerStatus, !access.endpointOverridden, currency);
|
|
26128
26153
|
transport.close();
|
|
26129
26154
|
const identifier = stored.dvmId ? formatIdentifier(stored.dvmId, stored.capability) : void 0;
|
|
26130
26155
|
if (opts.human) {
|
|
@@ -27227,9 +27252,15 @@ function quoteWithinDeclaredLimit(quote2, limitMsats, declaredLimit, rail) {
|
|
|
27227
27252
|
}
|
|
27228
27253
|
function quoteWithinNativeDollarLimit(quote2, declaredLimit, rail) {
|
|
27229
27254
|
const normalizedRail = rail?.trim().toLowerCase();
|
|
27230
|
-
if (normalizedRail === "x402")
|
|
27231
|
-
|
|
27232
|
-
|
|
27255
|
+
if (normalizedRail === "x402") {
|
|
27256
|
+
const native = x402QuoteWithinDollarLimit(quote2, declaredLimit);
|
|
27257
|
+
if (native !== void 0) return native;
|
|
27258
|
+
}
|
|
27259
|
+
const upfront = upfrontQuoteWithinDollarLimit(quote2, declaredLimit);
|
|
27260
|
+
if (normalizedRail === "tempo" && declaredLimit?.trim().startsWith("$")) {
|
|
27261
|
+
return upfront ?? false;
|
|
27262
|
+
}
|
|
27263
|
+
return upfront;
|
|
27233
27264
|
}
|
|
27234
27265
|
function x402QuoteWithinDollarLimit(quote2, declaredLimit) {
|
|
27235
27266
|
if (!declaredLimit || !quote2.requiredUsdcMicro) return void 0;
|
|
@@ -27237,12 +27268,12 @@ function x402QuoteWithinDollarLimit(quote2, declaredLimit) {
|
|
|
27237
27268
|
if (limitMicro === void 0 || !/^\d+$/.test(quote2.requiredUsdcMicro)) return void 0;
|
|
27238
27269
|
return BigInt(quote2.requiredUsdcMicro) <= limitMicro;
|
|
27239
27270
|
}
|
|
27240
|
-
function
|
|
27271
|
+
function upfrontQuoteWithinDollarLimit(quote2, declaredLimit) {
|
|
27241
27272
|
if (!declaredLimit?.trim().startsWith("$")) return void 0;
|
|
27242
27273
|
const limitMicro = dollarLimitMicro(declaredLimit);
|
|
27243
|
-
const amountMicro = quote2.upfront
|
|
27244
|
-
if (limitMicro === void 0 || quote2.upfront
|
|
27245
|
-
return
|
|
27274
|
+
const amountMicro = quote2.upfront?.amount_micro;
|
|
27275
|
+
if (limitMicro === void 0 || quote2.upfront?.currency !== "usd" || amountMicro === void 0 || !Number.isSafeInteger(amountMicro) || amountMicro <= 0) {
|
|
27276
|
+
return void 0;
|
|
27246
27277
|
}
|
|
27247
27278
|
return BigInt(amountMicro) <= limitMicro;
|
|
27248
27279
|
}
|
|
@@ -28079,7 +28110,7 @@ async function requestWithWarnings(opts, stage) {
|
|
|
28079
28110
|
console.log(receipt.summary);
|
|
28080
28111
|
const hint = nextStepHint(receipt.jobId, receipt.payloadIn, receipt.artifactCount, true);
|
|
28081
28112
|
if (hint) info(`\u{1F4CE} ${hint}`);
|
|
28082
|
-
renderReceiptHuman(captured, receipt.jobId);
|
|
28113
|
+
await renderReceiptHuman(captured, receipt.jobId);
|
|
28083
28114
|
echoTraceIdHuman();
|
|
28084
28115
|
} else {
|
|
28085
28116
|
providerJobJson({
|
|
@@ -28090,7 +28121,7 @@ async function requestWithWarnings(opts, stage) {
|
|
|
28090
28121
|
summary: receipt.summary,
|
|
28091
28122
|
_provider_fields: ["summary"],
|
|
28092
28123
|
...buildCompletionHintFields(receipt.jobId, receipt),
|
|
28093
|
-
...receiptJsonFields(captured, receipt.jobId),
|
|
28124
|
+
...await receiptJsonFields(captured, receipt.jobId),
|
|
28094
28125
|
...takeCreditNoticeFields(),
|
|
28095
28126
|
...takeFeedbackNoticeFields(),
|
|
28096
28127
|
next_action: null
|
|
@@ -28159,8 +28190,8 @@ async function requestWithWarnings(opts, stage) {
|
|
|
28159
28190
|
const hint = nextStepHint(receipt.jobId, completion.payloadIn, completion.artifactCount, true);
|
|
28160
28191
|
if (hint) info(`\u{1F4CE} ${hint}`);
|
|
28161
28192
|
}
|
|
28162
|
-
if (captured) renderReceiptHuman(captured, receipt.jobId);
|
|
28163
|
-
else renderSettlementHuman(
|
|
28193
|
+
if (captured) await renderReceiptHuman(captured, receipt.jobId);
|
|
28194
|
+
else renderSettlementHuman(await terminalSettlementReport(receipt.jobId));
|
|
28164
28195
|
finalizeProgressLine();
|
|
28165
28196
|
echoTraceIdHuman();
|
|
28166
28197
|
printNextActionHuman(result.nextAction, { refunds: result.refunds, terminal: isTerminalJobStatus(receipt.status) || !!streamTerminalStatus(result.messages) });
|
|
@@ -28184,7 +28215,7 @@ async function requestWithWarnings(opts, stage) {
|
|
|
28184
28215
|
...completion?.message !== void 0 ? ["message"] : []
|
|
28185
28216
|
],
|
|
28186
28217
|
...completion ? buildCompletionHintFields(receipt.jobId, completion) : {},
|
|
28187
|
-
...captured ? receiptJsonFields(captured, receipt.jobId) :
|
|
28218
|
+
...captured ? await receiptJsonFields(captured, receipt.jobId) : await terminalSettlementReport(receipt.jobId),
|
|
28188
28219
|
...takeCreditNoticeFields(),
|
|
28189
28220
|
...takeFeedbackNoticeFields(),
|
|
28190
28221
|
next_action: result.nextAction,
|
|
@@ -28226,15 +28257,16 @@ async function requestWithWarnings(opts, stage) {
|
|
|
28226
28257
|
human: opts.human
|
|
28227
28258
|
});
|
|
28228
28259
|
transport.close();
|
|
28260
|
+
const report = await terminalSettlementReport(receipt.jobId, { receipt: captured.receipt });
|
|
28229
28261
|
if (opts.human) {
|
|
28230
28262
|
for (const msg of failureMessages) {
|
|
28231
28263
|
formatMessageHuman(msg, receipt.jobId, artifactSession);
|
|
28232
28264
|
}
|
|
28233
|
-
renderReceiptHuman(captured, receipt.jobId);
|
|
28265
|
+
await renderReceiptHuman(captured, receipt.jobId, report);
|
|
28234
28266
|
}
|
|
28235
28267
|
throw new DvmError(terminalStatus === "failed" ? "job_failed" : "cancelled", completion?.message ?? `Job ${terminalStatus}.`, void 0, {
|
|
28236
28268
|
status: terminalStatus,
|
|
28237
|
-
...receiptJsonFields(captured, receipt.jobId),
|
|
28269
|
+
...await receiptJsonFields(captured, receipt.jobId, report),
|
|
28238
28270
|
...failureMessages.length > 0 ? { messages: failureMessages.map(serializeMessageForOutput) } : {}
|
|
28239
28271
|
}, void 0, completion?.message !== void 0 ? { message: "provider" } : void 0);
|
|
28240
28272
|
}
|
|
@@ -29084,7 +29116,7 @@ async function payWithTempo(args, credential) {
|
|
|
29084
29116
|
console.log(receipt.summary);
|
|
29085
29117
|
const hint = nextStepHint(effectiveJobId, receipt.payloadIn, receipt.artifactCount, true);
|
|
29086
29118
|
if (hint) info(`\u{1F4CE} ${hint}`);
|
|
29087
|
-
renderReceiptHuman(captured, effectiveJobId);
|
|
29119
|
+
await renderReceiptHuman(captured, effectiveJobId);
|
|
29088
29120
|
} else {
|
|
29089
29121
|
providerJobJson({
|
|
29090
29122
|
jobId: effectiveJobId,
|
|
@@ -29094,7 +29126,7 @@ async function payWithTempo(args, credential) {
|
|
|
29094
29126
|
summary: receipt.summary,
|
|
29095
29127
|
_provider_fields: ["summary"],
|
|
29096
29128
|
...buildCompletionHintFields(effectiveJobId, receipt),
|
|
29097
|
-
...receiptJsonFields(captured, effectiveJobId),
|
|
29129
|
+
...await receiptJsonFields(captured, effectiveJobId),
|
|
29098
29130
|
paidWith: "tempo",
|
|
29099
29131
|
account: account.address,
|
|
29100
29132
|
...takeCreditNoticeFields(),
|
|
@@ -29763,7 +29795,7 @@ async function payWithAgentWallet(transport, ref, envelope, jobId, deadlineMs, c
|
|
|
29763
29795
|
console.log(receipt.summary);
|
|
29764
29796
|
const hint = nextStepHint(effectiveJobId, receipt.payloadIn, receipt.artifactCount, true);
|
|
29765
29797
|
if (hint) info(`\u{1F4CE} ${hint}`);
|
|
29766
|
-
renderReceiptHuman(captured, effectiveJobId);
|
|
29798
|
+
await renderReceiptHuman(captured, effectiveJobId);
|
|
29767
29799
|
} else {
|
|
29768
29800
|
providerJobJson({
|
|
29769
29801
|
jobId: effectiveJobId,
|
|
@@ -29771,7 +29803,7 @@ async function payWithAgentWallet(transport, ref, envelope, jobId, deadlineMs, c
|
|
|
29771
29803
|
summary: receipt.summary,
|
|
29772
29804
|
_provider_fields: ["summary"],
|
|
29773
29805
|
...buildCompletionHintFields(effectiveJobId, receipt),
|
|
29774
|
-
...receiptJsonFields(captured, effectiveJobId),
|
|
29806
|
+
...await receiptJsonFields(captured, effectiveJobId),
|
|
29775
29807
|
paidWith: "cashu_p2pk",
|
|
29776
29808
|
mint: prepared.mint,
|
|
29777
29809
|
amountSats: prepared.totalSats,
|
|
@@ -29964,7 +29996,7 @@ async function payWithX402(args, proof) {
|
|
|
29964
29996
|
console.log(receipt.summary);
|
|
29965
29997
|
const hint = nextStepHint(effectiveJobId, receipt.payloadIn, receipt.artifactCount, true);
|
|
29966
29998
|
if (hint) info(`\u{1F4CE} ${hint}`);
|
|
29967
|
-
renderReceiptHuman(captured, effectiveJobId);
|
|
29999
|
+
await renderReceiptHuman(captured, effectiveJobId);
|
|
29968
30000
|
} else {
|
|
29969
30001
|
providerJobJson({
|
|
29970
30002
|
jobId: effectiveJobId,
|
|
@@ -29974,7 +30006,7 @@ async function payWithX402(args, proof) {
|
|
|
29974
30006
|
summary: receipt.summary,
|
|
29975
30007
|
_provider_fields: ["summary"],
|
|
29976
30008
|
...buildCompletionHintFields(effectiveJobId, receipt),
|
|
29977
|
-
...receiptJsonFields(captured, effectiveJobId),
|
|
30009
|
+
...await receiptJsonFields(captured, effectiveJobId),
|
|
29978
30010
|
paidWith: "x402",
|
|
29979
30011
|
account: wallet.address,
|
|
29980
30012
|
...takeCreditNoticeFields(),
|
|
@@ -30157,8 +30189,8 @@ async function streamAfterPayment(args) {
|
|
|
30157
30189
|
const hint = nextStepHint(jobId, completion.payloadIn, completion.artifactCount, true);
|
|
30158
30190
|
if (hint) info(`\u{1F4CE} ${hint}`);
|
|
30159
30191
|
}
|
|
30160
|
-
if (captured) renderReceiptHuman(captured, jobId);
|
|
30161
|
-
else renderSettlementHuman(
|
|
30192
|
+
if (captured) await renderReceiptHuman(captured, jobId);
|
|
30193
|
+
else renderSettlementHuman(await terminalSettlementReport(jobId));
|
|
30162
30194
|
finalizeProgressLine();
|
|
30163
30195
|
printNextActionHuman(result.nextAction, { refunds: result.refunds, terminal: !!streamTerminalStatus(result.messages) });
|
|
30164
30196
|
} else {
|
|
@@ -30177,7 +30209,7 @@ async function streamAfterPayment(args) {
|
|
|
30177
30209
|
...completion?.message !== void 0 ? ["message"] : []
|
|
30178
30210
|
],
|
|
30179
30211
|
...completion ? buildCompletionHintFields(jobId, completion) : {},
|
|
30180
|
-
...captured ? receiptJsonFields(captured, jobId) :
|
|
30212
|
+
...captured ? await receiptJsonFields(captured, jobId) : await terminalSettlementReport(jobId),
|
|
30181
30213
|
...takeCreditNoticeFields(),
|
|
30182
30214
|
...takeFeedbackNoticeFields(),
|
|
30183
30215
|
next_action: result.nextAction,
|
|
@@ -30223,7 +30255,7 @@ async function recoverViaStatusPoll(args) {
|
|
|
30223
30255
|
});
|
|
30224
30256
|
if (human) {
|
|
30225
30257
|
info(status2.summary ?? "Job completed (recovered via status check).");
|
|
30226
|
-
renderReceiptHuman(captured, jobId);
|
|
30258
|
+
await renderReceiptHuman(captured, jobId);
|
|
30227
30259
|
} else {
|
|
30228
30260
|
providerJobJson({
|
|
30229
30261
|
jobId,
|
|
@@ -30233,7 +30265,7 @@ async function recoverViaStatusPoll(args) {
|
|
|
30233
30265
|
_provider_fields: ["summary"],
|
|
30234
30266
|
recovered: true,
|
|
30235
30267
|
...paymentFields,
|
|
30236
|
-
...receiptJsonFields(captured, jobId),
|
|
30268
|
+
...await receiptJsonFields(captured, jobId),
|
|
30237
30269
|
...takeCreditNoticeFields(),
|
|
30238
30270
|
...takeFeedbackNoticeFields(),
|
|
30239
30271
|
next_action: null
|
|
@@ -30255,7 +30287,7 @@ async function recoverViaStatusPoll(args) {
|
|
|
30255
30287
|
const errorMsg = status2.message ?? `Job ${status2.status}.`;
|
|
30256
30288
|
if (human) {
|
|
30257
30289
|
info(errorMsg);
|
|
30258
|
-
renderReceiptHuman(captured, jobId);
|
|
30290
|
+
await renderReceiptHuman(captured, jobId);
|
|
30259
30291
|
} else {
|
|
30260
30292
|
providerJobJson({
|
|
30261
30293
|
jobId,
|
|
@@ -30264,7 +30296,7 @@ async function recoverViaStatusPoll(args) {
|
|
|
30264
30296
|
message: errorMsg,
|
|
30265
30297
|
...status2.message !== void 0 ? { _provider_fields: ["message"] } : {},
|
|
30266
30298
|
...paymentFields,
|
|
30267
|
-
...receiptJsonFields(captured, jobId),
|
|
30299
|
+
...await receiptJsonFields(captured, jobId),
|
|
30268
30300
|
...takeCreditNoticeFields(),
|
|
30269
30301
|
...takeFeedbackNoticeFields(),
|
|
30270
30302
|
next_action: null
|
|
@@ -30452,12 +30484,14 @@ async function requestResultWithWarnings(requestId, opts) {
|
|
|
30452
30484
|
endpoint: intent.endpoint,
|
|
30453
30485
|
jobId: receipt.jobId
|
|
30454
30486
|
});
|
|
30487
|
+
const { wallet_remaining } = await terminalSettlementReport(receipt.jobId);
|
|
30455
30488
|
if (opts.human) {
|
|
30456
30489
|
info(`Recovered request ${requestId} as job ${receipt.jobId} (${receipt.status}).`);
|
|
30490
|
+
if (wallet_remaining) info(wallet_remaining.display);
|
|
30457
30491
|
if (confirmed.length > 0) {
|
|
30458
30492
|
info(`The wallet payment held for this request is now confirmed as spent on that job.`);
|
|
30459
30493
|
}
|
|
30460
|
-
renderReceiptHuman(captured);
|
|
30494
|
+
await renderReceiptHuman(captured);
|
|
30461
30495
|
return;
|
|
30462
30496
|
}
|
|
30463
30497
|
json({
|
|
@@ -30468,7 +30502,8 @@ async function requestResultWithWarnings(requestId, opts) {
|
|
|
30468
30502
|
...dvmIdentity(intent.dvmId, intent.capability),
|
|
30469
30503
|
...receipt.summary !== void 0 ? { summary: receipt.summary } : {},
|
|
30470
30504
|
...confirmed.length > 0 ? { confirmed_pending_submissions: confirmed } : {},
|
|
30471
|
-
...receiptJsonFields(captured),
|
|
30505
|
+
...await receiptJsonFields(captured),
|
|
30506
|
+
...wallet_remaining ? { wallet_remaining } : {},
|
|
30472
30507
|
next_action: receipt.status === "completed" || receipt.status === "failed" || receipt.status === "cancelled" ? null : {
|
|
30473
30508
|
type: "poll",
|
|
30474
30509
|
job_id: receipt.jobId,
|
|
@@ -30934,7 +30969,7 @@ async function statusWithAccess(jobId, opts, access) {
|
|
|
30934
30969
|
}
|
|
30935
30970
|
await settleCreditAfterRead({ job: stored, capture: receipt2, transport: transport2, human: opts.human });
|
|
30936
30971
|
transport2.close();
|
|
30937
|
-
renderStatus(jobId, stored, terminalStatus, completion2, "local", null, opts, {
|
|
30972
|
+
await renderStatus(jobId, stored, terminalStatus, completion2, "local", null, opts, {
|
|
30938
30973
|
receipt: receipt2,
|
|
30939
30974
|
content
|
|
30940
30975
|
});
|
|
@@ -31014,7 +31049,7 @@ async function statusWithAccess(jobId, opts, access) {
|
|
|
31014
31049
|
if (Object.keys(updates).length > 0) updateObservedJob(jobId, updates);
|
|
31015
31050
|
}
|
|
31016
31051
|
transport.close();
|
|
31017
|
-
renderStatus(jobId, stored, result.status, completion, "provider", nextAction, opts, {
|
|
31052
|
+
await renderStatus(jobId, stored, result.status, completion, "provider", nextAction, opts, {
|
|
31018
31053
|
msgs,
|
|
31019
31054
|
cursor: newCursor,
|
|
31020
31055
|
receipt,
|
|
@@ -31034,7 +31069,7 @@ function transientReceiptCapture(jobId, response, endpoint, currency) {
|
|
|
31034
31069
|
const result = verifyJobReceipt({ receipt: response.receipt, expectedJobId: jobId });
|
|
31035
31070
|
return toCapture(response.receipt, result, { currency }, endpoint);
|
|
31036
31071
|
}
|
|
31037
|
-
function renderStatus(jobId, stored, jobStatus, completion, source, nextAction, opts, fetched) {
|
|
31072
|
+
async function renderStatus(jobId, stored, jobStatus, completion, source, nextAction, opts, fetched) {
|
|
31038
31073
|
const identifier = stored?.dvmId ? formatIdentifier(stored.dvmId, stored.capability) : void 0;
|
|
31039
31074
|
const artifacts = terminalCompletionOutput(jobId, jobStatus, completion, {
|
|
31040
31075
|
human: opts.human,
|
|
@@ -31047,7 +31082,7 @@ function renderStatus(jobId, stored, jobStatus, completion, source, nextAction,
|
|
|
31047
31082
|
...loadJob(jobId) ?? stored,
|
|
31048
31083
|
status: jobStatus
|
|
31049
31084
|
}, receipt?.receipt) : void 0;
|
|
31050
|
-
const settlement =
|
|
31085
|
+
const settlement = await terminalSettlementReport(jobId, {
|
|
31051
31086
|
status: jobStatus,
|
|
31052
31087
|
receipt: receipt?.receipt,
|
|
31053
31088
|
persistLocalState: !!stored,
|
|
@@ -31074,7 +31109,8 @@ ${msgs.length} new message(s):`);
|
|
|
31074
31109
|
if (traceId) info(`Trace: ${traceId}`);
|
|
31075
31110
|
if (spend) renderSpendHuman(spend, info);
|
|
31076
31111
|
else if (settlement.settlement) info(settlement.settlement.display);
|
|
31077
|
-
if (
|
|
31112
|
+
if (settlement.wallet_remaining) info(settlement.wallet_remaining.display);
|
|
31113
|
+
if (receipt) await renderReceiptHuman(receipt);
|
|
31078
31114
|
if (settlement.settlement_hint && !receipt?.currencyHint) info(` ${settlement.settlement_hint}`);
|
|
31079
31115
|
printNextActionHuman(nextAction);
|
|
31080
31116
|
return;
|
|
@@ -31096,7 +31132,7 @@ ${msgs.length} new message(s):`);
|
|
|
31096
31132
|
...completion.message ? { message: completion.message } : {},
|
|
31097
31133
|
// terminal responses only. On a still-running job "absent" would
|
|
31098
31134
|
// read as "this DVM doesn't issue receipts" rather than "not yet".
|
|
31099
|
-
...receipt ? receiptJsonFields(receipt) : {},
|
|
31135
|
+
...receipt ? await receiptJsonFields(receipt) : {},
|
|
31100
31136
|
...settlement,
|
|
31101
31137
|
...receipt?.currencyHint ? { settlement_hint: void 0 } : {},
|
|
31102
31138
|
// `dvm status` is a job-terminal emission for `--no-stream`
|
|
@@ -34206,10 +34242,10 @@ var NON_FUNGIBLE_MINT_NOTE = "Balances are per-mint: each mint is a separate cus
|
|
|
34206
34242
|
async function walletFund(amount, opts) {
|
|
34207
34243
|
const rail = (opts.rail ?? "cashu").toLowerCase();
|
|
34208
34244
|
if (rail === "tempo" || rail === "x402") {
|
|
34209
|
-
if (opts.mint !== void 0 || opts.timeout !== void 0 || opts.sats || opts.testSkipLightning || opts.float === false) {
|
|
34245
|
+
if (opts.mint !== void 0 || opts.timeout !== void 0 || opts.sats || opts.testSkipLightning || opts.float === false || opts.wait === false) {
|
|
34210
34246
|
throw new DvmError(
|
|
34211
34247
|
"invalid_flags_for_rail",
|
|
34212
|
-
"--mint, --timeout, --sats, --test-skip-lightning, and --no-
|
|
34248
|
+
"--mint, --timeout, --sats, --test-skip-lightning, --no-float, and --no-wait only apply to --rail cashu.",
|
|
34213
34249
|
`Drop these flags when running \`dvm wallet fund --rail ${rail}\`.`
|
|
34214
34250
|
);
|
|
34215
34251
|
}
|
|
@@ -34224,6 +34260,21 @@ async function walletFund(amount, opts) {
|
|
|
34224
34260
|
"Supported rails: cashu (default), tempo, x402."
|
|
34225
34261
|
);
|
|
34226
34262
|
}
|
|
34263
|
+
if (opts.wait === false && opts.testSkipLightning) {
|
|
34264
|
+
throw new DvmError(
|
|
34265
|
+
"invalid_fund_options",
|
|
34266
|
+
"--no-wait cannot be combined with --test-skip-lightning: there is no human-paid invoice to hand off.",
|
|
34267
|
+
"Drop --no-wait to wait for the test mint to settle."
|
|
34268
|
+
);
|
|
34269
|
+
}
|
|
34270
|
+
const float = opts.float === false || opts.testSkipLightning ? null : loadFloat();
|
|
34271
|
+
if (opts.wait === false && float) {
|
|
34272
|
+
throw new DvmError(
|
|
34273
|
+
"invalid_fund_options",
|
|
34274
|
+
"--no-wait cannot be used while the connected Lightning float pays the invoice.",
|
|
34275
|
+
"Add --no-float to hand the invoice to a human, or drop --no-wait for autonomous funding."
|
|
34276
|
+
);
|
|
34277
|
+
}
|
|
34227
34278
|
await loadConfiguredMints();
|
|
34228
34279
|
const wallet = loadAgentWallet();
|
|
34229
34280
|
if (!wallet) {
|
|
@@ -34242,7 +34293,6 @@ async function walletFund(amount, opts) {
|
|
|
34242
34293
|
const amountPhrase = describeAmount(amt);
|
|
34243
34294
|
const timeoutMs = parseTimeout2(opts.timeout);
|
|
34244
34295
|
const human = opts.human ?? false;
|
|
34245
|
-
const float = opts.float === false || opts.testSkipLightning ? null : loadFloat();
|
|
34246
34296
|
const btcRate = float ? await assertFloatBudget(sats * 1e3) : null;
|
|
34247
34297
|
let fundedQuoteId;
|
|
34248
34298
|
const selection = await resolveFundMint({
|
|
@@ -34297,6 +34347,68 @@ async function walletFund(amount, opts) {
|
|
|
34297
34347
|
info(`Paying from your Lightning wallet${float.alias ? ` (${float.alias})` : ""}\u2026`);
|
|
34298
34348
|
}
|
|
34299
34349
|
}
|
|
34350
|
+
const onInvoice = async (invoice, quote2) => {
|
|
34351
|
+
const expiresAt = quote2.expiry !== null ? new Date(quote2.expiry * 1e3).toISOString() : null;
|
|
34352
|
+
const previousUnpaid = sweep.still_pending.map((entry) => ({
|
|
34353
|
+
quote_id: entry.quote_id,
|
|
34354
|
+
mint: entry.mint,
|
|
34355
|
+
amount_sats: entry.amount_sats
|
|
34356
|
+
}));
|
|
34357
|
+
const warning = opts.wait === false && previousUnpaid.length > 0 ? `An unpaid quote already exists: ${previousUnpaid.map((entry) => `${entry.quote_id} at ${entry.mint} (${entry.amount_sats} sats)`).join(", ")}. This is a new invoice; avoid asking a human to pay both for the same top-up.` : void 0;
|
|
34358
|
+
if (human) {
|
|
34359
|
+
if (warning) info(`Warning: ${warning}`);
|
|
34360
|
+
info("");
|
|
34361
|
+
info("Pay this Lightning invoice from any Lightning wallet:");
|
|
34362
|
+
info("");
|
|
34363
|
+
info(invoice);
|
|
34364
|
+
info("");
|
|
34365
|
+
const ascii = await renderQrTerminal(invoice.toUpperCase());
|
|
34366
|
+
info(ascii);
|
|
34367
|
+
if (opts.qrImage !== void 0) {
|
|
34368
|
+
await writeInvoicePng(invoice, opts.qrImage);
|
|
34369
|
+
info(`QR PNG written to ${opts.qrImage}`);
|
|
34370
|
+
}
|
|
34371
|
+
if (opts.wait === false) {
|
|
34372
|
+
info(`Quote ID: ${quote2.quote}`);
|
|
34373
|
+
if (expiresAt) info(`Invoice expires: ${expiresAt}`);
|
|
34374
|
+
info("After payment, run `dvm wallet show` to collect the sats and check the new balance.");
|
|
34375
|
+
} else {
|
|
34376
|
+
info(
|
|
34377
|
+
"Polling for payment every 2s; press Ctrl-C to bail (the quote will be recoverable on next run)."
|
|
34378
|
+
);
|
|
34379
|
+
}
|
|
34380
|
+
} else {
|
|
34381
|
+
const qrImagePath = opts.qrImage ?? defaultQrImagePath();
|
|
34382
|
+
await writeInvoicePng(invoice, qrImagePath);
|
|
34383
|
+
json({
|
|
34384
|
+
status: "awaiting_payment",
|
|
34385
|
+
mint: mintUrl,
|
|
34386
|
+
mint_selection: mintSelection,
|
|
34387
|
+
amount_sats: sats,
|
|
34388
|
+
...amountSourceFields(amt),
|
|
34389
|
+
invoice,
|
|
34390
|
+
quote_id: quote2.quote,
|
|
34391
|
+
next_step: "dvm wallet show",
|
|
34392
|
+
qr_image_path: qrImagePath,
|
|
34393
|
+
relay: { copy_text: invoice, standalone: true },
|
|
34394
|
+
expires_at: expiresAt,
|
|
34395
|
+
lock_pubkey: wallet.lock_pubkey,
|
|
34396
|
+
display: `Pay ${sats} sats to the Lightning invoice to fund ${amountPhrase} into the agent wallet at ${mintUrl} (${selectionPhrase}). Scannable QR at ${qrImagePath}.`,
|
|
34397
|
+
...opts.wait === false ? {
|
|
34398
|
+
existing_unpaid_quotes: previousUnpaid,
|
|
34399
|
+
...warning ? { warning } : {},
|
|
34400
|
+
sweep: summarizeSweep(sweep),
|
|
34401
|
+
melt_sweep: summarizeMeltSweep(meltSweep)
|
|
34402
|
+
} : {},
|
|
34403
|
+
hint: opts.wait === false ? "Forward the QR PNG (or raw invoice) to a human. After payment, run `dvm wallet show` to collect the sats and check the new balance. Funding is still pending." : "Forward the QR PNG (or raw invoice) to a human; the CLI will mint P2PK-locked Cashu proofs into ~/.dvm/wallet.json once paid."
|
|
34404
|
+
});
|
|
34405
|
+
}
|
|
34406
|
+
};
|
|
34407
|
+
if (opts.wait === false) {
|
|
34408
|
+
const { quote: quote2 } = await createPendingMintQuote(sats, { mintUrl });
|
|
34409
|
+
await onInvoice(quote2.request, quote2);
|
|
34410
|
+
return;
|
|
34411
|
+
}
|
|
34300
34412
|
const result = await fundWithRecoverableWait(sats, {
|
|
34301
34413
|
mintUrl,
|
|
34302
34414
|
timeoutMs,
|
|
@@ -34355,42 +34467,7 @@ async function walletFund(amount, opts) {
|
|
|
34355
34467
|
});
|
|
34356
34468
|
}
|
|
34357
34469
|
},
|
|
34358
|
-
onInvoice
|
|
34359
|
-
const expiresAt = quote2.expiry !== null ? new Date(quote2.expiry * 1e3).toISOString() : null;
|
|
34360
|
-
if (human) {
|
|
34361
|
-
info("");
|
|
34362
|
-
info("Pay this Lightning invoice from any Lightning wallet:");
|
|
34363
|
-
info("");
|
|
34364
|
-
info(invoice);
|
|
34365
|
-
info("");
|
|
34366
|
-
const ascii = await renderQrTerminal(invoice.toUpperCase());
|
|
34367
|
-
info(ascii);
|
|
34368
|
-
if (opts.qrImage !== void 0) {
|
|
34369
|
-
await writeInvoicePng(invoice, opts.qrImage);
|
|
34370
|
-
info(`QR PNG written to ${opts.qrImage}`);
|
|
34371
|
-
}
|
|
34372
|
-
info(
|
|
34373
|
-
"Polling for payment every 2s; press Ctrl-C to bail (the quote will be recoverable on next run)."
|
|
34374
|
-
);
|
|
34375
|
-
} else {
|
|
34376
|
-
const qrImagePath = opts.qrImage ?? defaultQrImagePath();
|
|
34377
|
-
await writeInvoicePng(invoice, qrImagePath);
|
|
34378
|
-
json({
|
|
34379
|
-
status: "awaiting_payment",
|
|
34380
|
-
mint: mintUrl,
|
|
34381
|
-
mint_selection: mintSelection,
|
|
34382
|
-
amount_sats: sats,
|
|
34383
|
-
...amountSourceFields(amt),
|
|
34384
|
-
invoice,
|
|
34385
|
-
qr_image_path: qrImagePath,
|
|
34386
|
-
relay: { copy_text: invoice, standalone: true },
|
|
34387
|
-
expires_at: expiresAt,
|
|
34388
|
-
lock_pubkey: wallet.lock_pubkey,
|
|
34389
|
-
display: `Pay ${sats} sats to the Lightning invoice to fund ${amountPhrase} into the agent wallet at ${mintUrl} (${selectionPhrase}). Scannable QR at ${qrImagePath}.`,
|
|
34390
|
-
hint: "Forward the QR PNG (or raw invoice) to a human; the CLI will mint P2PK-locked Cashu proofs into ~/.dvm/wallet.json once paid."
|
|
34391
|
-
});
|
|
34392
|
-
}
|
|
34393
|
-
}
|
|
34470
|
+
onInvoice
|
|
34394
34471
|
});
|
|
34395
34472
|
const totalProofSats = result.proofs.reduce((sum, p) => sum + p.amount, 0);
|
|
34396
34473
|
if (human) {
|
|
@@ -34510,6 +34587,9 @@ async function walletShow(opts) {
|
|
|
34510
34587
|
const recovered = sweep.recovered_proofs.reduce((sum, p) => sum + p.amount, 0);
|
|
34511
34588
|
info(`Recovered ${recovered} sats from ${sweep.recovered_proofs.length} pending mint(s).`);
|
|
34512
34589
|
}
|
|
34590
|
+
for (const collected of summarizeSweep(sweep).collected) {
|
|
34591
|
+
info(`${collected.display} Added ${collected.sats_collected} sats at ${collected.mint}.`);
|
|
34592
|
+
}
|
|
34513
34593
|
for (const expired of expiredMints) {
|
|
34514
34594
|
info(
|
|
34515
34595
|
`Unpaid mint quote expired: ${expired.amount_sats} sats at ${expired.mint} (quote ID ${expired.quote_id}) \u2014 local recovery entry removed.`
|
|
@@ -34772,7 +34852,7 @@ async function fundX402Rail(amount, opts) {
|
|
|
34772
34852
|
const { connected, isNew } = await withX402ChannelLock(async () => {
|
|
34773
34853
|
const existing = loadX402Wallet();
|
|
34774
34854
|
return existing ? { connected: await ensureAddress(existing), isNew: false } : {
|
|
34775
|
-
connected: await saveX402Wallet(await generateX402PrivateKey(), X402_DEFAULT_NETWORK),
|
|
34855
|
+
connected: await saveX402Wallet(await generateX402PrivateKey(), X402_DEFAULT_NETWORK, true),
|
|
34776
34856
|
isNew: true
|
|
34777
34857
|
};
|
|
34778
34858
|
});
|
|
@@ -34987,7 +35067,7 @@ function formatFeePpk(fee) {
|
|
|
34987
35067
|
function formatPending(p, unchecked) {
|
|
34988
35068
|
const row = `${p.amount_sats} sats at ${p.mint} (quote ${p.quote_id}, requested ${p.requested_at})`;
|
|
34989
35069
|
return unchecked ? `${row}
|
|
34990
|
-
\u21B3 ${uncheckedPendingNote(unchecked)}` : `${row} \u2014 awaiting payment`;
|
|
35070
|
+
\u21B3 ${uncheckedPendingNote(unchecked)}` : `${row} \u2014 not paid yet; awaiting payment`;
|
|
34991
35071
|
}
|
|
34992
35072
|
function reportUncheckedMints(unchecked) {
|
|
34993
35073
|
for (const entry of unchecked) {
|
|
@@ -35034,6 +35114,20 @@ function summarizeMeltSweep(sweep) {
|
|
|
35034
35114
|
}
|
|
35035
35115
|
function summarizeSweep(sweep) {
|
|
35036
35116
|
return {
|
|
35117
|
+
pending: sweep.still_pending.map((entry) => ({
|
|
35118
|
+
quote_id: entry.quote_id,
|
|
35119
|
+
mint: entry.mint,
|
|
35120
|
+
amount_sats: entry.amount_sats,
|
|
35121
|
+
display: `Mint quote ${entry.quote_id} is not paid yet.`
|
|
35122
|
+
})),
|
|
35123
|
+
collected: sweep.outcomes.flatMap(
|
|
35124
|
+
(outcome) => outcome.kind === "minted" || outcome.kind === "restored" ? [{
|
|
35125
|
+
quote_id: outcome.entry.quote_id,
|
|
35126
|
+
mint: outcome.entry.mint,
|
|
35127
|
+
sats_collected: outcome.proofs.reduce((sum, proof) => sum + proof.amount, 0),
|
|
35128
|
+
display: `Mint quote ${outcome.entry.quote_id} was paid and collected.`
|
|
35129
|
+
}] : []
|
|
35130
|
+
),
|
|
35037
35131
|
recovered_count: sweep.recovered_proofs.length,
|
|
35038
35132
|
recovered_sats: sweep.recovered_proofs.reduce((s, p) => s + p.amount, 0),
|
|
35039
35133
|
// Additive to `dropped`, which remains the compatibility field for callers
|
|
@@ -35990,35 +36084,132 @@ function mnemonicValidationError2(result) {
|
|
|
35990
36084
|
);
|
|
35991
36085
|
}
|
|
35992
36086
|
|
|
35993
|
-
// src/lib/wallet-agent/
|
|
35994
|
-
|
|
35995
|
-
const
|
|
35996
|
-
|
|
35997
|
-
|
|
35998
|
-
|
|
35999
|
-
|
|
36000
|
-
|
|
36087
|
+
// src/lib/wallet-agent/invoice.ts
|
|
36088
|
+
function invoiceDestination(destination) {
|
|
36089
|
+
const invoice = destination.replace(/^lightning:/i, "").toLowerCase();
|
|
36090
|
+
return !invoice.includes("@") && /^ln(bcrt|tbs|tb|bc)([0-9]+[munp]?)?1[02-9ac-hj-np-z]+$/.test(invoice) ? invoice : void 0;
|
|
36091
|
+
}
|
|
36092
|
+
function invalidInvoice(message2) {
|
|
36093
|
+
throw new DvmError(
|
|
36094
|
+
"invalid_invoice",
|
|
36095
|
+
`${message2} No money moved.`,
|
|
36096
|
+
"Ask for a valid mainnet invoice with an amount, then run `dvm wallet cash-out <invoice>`."
|
|
36097
|
+
);
|
|
36098
|
+
}
|
|
36099
|
+
function invoiceAmountSats(invoice, now = Date.now()) {
|
|
36100
|
+
let decoded;
|
|
36101
|
+
try {
|
|
36102
|
+
decoded = bech32.decode(invoice, false);
|
|
36103
|
+
} catch {
|
|
36104
|
+
return invalidInvoice("The invoice has invalid Bech32 encoding or checksum.");
|
|
36105
|
+
}
|
|
36106
|
+
const header = /^ln(bcrt|tbs|tb|bc)([0-9]+)?([munp]?)$/.exec(decoded.prefix);
|
|
36107
|
+
if (!header || header[1] !== "bc") return invalidInvoice("The invoice is on the wrong network; this wallet pays Bitcoin mainnet invoices.");
|
|
36108
|
+
if (!header[2]) return invalidInvoice("An amountless invoice cannot be cashed out.");
|
|
36109
|
+
const scale = { "": 1000000000000n, m: 1000000000n, u: 1000000n, n: 1000n, p: 1n };
|
|
36110
|
+
const picoBtc = BigInt(header[2]) * scale[header[3]];
|
|
36111
|
+
if (picoBtc <= 0n || picoBtc % 10n !== 0n) return invalidInvoice("The invoice amount must be positive and represent whole millisatoshis.");
|
|
36112
|
+
const sats = Number((picoBtc + 9999n) / 10000n);
|
|
36113
|
+
const words = decoded.words;
|
|
36114
|
+
const end = words.length - 104;
|
|
36115
|
+
if (end < 7 || !Number.isSafeInteger(sats)) return invalidInvoice("The invoice has invalid payment data or amount.");
|
|
36116
|
+
const integer = (data) => data.reduce((value, word) => value * 32 + word, 0);
|
|
36117
|
+
const timestamp = integer(words.slice(0, 7));
|
|
36118
|
+
let expiry = 3600;
|
|
36119
|
+
let hasExpiry = false;
|
|
36120
|
+
for (let pos = 7; pos < end; ) {
|
|
36121
|
+
if (pos + 3 > end) return invalidInvoice("The invoice has a truncated tagged field.");
|
|
36122
|
+
const tag = words[pos], length = words[pos + 1] * 32 + words[pos + 2];
|
|
36123
|
+
pos += 3;
|
|
36124
|
+
if (pos + length > end) return invalidInvoice("The invoice has a truncated tagged field.");
|
|
36125
|
+
if (tag === 6) {
|
|
36126
|
+
if (hasExpiry || length === 0) return invalidInvoice("The invoice has an invalid expiry field.");
|
|
36127
|
+
expiry = integer(words.slice(pos, pos + length));
|
|
36128
|
+
hasExpiry = true;
|
|
36129
|
+
}
|
|
36130
|
+
pos += length;
|
|
36131
|
+
}
|
|
36132
|
+
if (!Number.isSafeInteger(timestamp + expiry)) return invalidInvoice("The invoice expiry is out of range.");
|
|
36133
|
+
const remainingMs = (timestamp + expiry) * 1e3 - now;
|
|
36134
|
+
if (remainingMs <= 0) return invalidInvoice("The invoice has expired.");
|
|
36135
|
+
if (remainingMs < 6e4) return invalidInvoice("The invoice expires in less than 60 seconds.");
|
|
36136
|
+
return sats;
|
|
36137
|
+
}
|
|
36138
|
+
function assertInvoiceNotPending(wallet, invoice) {
|
|
36139
|
+
const normalized = invoiceDestination(invoice);
|
|
36140
|
+
if (normalized && wallet.pending_melts.some((entry) => invoiceDestination(entry.bolt11) === normalized)) {
|
|
36001
36141
|
throw new DvmError(
|
|
36002
|
-
"
|
|
36003
|
-
"
|
|
36004
|
-
"Run `dvm wallet
|
|
36142
|
+
"cash_out_pending",
|
|
36143
|
+
"This invoice already has a cash-out in flight. No money moved.",
|
|
36144
|
+
"Run `dvm wallet show` to reconcile it before retrying."
|
|
36005
36145
|
);
|
|
36006
36146
|
}
|
|
36007
|
-
|
|
36008
|
-
|
|
36009
|
-
|
|
36010
|
-
|
|
36011
|
-
|
|
36012
|
-
|
|
36013
|
-
|
|
36014
|
-
|
|
36015
|
-
|
|
36016
|
-
|
|
36147
|
+
}
|
|
36148
|
+
|
|
36149
|
+
// src/lib/wallet-agent/cash-out-invoice.ts
|
|
36150
|
+
async function prepareInvoice(opts, candidates, bounds) {
|
|
36151
|
+
const mint = opts.mintUrl;
|
|
36152
|
+
const refuse = (reason, message2) => ({
|
|
36153
|
+
kind: "skipped",
|
|
36154
|
+
mint,
|
|
36155
|
+
reason,
|
|
36156
|
+
message: `${message2} No money moved. Run \`dvm wallet mint-health\`, then retry \`dvm wallet cash-out <invoice>\`.`
|
|
36157
|
+
});
|
|
36158
|
+
const invoice = opts.bolt11;
|
|
36159
|
+
const amount = invoiceAmountSats(invoice, (opts.now ?? Date.now)());
|
|
36017
36160
|
try {
|
|
36018
|
-
|
|
36161
|
+
const quote2 = await fetchMeltQuote(mint, invoice);
|
|
36162
|
+
if (quote2.amountSats !== amount) {
|
|
36163
|
+
return refuse("quote_amount_mismatch", `The mint quoted ${quote2.amountSats} sats for a ${amount} sat invoice.`);
|
|
36164
|
+
}
|
|
36165
|
+
if (typeof quote2.rawQuote.expiry === "number" && quote2.rawQuote.expiry * 1e3 <= (opts.now ?? Date.now)()) {
|
|
36166
|
+
return refuse("quote_expired", "The invoice's melt quote has expired.");
|
|
36167
|
+
}
|
|
36168
|
+
const inBounds = (bounds.minSats === null || amount >= bounds.minSats) && (bounds.maxSats === null || amount <= bounds.maxSats);
|
|
36169
|
+
const selected = [];
|
|
36170
|
+
let selectedTotal = 0;
|
|
36171
|
+
let inputFees = 0;
|
|
36172
|
+
for (const proof of candidates) {
|
|
36173
|
+
selected.push(proof);
|
|
36174
|
+
selectedTotal += proof.amount;
|
|
36175
|
+
inputFees = await getInputFeesForProofs(mint, toCashuProofs(selected));
|
|
36176
|
+
if (inBounds && selectedTotal >= quote2.amountSats + quote2.feeReserveSats + inputFees) break;
|
|
36177
|
+
}
|
|
36178
|
+
let largest = Math.max(0, Math.min(selectedTotal - quote2.feeReserveSats - inputFees, bounds.maxSats ?? Infinity));
|
|
36179
|
+
if (largest < (bounds.minSats ?? 1)) largest = 0;
|
|
36180
|
+
const fits = largest > 0 ? `The largest invoice amount that fits at the quoted fees is ${largest} sats. No money moved. Ask for an invoice of at most ${largest} sats, then run \`dvm wallet cash-out <invoice>\`.` : "No invoice can be paid from this balance at the quoted fees and mint limits. No money moved. Run `dvm wallet show` to check your balance, or `dvm wallet fund` to add funds.";
|
|
36181
|
+
if (selectedTotal < quote2.amountSats + quote2.feeReserveSats + inputFees) {
|
|
36182
|
+
return {
|
|
36183
|
+
kind: "skipped",
|
|
36184
|
+
mint,
|
|
36185
|
+
reason: "fees_exceed_balance",
|
|
36186
|
+
message: `The ${quote2.amountSats} sat invoice plus fees exceeds the ${selectedTotal} sat balance at ${mint}. ${fits}`
|
|
36187
|
+
};
|
|
36188
|
+
}
|
|
36189
|
+
if (bounds.minSats !== null && amount < bounds.minSats || bounds.maxSats !== null && amount > bounds.maxSats) {
|
|
36190
|
+
return {
|
|
36191
|
+
kind: "skipped",
|
|
36192
|
+
mint,
|
|
36193
|
+
reason: "amount_out_of_range",
|
|
36194
|
+
message: `The ${amount} sat invoice is outside this mint's payout limits. ${fits}`
|
|
36195
|
+
};
|
|
36196
|
+
}
|
|
36197
|
+
return { invoice, quote: quote2, selected, selectedTotal, inputFees };
|
|
36019
36198
|
} catch (err) {
|
|
36020
|
-
return {
|
|
36199
|
+
return {
|
|
36200
|
+
kind: "failed",
|
|
36201
|
+
mint,
|
|
36202
|
+
settlement: "reverted",
|
|
36203
|
+
message: `Could not obtain a cash-out quote or input fees at ${mint}: ${err instanceof Error ? err.message : String(err)}. No money moved. Run \`dvm wallet mint-health\`, then retry \`dvm wallet cash-out <invoice>\`.`
|
|
36204
|
+
};
|
|
36021
36205
|
}
|
|
36206
|
+
}
|
|
36207
|
+
|
|
36208
|
+
// src/lib/wallet-agent/cash-out-prepare.ts
|
|
36209
|
+
async function prepareCashOut(opts, candidates, cashuWallet) {
|
|
36210
|
+
const mintUrl = opts.mintUrl;
|
|
36211
|
+
const fetchInvoice = opts.fetchInvoice ?? fetchLnurlPayInvoice;
|
|
36212
|
+
if (opts.bolt11 !== void 0) return prepareInvoice(opts, candidates, meltBoundsOf(cashuWallet));
|
|
36022
36213
|
const meltBounds = meltBoundsOf(cashuWallet);
|
|
36023
36214
|
let target = opts.target;
|
|
36024
36215
|
let cappedByMintMax;
|
|
@@ -36134,6 +36325,92 @@ async function cashOutFromMint(opts) {
|
|
|
36134
36325
|
}
|
|
36135
36326
|
}
|
|
36136
36327
|
}
|
|
36328
|
+
return { invoice, quote: quote2, selected, selectedTotal, inputFees, cappedByMintMax };
|
|
36329
|
+
}
|
|
36330
|
+
function meltBoundsOf(wallet) {
|
|
36331
|
+
const reader = wallet;
|
|
36332
|
+
try {
|
|
36333
|
+
const nuts = reader.getMintInfo?.().cache?.nuts;
|
|
36334
|
+
if (nuts === void 0 || nuts === null) return { minSats: null, maxSats: null };
|
|
36335
|
+
return meltAmountBounds(nuts);
|
|
36336
|
+
} catch {
|
|
36337
|
+
return { minSats: null, maxSats: null };
|
|
36338
|
+
}
|
|
36339
|
+
}
|
|
36340
|
+
function selectInputs(candidates, target) {
|
|
36341
|
+
if (target.kind === "all") return [...candidates];
|
|
36342
|
+
const selected = [];
|
|
36343
|
+
let total = 0;
|
|
36344
|
+
for (const p of candidates) {
|
|
36345
|
+
selected.push(p);
|
|
36346
|
+
total += p.amount;
|
|
36347
|
+
if (total >= target.sats) return selected;
|
|
36348
|
+
}
|
|
36349
|
+
return selected;
|
|
36350
|
+
}
|
|
36351
|
+
function widenSelection(candidates, selected, needed, currentInputFees) {
|
|
36352
|
+
const chosen = new Set(selected.map((p) => proofKey(p)));
|
|
36353
|
+
const rest = candidates.filter((p) => !chosen.has(proofKey(p)));
|
|
36354
|
+
if (rest.length === 0) return null;
|
|
36355
|
+
const next = [...selected];
|
|
36356
|
+
let total = sumSats2(next);
|
|
36357
|
+
for (const p of rest) {
|
|
36358
|
+
if (total >= needed + currentInputFees) break;
|
|
36359
|
+
next.push(p);
|
|
36360
|
+
total += p.amount;
|
|
36361
|
+
}
|
|
36362
|
+
return next.length === selected.length ? null : { selected: next };
|
|
36363
|
+
}
|
|
36364
|
+
function classifyPreCommitError(mintUrl, err) {
|
|
36365
|
+
if (err instanceof DvmError && err.code === "lnurl_amount_out_of_range") {
|
|
36366
|
+
return {
|
|
36367
|
+
kind: "skipped",
|
|
36368
|
+
mint: mintUrl,
|
|
36369
|
+
reason: "amount_out_of_range",
|
|
36370
|
+
message: err.message
|
|
36371
|
+
};
|
|
36372
|
+
}
|
|
36373
|
+
return { kind: "failed", mint: mintUrl, message: errorMessage2(err), settlement: "reverted" };
|
|
36374
|
+
}
|
|
36375
|
+
function sumSats2(proofs) {
|
|
36376
|
+
return proofs.reduce((sum, p) => sum + p.amount, 0);
|
|
36377
|
+
}
|
|
36378
|
+
function errorMessage2(err) {
|
|
36379
|
+
return err instanceof Error ? err.message : String(err);
|
|
36380
|
+
}
|
|
36381
|
+
|
|
36382
|
+
// src/lib/wallet-agent/cash-out.ts
|
|
36383
|
+
async function cashOutFromMint(opts) {
|
|
36384
|
+
const mintUrl = opts.mintUrl;
|
|
36385
|
+
const now = opts.now ?? (() => Date.now());
|
|
36386
|
+
const getWalletForMint = opts.getWalletForMint ?? getWallet;
|
|
36387
|
+
const initial = loadAgentWallet();
|
|
36388
|
+
if (!initial) {
|
|
36389
|
+
throw new DvmError(
|
|
36390
|
+
"wallet_missing",
|
|
36391
|
+
"No agent wallet found.",
|
|
36392
|
+
"Run `dvm wallet init` first to generate a lock keypair."
|
|
36393
|
+
);
|
|
36394
|
+
}
|
|
36395
|
+
if (opts.bolt11) assertInvoiceNotPending(initial, opts.bolt11);
|
|
36396
|
+
const candidates = spendableAt(initial.proofs, mintUrl);
|
|
36397
|
+
if (candidates.length === 0) {
|
|
36398
|
+
return {
|
|
36399
|
+
kind: "skipped",
|
|
36400
|
+
mint: mintUrl,
|
|
36401
|
+
reason: "no_balance",
|
|
36402
|
+
message: `No spendable proofs at ${mintUrl}.`
|
|
36403
|
+
};
|
|
36404
|
+
}
|
|
36405
|
+
let cashuWallet;
|
|
36406
|
+
try {
|
|
36407
|
+
cashuWallet = await getWalletForMint(mintUrl);
|
|
36408
|
+
} catch (err) {
|
|
36409
|
+
return { kind: "failed", mint: mintUrl, message: errorMessage3(err), settlement: "reverted" };
|
|
36410
|
+
}
|
|
36411
|
+
const prepared = await prepareCashOut(opts, candidates, cashuWallet);
|
|
36412
|
+
if ("kind" in prepared) return prepared;
|
|
36413
|
+
const { invoice, quote: quote2, selected, selectedTotal, inputFees, cappedByMintMax } = prepared;
|
|
36137
36414
|
const quoteView = {
|
|
36138
36415
|
mint: mintUrl,
|
|
36139
36416
|
quote_id: quote2.rawQuote.quote,
|
|
@@ -36149,7 +36426,7 @@ async function cashOutFromMint(opts) {
|
|
|
36149
36426
|
kind: "skipped",
|
|
36150
36427
|
mint: mintUrl,
|
|
36151
36428
|
reason: "fee_cap_exceeded",
|
|
36152
|
-
message: `Fees at ${mintUrl} would be up to ${totalFees} sats, over the ${opts.maxFeeSats} sat cap
|
|
36429
|
+
message: `Fees at ${mintUrl} would be up to ${totalFees} sats, over the ${opts.maxFeeSats} sat cap.${opts.bolt11 ? " No money moved. Run `dvm wallet cash-out <invoice> --max-fee <sats>` with a sufficient cap if you accept these fees." : ""}`,
|
|
36153
36430
|
quote: quoteView
|
|
36154
36431
|
};
|
|
36155
36432
|
}
|
|
@@ -36169,7 +36446,7 @@ async function cashOutFromMint(opts) {
|
|
|
36169
36446
|
return {
|
|
36170
36447
|
kind: "failed",
|
|
36171
36448
|
mint: mintUrl,
|
|
36172
|
-
message:
|
|
36449
|
+
message: errorMessage3(err),
|
|
36173
36450
|
settlement: "reverted",
|
|
36174
36451
|
quote: quoteView
|
|
36175
36452
|
};
|
|
@@ -36195,6 +36472,10 @@ async function cashOutFromMint(opts) {
|
|
|
36195
36472
|
const committed = await withWalletLock(() => {
|
|
36196
36473
|
const fresh = loadAgentWallet();
|
|
36197
36474
|
if (!fresh) return false;
|
|
36475
|
+
if (opts.bolt11) {
|
|
36476
|
+
assertInvoiceNotPending(fresh, opts.bolt11);
|
|
36477
|
+
invoiceAmountSats(opts.bolt11, now());
|
|
36478
|
+
}
|
|
36198
36479
|
const swept = sweepStaleInFlight(fresh, now());
|
|
36199
36480
|
const available = new Set(spendableAt(swept.wallet.proofs, mintUrl).map((p) => proofKey(p)));
|
|
36200
36481
|
if (![...selectedKeys].every((k) => available.has(k))) {
|
|
@@ -36238,20 +36519,10 @@ async function cashOutFromMint(opts) {
|
|
|
36238
36519
|
mint: mintUrl,
|
|
36239
36520
|
quote: quoteView,
|
|
36240
36521
|
preimage,
|
|
36241
|
-
change_sats:
|
|
36522
|
+
change_sats: sumSats3(changeProofs),
|
|
36242
36523
|
...cappedByMintMax !== void 0 ? { mint_max_sats: cappedByMintMax } : {}
|
|
36243
36524
|
};
|
|
36244
36525
|
}
|
|
36245
|
-
function meltBoundsOf(wallet) {
|
|
36246
|
-
const reader = wallet;
|
|
36247
|
-
try {
|
|
36248
|
-
const nuts = reader.getMintInfo?.().cache?.nuts;
|
|
36249
|
-
if (nuts === void 0 || nuts === null) return { minSats: null, maxSats: null };
|
|
36250
|
-
return meltAmountBounds(nuts);
|
|
36251
|
-
} catch {
|
|
36252
|
-
return { minSats: null, maxSats: null };
|
|
36253
|
-
}
|
|
36254
|
-
}
|
|
36255
36526
|
function spendableAt(proofs, mintUrl) {
|
|
36256
36527
|
return proofs.filter((p) => p.mint === mintUrl && p.status === "valid" && p.reserved_for === void 0).slice().sort((a, b) => b.amount - a.amount);
|
|
36257
36528
|
}
|
|
@@ -36267,7 +36538,7 @@ async function resolveFailedMelt(cashuWallet, mintUrl, entry, selectedKeys, quot
|
|
|
36267
36538
|
return {
|
|
36268
36539
|
kind: "failed",
|
|
36269
36540
|
mint: mintUrl,
|
|
36270
|
-
message: `${
|
|
36541
|
+
message: `${errorMessage3(err)} \u2014 ${entry.amount_sats} sats may still be in flight at ${mintUrl}. Run \`dvm wallet show\` to reconcile before retrying.`,
|
|
36271
36542
|
settlement: "unresolved",
|
|
36272
36543
|
quote: quoteView
|
|
36273
36544
|
};
|
|
@@ -36284,63 +36555,37 @@ async function resolveFailedMelt(cashuWallet, mintUrl, entry, selectedKeys, quot
|
|
|
36284
36555
|
return {
|
|
36285
36556
|
kind: "failed",
|
|
36286
36557
|
mint: mintUrl,
|
|
36287
|
-
message: `${
|
|
36558
|
+
message: `${errorMessage3(err)} \u2014 the mint confirms the invoice is unpaid, so the ${quoteView.debit_sats} sats are back in the wallet.`,
|
|
36288
36559
|
settlement: "reverted",
|
|
36289
36560
|
quote: quoteView
|
|
36290
36561
|
};
|
|
36291
36562
|
}
|
|
36292
|
-
function
|
|
36293
|
-
if (target.kind === "all") return [...candidates];
|
|
36294
|
-
const selected = [];
|
|
36295
|
-
let total = 0;
|
|
36296
|
-
for (const p of candidates) {
|
|
36297
|
-
selected.push(p);
|
|
36298
|
-
total += p.amount;
|
|
36299
|
-
if (total >= target.sats) return selected;
|
|
36300
|
-
}
|
|
36301
|
-
return selected;
|
|
36302
|
-
}
|
|
36303
|
-
function widenSelection(candidates, selected, needed, currentInputFees) {
|
|
36304
|
-
const chosen = new Set(selected.map((p) => proofKey(p)));
|
|
36305
|
-
const rest = candidates.filter((p) => !chosen.has(proofKey(p)));
|
|
36306
|
-
if (rest.length === 0) return null;
|
|
36307
|
-
const next = [...selected];
|
|
36308
|
-
let total = sumSats2(next);
|
|
36309
|
-
for (const p of rest) {
|
|
36310
|
-
if (total >= needed + currentInputFees) break;
|
|
36311
|
-
next.push(p);
|
|
36312
|
-
total += p.amount;
|
|
36313
|
-
}
|
|
36314
|
-
return next.length === selected.length ? null : { selected: next };
|
|
36315
|
-
}
|
|
36316
|
-
function classifyPreCommitError(mintUrl, err) {
|
|
36317
|
-
if (err instanceof DvmError && err.code === "lnurl_amount_out_of_range") {
|
|
36318
|
-
return {
|
|
36319
|
-
kind: "skipped",
|
|
36320
|
-
mint: mintUrl,
|
|
36321
|
-
reason: "amount_out_of_range",
|
|
36322
|
-
message: err.message
|
|
36323
|
-
};
|
|
36324
|
-
}
|
|
36325
|
-
return { kind: "failed", mint: mintUrl, message: errorMessage2(err), settlement: "reverted" };
|
|
36326
|
-
}
|
|
36327
|
-
function sumSats2(proofs) {
|
|
36563
|
+
function sumSats3(proofs) {
|
|
36328
36564
|
return proofs.reduce((sum, p) => sum + p.amount, 0);
|
|
36329
36565
|
}
|
|
36330
|
-
function
|
|
36566
|
+
function errorMessage3(err) {
|
|
36331
36567
|
return err instanceof Error ? err.message : String(err);
|
|
36332
36568
|
}
|
|
36333
36569
|
|
|
36334
36570
|
// src/commands/wallet-cash-out.ts
|
|
36335
36571
|
async function walletCashOut(destination, opts) {
|
|
36336
36572
|
const human = opts.human ?? false;
|
|
36337
|
-
|
|
36573
|
+
const bolt11 = invoiceDestination(destination);
|
|
36574
|
+
if (bolt11 && (opts.amount !== void 0 || opts.all === true || opts.sats === true)) {
|
|
36575
|
+
throw new DvmError(
|
|
36576
|
+
"invalid_flags",
|
|
36577
|
+
"The invoice fixes the amount; --amount, --all, and --sats cannot be used with it. No money moved.",
|
|
36578
|
+
"Run `dvm wallet cash-out <invoice>` without --amount, --all, or --sats."
|
|
36579
|
+
);
|
|
36580
|
+
}
|
|
36581
|
+
if (!bolt11 && opts.amount === void 0 === (opts.all !== true)) {
|
|
36338
36582
|
throw new DvmError(
|
|
36339
36583
|
"invalid_flags",
|
|
36340
36584
|
"Pass exactly one of --amount <amount> or --all.",
|
|
36341
36585
|
"`--amount 1000` sends 1000 sats and draws the fees on top; `--all` empties the wallet, with fees coming out of the balance."
|
|
36342
36586
|
);
|
|
36343
36587
|
}
|
|
36588
|
+
const invoiceSats = bolt11 ? invoiceAmountSats(bolt11) : void 0;
|
|
36344
36589
|
await loadConfiguredMints();
|
|
36345
36590
|
const wallet = loadAgentWallet();
|
|
36346
36591
|
if (!wallet) {
|
|
@@ -36353,9 +36598,10 @@ async function walletCashOut(destination, opts) {
|
|
|
36353
36598
|
await sweepPendingMints().catch(() => void 0);
|
|
36354
36599
|
await sweepPendingMelts().catch(() => void 0);
|
|
36355
36600
|
const fresh = loadAgentWallet() ?? wallet;
|
|
36601
|
+
if (bolt11) assertInvoiceNotPending(fresh, bolt11);
|
|
36356
36602
|
const requested = opts.amount ? await resolveFundingAmountSats(opts.amount, opts.sats) : null;
|
|
36357
36603
|
const maxFeeSats = parseMaxFee(opts.maxFee);
|
|
36358
|
-
await validateLnAddress(destination);
|
|
36604
|
+
if (!bolt11) await validateLnAddress(destination);
|
|
36359
36605
|
const mints = resolveMints(fresh, opts.mint);
|
|
36360
36606
|
if (mints.length === 0) {
|
|
36361
36607
|
throw new DvmError(
|
|
@@ -36365,9 +36611,9 @@ async function walletCashOut(destination, opts) {
|
|
|
36365
36611
|
);
|
|
36366
36612
|
}
|
|
36367
36613
|
if (human) {
|
|
36368
|
-
const what = requested ? describeAmount(requested) : "everything";
|
|
36614
|
+
const what = bolt11 ? "the invoice amount" : requested ? describeAmount(requested) : "everything";
|
|
36369
36615
|
info(
|
|
36370
|
-
`Cashing out ${what} to ${destination} across ${mints.length} mint(s)${opts.dryRun ? " (dry run \u2014 nothing will be paid)" : ""}\u2026`
|
|
36616
|
+
`Cashing out ${what} to ${destination}${bolt11 ? " from one mint" : ` across ${mints.length} mint(s)`}${opts.dryRun ? " (dry run \u2014 nothing will be paid)" : ""}\u2026`
|
|
36371
36617
|
);
|
|
36372
36618
|
}
|
|
36373
36619
|
const outcomes = [];
|
|
@@ -36378,6 +36624,7 @@ async function walletCashOut(destination, opts) {
|
|
|
36378
36624
|
mintUrl,
|
|
36379
36625
|
target: requested ? { kind: "exact", sats: remaining } : { kind: "all" },
|
|
36380
36626
|
destination,
|
|
36627
|
+
bolt11,
|
|
36381
36628
|
maxFeeSats,
|
|
36382
36629
|
dryRun: opts.dryRun,
|
|
36383
36630
|
onQuote: (quote2) => {
|
|
@@ -36385,6 +36632,7 @@ async function walletCashOut(destination, opts) {
|
|
|
36385
36632
|
}
|
|
36386
36633
|
});
|
|
36387
36634
|
outcomes.push(outcome);
|
|
36635
|
+
if (bolt11 && (outcome.kind !== "skipped" && !(outcome.kind === "failed" && !outcome.quote))) break;
|
|
36388
36636
|
if (requested && (outcome.kind === "sent" || outcome.kind === "quoted")) {
|
|
36389
36637
|
remaining -= outcome.quote.amount_sats;
|
|
36390
36638
|
}
|
|
@@ -36404,7 +36652,7 @@ async function walletCashOut(destination, opts) {
|
|
|
36404
36652
|
const moreToSend = opts.all === true || shortfall > 0;
|
|
36405
36653
|
const rows = outcomes.map((o) => toRow(o, moreToSend));
|
|
36406
36654
|
const status2 = opts.dryRun ? "quoted" : sentSats > 0 ? "cashed_out" : "nothing_sent";
|
|
36407
|
-
const display = opts.dryRun ? `Quoted ${quotedSats} sats to ${destination} across ${rows.length} mint(s). Nothing was paid.` : sentSats > 0 ? `Sent ${sentSats} sats to ${destination}${feeSats > 0 ? `, plus ${feeSats} sats in fees` : ""}${shortfall > 0 ? ` \u2014 ${shortfall} sats short of what you asked for` : ""}.` : `Nothing was sent to ${destination}.`;
|
|
36655
|
+
const display = opts.dryRun ? `Quoted ${quotedSats} sats to ${destination}${bolt11 ? " from one mint" : ` across ${rows.length} mint(s)`}. Nothing was paid.` : sentSats > 0 ? `Sent ${sentSats} sats to ${destination}${feeSats > 0 ? `, plus ${feeSats} sats in fees` : ""}${shortfall > 0 ? ` \u2014 ${shortfall} sats short of what you asked for` : ""}.` : `Nothing was sent to ${destination}.`;
|
|
36408
36656
|
const cappedCount = moreToSend ? rows.filter((r) => r.mint_max_sats !== void 0).length : 0;
|
|
36409
36657
|
const hint = buildHint({
|
|
36410
36658
|
unresolvedCount: unresolved.length,
|
|
@@ -36425,7 +36673,7 @@ async function walletCashOut(destination, opts) {
|
|
|
36425
36673
|
status: status2,
|
|
36426
36674
|
destination,
|
|
36427
36675
|
...requested ? amountSourceFields(requested) : { source_currency: "sats" },
|
|
36428
|
-
requested_sats: requested?.sats ?? null,
|
|
36676
|
+
requested_sats: requested?.sats ?? invoiceSats ?? null,
|
|
36429
36677
|
sats_sent: sentSats,
|
|
36430
36678
|
fee_sats: feeSats,
|
|
36431
36679
|
change_sats: changeSats,
|
|
@@ -36438,7 +36686,7 @@ async function walletCashOut(destination, opts) {
|
|
|
36438
36686
|
if (!opts.dryRun && sentSats === 0) {
|
|
36439
36687
|
throw new DvmError(
|
|
36440
36688
|
"cash_out_failed",
|
|
36441
|
-
`No mint could pay ${destination}.`,
|
|
36689
|
+
bolt11 && outcomes.every((o) => o.kind === "skipped" && o.reason === "fees_exceed_balance") ? "No single mint could cover this invoice and its fees. No money moved; invoice payments cannot be split across mints." : bolt11 && unresolved.length === 0 ? outcomes.map((o) => "message" in o ? o.message : "").filter(Boolean).join(" ") : `No mint could pay ${destination}.`,
|
|
36442
36690
|
unresolved.length > 0 ? "At least one melt's outcome is unknown \u2014 run `dvm wallet show` to reconcile it against the mint before retrying." : "See the per-mint reasons above. `dvm wallet mint-health` reports whether a mint is currently able to melt."
|
|
36443
36691
|
);
|
|
36444
36692
|
}
|
|
@@ -36530,7 +36778,7 @@ function resolveMints(wallet, explicit) {
|
|
|
36530
36778
|
return spendableAt(wallet.proofs, explicit).length > 0 ? [explicit] : [];
|
|
36531
36779
|
}
|
|
36532
36780
|
const candidates = /* @__PURE__ */ new Set([...effectiveMints(wallet), ...wallet.proofs.map((p) => p.mint)]);
|
|
36533
|
-
return [...candidates].map((url2) => ({ url: url2, sats:
|
|
36781
|
+
return [...candidates].map((url2) => ({ url: url2, sats: sumSats4(spendableAt(wallet.proofs, url2)) })).filter((m) => m.sats > 0).sort((a, b) => b.sats - a.sats || a.url.localeCompare(b.url)).map((m) => m.url);
|
|
36534
36782
|
}
|
|
36535
36783
|
function buildHint(args) {
|
|
36536
36784
|
if (args.unresolvedCount > 0) {
|
|
@@ -36559,7 +36807,7 @@ function parseMaxFee(raw2) {
|
|
|
36559
36807
|
}
|
|
36560
36808
|
return Math.floor(n);
|
|
36561
36809
|
}
|
|
36562
|
-
function
|
|
36810
|
+
function sumSats4(proofs) {
|
|
36563
36811
|
return proofs.reduce((sum, p) => sum + p.amount, 0);
|
|
36564
36812
|
}
|
|
36565
36813
|
|
|
@@ -38743,7 +38991,7 @@ async function walletX402Connect(keyArg, opts) {
|
|
|
38743
38991
|
qrImagePath: opts.qrImage
|
|
38744
38992
|
});
|
|
38745
38993
|
return {
|
|
38746
|
-
connected: { ...await saveX402Wallet(privateKey, network), generated: true },
|
|
38994
|
+
connected: { ...await saveX402Wallet(privateKey, network, true), generated: true },
|
|
38747
38995
|
handoff: handoff2
|
|
38748
38996
|
};
|
|
38749
38997
|
});
|
|
@@ -39936,6 +40184,9 @@ Docs:
|
|
|
39936
40184
|
"--sats",
|
|
39937
40185
|
"Treat numeric input as sats (Cashu only; default: fiat if a currency symbol/code is present \u2014 $5, \xA35, 5eur \u2014 else sats)"
|
|
39938
40186
|
).option("--mint <url>", "Cashu mint URL (default: configured mint, or Coinos)").option("--timeout <sec>", "Override DVM_FUND_TIMEOUT_SEC (default 600s)").option(
|
|
40187
|
+
"--no-wait",
|
|
40188
|
+
"Print a human-paid Lightning invoice and exit; collect after payment with 'dvm wallet show'. Cashu only; use --no-float if a float is connected."
|
|
40189
|
+
).option(
|
|
39939
40190
|
"--test-skip-lightning",
|
|
39940
40191
|
"Skip Lightning \u2014 for test mints that auto-pay invoices (FakeWallet). Cashu rail only."
|
|
39941
40192
|
).option(
|
|
@@ -39947,16 +40198,16 @@ Docs:
|
|
|
39947
40198
|
).option("--human", "Human-readable output instead of JSON").action((amount, opts) => {
|
|
39948
40199
|
return catchErrors(() => walletFund(amount, opts), opts.human);
|
|
39949
40200
|
});
|
|
39950
|
-
wallet.command("cash-out <
|
|
39951
|
-
"Move value out of the agent wallet to a Lightning address
|
|
40201
|
+
wallet.command("cash-out <destination>").description(
|
|
40202
|
+
"Move value out of the agent wallet to a Lightning address, lnurl1\u2026 string, or BOLT11 invoice (optionally lightning:). An invoice fixes the amount; otherwise pass --amount or --all. Fees are drawn on top of --amount"
|
|
39952
40203
|
).option(
|
|
39953
40204
|
"--amount <amount>",
|
|
39954
40205
|
"How much should arrive. Accepts sats (1000), USD ($5), GBP (\xA35 / 5gbp), EUR (\u20AC5 / 5eur), or JPY"
|
|
39955
40206
|
).option(
|
|
39956
40207
|
"--sats",
|
|
39957
40208
|
"Treat numeric input as sats (default: fiat if a currency symbol/code is present \u2014 $5, \xA35, 5eur \u2014 else sats)"
|
|
39958
|
-
).option("--all", "Empty the wallet (or the --mint mint) \u2014 fees come out of the balance").option("--mint <url>", "Cash out from this mint only (default: every mint, richest first)").option("--max-fee <sats>", "Refuse a mint whose routing reserve + input fee exceeds this").option("--dry-run", "Quote the melt and report the fee without paying anything").option("--human", "Human-readable output instead of JSON").action((
|
|
39959
|
-
return catchErrors(() => walletCashOut(
|
|
40209
|
+
).option("--all", "Empty the wallet (or the --mint mint) \u2014 fees come out of the balance").option("--mint <url>", "Cash out from this mint only (default: every mint, richest first)").option("--max-fee <sats>", "Refuse a mint whose routing reserve + input fee exceeds this").option("--dry-run", "Quote the melt and report the fee without paying anything").option("--human", "Human-readable output instead of JSON").action((destination, opts) => {
|
|
40210
|
+
return catchErrors(() => walletCashOut(destination, opts), opts.human);
|
|
39960
40211
|
});
|
|
39961
40212
|
wallet.command("receive-token <token>").description("Claim an external Cashu token into the agent wallet as spendable balance").option("--human", "Human-readable output instead of JSON").action((token, opts) => {
|
|
39962
40213
|
return catchErrors(() => walletReceiveToken(token, opts), opts.human);
|