shinjuku-shield 0.3.219 → 0.3.221
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 +4 -4
- package/manifest.json +6 -6
- package/package.json +3 -3
- package/shinjuku-seller.mjs +73 -14
- package/shinjuku-wallet.mjs +272 -57
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@ web services and AI answers from your private balance, so the payment does
|
|
|
5
5
|
not show who paid. It works inside your AI app (Claude, Cursor, Codex) and in
|
|
6
6
|
a terminal. Only you hold the keys: they never leave your computer.
|
|
7
7
|
|
|
8
|
-
This is version 0.3.
|
|
8
|
+
This is version 0.3.221. The command is `shinjuku`.
|
|
9
9
|
|
|
10
10
|
## Set up
|
|
11
11
|
|
|
12
12
|
```sh
|
|
13
|
-
npx -y shinjuku@0.3.
|
|
13
|
+
npx -y shinjuku@0.3.221 setup
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Setup does every step for you:
|
|
@@ -100,7 +100,7 @@ Add it yourself. The name of the wallet in your app is `shinjuku`.
|
|
|
100
100
|
Claude Code:
|
|
101
101
|
|
|
102
102
|
```sh
|
|
103
|
-
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.
|
|
103
|
+
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.221 mcp
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
## For builders: check what you install
|
|
@@ -116,7 +116,7 @@ with the Releases table in
|
|
|
116
116
|
Versions are published from GitHub Actions with npm provenance.
|
|
117
117
|
|
|
118
118
|
`shinjuku-shield` is the package that holds the wallet. `shinjuku-shielded`
|
|
119
|
-
0.3.
|
|
119
|
+
0.3.221, its older name, runs this package at the same version, so wallets
|
|
120
120
|
installed under that name keep updating. New installs use `shinjuku`.
|
|
121
121
|
|
|
122
122
|
The full guide is
|
package/manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": "carbon-shielded-wallet/bundle-manifest/v1",
|
|
3
3
|
"file": "shinjuku-wallet.mjs",
|
|
4
|
-
"sha256": "
|
|
5
|
-
"bytes":
|
|
6
|
-
"sourceCommit": "
|
|
4
|
+
"sha256": "52c863352dfca86ebd1266a905c55445c48cadc8b53b77d349725fd5062a2a62",
|
|
5
|
+
"bytes": 10298934,
|
|
6
|
+
"sourceCommit": "7411e830aea9ee9b7143b5c895a054606cfecaf8",
|
|
7
7
|
"sourceDirty": false,
|
|
8
8
|
"installRecordMatchesLockfile": true,
|
|
9
9
|
"releaseRule": "valid only when two fresh npm ci --ignore-scripts builds on different OSes give the same sha256; installRecordMatchesLockfile true means every entry npm installed equals its package-lock.json entry and every entry not marked optional, devOptional included, is installed: an optional entry (a package for another platform) may be absent",
|
|
@@ -1075,8 +1075,8 @@
|
|
|
1075
1075
|
],
|
|
1076
1076
|
"seller": {
|
|
1077
1077
|
"file": "shinjuku-seller.mjs",
|
|
1078
|
-
"sha256": "
|
|
1079
|
-
"bytes":
|
|
1078
|
+
"sha256": "3fbd12397c06f6b157b183fafd86d9f0d72e708c0c97887833ead480da1aabe6",
|
|
1079
|
+
"bytes": 4182433,
|
|
1080
1080
|
"entry": "wallet/src/seller/exact/index.mjs",
|
|
1081
1081
|
"external": [
|
|
1082
1082
|
"@x402/core/http",
|
|
@@ -1968,5 +1968,5 @@
|
|
|
1968
1968
|
}
|
|
1969
1969
|
]
|
|
1970
1970
|
},
|
|
1971
|
-
"publishedAt": "2026-11-
|
|
1971
|
+
"publishedAt": "2026-11-12T16:14:06.249Z"
|
|
1972
1972
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shield",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.221",
|
|
4
4
|
"mcpName": "io.github.ShinjukuStaition/shinjuku-shield",
|
|
5
5
|
"description": "Shinjuku Shield, private x402 payments on Solana: the self-custody wallet CLI and its MCP server. Shield, pay, and unshield USDC from any MCP agent, under caps you set.",
|
|
6
|
-
"shinjukuRelease": "
|
|
7
|
-
"shinjukuSha256": "
|
|
6
|
+
"shinjukuRelease": "52c86335",
|
|
7
|
+
"shinjukuSha256": "52c863352dfca86ebd1266a905c55445c48cadc8b53b77d349725fd5062a2a62",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shield",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
|
package/shinjuku-seller.mjs
CHANGED
|
@@ -45162,6 +45162,8 @@ var init_errorCodes = __esm({
|
|
|
45162
45162
|
// A damaged config.json (row 78): the setup-mode server repairs it and keeps the wallet (cli runMcpFirstRun).
|
|
45163
45163
|
"mcp_config_damaged",
|
|
45164
45164
|
"setup_tor_unavailable",
|
|
45165
|
+
// The agent-app setup's own Tor did not start before setup ran (cli mcpSetupBehindTor; nothing ran).
|
|
45166
|
+
"setup_tor_not_started",
|
|
45165
45167
|
// The wallet server behind Tor that the setup server starts after a Tor setup (stdioServer.mjs startTorRelay).
|
|
45166
45168
|
"setup_tor_wallet_ended",
|
|
45167
45169
|
"setup_tor_wallet_slow",
|
|
@@ -60816,6 +60818,7 @@ async function compactP03HistoryReportRun({
|
|
|
60816
60818
|
poolPreRead,
|
|
60817
60819
|
firstPreRead,
|
|
60818
60820
|
onList,
|
|
60821
|
+
onUnlist,
|
|
60819
60822
|
tailGrid,
|
|
60820
60823
|
heldPicks = {},
|
|
60821
60824
|
signal,
|
|
@@ -60992,6 +60995,10 @@ async function compactP03HistoryReportRun({
|
|
|
60992
60995
|
} catch (error) {
|
|
60993
60996
|
if (tailHit === void 0 || !TAIL_RETRY_REFUSALS.has(error?.compactHistoryRefusal)) throw error;
|
|
60994
60997
|
markPhase("compact-tail-refused-page0");
|
|
60998
|
+
try {
|
|
60999
|
+
onUnlist?.();
|
|
61000
|
+
} catch {
|
|
61001
|
+
}
|
|
60995
61002
|
readAgain = true;
|
|
60996
61003
|
lastFolds.delete(poolKey.toBase58());
|
|
60997
61004
|
try {
|
|
@@ -62014,10 +62021,17 @@ async function loadWalletP03History(args) {
|
|
|
62014
62021
|
const walkOwn = (signal) => {
|
|
62015
62022
|
ownStartedAt = Date.now();
|
|
62016
62023
|
const stop = new AbortController();
|
|
62017
|
-
const loading = loadWalletP03HistoryNow({ ...walkArgs, signal: stop.signal });
|
|
62018
62024
|
let entry;
|
|
62025
|
+
const loading = loadWalletP03HistoryNow({
|
|
62026
|
+
...walkArgs,
|
|
62027
|
+
signal: stop.signal,
|
|
62028
|
+
onListed: (listed) => {
|
|
62029
|
+
if (entry !== void 0) setListed(entry, listed);
|
|
62030
|
+
}
|
|
62031
|
+
});
|
|
62019
62032
|
if (joinable) {
|
|
62020
62033
|
entry = { startedAt: ownStartedAt, promise: loading, joined: false };
|
|
62034
|
+
endListed(entry);
|
|
62021
62035
|
sharedWalks.set(runKey, entry);
|
|
62022
62036
|
const ended2 = () => {
|
|
62023
62037
|
if (sharedWalks.get(runKey) === entry) sharedWalks.delete(runKey);
|
|
@@ -62041,7 +62055,7 @@ async function loadWalletP03History(args) {
|
|
|
62041
62055
|
prewarm.promise,
|
|
62042
62056
|
walkOwn,
|
|
62043
62057
|
"walk-prewarm-share",
|
|
62044
|
-
{ listed: () => prewarm.listedAt !== void 0 }
|
|
62058
|
+
{ listed: () => prewarm.listedAt !== void 0, unlisted: () => whenUnlisted(prewarm) }
|
|
62045
62059
|
);
|
|
62046
62060
|
if (taken?.own === true) return ownReport(taken.report);
|
|
62047
62061
|
if (taken !== void 0) {
|
|
@@ -62065,7 +62079,8 @@ async function loadWalletP03History(args) {
|
|
|
62065
62079
|
return loadWalletP03HistoryNow({ ...args, signal });
|
|
62066
62080
|
}, joinedRefresh ? "walk-joined-refresh" : "walk-prewarm", {
|
|
62067
62081
|
...joinedRefresh ? { untilMs: prewarm.ownAtMs } : {},
|
|
62068
|
-
listed: () => prewarm.listedAt !== void 0
|
|
62082
|
+
listed: () => prewarm.listedAt !== void 0,
|
|
62083
|
+
unlisted: () => whenUnlisted(prewarm)
|
|
62069
62084
|
});
|
|
62070
62085
|
if (taken?.own === true) {
|
|
62071
62086
|
if (runKey !== void 0) recentLoads.set(runKey, { startedAt: ownStartedAt, report: taken.report });
|
|
@@ -62095,7 +62110,7 @@ async function loadWalletP03History(args) {
|
|
|
62095
62110
|
const taken = await joinedWalkOrOwn(shared2.promise, (signal) => {
|
|
62096
62111
|
ownStartedAt = Date.now();
|
|
62097
62112
|
return loadWalletP03HistoryNow({ ...args, signal });
|
|
62098
|
-
}, "walk-shared");
|
|
62113
|
+
}, "walk-shared", { listed: () => shared2.listedAt !== void 0, unlisted: () => whenUnlisted(shared2) });
|
|
62099
62114
|
if (taken?.own === true) {
|
|
62100
62115
|
recentLoads.set(runKey, { startedAt: ownStartedAt, report: taken.report });
|
|
62101
62116
|
return taken.report;
|
|
@@ -62136,7 +62151,30 @@ function recentBeforePrewarm(runKey, prewarm) {
|
|
|
62136
62151
|
markPhase("walk-recent-before-prewarm");
|
|
62137
62152
|
return recent.report;
|
|
62138
62153
|
}
|
|
62139
|
-
|
|
62154
|
+
function setListed(entry, listed) {
|
|
62155
|
+
if (listed !== false) {
|
|
62156
|
+
entry.listedAt ??= Date.now();
|
|
62157
|
+
return;
|
|
62158
|
+
}
|
|
62159
|
+
if (entry.listedAt === void 0) return;
|
|
62160
|
+
entry.listedAt = void 0;
|
|
62161
|
+
const waiters = entry.unlistedWaiters;
|
|
62162
|
+
entry.unlistedWaiters = void 0;
|
|
62163
|
+
for (const wake of waiters ?? []) wake();
|
|
62164
|
+
}
|
|
62165
|
+
function whenUnlisted(entry) {
|
|
62166
|
+
const own = entry.of ?? entry;
|
|
62167
|
+
return new Promise((resolve18) => {
|
|
62168
|
+
(own.unlistedWaiters ??= /* @__PURE__ */ new Set()).add(resolve18);
|
|
62169
|
+
});
|
|
62170
|
+
}
|
|
62171
|
+
function endListed(entry) {
|
|
62172
|
+
const end = () => {
|
|
62173
|
+
entry.unlistedWaiters = void 0;
|
|
62174
|
+
};
|
|
62175
|
+
entry.promise.then(end, end);
|
|
62176
|
+
}
|
|
62177
|
+
async function joinedWalkOrOwn(joined, startOwn, mark, { untilMs = Date.now() + SHARED_WALK_WAIT_MS, listed, unlisted } = {}) {
|
|
62140
62178
|
const isReport = (report) => report !== null && typeof report === "object";
|
|
62141
62179
|
let timer;
|
|
62142
62180
|
let first;
|
|
@@ -62154,12 +62192,16 @@ async function joinedWalkOrOwn(joined, startOwn, mark, { untilMs = Date.now() +
|
|
|
62154
62192
|
markPhase(`${mark}-slow`);
|
|
62155
62193
|
if (listed?.() === true) {
|
|
62156
62194
|
markPhase(`${mark}-listed-wait`);
|
|
62195
|
+
const dropped = unlisted?.()?.then(() => JOINED_WALK_UNLISTED);
|
|
62196
|
+
let waited;
|
|
62157
62197
|
try {
|
|
62158
|
-
|
|
62159
|
-
return isReport(report) ? { own: false, report } : void 0;
|
|
62198
|
+
waited = await (dropped ? Promise.race([joined, dropped]) : joined);
|
|
62160
62199
|
} catch {
|
|
62161
62200
|
return void 0;
|
|
62162
62201
|
}
|
|
62202
|
+
if (waited !== JOINED_WALK_UNLISTED) return isReport(waited) ? { own: false, report: waited } : void 0;
|
|
62203
|
+
if (runEnded()) return void 0;
|
|
62204
|
+
markPhase(`${mark}-listed-dropped`);
|
|
62163
62205
|
}
|
|
62164
62206
|
const stop = new AbortController();
|
|
62165
62207
|
const own = startOwn(stop.signal);
|
|
@@ -62213,6 +62255,10 @@ async function loadWalletP03HistoryNow(args) {
|
|
|
62213
62255
|
if (!await channelMovedSince(startedAt)) throw error;
|
|
62214
62256
|
if (args.signal?.aborted) throw error;
|
|
62215
62257
|
markPhase("walk-channel-refreshed");
|
|
62258
|
+
try {
|
|
62259
|
+
args.onListed?.(false);
|
|
62260
|
+
} catch {
|
|
62261
|
+
}
|
|
62216
62262
|
startedAt = Date.now();
|
|
62217
62263
|
report = await untilHistorySourceSilent(walkWalletP03HistoryNow(args), startedAt);
|
|
62218
62264
|
}
|
|
@@ -62463,11 +62509,13 @@ async function compactFirst({
|
|
|
62463
62509
|
// `onListed` (PF146 (a), 2026-10-30: its pages passed; the fold and the deployment check follow).
|
|
62464
62510
|
...typeof onCompactList === "function" || typeof onListed === "function" ? { onList: (contexts) => {
|
|
62465
62511
|
try {
|
|
62466
|
-
onListed?.();
|
|
62512
|
+
onListed?.(true);
|
|
62467
62513
|
} catch {
|
|
62468
62514
|
}
|
|
62469
62515
|
onCompactList?.(contexts);
|
|
62470
62516
|
} } : {},
|
|
62517
|
+
// compact.mjs's cached-tail retry throws its first list away inside one try.
|
|
62518
|
+
...typeof onListed === "function" ? { onUnlist: () => onListed(false) } : {},
|
|
62471
62519
|
...signal !== void 0 ? { signal } : {},
|
|
62472
62520
|
// A program upgrade the list's pool read or deployment check meets: the AB175 channel fetch inside this read (compact.mjs
|
|
62473
62521
|
// programUpgrade), so the check runs again on this list instead of a second walk asking the page set again. It waits
|
|
@@ -62496,6 +62544,12 @@ async function compactFirst({
|
|
|
62496
62544
|
...firstPreRead !== void 0 ? { firstPreRead } : {}
|
|
62497
62545
|
} : options);
|
|
62498
62546
|
behindAnswer = void 0;
|
|
62547
|
+
if (!result.ok) {
|
|
62548
|
+
try {
|
|
62549
|
+
onListed?.(false);
|
|
62550
|
+
} catch {
|
|
62551
|
+
}
|
|
62552
|
+
}
|
|
62499
62553
|
if (!result.ok && signal?.aborted) throw signal.reason;
|
|
62500
62554
|
if (result.ok) {
|
|
62501
62555
|
markPhase("walk-compact");
|
|
@@ -62719,7 +62773,7 @@ function reportHistoryRpc(split3, source, result, crossChecked, rpcName) {
|
|
|
62719
62773
|
writeStderr(`history: ${who} answered ${list(split3.history)}; ${rpcName} answered ${list(split3.own)} (the pool's state on chain that the history must match, and the cross-check)${window2}${integrity}
|
|
62720
62774
|
`);
|
|
62721
62775
|
}
|
|
62722
|
-
var strictScope, recentScope, recentLoads, recentAgeStart, proofBuiltAt, historyCacheKey, sweptFolders, HISTORY_PREWARM_JOIN_MS, SHARED_WALK_WAIT_MS, JOINED_WALK_SLOW, PAGE0_PREREAD_AFTER_MS, SUBTREE_LEAVES4, prewarmedWalks, sharedWalks, PREWARMED_REPORTS, PAYMENT_TAKEN_REPORTS, REPORT_STARTED_AT, upgradeRefresh, upgradeRefreshRunning, upgradeRefreshTriedAt, UPGRADE_REFRESH_GAP_MS, behindPollMs, COMPACT_BEHIND_POLL_MS, COMPACT_BEHIND_POLL_MAX_MS, COMPACT_BEHIND_READ_MS, COMPACT_BEHIND_TOR_READ_MS, COMPACT_BEHIND_REFUSAL_MAX_BYTES, COMPACT_BEHIND_PAGE_BODY_MS, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, OWN_WALK_STEPS, announcedSources, ownSourceWords;
|
|
62776
|
+
var strictScope, recentScope, recentLoads, recentAgeStart, proofBuiltAt, historyCacheKey, sweptFolders, HISTORY_PREWARM_JOIN_MS, SHARED_WALK_WAIT_MS, JOINED_WALK_SLOW, JOINED_WALK_UNLISTED, PAGE0_PREREAD_AFTER_MS, SUBTREE_LEAVES4, prewarmedWalks, sharedWalks, PREWARMED_REPORTS, PAYMENT_TAKEN_REPORTS, REPORT_STARTED_AT, upgradeRefresh, upgradeRefreshRunning, upgradeRefreshTriedAt, UPGRADE_REFRESH_GAP_MS, behindPollMs, COMPACT_BEHIND_POLL_MS, COMPACT_BEHIND_POLL_MAX_MS, COMPACT_BEHIND_READ_MS, COMPACT_BEHIND_TOR_READ_MS, COMPACT_BEHIND_REFUSAL_MAX_BYTES, COMPACT_BEHIND_PAGE_BODY_MS, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, OWN_WALK_STEPS, announcedSources, ownSourceWords;
|
|
62723
62777
|
var init_walletHistory = __esm({
|
|
62724
62778
|
"wallet/src/history/walletHistory.mjs"() {
|
|
62725
62779
|
"use strict";
|
|
@@ -62746,6 +62800,7 @@ var init_walletHistory = __esm({
|
|
|
62746
62800
|
HISTORY_PREWARM_JOIN_MS = 1e4;
|
|
62747
62801
|
SHARED_WALK_WAIT_MS = 6e3;
|
|
62748
62802
|
JOINED_WALK_SLOW = /* @__PURE__ */ Symbol("joined_walk_slow");
|
|
62803
|
+
JOINED_WALK_UNLISTED = /* @__PURE__ */ Symbol("joined_walk_unlisted");
|
|
62749
62804
|
PAGE0_PREREAD_AFTER_MS = 4e4;
|
|
62750
62805
|
SUBTREE_LEAVES4 = 128n;
|
|
62751
62806
|
prewarmedWalks = /* @__PURE__ */ new Map();
|
|
@@ -70442,7 +70497,7 @@ function computeBalance({ store, snapshotRead, source = "local", now = Date.now(
|
|
|
70442
70497
|
let heldAtomic;
|
|
70443
70498
|
let heldWholeAtomic;
|
|
70444
70499
|
let spareMost = 0n;
|
|
70445
|
-
const report = (status, gross, next2, cause, largest2, change, changes) => {
|
|
70500
|
+
const report = (status, gross, next2, cause, largest2, change, changes, restOther) => {
|
|
70446
70501
|
const atomic4 = gross === null || privateSendPending === null ? null : gross > privateSendPending ? gross - privateSendPending : 0n;
|
|
70447
70502
|
if (atomic4 !== null && BigInt(detail.belowAccountsAtomic ?? "0") > atomic4) detail.belowAccountsAtomic = atomic4.toString();
|
|
70448
70503
|
const built = {
|
|
@@ -70485,6 +70540,7 @@ function computeBalance({ store, snapshotRead, source = "local", now = Date.now(
|
|
|
70485
70540
|
if (change !== void 0 && one === 0n && atomic4 > 0n) {
|
|
70486
70541
|
CHANGE_SETTLING.set(built, (change < atomic4 ? change : atomic4).toString());
|
|
70487
70542
|
if (Number.isSafeInteger(changes) && changes >= 2) CHANGE_COUNT.set(built, changes);
|
|
70543
|
+
if (restOther === true) CHANGE_REST_OTHER.add(built);
|
|
70488
70544
|
}
|
|
70489
70545
|
}
|
|
70490
70546
|
return built;
|
|
@@ -70811,7 +70867,8 @@ If a payment to this wallet settled, read the chain again with:
|
|
|
70811
70867
|
return change > most ? change : most;
|
|
70812
70868
|
}, 0n);
|
|
70813
70869
|
const changeFreeAtomic = sendHold === null || sendHold.unpacked.length === 0 ? changeAtomic : changeAtomic > privateSendPending ? changeAtomic - privateSendPending : 0n;
|
|
70814
|
-
const
|
|
70870
|
+
const restAtomic = sendHeldAtomic === null ? null : unspentAtomic - sendHeldAtomic - inputsAtomic;
|
|
70871
|
+
const changeOnly = settling.length > 0 && distinctInputs && (settling.length === 1 || sendHeldAtomic === 0n && privateSendPending === 0n) && settling.every((payment) => payment.join !== true && payment.exit !== true && inputsOf(payment) > payment.amountAtomic) && reservedAtomic === 0n && detail.joiningAtomic === "0" && successionMovableAtomic === 0n && restAtomic !== null && restAtomic >= 0n && changeFreeAtomic > 0n;
|
|
70815
70872
|
return report(
|
|
70816
70873
|
"stale",
|
|
70817
70874
|
spendable + successionMovableAtomic,
|
|
@@ -70821,7 +70878,8 @@ If a payment to this wallet settled, read the chain again with:
|
|
|
70821
70878
|
settlingRecent ? movedInAtomic === 0n && settling.length > 0 && settling.every((payment) => payment.join) ? "account_join" : "payment_settling" : movedInAtomic > 0n ? "pool_move" : void 0,
|
|
70822
70879
|
largest,
|
|
70823
70880
|
changeOnly ? changeFreeAtomic : void 0,
|
|
70824
|
-
settling.length
|
|
70881
|
+
settling.length,
|
|
70882
|
+
changeOnly && restAtomic > 0n
|
|
70825
70883
|
);
|
|
70826
70884
|
}
|
|
70827
70885
|
const newestSale = store.path ? newestSalePaidAt(store.path) : void 0;
|
|
@@ -70831,7 +70889,7 @@ If a payment to this wallet settled, read the chain again with:
|
|
|
70831
70889
|
}
|
|
70832
70890
|
return report("current", spendable + successionMovableAtomic, next, void 0, largest);
|
|
70833
70891
|
}
|
|
70834
|
-
var PAY_ME_WAL_SCHEMA, BALANCE_SNAPSHOT_SCHEMA, BALANCE_SNAPSHOT_FILE, STALE_CAUSES, LARGEST_PAYMENTS, CHANGE_SETTLING, CHANGE_COUNT, SPEND_INPUTS, SEND_HOLDS, PAYMENT_SETTLING_MS, NO_VALUE_TYPES, PLAN_ONLY_TYPES, UNSENT_SELF_PAY_FIELDS, isUnsentSelfPay, planOnly, SNAPSHOT_KEY_LABEL, MAINNET_USDC, SELF_PAY_ORIGIN, POCKET_FILL_RECORD, MERGE_RECORD, POOL_MOVE_SCHEMA, FLOAT_PAYMENT_SCHEMA, POOL_MOVE_PATH, POOL_SUCCESSION_SCHEMAS, digestKey, canonicalAtomic, SUCCESSION_JOB_SCHEMA, MERGE_PAYMENT_PATH, spendEntry, PROOF_RECORD;
|
|
70892
|
+
var PAY_ME_WAL_SCHEMA, BALANCE_SNAPSHOT_SCHEMA, BALANCE_SNAPSHOT_FILE, STALE_CAUSES, LARGEST_PAYMENTS, CHANGE_SETTLING, CHANGE_COUNT, CHANGE_REST_OTHER, SPEND_INPUTS, SEND_HOLDS, PAYMENT_SETTLING_MS, NO_VALUE_TYPES, PLAN_ONLY_TYPES, UNSENT_SELF_PAY_FIELDS, isUnsentSelfPay, planOnly, SNAPSHOT_KEY_LABEL, MAINNET_USDC, SELF_PAY_ORIGIN, POCKET_FILL_RECORD, MERGE_RECORD, POOL_MOVE_SCHEMA, FLOAT_PAYMENT_SCHEMA, POOL_MOVE_PATH, POOL_SUCCESSION_SCHEMAS, digestKey, canonicalAtomic, SUCCESSION_JOB_SCHEMA, MERGE_PAYMENT_PATH, spendEntry, PROOF_RECORD;
|
|
70835
70893
|
var init_balance = __esm({
|
|
70836
70894
|
"wallet/src/balance/balance.mjs"() {
|
|
70837
70895
|
"use strict";
|
|
@@ -70856,6 +70914,7 @@ var init_balance = __esm({
|
|
|
70856
70914
|
LARGEST_PAYMENTS = /* @__PURE__ */ new WeakMap();
|
|
70857
70915
|
CHANGE_SETTLING = /* @__PURE__ */ new WeakMap();
|
|
70858
70916
|
CHANGE_COUNT = /* @__PURE__ */ new WeakMap();
|
|
70917
|
+
CHANGE_REST_OTHER = /* @__PURE__ */ new WeakSet();
|
|
70859
70918
|
SPEND_INPUTS = /* @__PURE__ */ new WeakMap();
|
|
70860
70919
|
SEND_HOLDS = /* @__PURE__ */ new WeakMap();
|
|
70861
70920
|
PAYMENT_SETTLING_MS = 12e4;
|
|
@@ -79920,7 +79979,7 @@ async function installBundle(home, say) {
|
|
|
79920
79979
|
say(`Getting Tor for the wallet (once, about ${pinned.mb} MB from the Tor Project, checked).`);
|
|
79921
79980
|
let response;
|
|
79922
79981
|
try {
|
|
79923
|
-
response = await fetch(pinned.url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
|
|
79982
|
+
response = await fetch(pinned.url, { redirect: "error", signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
|
|
79924
79983
|
} catch (error) {
|
|
79925
79984
|
throw failure("the Tor download did not finish. Check the internet connection, then ask again", `the Tor download did not answer (${error?.name === "TimeoutError" ? "no answer in 5 minutes" : error?.cause?.code ?? error?.message ?? error})`);
|
|
79926
79985
|
}
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -44470,6 +44470,7 @@ async function routeOverOnions(argv2, {
|
|
|
44470
44470
|
onions: [...onions, ...spares],
|
|
44471
44471
|
live: onions.length,
|
|
44472
44472
|
spares,
|
|
44473
|
+
spareAfterMs,
|
|
44473
44474
|
waitMs: routeWaitMs,
|
|
44474
44475
|
label: origin,
|
|
44475
44476
|
// The line names the time and the spare wait, so a live run counts how often and when the spares join.
|
|
@@ -44499,10 +44500,11 @@ async function routeOverOnions(argv2, {
|
|
|
44499
44500
|
onions: [...onions, ...spares],
|
|
44500
44501
|
live: onions.length,
|
|
44501
44502
|
spares,
|
|
44503
|
+
spareAfterMs: HISTORY_SPARE_AFTER_MS,
|
|
44502
44504
|
path: HISTORY_PROBE_PATH,
|
|
44503
44505
|
label: "the history proxy",
|
|
44504
44506
|
kind: "history",
|
|
44505
|
-
onSpares: ({ afterMs, cause }) => err(`tor: the ${spares.length} spare history-proxy onion ${spareHosts} comes into use after ${(afterMs / 1e3).toFixed(1)} s (${SPARE_CAUSE[cause]}; the spare wait is ${
|
|
44507
|
+
onSpares: ({ afterMs, cause }) => err(`tor: the ${spares.length} spare history-proxy onion ${spareHosts} comes into use after ${(afterMs / 1e3).toFixed(1)} s (${SPARE_CAUSE[cause]}; the spare wait is ${HISTORY_SPARE_AFTER_MS / 1e3} s; Tor may still be fetching the onion addresses)
|
|
44506
44508
|
`),
|
|
44507
44509
|
onNone: () => err(`tor: no history-proxy onion answered its start probe (${liveOnions(group).length} tried); the pool history reads go to the pinned onion ${hostOf(onions[0])} and wait for it
|
|
44508
44510
|
`)
|
|
@@ -44595,7 +44597,7 @@ async function routeOverOnions(argv2, {
|
|
|
44595
44597
|
const spares = group.spares ?? [];
|
|
44596
44598
|
group.startSpares = race(group, liveOnions(group), {
|
|
44597
44599
|
...group.onNone ? { onNone: group.onNone } : {},
|
|
44598
|
-
...spares.length > 0 ? { spares, spareAfterMs, onSpares: (info) => {
|
|
44600
|
+
...spares.length > 0 ? { spares, spareAfterMs: group.spareAfterMs, onSpares: (info) => {
|
|
44599
44601
|
group.live = group.onions.length;
|
|
44600
44602
|
group.onSpares?.(info);
|
|
44601
44603
|
} } : {}
|
|
@@ -44821,7 +44823,7 @@ async function routeOverOnions(argv2, {
|
|
|
44821
44823
|
}
|
|
44822
44824
|
};
|
|
44823
44825
|
}
|
|
44824
|
-
var SITE_ONIONS, SITE_SPARE_ONIONS, PINNED_FACILITATOR_ONIONS, PINNED_SPARE_ONIONS, HISTORY_ONIONS, HISTORY_SPARE_ONIONS, PINNED_HISTORY_ONIONS, PINNED_HISTORY_SPARE_ONIONS, HISTORY_PROBE_PATH, SITE_PROBE_PATH, SITE_PROBE_ANSWERS, KEPT_ANSWER_MS, KEPT_ANSWER_BYTES, KEPT_BODY_MS, FACILITATOR_FLAGS, V3_ONION, DISCOVERY_TIMEOUT_MS, WARM_TIMEOUT_MS, RACE_TIMEOUT_MS, ROUTE_WAIT_MS, SPARE_AFTER_MS, HEDGE_MS, streamScope, requestStreams, socketRequests, guarded, STREAM_CHANNELS, streamSubscribers, streamWords, streamText, RESEND_LABELS, CHAIN_WAIT_LABELS, SPARE_CAUSE, routedGroups, liveOnions, hostOf, noAnswer, routedOnions, routedOrigins, onionsOfOrigin, routesOverOnion, routedGroupOf, answeredOn, noteAnswered, firstRaces, firstRaceRecords, firstRacesMarked, roleOf, ROUTE_LABELS, requestLabel, moveRecords, moveTimingLog, writeMove, firstOnionRace, onionDispatchers, ownTag, ownTagDispatchers, onOwnTagNow, ownTagInit;
|
|
44826
|
+
var SITE_ONIONS, SITE_SPARE_ONIONS, PINNED_FACILITATOR_ONIONS, PINNED_SPARE_ONIONS, HISTORY_ONIONS, HISTORY_SPARE_ONIONS, PINNED_HISTORY_ONIONS, PINNED_HISTORY_SPARE_ONIONS, HISTORY_PROBE_PATH, SITE_PROBE_PATH, SITE_PROBE_ANSWERS, KEPT_ANSWER_MS, KEPT_ANSWER_BYTES, KEPT_BODY_MS, FACILITATOR_FLAGS, V3_ONION, DISCOVERY_TIMEOUT_MS, WARM_TIMEOUT_MS, RACE_TIMEOUT_MS, ROUTE_WAIT_MS, SPARE_AFTER_MS, HISTORY_SPARE_AFTER_MS, HEDGE_MS, streamScope, requestStreams, socketRequests, guarded, STREAM_CHANNELS, streamSubscribers, streamWords, streamText, RESEND_LABELS, CHAIN_WAIT_LABELS, SPARE_CAUSE, routedGroups, liveOnions, hostOf, noAnswer, routedOnions, routedOrigins, onionsOfOrigin, routesOverOnion, routedGroupOf, answeredOn, noteAnswered, firstRaces, firstRaceRecords, firstRacesMarked, roleOf, ROUTE_LABELS, requestLabel, moveRecords, moveTimingLog, writeMove, firstOnionRace, onionDispatchers, ownTag, ownTagDispatchers, onOwnTagNow, ownTagInit;
|
|
44825
44827
|
var init_facilitatorOnion = __esm({
|
|
44826
44828
|
"wallet/src/net/facilitatorOnion.mjs"() {
|
|
44827
44829
|
"use strict";
|
|
@@ -44863,7 +44865,8 @@ var init_facilitatorOnion = __esm({
|
|
|
44863
44865
|
WARM_TIMEOUT_MS = 3e4;
|
|
44864
44866
|
RACE_TIMEOUT_MS = 9e4;
|
|
44865
44867
|
ROUTE_WAIT_MS = 15e3;
|
|
44866
|
-
SPARE_AFTER_MS =
|
|
44868
|
+
SPARE_AFTER_MS = 4e3;
|
|
44869
|
+
HISTORY_SPARE_AFTER_MS = 8e3;
|
|
44867
44870
|
HEDGE_MS = 5e3;
|
|
44868
44871
|
streamScope = new AsyncLocalStorage2();
|
|
44869
44872
|
requestStreams = /* @__PURE__ */ new WeakMap();
|
|
@@ -65452,6 +65455,7 @@ async function compactP03HistoryReportRun({
|
|
|
65452
65455
|
poolPreRead,
|
|
65453
65456
|
firstPreRead,
|
|
65454
65457
|
onList,
|
|
65458
|
+
onUnlist,
|
|
65455
65459
|
tailGrid,
|
|
65456
65460
|
heldPicks = {},
|
|
65457
65461
|
signal,
|
|
@@ -65628,6 +65632,10 @@ async function compactP03HistoryReportRun({
|
|
|
65628
65632
|
} catch (error) {
|
|
65629
65633
|
if (tailHit === void 0 || !TAIL_RETRY_REFUSALS.has(error?.compactHistoryRefusal)) throw error;
|
|
65630
65634
|
markPhase("compact-tail-refused-page0");
|
|
65635
|
+
try {
|
|
65636
|
+
onUnlist?.();
|
|
65637
|
+
} catch {
|
|
65638
|
+
}
|
|
65631
65639
|
readAgain = true;
|
|
65632
65640
|
lastFolds.delete(poolKey.toBase58());
|
|
65633
65641
|
try {
|
|
@@ -66651,10 +66659,17 @@ async function loadWalletP03History(args) {
|
|
|
66651
66659
|
const walkOwn = (signal) => {
|
|
66652
66660
|
ownStartedAt = Date.now();
|
|
66653
66661
|
const stop2 = new AbortController();
|
|
66654
|
-
const loading = loadWalletP03HistoryNow({ ...walkArgs, signal: stop2.signal });
|
|
66655
66662
|
let entry;
|
|
66663
|
+
const loading = loadWalletP03HistoryNow({
|
|
66664
|
+
...walkArgs,
|
|
66665
|
+
signal: stop2.signal,
|
|
66666
|
+
onListed: (listed) => {
|
|
66667
|
+
if (entry !== void 0) setListed(entry, listed);
|
|
66668
|
+
}
|
|
66669
|
+
});
|
|
66656
66670
|
if (joinable) {
|
|
66657
66671
|
entry = { startedAt: ownStartedAt, promise: loading, joined: false };
|
|
66672
|
+
endListed(entry);
|
|
66658
66673
|
sharedWalks.set(runKey, entry);
|
|
66659
66674
|
const ended2 = () => {
|
|
66660
66675
|
if (sharedWalks.get(runKey) === entry) sharedWalks.delete(runKey);
|
|
@@ -66678,7 +66693,7 @@ async function loadWalletP03History(args) {
|
|
|
66678
66693
|
prewarm.promise,
|
|
66679
66694
|
walkOwn,
|
|
66680
66695
|
"walk-prewarm-share",
|
|
66681
|
-
{ listed: () => prewarm.listedAt !== void 0 }
|
|
66696
|
+
{ listed: () => prewarm.listedAt !== void 0, unlisted: () => whenUnlisted(prewarm) }
|
|
66682
66697
|
);
|
|
66683
66698
|
if (taken?.own === true) return ownReport(taken.report);
|
|
66684
66699
|
if (taken !== void 0) {
|
|
@@ -66702,7 +66717,8 @@ async function loadWalletP03History(args) {
|
|
|
66702
66717
|
return loadWalletP03HistoryNow({ ...args, signal });
|
|
66703
66718
|
}, joinedRefresh ? "walk-joined-refresh" : "walk-prewarm", {
|
|
66704
66719
|
...joinedRefresh ? { untilMs: prewarm.ownAtMs } : {},
|
|
66705
|
-
listed: () => prewarm.listedAt !== void 0
|
|
66720
|
+
listed: () => prewarm.listedAt !== void 0,
|
|
66721
|
+
unlisted: () => whenUnlisted(prewarm)
|
|
66706
66722
|
});
|
|
66707
66723
|
if (taken?.own === true) {
|
|
66708
66724
|
if (runKey !== void 0) recentLoads.set(runKey, { startedAt: ownStartedAt, report: taken.report });
|
|
@@ -66732,7 +66748,7 @@ async function loadWalletP03History(args) {
|
|
|
66732
66748
|
const taken = await joinedWalkOrOwn(shared2.promise, (signal) => {
|
|
66733
66749
|
ownStartedAt = Date.now();
|
|
66734
66750
|
return loadWalletP03HistoryNow({ ...args, signal });
|
|
66735
|
-
}, "walk-shared");
|
|
66751
|
+
}, "walk-shared", { listed: () => shared2.listedAt !== void 0, unlisted: () => whenUnlisted(shared2) });
|
|
66736
66752
|
if (taken?.own === true) {
|
|
66737
66753
|
recentLoads.set(runKey, { startedAt: ownStartedAt, report: taken.report });
|
|
66738
66754
|
return taken.report;
|
|
@@ -66811,7 +66827,17 @@ function prewarmWalletP03History(args) {
|
|
|
66811
66827
|
rejectJoin(error);
|
|
66812
66828
|
});
|
|
66813
66829
|
});
|
|
66814
|
-
const joined = {
|
|
66830
|
+
const joined = {
|
|
66831
|
+
startedAt: shared2.startedAt,
|
|
66832
|
+
promise: bounded,
|
|
66833
|
+
settled: false,
|
|
66834
|
+
raw: shared2.promise,
|
|
66835
|
+
ownAtMs,
|
|
66836
|
+
of: shared2,
|
|
66837
|
+
get listedAt() {
|
|
66838
|
+
return shared2.listedAt;
|
|
66839
|
+
}
|
|
66840
|
+
};
|
|
66815
66841
|
joined.promise.then(() => {
|
|
66816
66842
|
joined.settled = true;
|
|
66817
66843
|
}, () => {
|
|
@@ -66825,9 +66851,8 @@ function prewarmWalletP03History(args) {
|
|
|
66825
66851
|
const marks = walletHistoryHomeMarks(args.store);
|
|
66826
66852
|
const entry = { startedAt: Date.now(), settled: false, marks };
|
|
66827
66853
|
const { paymentStartedAt: _paymentStartedAt, ...walkArgs } = args;
|
|
66828
|
-
entry.promise = loadWalletP03HistoryNow({ ...walkArgs, forceRead: false, onListed: () =>
|
|
66829
|
-
|
|
66830
|
-
} });
|
|
66854
|
+
entry.promise = loadWalletP03HistoryNow({ ...walkArgs, forceRead: false, onListed: (listed) => setListed(entry, listed) });
|
|
66855
|
+
endListed(entry);
|
|
66831
66856
|
entry.promise.then(prepareReport).catch(() => {
|
|
66832
66857
|
});
|
|
66833
66858
|
entry.promise.then((report) => {
|
|
@@ -66843,6 +66868,29 @@ function prewarmWalletP03History(args) {
|
|
|
66843
66868
|
return false;
|
|
66844
66869
|
}
|
|
66845
66870
|
}
|
|
66871
|
+
function setListed(entry, listed) {
|
|
66872
|
+
if (listed !== false) {
|
|
66873
|
+
entry.listedAt ??= Date.now();
|
|
66874
|
+
return;
|
|
66875
|
+
}
|
|
66876
|
+
if (entry.listedAt === void 0) return;
|
|
66877
|
+
entry.listedAt = void 0;
|
|
66878
|
+
const waiters = entry.unlistedWaiters;
|
|
66879
|
+
entry.unlistedWaiters = void 0;
|
|
66880
|
+
for (const wake of waiters ?? []) wake();
|
|
66881
|
+
}
|
|
66882
|
+
function whenUnlisted(entry) {
|
|
66883
|
+
const own = entry.of ?? entry;
|
|
66884
|
+
return new Promise((resolve43) => {
|
|
66885
|
+
(own.unlistedWaiters ??= /* @__PURE__ */ new Set()).add(resolve43);
|
|
66886
|
+
});
|
|
66887
|
+
}
|
|
66888
|
+
function endListed(entry) {
|
|
66889
|
+
const end2 = () => {
|
|
66890
|
+
entry.unlistedWaiters = void 0;
|
|
66891
|
+
};
|
|
66892
|
+
entry.promise.then(end2, end2);
|
|
66893
|
+
}
|
|
66846
66894
|
function walletHistoryHomeMarks(store) {
|
|
66847
66895
|
try {
|
|
66848
66896
|
const readAtMs = Date.now();
|
|
@@ -66859,7 +66907,7 @@ function walletHistoryHomeMarks(store) {
|
|
|
66859
66907
|
function latestPrewarmedWalletHistory() {
|
|
66860
66908
|
return latestPrewarm;
|
|
66861
66909
|
}
|
|
66862
|
-
async function joinedWalkOrOwn(joined, startOwn, mark, { untilMs = Date.now() + SHARED_WALK_WAIT_MS, listed } = {}) {
|
|
66910
|
+
async function joinedWalkOrOwn(joined, startOwn, mark, { untilMs = Date.now() + SHARED_WALK_WAIT_MS, listed, unlisted } = {}) {
|
|
66863
66911
|
const isReport = (report) => report !== null && typeof report === "object";
|
|
66864
66912
|
let timer;
|
|
66865
66913
|
let first;
|
|
@@ -66877,12 +66925,16 @@ async function joinedWalkOrOwn(joined, startOwn, mark, { untilMs = Date.now() +
|
|
|
66877
66925
|
markPhase(`${mark}-slow`);
|
|
66878
66926
|
if (listed?.() === true) {
|
|
66879
66927
|
markPhase(`${mark}-listed-wait`);
|
|
66928
|
+
const dropped = unlisted?.()?.then(() => JOINED_WALK_UNLISTED);
|
|
66929
|
+
let waited;
|
|
66880
66930
|
try {
|
|
66881
|
-
|
|
66882
|
-
return isReport(report) ? { own: false, report } : void 0;
|
|
66931
|
+
waited = await (dropped ? Promise.race([joined, dropped]) : joined);
|
|
66883
66932
|
} catch {
|
|
66884
66933
|
return void 0;
|
|
66885
66934
|
}
|
|
66935
|
+
if (waited !== JOINED_WALK_UNLISTED) return isReport(waited) ? { own: false, report: waited } : void 0;
|
|
66936
|
+
if (runEnded()) return void 0;
|
|
66937
|
+
markPhase(`${mark}-listed-dropped`);
|
|
66886
66938
|
}
|
|
66887
66939
|
const stop2 = new AbortController();
|
|
66888
66940
|
const own = startOwn(stop2.signal);
|
|
@@ -66936,6 +66988,10 @@ async function loadWalletP03HistoryNow(args) {
|
|
|
66936
66988
|
if (!await channelMovedSince(startedAt)) throw error;
|
|
66937
66989
|
if (args.signal?.aborted) throw error;
|
|
66938
66990
|
markPhase("walk-channel-refreshed");
|
|
66991
|
+
try {
|
|
66992
|
+
args.onListed?.(false);
|
|
66993
|
+
} catch {
|
|
66994
|
+
}
|
|
66939
66995
|
startedAt = Date.now();
|
|
66940
66996
|
report = await untilHistorySourceSilent(walkWalletP03HistoryNow(args), startedAt);
|
|
66941
66997
|
}
|
|
@@ -67191,11 +67247,13 @@ async function compactFirst({
|
|
|
67191
67247
|
// `onListed` (PF146 (a), 2026-10-30: its pages passed; the fold and the deployment check follow).
|
|
67192
67248
|
...typeof onCompactList === "function" || typeof onListed === "function" ? { onList: (contexts) => {
|
|
67193
67249
|
try {
|
|
67194
|
-
onListed?.();
|
|
67250
|
+
onListed?.(true);
|
|
67195
67251
|
} catch {
|
|
67196
67252
|
}
|
|
67197
67253
|
onCompactList?.(contexts);
|
|
67198
67254
|
} } : {},
|
|
67255
|
+
// compact.mjs's cached-tail retry throws its first list away inside one try.
|
|
67256
|
+
...typeof onListed === "function" ? { onUnlist: () => onListed(false) } : {},
|
|
67199
67257
|
...signal !== void 0 ? { signal } : {},
|
|
67200
67258
|
// A program upgrade the list's pool read or deployment check meets: the AB175 channel fetch inside this read (compact.mjs
|
|
67201
67259
|
// programUpgrade), so the check runs again on this list instead of a second walk asking the page set again. It waits
|
|
@@ -67224,6 +67282,12 @@ async function compactFirst({
|
|
|
67224
67282
|
...firstPreRead !== void 0 ? { firstPreRead } : {}
|
|
67225
67283
|
} : options);
|
|
67226
67284
|
behindAnswer = void 0;
|
|
67285
|
+
if (!result.ok) {
|
|
67286
|
+
try {
|
|
67287
|
+
onListed?.(false);
|
|
67288
|
+
} catch {
|
|
67289
|
+
}
|
|
67290
|
+
}
|
|
67227
67291
|
if (!result.ok && signal?.aborted) throw signal.reason;
|
|
67228
67292
|
if (result.ok) {
|
|
67229
67293
|
markPhase("walk-compact");
|
|
@@ -67456,7 +67520,7 @@ function reportHistoryRpc(split4, source, result, crossChecked, rpcName) {
|
|
|
67456
67520
|
writeStderr(`history: ${who} answered ${list(split4.history)}; ${rpcName} answered ${list(split4.own)} (the pool's state on chain that the history must match, and the cross-check)${window2}${integrity}
|
|
67457
67521
|
`);
|
|
67458
67522
|
}
|
|
67459
|
-
var prepareReport, strictScope, withStrictHistorySource, recentScope, withRecentWalletHistory, recentLoads, recentAgeStart, forgetRecentWalletHistory, proofBuiltAt, historyCacheKey, sweptFolders, latestPrewarm, HOME_MARKS_SETTLED_MS, PREWARM_RUNNING_MAX_MS, historyPrewarmRunning, HISTORY_PREWARM_JOIN_MS, SHARED_WALK_WAIT_MS, JOINED_WALK_SLOW, PAGE0_PREREAD_AFTER_MS, SUBTREE_LEAVES4, prewarmedWalks, sharedWalks, PREWARMED_REPORTS, PAYMENT_TAKEN_REPORTS, isPrewarmedWalletHistory, REPORT_STARTED_AT, walkStartedAtOf, upgradeRefresh, upgradeRefreshRunning, upgradeRefreshTriedAt, UPGRADE_REFRESH_GAP_MS, behindPollMs, COMPACT_BEHIND_POLL_MS, COMPACT_BEHIND_POLL_MAX_MS, COMPACT_BEHIND_READ_MS, COMPACT_BEHIND_TOR_READ_MS, COMPACT_BEHIND_REFUSAL_MAX_BYTES, COMPACT_BEHIND_PAGE_BODY_MS, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, OWN_WALK_STEPS, announcedSources, ownSourceWords;
|
|
67523
|
+
var prepareReport, strictScope, withStrictHistorySource, recentScope, withRecentWalletHistory, recentLoads, recentAgeStart, forgetRecentWalletHistory, proofBuiltAt, historyCacheKey, sweptFolders, latestPrewarm, HOME_MARKS_SETTLED_MS, PREWARM_RUNNING_MAX_MS, historyPrewarmRunning, HISTORY_PREWARM_JOIN_MS, SHARED_WALK_WAIT_MS, JOINED_WALK_SLOW, JOINED_WALK_UNLISTED, PAGE0_PREREAD_AFTER_MS, SUBTREE_LEAVES4, prewarmedWalks, sharedWalks, PREWARMED_REPORTS, PAYMENT_TAKEN_REPORTS, isPrewarmedWalletHistory, REPORT_STARTED_AT, walkStartedAtOf, upgradeRefresh, upgradeRefreshRunning, upgradeRefreshTriedAt, UPGRADE_REFRESH_GAP_MS, behindPollMs, COMPACT_BEHIND_POLL_MS, COMPACT_BEHIND_POLL_MAX_MS, COMPACT_BEHIND_READ_MS, COMPACT_BEHIND_TOR_READ_MS, COMPACT_BEHIND_REFUSAL_MAX_BYTES, COMPACT_BEHIND_PAGE_BODY_MS, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, OWN_WALK_STEPS, announcedSources, ownSourceWords;
|
|
67460
67524
|
var init_walletHistory = __esm({
|
|
67461
67525
|
"wallet/src/history/walletHistory.mjs"() {
|
|
67462
67526
|
"use strict";
|
|
@@ -67496,6 +67560,7 @@ var init_walletHistory = __esm({
|
|
|
67496
67560
|
HISTORY_PREWARM_JOIN_MS = 1e4;
|
|
67497
67561
|
SHARED_WALK_WAIT_MS = 6e3;
|
|
67498
67562
|
JOINED_WALK_SLOW = /* @__PURE__ */ Symbol("joined_walk_slow");
|
|
67563
|
+
JOINED_WALK_UNLISTED = /* @__PURE__ */ Symbol("joined_walk_unlisted");
|
|
67499
67564
|
PAGE0_PREREAD_AFTER_MS = 4e4;
|
|
67500
67565
|
SUBTREE_LEAVES4 = 128n;
|
|
67501
67566
|
prewarmedWalks = /* @__PURE__ */ new Map();
|
|
@@ -67677,6 +67742,17 @@ function spendHeads(spendableAtomic, largestAtomic, change = {}, options = {}) {
|
|
|
67677
67742
|
if (change?.changeSettling === true) {
|
|
67678
67743
|
const seconds2 = change.changeReadyInSeconds;
|
|
67679
67744
|
const upTo = String(change.changeUpToAtomic ?? "");
|
|
67745
|
+
if (change.changeRestOther === true) {
|
|
67746
|
+
const part = ATOMIC.test(upTo) && BigInt(upTo) > 0n && BigInt(upTo) < BigInt(spendable) ? usdcWords(upTo) : total;
|
|
67747
|
+
const settle = Number.isSafeInteger(change.changeCount) && change.changeCount >= 2 ? "once your recent payments settle" : "once your last payment settles";
|
|
67748
|
+
return [
|
|
67749
|
+
Number.isSafeInteger(seconds2) && seconds2 > 0 ? `You have ${total}; a payment now waits about ${seconds2} s, then can use up to ${part}` : `You have ${total}; a payment now can use up to ${part} ${settle}`,
|
|
67750
|
+
`You have ${total}; a payment can use up to ${part} after your ${settle.endsWith("settle") ? "recent ones settle" : "last one settles"}`,
|
|
67751
|
+
// 13 words: it fits the say with the longest public-USDC clause, 12 words with its read age (Codex round on 2ab1930a8,
|
|
67752
|
+
// P2: the say dropped the public 0.1 USDC); say.mjs drops its "counts a settling payment" clause first.
|
|
67753
|
+
`You have ${total}; ${part} can pay ${settle}`
|
|
67754
|
+
];
|
|
67755
|
+
}
|
|
67680
67756
|
if (Number.isSafeInteger(change.changeCount) && change.changeCount >= 2 && ATOMIC.test(upTo) && BigInt(upTo) > 0n && BigInt(upTo) < BigInt(spendable)) {
|
|
67681
67757
|
const part = usdcWords(upTo);
|
|
67682
67758
|
return Number.isSafeInteger(seconds2) && seconds2 > 0 ? [
|
|
@@ -80789,6 +80865,8 @@ var init_errorCodes = __esm({
|
|
|
80789
80865
|
// A damaged config.json (row 78): the setup-mode server repairs it and keeps the wallet (cli runMcpFirstRun).
|
|
80790
80866
|
"mcp_config_damaged",
|
|
80791
80867
|
"setup_tor_unavailable",
|
|
80868
|
+
// The agent-app setup's own Tor did not start before setup ran (cli mcpSetupBehindTor; nothing ran).
|
|
80869
|
+
"setup_tor_not_started",
|
|
80792
80870
|
// The wallet server behind Tor that the setup server starts after a Tor setup (stdioServer.mjs startTorRelay).
|
|
80793
80871
|
"setup_tor_wallet_ended",
|
|
80794
80872
|
"setup_tor_wallet_slow",
|
|
@@ -114034,7 +114112,7 @@ function computeBalance({ store, snapshotRead, source = "local", now = Date.now(
|
|
|
114034
114112
|
let heldAtomic;
|
|
114035
114113
|
let heldWholeAtomic;
|
|
114036
114114
|
let spareMost = 0n;
|
|
114037
|
-
const report = (status, gross, next2, cause, largest2, change, changes) => {
|
|
114115
|
+
const report = (status, gross, next2, cause, largest2, change, changes, restOther) => {
|
|
114038
114116
|
const atomic5 = gross === null || privateSendPending === null ? null : gross > privateSendPending ? gross - privateSendPending : 0n;
|
|
114039
114117
|
if (atomic5 !== null && BigInt(detail.belowAccountsAtomic ?? "0") > atomic5) detail.belowAccountsAtomic = atomic5.toString();
|
|
114040
114118
|
const built = {
|
|
@@ -114077,6 +114155,7 @@ function computeBalance({ store, snapshotRead, source = "local", now = Date.now(
|
|
|
114077
114155
|
if (change !== void 0 && one === 0n && atomic5 > 0n) {
|
|
114078
114156
|
CHANGE_SETTLING.set(built, (change < atomic5 ? change : atomic5).toString());
|
|
114079
114157
|
if (Number.isSafeInteger(changes) && changes >= 2) CHANGE_COUNT.set(built, changes);
|
|
114158
|
+
if (restOther === true) CHANGE_REST_OTHER.add(built);
|
|
114080
114159
|
}
|
|
114081
114160
|
}
|
|
114082
114161
|
return built;
|
|
@@ -114403,7 +114482,8 @@ If a payment to this wallet settled, read the chain again with:
|
|
|
114403
114482
|
return change > most ? change : most;
|
|
114404
114483
|
}, 0n);
|
|
114405
114484
|
const changeFreeAtomic = sendHold === null || sendHold.unpacked.length === 0 ? changeAtomic : changeAtomic > privateSendPending ? changeAtomic - privateSendPending : 0n;
|
|
114406
|
-
const
|
|
114485
|
+
const restAtomic = sendHeldAtomic === null ? null : unspentAtomic - sendHeldAtomic - inputsAtomic;
|
|
114486
|
+
const changeOnly = settling.length > 0 && distinctInputs && (settling.length === 1 || sendHeldAtomic === 0n && privateSendPending === 0n) && settling.every((payment) => payment.join !== true && payment.exit !== true && inputsOf(payment) > payment.amountAtomic) && reservedAtomic === 0n && detail.joiningAtomic === "0" && successionMovableAtomic === 0n && restAtomic !== null && restAtomic >= 0n && changeFreeAtomic > 0n;
|
|
114407
114487
|
return report(
|
|
114408
114488
|
"stale",
|
|
114409
114489
|
spendable + successionMovableAtomic,
|
|
@@ -114413,7 +114493,8 @@ If a payment to this wallet settled, read the chain again with:
|
|
|
114413
114493
|
settlingRecent ? movedInAtomic === 0n && settling.length > 0 && settling.every((payment) => payment.join) ? "account_join" : "payment_settling" : movedInAtomic > 0n ? "pool_move" : void 0,
|
|
114414
114494
|
largest,
|
|
114415
114495
|
changeOnly ? changeFreeAtomic : void 0,
|
|
114416
|
-
settling.length
|
|
114496
|
+
settling.length,
|
|
114497
|
+
changeOnly && restAtomic > 0n
|
|
114417
114498
|
);
|
|
114418
114499
|
}
|
|
114419
114500
|
const newestSale = store.path ? newestSalePaidAt(store.path) : void 0;
|
|
@@ -114437,7 +114518,7 @@ function combinePoolBalances(partsAtomic, movingAtomic = "0") {
|
|
|
114437
114518
|
if (!canonicalAtomic(String(movingAtomic))) return null;
|
|
114438
114519
|
return (partsAtomic.reduce((total, part) => total + BigInt(part), 0n) + BigInt(movingAtomic)).toString();
|
|
114439
114520
|
}
|
|
114440
|
-
var PAY_ME_WAL_SCHEMA, BALANCE_SNAPSHOT_SCHEMA, BALANCE_SNAPSHOT_FILE, STALE_CAUSES, staleCauseOf, LARGEST_PAYMENTS, largestPaymentOf, CHANGE_SETTLING, changeSettlingOf, changeUpToOf, CHANGE_COUNT, changeCountOf, SPEND_INPUTS, SEND_HOLDS, sendHoldOf, PAYMENT_SETTLING_MS, NO_VALUE_TYPES, PLAN_ONLY_TYPES, UNSENT_SELF_PAY_FIELDS, isUnsentSelfPay, planOnly, SNAPSHOT_KEY_LABEL, SPEND_STATUSES, MAINNET_USDC, SELF_PAY_ORIGIN2, POCKET_FILL_RECORD, MERGE_RECORD2, POOL_MOVE_SCHEMA, FLOAT_PAYMENT_SCHEMA2, POOL_MOVE_PATH2, POOL_SUCCESSION_SCHEMAS, digestKey, canonicalAtomic, SUCCESSION_JOB_SCHEMA, MERGE_PAYMENT_PATH, spendEntry, PROOF_RECORD;
|
|
114521
|
+
var PAY_ME_WAL_SCHEMA, BALANCE_SNAPSHOT_SCHEMA, BALANCE_SNAPSHOT_FILE, STALE_CAUSES, staleCauseOf, LARGEST_PAYMENTS, largestPaymentOf, CHANGE_SETTLING, changeSettlingOf, changeUpToOf, CHANGE_COUNT, changeCountOf, CHANGE_REST_OTHER, changeRestOtherOf, SPEND_INPUTS, SEND_HOLDS, sendHoldOf, PAYMENT_SETTLING_MS, NO_VALUE_TYPES, PLAN_ONLY_TYPES, UNSENT_SELF_PAY_FIELDS, isUnsentSelfPay, planOnly, SNAPSHOT_KEY_LABEL, SPEND_STATUSES, MAINNET_USDC, SELF_PAY_ORIGIN2, POCKET_FILL_RECORD, MERGE_RECORD2, POOL_MOVE_SCHEMA, FLOAT_PAYMENT_SCHEMA2, POOL_MOVE_PATH2, POOL_SUCCESSION_SCHEMAS, digestKey, canonicalAtomic, SUCCESSION_JOB_SCHEMA, MERGE_PAYMENT_PATH, spendEntry, PROOF_RECORD;
|
|
114441
114522
|
var init_balance = __esm({
|
|
114442
114523
|
"wallet/src/balance/balance.mjs"() {
|
|
114443
114524
|
"use strict";
|
|
@@ -114467,6 +114548,8 @@ var init_balance = __esm({
|
|
|
114467
114548
|
changeUpToOf = (report) => report !== null && typeof report === "object" ? CHANGE_SETTLING.get(report) : void 0;
|
|
114468
114549
|
CHANGE_COUNT = /* @__PURE__ */ new WeakMap();
|
|
114469
114550
|
changeCountOf = (report) => report !== null && typeof report === "object" ? CHANGE_COUNT.get(report) : void 0;
|
|
114551
|
+
CHANGE_REST_OTHER = /* @__PURE__ */ new WeakSet();
|
|
114552
|
+
changeRestOtherOf = (report) => report !== null && typeof report === "object" && CHANGE_REST_OTHER.has(report);
|
|
114470
114553
|
SPEND_INPUTS = /* @__PURE__ */ new WeakMap();
|
|
114471
114554
|
SEND_HOLDS = /* @__PURE__ */ new WeakMap();
|
|
114472
114555
|
sendHoldOf = (report) => report !== null && typeof report === "object" ? SEND_HOLDS.get(report) : void 0;
|
|
@@ -122318,6 +122401,7 @@ function partsOf(report, store, snapshot) {
|
|
|
122318
122401
|
changeReadyInSeconds: changeSettling ? changeReadyInSeconds() : null,
|
|
122319
122402
|
changeUpToAtomic: changeSettling ? changeUpToOf(report) ?? null : null,
|
|
122320
122403
|
...changeSettling && Number.isSafeInteger(changeCountOf(report)) ? { changeCount: changeCountOf(report) } : {},
|
|
122404
|
+
...changeSettling && changeRestOtherOf(report) ? { changeRestOther: true } : {},
|
|
122321
122405
|
refundsInFlightAtomic: refunds.proven.toString(),
|
|
122322
122406
|
refundsNotCertainAtomic: refunds.notCertain.toString(),
|
|
122323
122407
|
refundsInFlight: refunds.provenFor,
|
|
@@ -122540,14 +122624,14 @@ var init_models = __esm({
|
|
|
122540
122624
|
});
|
|
122541
122625
|
MODELS = Object.freeze([
|
|
122542
122626
|
model("claude-opus-5", 5000000n, 25000000n, "strongest"),
|
|
122543
|
-
//
|
|
122544
|
-
// 2026-11-
|
|
122545
|
-
//
|
|
122546
|
-
// left none under the caps (the
|
|
122547
|
-
//
|
|
122548
|
-
//
|
|
122549
|
-
// 0.0036 USDC for 4096 tokens
|
|
122550
|
-
model("deepseek-v4-1-flash",
|
|
122627
|
+
// Input 106000 since 2026-11-12 (was 77800; output 567000 since 2026-11-06, for openrouter's 51000 / 567000 then):
|
|
122628
|
+
// usePod's list read 2026-11-12 15:24:54, 15:26:24 and 15:27:23 UTC (api.usepod.ai/v1/marketplace/models, through Tor;
|
|
122629
|
+
// the same list each time) gives its centralized providers nousresearch 106000 / 513000, openrouter, venice and together
|
|
122630
|
+
// 300000 / 1200000, uomi 354210 / 1432140, so 77800 left none under the caps (the gates on c93243b99, served models).
|
|
122631
|
+
// 106000 / 567000 fits nousresearch, the only one under 300000 in; the output cap stays (it still fits openrouter's
|
|
122632
|
+
// 567000 if that price comes back). A short answer stays under usePod's floor, so "at most 0.011 USDC" stays; the
|
|
122633
|
+
// "about" price from the listed prices (answerPriceOf) stays 0.0036 USDC for 4096 tokens and 0.0014 for 512.
|
|
122634
|
+
model("deepseek-v4-1-flash", 106000n, 567000n, "fast and cheap"),
|
|
122551
122635
|
model("qwen3-8-flash", 150000n, 470000n, `small; thinks before it answers, so its length limit is at least ${THINKING_MIN_MAX_TOKENS} tokens`, { thinks: true })
|
|
122552
122636
|
]);
|
|
122553
122637
|
}
|
|
@@ -123528,9 +123612,13 @@ function balanceLine(a, room = SAY_MAX_WORDS) {
|
|
|
123528
123612
|
}
|
|
123529
123613
|
if (a.refreshing === true && a.refreshReason === "first_check") return `You have ${balance} USDC private from your deposits. The wallet's first full check of your balance is not done yet.${pubPart}`;
|
|
123530
123614
|
if (a.refreshing === true && a.refreshReason === "payment_settling" && !moving) {
|
|
123615
|
+
if (a.changeSettling === true && a.changeRestOther === true) {
|
|
123616
|
+
return have(`. This number already counts a settling payment.${pubPart}`, ...pubPart ? [`.${pubPart}`] : [], ". This number already counts a settling payment.");
|
|
123617
|
+
}
|
|
123531
123618
|
return have(
|
|
123532
123619
|
`. A payment is still settling; this number already counts it.${pubPart}`,
|
|
123533
123620
|
`. This number already counts a settling payment.${pubPart}`,
|
|
123621
|
+
...a.changeSettling === true && pubPart ? [`.${pubPart}`] : [],
|
|
123534
123622
|
". This number already counts a settling payment."
|
|
123535
123623
|
);
|
|
123536
123624
|
}
|
|
@@ -123798,8 +123886,13 @@ function build(a, tool, npmVersion) {
|
|
|
123798
123886
|
if (tool === "find_paid_services" || tool === void 0 && Array.isArray(a.results) && typeof a.query === "string") return discoverSay(a);
|
|
123799
123887
|
if (a.paid === false && a.replayed === true) return "Here is the same answer as before. Nothing was paid: the earlier payment for it never went through.";
|
|
123800
123888
|
if (a.paid === true) {
|
|
123801
|
-
const unconfirmed = a.receiptFinality === "pending" ? "
|
|
123802
|
-
if (a.replayed === true)
|
|
123889
|
+
const unconfirmed = a.receiptFinality === "pending" ? " This wallet has not seen the payment to the seller on the chain yet." : "";
|
|
123890
|
+
if (a.replayed === true) {
|
|
123891
|
+
return firstFit(
|
|
123892
|
+
`This request was already paid. Here is the same answer; nothing new was paid.${unconfirmed}`,
|
|
123893
|
+
`Already paid: here is the same answer, nothing new was paid.${unconfirmed}`
|
|
123894
|
+
);
|
|
123895
|
+
}
|
|
123803
123896
|
if (tool === "inference_chat" || typeof a.model === "string" && Object.hasOwn(a, "content")) {
|
|
123804
123897
|
const paid = usdcText2(a.paidAtomic);
|
|
123805
123898
|
const price3 = usdcText2(a.priceAtomic);
|
|
@@ -123813,7 +123906,7 @@ function build(a, tool, npmVersion) {
|
|
|
123813
123906
|
if (!total) return withBalance(`Paid. Here is the answer.${unconfirmed}`, a);
|
|
123814
123907
|
if (price2 && positive(fee)) {
|
|
123815
123908
|
const paid = `Paid ${total} USDC (${price2} price + ${fee} Shinjuku fee).`;
|
|
123816
|
-
return withBalance([`${paid} Here is the answer.${unconfirmed}`, `${paid}${unconfirmed}`], a);
|
|
123909
|
+
return withBalance([`${paid} Here is the answer.${unconfirmed}`, `${paid}${unconfirmed}`].filter((line, index, all) => words(line) <= SAY_MAX_WORDS || index === all.length - 1), a);
|
|
123817
123910
|
}
|
|
123818
123911
|
return withBalance(`Paid ${total} USDC. Here is the answer.${unconfirmed}`, a);
|
|
123819
123912
|
}
|
|
@@ -138173,7 +138266,11 @@ function createAddFundsTool({
|
|
|
138173
138266
|
wake,
|
|
138174
138267
|
timing,
|
|
138175
138268
|
// Lotus to-do 75: the pool a new address derives from (the wallet's own pool), so a refusal names that family's reason.
|
|
138176
|
-
familyPool
|
|
138269
|
+
familyPool,
|
|
138270
|
+
// The time from the call's arrival by which the chain reads before an answer must end (tools.mjs MONEY_FIRST_ANSWER_MS).
|
|
138271
|
+
firstAnswerMs = 2e4,
|
|
138272
|
+
// True for a link this build stopped for an update (payMe.mjs stoppedForUpdate with the wallet's build): no chain read.
|
|
138273
|
+
stoppedForBuild = () => false
|
|
138177
138274
|
} = {}) {
|
|
138178
138275
|
const note = (line) => {
|
|
138179
138276
|
try {
|
|
@@ -138218,13 +138315,17 @@ function createAddFundsTool({
|
|
|
138218
138315
|
op = void 0;
|
|
138219
138316
|
}
|
|
138220
138317
|
if (typeof op !== "function") return NO_MARKS;
|
|
138318
|
+
let answered2 = false;
|
|
138319
|
+
const lateOutcome = (outcome) => typeof outcome === "string" && outcome ? `${outcome.slice(0, 91)}_late` : "late";
|
|
138221
138320
|
const write = (phase, outcome) => {
|
|
138222
138321
|
try {
|
|
138223
|
-
op(phase, outcome);
|
|
138322
|
+
op(phase, answered2 ? lateOutcome(outcome) : outcome);
|
|
138224
138323
|
} catch {
|
|
138225
138324
|
}
|
|
138226
138325
|
};
|
|
138227
|
-
return { mark: (step2, outcome) => write(`add-funds:${step2}`, outcome), write, requests: 0, tunnels: 0
|
|
138326
|
+
return { mark: (step2, outcome) => write(`add-funds:${step2}`, outcome), write, requests: 0, tunnels: 0, answered: () => {
|
|
138327
|
+
answered2 = true;
|
|
138328
|
+
} };
|
|
138228
138329
|
}
|
|
138229
138330
|
async function step(call2, name, task) {
|
|
138230
138331
|
if (call2 === NO_MARKS) return task();
|
|
@@ -138241,6 +138342,39 @@ function createAddFundsTool({
|
|
|
138241
138342
|
release();
|
|
138242
138343
|
}
|
|
138243
138344
|
}
|
|
138345
|
+
async function bounded(call2, name, task, deadline) {
|
|
138346
|
+
call2.mark(`${name}-start`);
|
|
138347
|
+
const release = call2 === NO_MARKS ? () => {
|
|
138348
|
+
} : watchRequests();
|
|
138349
|
+
let started;
|
|
138350
|
+
try {
|
|
138351
|
+
started = Promise.resolve(call2 === NO_MARKS ? task() : stepScope.run(call2, () => withPhaseScope(call2.write, "add-funds", task)));
|
|
138352
|
+
} catch (error) {
|
|
138353
|
+
started = Promise.reject(error);
|
|
138354
|
+
}
|
|
138355
|
+
const read = started.then((value2) => {
|
|
138356
|
+
call2.mark(`${name}-end`);
|
|
138357
|
+
return value2;
|
|
138358
|
+
}, (error) => {
|
|
138359
|
+
call2.mark(`${name}-failed`, error instanceof PayMeError ? error.code : codeOf5(error));
|
|
138360
|
+
throw error;
|
|
138361
|
+
}).finally(release);
|
|
138362
|
+
let timer;
|
|
138363
|
+
const late2 = new Promise((resolve43) => {
|
|
138364
|
+
timer = setTimeout(() => resolve43(LATE2), Math.max(0, deadline - Date.now()));
|
|
138365
|
+
});
|
|
138366
|
+
try {
|
|
138367
|
+
const value2 = await Promise.race([read, late2]);
|
|
138368
|
+
if (value2 === LATE2) {
|
|
138369
|
+
read.catch(() => {
|
|
138370
|
+
});
|
|
138371
|
+
call2.mark(`${name}-late`);
|
|
138372
|
+
}
|
|
138373
|
+
return value2;
|
|
138374
|
+
} finally {
|
|
138375
|
+
clearTimeout(timer);
|
|
138376
|
+
}
|
|
138377
|
+
}
|
|
138244
138378
|
function nextFor(answer, agentId, prefix = "") {
|
|
138245
138379
|
const original = typeof answer.next === "string" ? answer.next : "";
|
|
138246
138380
|
if (original && !/wallet_pay_me/.test(original)) return prefix + original;
|
|
@@ -138391,20 +138525,34 @@ function createAddFundsTool({
|
|
|
138391
138525
|
});
|
|
138392
138526
|
return run2;
|
|
138393
138527
|
};
|
|
138394
|
-
async function withoutId(amountAtomic, text3, call2) {
|
|
138528
|
+
async function withoutId(amountAtomic, text3, call2, deadline) {
|
|
138395
138529
|
call2.mark("queued-end");
|
|
138396
138530
|
const open5 = payMeList().filter((record) => AUTO_ID.test(String(record?.id)) && record.state === "open");
|
|
138397
138531
|
call2.mark("listed");
|
|
138398
138532
|
if (open5.length >= ADD_FUNDS_OPEN_NO_ID_MAX) {
|
|
138399
138533
|
const newest = [...open5].sort((a, b) => String(b.createdAt).localeCompare(String(a.createdAt)));
|
|
138400
138534
|
const candidate = newest.find((record) => record.amountAtomic === amountAtomic) ?? newest[0];
|
|
138535
|
+
const reuseBy = deadline - CREATE_BUDGET_MS;
|
|
138536
|
+
const heldPending = bounded(call2, "held", () => payMeHeld(candidate), reuseBy);
|
|
138537
|
+
const wrongPending = bounded(call2, "wrong-coins", () => wrongCoinsOf(candidate, { fresh: true }), reuseBy);
|
|
138538
|
+
wrongPending.catch(() => {
|
|
138539
|
+
});
|
|
138401
138540
|
let held2;
|
|
138402
138541
|
try {
|
|
138403
|
-
|
|
138542
|
+
const read = await heldPending;
|
|
138543
|
+
held2 = read === LATE2 ? void 0 : BigInt(String(read));
|
|
138404
138544
|
} catch {
|
|
138405
138545
|
held2 = void 0;
|
|
138406
138546
|
}
|
|
138407
|
-
|
|
138547
|
+
let wrong;
|
|
138548
|
+
if (held2 === 0n) {
|
|
138549
|
+
try {
|
|
138550
|
+
const read = await wrongPending;
|
|
138551
|
+
wrong = read === LATE2 ? void 0 : read;
|
|
138552
|
+
} catch {
|
|
138553
|
+
wrong = void 0;
|
|
138554
|
+
}
|
|
138555
|
+
}
|
|
138408
138556
|
if (held2 === 0n && Array.isArray(wrong) && wrong.length === 0) {
|
|
138409
138557
|
const backup = await step(call2, "backup", () => backupAddress(candidate.owner));
|
|
138410
138558
|
if (backup?.backupError) return backupRefusal(candidate.id, backup.backupError);
|
|
@@ -138425,6 +138573,7 @@ function createAddFundsTool({
|
|
|
138425
138573
|
}
|
|
138426
138574
|
async function answerCall(args, progress2, calledAt, call2) {
|
|
138427
138575
|
const given = args?.request_id;
|
|
138576
|
+
const deadline = (Number.isFinite(calledAt) ? calledAt : Date.now()) + firstAnswerMs;
|
|
138428
138577
|
if (!enabled()) {
|
|
138429
138578
|
const { step: step2, extra } = offStep();
|
|
138430
138579
|
return refuse9(
|
|
@@ -138473,7 +138622,7 @@ function createAddFundsTool({
|
|
|
138473
138622
|
if (given === void 0) {
|
|
138474
138623
|
call2.mark("queued-start");
|
|
138475
138624
|
try {
|
|
138476
|
-
return await oneAtATime(() => withoutId(amountAtomic, text3, call2));
|
|
138625
|
+
return await oneAtATime(() => withoutId(amountAtomic, text3, call2, deadline));
|
|
138477
138626
|
} catch (error) {
|
|
138478
138627
|
return failure3(error);
|
|
138479
138628
|
}
|
|
@@ -138509,6 +138658,9 @@ function createAddFundsTool({
|
|
|
138509
138658
|
}
|
|
138510
138659
|
const backup = await step(call2, "backup", () => backupAddress(existing.owner));
|
|
138511
138660
|
if (backup?.backupError) return backupRefusal(given, backup.backupError);
|
|
138661
|
+
const wrongPending = stoppedForBuild(existing) ? void 0 : bounded(call2, "wrong-coins", () => wrongCoinsOf(existing), deadline);
|
|
138662
|
+
wrongPending?.catch(() => {
|
|
138663
|
+
});
|
|
138512
138664
|
call2.mark("status-start");
|
|
138513
138665
|
const status = await payMeAnswerSoon(linkId, { reused: true }, { progress: progress2, ...Number.isFinite(calledAt) ? { startedAt: calledAt } : {} });
|
|
138514
138666
|
call2.mark("status-end");
|
|
@@ -138518,8 +138670,15 @@ function createAddFundsTool({
|
|
|
138518
138670
|
} catch {
|
|
138519
138671
|
stopped = false;
|
|
138520
138672
|
}
|
|
138521
|
-
|
|
138522
|
-
|
|
138673
|
+
let wrong = [];
|
|
138674
|
+
if (wrongPending && !stopped) {
|
|
138675
|
+
try {
|
|
138676
|
+
wrong = await wrongPending;
|
|
138677
|
+
} catch {
|
|
138678
|
+
wrong = [];
|
|
138679
|
+
}
|
|
138680
|
+
}
|
|
138681
|
+
return await reshape(status, given, void 0, call2, wrong === LATE2 ? [] : wrong ?? []);
|
|
138523
138682
|
} catch (error) {
|
|
138524
138683
|
return failure3(error, given);
|
|
138525
138684
|
}
|
|
@@ -138548,14 +138707,18 @@ function createAddFundsTool({
|
|
|
138548
138707
|
output2 = await answerCall(args, progress2, calledAt, call2);
|
|
138549
138708
|
} catch (error) {
|
|
138550
138709
|
call2.mark("crashed", codeOf5(error));
|
|
138710
|
+
call2.answered?.();
|
|
138551
138711
|
throw error;
|
|
138552
138712
|
}
|
|
138553
|
-
if (call2 !== NO_MARKS)
|
|
138713
|
+
if (call2 !== NO_MARKS) {
|
|
138714
|
+
call2.mark("answered", answerOutcome(output2));
|
|
138715
|
+
call2.answered();
|
|
138716
|
+
}
|
|
138554
138717
|
return output2;
|
|
138555
138718
|
}
|
|
138556
138719
|
};
|
|
138557
138720
|
}
|
|
138558
|
-
var WRONG_COIN_READ_EVERY_MS, json, refuse9, ADD_FUNDS_REQUEST_ID, RESERVED_ID2, AUTO_ID, ADD_FUNDS_OPEN_NO_ID_MAX, POLL_SECONDS, QR_NEXT, usdc, NEXT_DEPOSIT_WHEN, LINK_AS_TEXT, ADD_FUNDS_LEAST, codeOf5, NO_MARKS, stepScope, stepRequests, outcomeOfError, onRequestEvent, REQUEST_EVENTS, watching, subscribed, answerOutcome;
|
|
138721
|
+
var WRONG_COIN_READ_EVERY_MS, LATE2, CREATE_BUDGET_MS, json, refuse9, ADD_FUNDS_REQUEST_ID, RESERVED_ID2, AUTO_ID, ADD_FUNDS_OPEN_NO_ID_MAX, POLL_SECONDS, QR_NEXT, usdc, NEXT_DEPOSIT_WHEN, LINK_AS_TEXT, ADD_FUNDS_LEAST, codeOf5, NO_MARKS, stepScope, stepRequests, outcomeOfError, onRequestEvent, REQUEST_EVENTS, watching, subscribed, answerOutcome;
|
|
138559
138722
|
var init_addFunds = __esm({
|
|
138560
138723
|
"wallet/src/mcp/addFunds.mjs"() {
|
|
138561
138724
|
"use strict";
|
|
@@ -138566,6 +138729,8 @@ var init_addFunds = __esm({
|
|
|
138566
138729
|
init_relayLimit();
|
|
138567
138730
|
init_say();
|
|
138568
138731
|
WRONG_COIN_READ_EVERY_MS = 6e4;
|
|
138732
|
+
LATE2 = /* @__PURE__ */ Symbol("late");
|
|
138733
|
+
CREATE_BUDGET_MS = 5e3;
|
|
138569
138734
|
json = (value2) => ({ text: JSON.stringify(value2, null, 2) });
|
|
138570
138735
|
refuse9 = (error, detail, next, extra = {}) => json({ ok: false, error, detail, next, ...extra });
|
|
138571
138736
|
ADD_FUNDS_REQUEST_ID = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
@@ -141951,7 +142116,7 @@ function leg1Transaction(store, float, requestId) {
|
|
|
141951
142116
|
}
|
|
141952
142117
|
function floatPaidNext({ transaction, shinjukuTransaction, pending = false }) {
|
|
141953
142118
|
if (pending) {
|
|
141954
|
-
return "the seller answered with its data, and this wallet's private payment to Shinjuku is done; Shinjuku's payment to the seller
|
|
142119
|
+
return "the seller answered with its data, and this wallet's private payment to Shinjuku is done; this wallet has not yet seen Shinjuku's payment to the seller on the public chain (a quick check; the chain can already hold it). Tell the user: the data came; this wallet has not seen the payment to the seller on the chain yet; wallet_receipts shows its state. Tell the user the price (priceAtomic), the Shinjuku fee (feeAtomic; never a network fee) and the total (amountAtomic). Do not pay this again: it is one payment. wallet_balance shows the new balance";
|
|
141955
142120
|
}
|
|
141956
142121
|
const ids = [
|
|
141957
142122
|
transaction ? "the transaction (the seller's settle transaction)" : void 0,
|
|
@@ -145016,7 +145181,7 @@ ${canonical5}`;
|
|
|
145016
145181
|
requestId,
|
|
145017
145182
|
scheme: receipt.scheme ?? null,
|
|
145018
145183
|
// AB249 live run 2 (echomarkets, 2026-11-07): a pending receipt named the seller's claimed signature as its
|
|
145019
|
-
// transaction. Until
|
|
145184
|
+
// transaction. Until this wallet sees it confirmed, it is only sellerClaimedTransaction.
|
|
145020
145185
|
...floatPaid && receipt.receiptFinality === "pending" ? { transaction: null, ...transaction ? { sellerClaimedTransaction: transaction } : {} } : { transaction: unpaid ? null : transaction },
|
|
145021
145186
|
...amounts,
|
|
145022
145187
|
replayed: receipt.replayed === true,
|
|
@@ -146498,6 +146663,8 @@ ${canonical5}`;
|
|
|
146498
146663
|
changeSettling: void 0,
|
|
146499
146664
|
changeReadyInSeconds: void 0,
|
|
146500
146665
|
changeUpToAtomic: void 0,
|
|
146666
|
+
changeCount: void 0,
|
|
146667
|
+
changeRestOther: void 0,
|
|
146501
146668
|
receivedOnly: void 0,
|
|
146502
146669
|
breakdown: { ...one.breakdown, shieldedAtomic: null, totalAtomic: null }
|
|
146503
146670
|
};
|
|
@@ -146706,7 +146873,7 @@ ${canonical5}`;
|
|
|
146706
146873
|
next = `${next}. Tell the user: ${failingSends.map((send3) => `payment ${send3.nextPayment} of ${send3.payments} of ${sendWords(send3)} did not go through in ${send3.failedTries} ${send3.failedTries === 1 ? "try" : "tries"}${send3.lastTryMinutesAgo !== void 0 ? ` (the last ${agoWords(send3.lastTryMinutesAgo)})` : ""}: ${send3.lastReason}. It sent ${usdcText3(send3.sentAtomic)} USDC so far. The wallet tries that payment again by itself at its next start`).join(". ")}. ` + failingSends.map((send3) => `${send3.tool === OLD_TRANSFER_TOOL ? "It is an older token transfer's send: no call runs it sooner" : `To try it now: wallet_unshield with request_id "${send3.requestId}" and the same arguments`}; to stop the send and return the USDC not sent yet to the private balance: ${cancelCall(send3)} (${sendWords(send3)})`).join(". ");
|
|
146707
146874
|
}
|
|
146708
146875
|
if (privateSends.length && one.largestPaymentAtomic === "0" && (one.changeSettling !== true || one.changeUpToAtomic !== void 0) && /^[1-9][0-9]*$/.test(String(one.balanceAtomic ?? ""))) {
|
|
146709
|
-
const soon = one.changeUpToAtomic === void 0 ? "" : `after the last payment settles${Number.isSafeInteger(one.changeReadyInSeconds) ? ` (about ${one.changeReadyInSeconds} s)` : ""}, one payment can use up to ${usdcText3(one.changeUpToAtomic)} USDC; the rest waits, `;
|
|
146876
|
+
const soon = one.changeUpToAtomic === void 0 ? "" : `after the last payment settles${Number.isSafeInteger(one.changeReadyInSeconds) ? ` (about ${one.changeReadyInSeconds} s)` : ""}, one payment can use up to ${usdcText3(one.changeUpToAtomic)} USDC; ${one.changeRestOther === true ? "some of the rest waits" : "the rest waits"}, `;
|
|
146710
146877
|
const many = privateSends.length > 1;
|
|
146711
146878
|
next = `${next}. Tell the user: ${soon || `no payment can use the ${usdcText3(one.balanceAtomic)} USDC yet, `}because ${privateSends.map(sendWords).join(" and ")} ${many ? "keep" : "keeps"} money aside for ${many ? "their" : "its"} unsent payments. A send keeps nothing after its last payment goes, and an earlier payment may free some (wallet_balance shows it). To pay now if the user asks: ${privateSends.map((send3) => `${cancelCall(send3)} (${sendWords(send3)})`).join(" or ")} stops the send and frees its money now`;
|
|
146712
146879
|
}
|
|
@@ -147186,7 +147353,7 @@ ${canonical5}`;
|
|
|
147186
147353
|
scheme: "exact",
|
|
147187
147354
|
state: "payment_not_confirmed",
|
|
147188
147355
|
...claimed ? { sellerClaimedTransaction: claimed } : {},
|
|
147189
|
-
note: "the seller answered with its data, but
|
|
147356
|
+
note: "the seller answered with its data, but this wallet has not seen Shinjuku's payment to the seller on the public chain yet. Each wallet_receipts call reads it again: when it lands, this row shows the seller's transaction; if it can never land, this row shows a refund. Do not pay for this again with a new request_id until then"
|
|
147190
147357
|
});
|
|
147191
147358
|
continue;
|
|
147192
147359
|
}
|
|
@@ -147981,7 +148148,7 @@ ${canonical5}`;
|
|
|
147981
148148
|
const record = float ? void 0 : [paymentRecordName(target), `${POCKET_PAYMENT_WAL_PREFIX}${key}`].map((name) => store.readWal(name)).find((one) => one?.state === "receipt" && one.receiptFinality !== "never-finalized");
|
|
147982
148149
|
if (float && floatReceiptPending(float)) {
|
|
147983
148150
|
return json4({
|
|
147984
|
-
say: "The seller already answered this payment, so there is nothing to cancel.
|
|
148151
|
+
say: "The seller already answered this payment, so there is nothing to cancel. This wallet has not seen the payment to the seller on the chain yet.",
|
|
147985
148152
|
ok: true,
|
|
147986
148153
|
requestId,
|
|
147987
148154
|
kind: "payment",
|
|
@@ -147989,7 +148156,7 @@ ${canonical5}`;
|
|
|
147989
148156
|
finished: true,
|
|
147990
148157
|
transaction: null,
|
|
147991
148158
|
receiptFinality: "pending",
|
|
147992
|
-
detail: "the seller answered this payment, so there is nothing to cancel;
|
|
148159
|
+
detail: "the seller answered this payment, so there is nothing to cancel; this wallet has not seen Shinjuku's payment to the seller on the public chain yet (wallet_receipts reads it again)",
|
|
147993
148160
|
next: "Tell the user the seller already answered, so there is nothing to cancel; nothing was changed. Do not pay for it again. wallet_receipts shows whether the payment to the seller landed or a refund comes"
|
|
147994
148161
|
});
|
|
147995
148162
|
}
|
|
@@ -148006,7 +148173,7 @@ ${canonical5}`;
|
|
|
148006
148173
|
finished: true,
|
|
148007
148174
|
transaction,
|
|
148008
148175
|
...typeof record?.receiptFinality === "string" ? { receiptFinality: record.receiptFinality } : {},
|
|
148009
|
-
detail: `this payment is finished and paid${transaction ? ` (transaction ${transaction})` : ""}${final ? "" : "; the seller answered and
|
|
148176
|
+
detail: `this payment is finished and paid${transaction ? ` (transaction ${transaction})` : ""}${final ? "" : "; the seller answered and this wallet has not seen it final on the chain yet"}; there is nothing to cancel, and a payment a seller took cannot be taken back`,
|
|
148010
148177
|
next: "Tell the user the payment is finished and paid; nothing was changed. wallet_receipts lists it"
|
|
148011
148178
|
});
|
|
148012
148179
|
}
|
|
@@ -152845,6 +153012,8 @@ ${canonical5}`;
|
|
|
152845
153012
|
};
|
|
152846
153013
|
const addFunds2 = createAddFundsTool({
|
|
152847
153014
|
familyPool: () => session.pool,
|
|
153015
|
+
firstAnswerMs: MONEY_FIRST_ANSWER_MS,
|
|
153016
|
+
stoppedForBuild: (record) => stoppedForUpdate(record, walletBuild),
|
|
152848
153017
|
payMeCreate: ({ id, requestId, amountAtomic, note }) => createPayMeLeased({ store: session.openStore(), connection: session.connection, id, requestId, amountAtomic, note }),
|
|
152849
153018
|
payMeRead: (id) => readPayMe(session.openStore(), id),
|
|
152850
153019
|
payMeList: () => listPayMe(session.openStore()),
|
|
@@ -153690,6 +153859,25 @@ function createSetupTools({
|
|
|
153690
153859
|
return out;
|
|
153691
153860
|
}
|
|
153692
153861
|
function statusOf(current, end2) {
|
|
153862
|
+
if (current.state === "failed" && current.ownTor === true && current.failure?.error === "setup_tor_not_started") {
|
|
153863
|
+
const recoveryFile = current.recoveryFile;
|
|
153864
|
+
end2();
|
|
153865
|
+
const reason = String(current.failure.detail ?? "").split("nothing was sent: ")[1]?.trim().replace(/\.$/, "") ?? "";
|
|
153866
|
+
const download3 = /^the Tor download/.test(reason);
|
|
153867
|
+
const what = download3 ? "the Tor download for the wallet did not finish" : "Tor did not start on this computer";
|
|
153868
|
+
return refuse11(
|
|
153869
|
+
"setup_tor_not_started",
|
|
153870
|
+
`the user chose Tor in the setup question, and the wallet's own Tor ${download3 ? "could not be downloaded" : "did not start"}${reason ? ` (${reason})` : ""}; ${recoveryFile ? "the wallet an earlier setup made stays as it is; nothing was paid" : "nothing was created or paid"}`,
|
|
153871
|
+
`Tell the user: ${reason ? `${reason[0].toUpperCase()}${reason.slice(1)}` : download3 ? "The wallet could not download Tor" : "Tor did not start on this computer"}. ` + (recoveryFile ? `Nothing was paid. The wallet was already made: tell the user to copy its recovery file (${recoveryFile}) to two offline places now. ` : "Nothing was created or paid. ") + `When the user asks again, call shinjuku_setup again: it tries Tor again (a Tor download that finished and passed its check is kept; an unfinished one starts again). Or, to set up without Tor, the user asks again and unticks "${SETUP_TOR_TITLE}" in the question`,
|
|
153872
|
+
recoveryFile ? { recoveryFile, say: fitSay([
|
|
153873
|
+
`Not set up: ${what}. Your wallet was made earlier: copy its recovery file ${recoveryFile} to two offline places now. Then ask me again, or set up without Tor.`,
|
|
153874
|
+
`Not set up: ${what}. Your wallet was made earlier: copy its recovery file (named below) to two offline places now. Then ask me again, or set up without Tor.`
|
|
153875
|
+
]) } : { say: fitSay([
|
|
153876
|
+
`Not set up: ${what}. Nothing was created. Ask me again, or set up without Tor.`,
|
|
153877
|
+
`Not set up: ${download3 ? "the Tor download failed" : "Tor did not start"}. Ask me again, or set up without Tor.`
|
|
153878
|
+
]) }
|
|
153879
|
+
);
|
|
153880
|
+
}
|
|
153693
153881
|
if (current.state === "failed") {
|
|
153694
153882
|
const { error, detail } = current.failure;
|
|
153695
153883
|
const recoveryFile = current.recoveryFile;
|
|
@@ -153914,8 +154102,11 @@ function createSetupTools({
|
|
|
153914
154102
|
answered2();
|
|
153915
154103
|
return;
|
|
153916
154104
|
}
|
|
153917
|
-
|
|
153918
|
-
|
|
154105
|
+
const ownTor = setup.ownTor?.() === true;
|
|
154106
|
+
job.ownTor = ownTor && answer.tor && !inTorRun();
|
|
154107
|
+
if (answer.tor && !inTorRun() && !ownTor) {
|
|
154108
|
+
const probed = setup.torTunnel?.() ?? TOR_HTTP_TUNNEL;
|
|
154109
|
+
const tunnel = await localTorCheck(probed);
|
|
153919
154110
|
if (tunnel.answer === "refused" || tunnel.answer === "too_old") {
|
|
153920
154111
|
if (tunnel.answer === "refused") job.torBrowser = await localTorProof(TOR_BROWSER_PORT) !== "refused";
|
|
153921
154112
|
else job.torTooOld = tunnel.version;
|
|
@@ -154663,7 +154854,8 @@ var init_tools = __esm({
|
|
|
154663
154854
|
...Number.isSafeInteger(one.changeReadyInSeconds) ? { changeReadyInSeconds: one.changeReadyInSeconds } : {},
|
|
154664
154855
|
...ATOMIC_TEXT.test(shown) && ATOMIC_TEXT.test(upTo) && BigInt(upTo) < BigInt(shown) ? { changeUpToAtomic: upTo } : {},
|
|
154665
154856
|
// UX129-9: the value is the changes of this many recent payments (2 or more); changeUpToAtomic is then the largest.
|
|
154666
|
-
...Number.isSafeInteger(one.changeCount) && one.changeCount >= 2 ? { changeCount: one.changeCount } : {}
|
|
154857
|
+
...Number.isSafeInteger(one.changeCount) && one.changeCount >= 2 ? { changeCount: one.changeCount } : {},
|
|
154858
|
+
...one.changeRestOther === true ? { changeRestOther: true } : {}
|
|
154667
154859
|
};
|
|
154668
154860
|
};
|
|
154669
154861
|
balanceAnswer = (one, { shown = true } = {}) => one ? { ...balanceTextFields(one), breakdown: shown ? shownBreakdown(one.breakdown) : one.breakdown } : {};
|
|
@@ -161973,7 +162165,7 @@ async function installBundle(home, say2) {
|
|
|
161973
162165
|
say2(`Getting Tor for the wallet (once, about ${pinned.mb} MB from the Tor Project, checked).`);
|
|
161974
162166
|
let response;
|
|
161975
162167
|
try {
|
|
161976
|
-
response = await fetch(pinned.url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
|
|
162168
|
+
response = await fetch(pinned.url, { redirect: "error", signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
|
|
161977
162169
|
} catch (error) {
|
|
161978
162170
|
throw failure2("the Tor download did not finish. Check the internet connection, then ask again", `the Tor download did not answer (${error?.name === "TimeoutError" ? "no answer in 5 minutes" : error?.cause?.code ?? error?.message ?? error})`);
|
|
161979
162171
|
}
|
|
@@ -162358,6 +162550,15 @@ function ownPortOf(home) {
|
|
|
162358
162550
|
return void 0;
|
|
162359
162551
|
}
|
|
162360
162552
|
}
|
|
162553
|
+
function isWalletOwnTunnel(home, tunnel) {
|
|
162554
|
+
const state2 = managedTorState(home);
|
|
162555
|
+
if (!state2) return false;
|
|
162556
|
+
try {
|
|
162557
|
+
return new URL(tunnel).origin === new URL(tunnelOf(state2.port)).origin;
|
|
162558
|
+
} catch {
|
|
162559
|
+
return false;
|
|
162560
|
+
}
|
|
162561
|
+
}
|
|
162361
162562
|
async function setWalletTor(home, on, { say: say2 = () => {
|
|
162362
162563
|
}, platform = process.platform } = {}) {
|
|
162363
162564
|
let config;
|
|
@@ -172313,6 +172514,17 @@ function mcpSetupAdapter(values, home, deps) {
|
|
|
172313
172514
|
return { ...platform, maxPaymentAtomic: caps.maxPayment, maxSessionAtomic: caps.maxSession };
|
|
172314
172515
|
},
|
|
172315
172516
|
missing: () => missingPieces(home, configOrNull(home)),
|
|
172517
|
+
// A "Use Tor?" yes: run() starts the wallet's own Tor first (mcpSetupBehindTor -> torTunnelReady -> ensureWalletTor)
|
|
172518
|
+
// when it applies, so the setup box probes no tunnel then (a live check on npm 0.3.219, a fresh computer, 2026-11-12 15:23:32 UTC: a
|
|
172519
|
+
// fresh home with nothing at 127.0.0.1:9080 stopped at tor_not_running with a terminal step before that start). The
|
|
172520
|
+
// rule: an own-Tor platform, and no recorded torTunnel, or the recorded one is the tunnel managed.json names (the Tor
|
|
172521
|
+
// this wallet started here; isWalletOwnTunnel). Any other recorded tunnel is the user's, and the box probes it.
|
|
172522
|
+
// torTunnel: the tunnel the probe checks otherwise (a Tor the user set, recorded in config.json; else the default).
|
|
172523
|
+
ownTor: () => {
|
|
172524
|
+
const recorded = configOrNull(home)?.torTunnel;
|
|
172525
|
+
return ownTorPlatform() && (recorded === void 0 || isWalletOwnTunnel(home, recorded));
|
|
172526
|
+
},
|
|
172527
|
+
torTunnel: () => configOrNull(home)?.torTunnel ?? TOR_HTTP_TUNNEL,
|
|
172316
172528
|
// privateInference: the human ticked "Add a private AI tool to this app" (a yes, as setup --private-inference);
|
|
172317
172529
|
// no tick keeps what config.json records. tor: the answer to "Use Tor?" (private inference turns it on). A server
|
|
172318
172530
|
// already behind Tor (or an old caller with no answer) sets up in place.
|
|
@@ -172339,7 +172551,9 @@ async function mcpSetupBehindTor(values, home, deps, { privateInference, onStage
|
|
|
172339
172551
|
const recorded = configOrNull(home)?.torTunnel;
|
|
172340
172552
|
tunnel = await torTunnelReady(recorded ?? TOR_HTTP_TUNNEL, { explicit: recorded !== void 0 });
|
|
172341
172553
|
} catch (error) {
|
|
172342
|
-
|
|
172554
|
+
const made = configOrNull(home)?.recoveryFile;
|
|
172555
|
+
if (made && existsSync(made)) onStage("wallet-created", { recoveryFile: made });
|
|
172556
|
+
throw new Error(`${error?.managedTor ? "setup_tor_not_started" : "setup_tor_unavailable"}: ${String(error.message).replace(/^[a-z][a-z0-9_]*: /, "")}`);
|
|
172343
172557
|
}
|
|
172344
172558
|
const resultDir = mkdtempSync(join58(tmpdir8(), "shinjuku-setup-"));
|
|
172345
172559
|
const prior = process.env[RESULT_FILE_ENV];
|
|
@@ -174427,7 +174641,7 @@ var COMMANDS = [
|
|
|
174427
174641
|
"Without --refresh, balance reads only local files: the last walk (recover or balance --refresh) and the wallet log. Outside a set-up home it makes no network call; in a set-up home it reads the chain once when the last walk is not current, and reads the public USDC on the wallet's own address (one RPC read, at most 3 s).",
|
|
174428
174642
|
"USDC on the wallet's own public address is not private: the line after the balance names it and how to make it private (publicOnOwnAddressAtomic in the JSON; null when not read).",
|
|
174429
174643
|
"shinjukuShielded is null when the last walk is missing, stale, or incomplete. reasons says why; next shows the command to run.",
|
|
174430
|
-
`In a terminal it prints one plain line: the private balance in USDC, and a short reason when it is not current (then the command to run). The wallet's own progress lines (Tor, the RPC relay, the pool history walk, the memo reads) show only with --verbose; warnings and failures always show. A program, or --json, gets the whole report as JSON (total, shinjukuShielded, status, reasons, next, detail). Its spend is the terminal's spend sentence ("You can spend X USDC, up to S USDC in one payment now"; the MCP says "X USDC (a payment above S USDC first gets the balance ready)"), and largestPaymentAtomic is the most one payment can spend now (changeSettling: 0 only while the last payment's change settles, about changeReadyInSeconds; then one payment can use all of it, or changeUpToAtomic when a private send holds the rest).`,
|
|
174644
|
+
`In a terminal it prints one plain line: the private balance in USDC, and a short reason when it is not current (then the command to run). The wallet's own progress lines (Tor, the RPC relay, the pool history walk, the memo reads) show only with --verbose; warnings and failures always show. A program, or --json, gets the whole report as JSON (total, shinjukuShielded, status, reasons, next, detail). Its spend is the terminal's spend sentence ("You can spend X USDC, up to S USDC in one payment now"; the MCP says "X USDC (a payment above S USDC first gets the balance ready)"), and largestPaymentAtomic is the most one payment can spend now (changeSettling: 0 only while the last payment's change settles, about changeReadyInSeconds; then one payment can use all of it, or changeUpToAtomic when a private send holds the rest or, with changeRestOther, other value no payment can use now).`,
|
|
174431
174645
|
"Payments that others send to this wallet appear only after a refresh.",
|
|
174432
174646
|
"With --refresh it also reads the one-time deposit addresses of this home's earlier pools (one address per request). USDC found there goes into this pool by itself (Shinjuku pays the fee), and earlierDeposits lists each one with a notice.",
|
|
174433
174647
|
"paymentsWithoutWaiting (and detail.fundedAccounts): your funded deposits that no in-flight work holds. A payment spends one funded deposit, and its change pays only after the next pool anchor, so this many payments can run before the next anchor without waiting (a funded deposit made since the last anchor, such as a change, waits for the next one). add-funds --split makes more of them."
|
|
@@ -177346,7 +177560,8 @@ async function runBalance(args, values, deps, io) {
|
|
|
177346
177560
|
...parts.changeSettling === true ? {
|
|
177347
177561
|
changeSettling: true,
|
|
177348
177562
|
...Number.isSafeInteger(parts.changeReadyInSeconds) ? { changeReadyInSeconds: parts.changeReadyInSeconds } : {},
|
|
177349
|
-
.../^[0-9]+$/.test(String(parts.changeUpToAtomic ?? "")) && BigInt(parts.changeUpToAtomic) < BigInt(parts.spendableAtomic) ? { changeUpToAtomic: parts.changeUpToAtomic } : {}
|
|
177563
|
+
.../^[0-9]+$/.test(String(parts.changeUpToAtomic ?? "")) && BigInt(parts.changeUpToAtomic) < BigInt(parts.spendableAtomic) ? { changeUpToAtomic: parts.changeUpToAtomic } : {},
|
|
177564
|
+
...parts.changeRestOther === true ? { changeRestOther: true } : {}
|
|
177350
177565
|
} : {},
|
|
177351
177566
|
spend: spendHeads(parts.spendableAtomic, parts.largestPaymentAtomic, parts, { surface: "cli" })[0] ?? null,
|
|
177352
177567
|
refundsInFlightAtomic: parts.refundsInFlightAtomic,
|