shinjuku-shield 0.3.188 → 0.3.190

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 CHANGED
@@ -6,8 +6,8 @@ answers privately, in a terminal chat or for your agent app. Its `mcp`
6
6
  command runs a local MCP server (stdio) for your agent. Your keys never
7
7
  leave your machine.
8
8
 
9
- This is version 0.3.188. The command is `shinjuku`. `shinjuku-shield`
10
- is the one package that holds the wallet. `shinjuku-shielded` 0.3.188,
9
+ This is version 0.3.190. The command is `shinjuku`. `shinjuku-shield`
10
+ is the one package that holds the wallet. `shinjuku-shielded` 0.3.190,
11
11
  its older npm name, is a small package that runs this package at the same
12
12
  version, so wallets installed under it keep updating (0.3.186 and earlier
13
13
  versions of `shinjuku-shielded` hold the same files as this package). New
@@ -16,7 +16,7 @@ installs use `shinjuku`.
16
16
  ## Set up
17
17
 
18
18
  ```sh
19
- npx -y shinjuku@0.3.188 setup
19
+ npx -y shinjuku@0.3.190 setup
20
20
  ```
21
21
 
22
22
  Setup offers to install the `shinjuku` command and, on Windows, adds npm's
@@ -39,13 +39,13 @@ Every wallet command works after `shinjuku`, for example `shinjuku balance`,
39
39
  Claude Code:
40
40
 
41
41
  ```sh
42
- claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.188 mcp
42
+ claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.190 mcp
43
43
  ```
44
44
 
45
45
  Claude Desktop (`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
46
46
 
47
47
  ```json
48
- { "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.188", "mcp"] } } }
48
+ { "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.190", "mcp"] } } }
49
49
  ```
50
50
 
51
51
  On native Windows, if the host cannot find `npx`, use `"command": "cmd"` and
@@ -58,7 +58,7 @@ Codex (the Codex app and Codex CLI read the same file, `~/.codex/config.toml`):
58
58
  ```toml
59
59
  [mcp_servers.shinjuku]
60
60
  command = "npx"
61
- args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.188", "mcp"]
61
+ args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.190", "mcp"]
62
62
  startup_timeout_sec = 120
63
63
  tool_timeout_sec = 300
64
64
  ```
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": "6816afb568f56eea0cdc61849cdbba1804ee43e3f22368f6c518c36c7cc2ec93",
5
- "bytes": 9340659,
6
- "sourceCommit": "98b1b756bcfe3ef96147d23ec8aeabc6a9dbf050",
4
+ "sha256": "af144e3c6a627910142f0a31ac16fa0cf3337d464a85afce247eb28be6575a66",
5
+ "bytes": 9345964,
6
+ "sourceCommit": "6b078599cc84abab71fe2adcfa5fa7427e9863f9",
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",
@@ -1040,8 +1040,8 @@
1040
1040
  ],
1041
1041
  "seller": {
1042
1042
  "file": "shinjuku-seller.mjs",
1043
- "sha256": "63aba369f3634380a640989582cc4cfee5e6924d92ae21abaedbe15e8a4d69df",
1044
- "bytes": 3659828,
1043
+ "sha256": "9608c16b1579cb3dbe664d433362b2deb531bfef3b586e4b33af44229deae1e0",
1044
+ "bytes": 3660091,
1045
1045
  "entry": "wallet/src/seller/exact/index.mjs",
1046
1046
  "external": [
1047
1047
  "@x402/core/http",
@@ -1932,5 +1932,5 @@
1932
1932
  }
1933
1933
  ]
1934
1934
  },
1935
- "publishedAt": "2026-11-07T17:48:04.331Z"
1935
+ "publishedAt": "2026-11-07T20:40:53.254Z"
1936
1936
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "shinjuku-shield",
3
- "version": "0.3.188",
3
+ "version": "0.3.190",
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": "6816afb5",
7
- "shinjukuSha256": "6816afb568f56eea0cdc61849cdbba1804ee43e3f22368f6c518c36c7cc2ec93",
6
+ "shinjukuRelease": "af144e3c",
7
+ "shinjukuSha256": "af144e3c6a627910142f0a31ac16fa0cf3337d464a85afce247eb28be6575a66",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "author": "Shinjuku Shield",
10
10
  "homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
@@ -35627,7 +35627,7 @@ async function rpcFetch(input, init) {
35627
35627
  rpcNotBefore.set(post.key, Math.max(rpcNotBefore.get(post.key) ?? 0, Date.now() + retryAfterMs(response)));
35628
35628
  }
35629
35629
  }
35630
- var relayKeyOf, READ_ONLY_METHOD, readOnlyPost, TOR_HTTP_TUNNEL, LOCAL_PROOF_TIMEOUT_MS, LOCAL_PROOF_MAX_BYTES, MARK, ownProxyRefused, ONION_V3, RETRY_AFTER_CAP_MS, RETRY_AFTER_FLOOR_MS, RETRY_AFTER_DEFAULT_MS, RPC_NO_ANSWER_LIMIT_MS, RPC_PACING_CAP_MS, PACING_NOTICE_EVERY_MS, PACING_RATE_WINDOW_MS, TOR_MAX_ROTATIONS, runStartedAt, rpcNotBefore, pacingWaiters, pacingSince, pacedMs, rpcAnswered, lastAnswerAt, readSteps, pacingNoticeAt, pacingSamples, torMoves, torCircuitId, torMovesRefused, pendingMove, inTorRunOf, inTorRun, isOnionOrigin, TOR_MIN_VERSION, TOR_EXPERT_BUNDLE, TOR_EXPERT_BUNDLE_SHA256, TOR_EXPERT_BUNDLE_URL, TUNNEL_LINE, TOR_DEB_KEY, TOR_DEB_KEYRING, TOR_INSTALL, torStart, LOCAL_TUNNEL, torStartText, TOR_WINDOW, torUpdateHow, TOR_STOP_OLD_WINDOWS, torTooOldWhy, withRunTag, proxyEnv, pacedSoFar, RESENDABLE_METHOD, torCircuit, GLOBAL_DISPATCHER2, laneDispatchers, laneOfDispatcher;
35630
+ var relayKeyOf, READ_ONLY_METHOD, readOnlyPost, TOR_HTTP_TUNNEL, LOCAL_PROOF_TIMEOUT_MS, LOCAL_PROOF_MAX_BYTES, MARK, ownProxyRefused, ONION_V3, RETRY_AFTER_CAP_MS, RETRY_AFTER_FLOOR_MS, RETRY_AFTER_DEFAULT_MS, RPC_NO_ANSWER_LIMIT_MS, RPC_PACING_CAP_MS, PACING_NOTICE_EVERY_MS, PACING_RATE_WINDOW_MS, TOR_MAX_ROTATIONS, runStartedAt, rpcNotBefore, pacingWaiters, pacingSince, pacedMs, rpcAnswered, lastAnswerAt, readSteps, pacingNoticeAt, pacingSamples, torMoves, torCircuitId, torMovesRefused, pendingMove, inTorRunOf, inTorRun, isOnionOrigin, TOR_MIN_VERSION, TOR_EXPERT_BUNDLE, TOR_EXPERT_BUNDLE_SHA256, TOR_EXPERT_BUNDLE_URL, TUNNEL_LINE, TOR_DEB_KEY, TOR_DEB_KEYRING, TOR_INSTALL, torStart, LOCAL_TUNNEL, torStartText, TOR_WINDOW, torUpdateHow, TOR_STOP_OLD_WINDOWS, torTooOldWhy, TOR_WAIT_WORDS, TOR_WAIT_PLAIN, withRunTag, proxyEnv, pacedSoFar, RESENDABLE_METHOD, torCircuit, GLOBAL_DISPATCHER2, laneDispatchers, laneOfDispatcher;
35631
35631
  var init_proxy = __esm({
35632
35632
  "wallet/src/net/proxy.mjs"() {
35633
35633
  "use strict";
@@ -35716,6 +35716,8 @@ ${command}`;
35716
35716
  torUpdateHow = (platform = process.platform) => platform === "win32" ? `${TOR_STOP_OLD_WINDOWS} Then start a newer Tor with the command below in PowerShell (it runs in the background, so you can close that window)` : `Install a newer Tor with the command below in ${TOR_WINDOW[platform] ?? "a terminal"}`;
35717
35717
  TOR_STOP_OLD_WINDOWS = "Stop your old Tor first: in PowerShell run Stop-Process -Name tor , or for a Tor in WSL run wsl -u root service tor stop .";
35718
35718
  torTooOldWhy = (version3) => `Your Tor program is too old (${version3}). It has a known fault that can link two of your payments, so the wallet sent nothing.`;
35719
+ TOR_WAIT_WORDS = "Tor is slow right now, so the wallet waits for it and tries again";
35720
+ TOR_WAIT_PLAIN = `${TOR_WAIT_WORDS}. This can take longer than usual.`;
35719
35721
  withRunTag = (proxy) => {
35720
35722
  const url = new URL(proxy);
35721
35723
  url.username = "tor";
@@ -38105,6 +38107,7 @@ var init_errorCodes = __esm({
38105
38107
  // p03_unshield_<reason> of the terminal's direct exit (cli/shinjukuWallet.mjs directExitRefusal).
38106
38108
  "received_payment_gone",
38107
38109
  "received_payment_too_small",
38110
+ "recipient_unread",
38108
38111
  "unshield_all_needs_several_sends",
38109
38112
  "recipient_encoding",
38110
38113
  "recipient_eta",
@@ -38878,6 +38881,7 @@ var init_errorCodes = __esm({
38878
38881
  "mcp_tool_disabled",
38879
38882
  "mcp_unshield_to_not_allowed",
38880
38883
  "mcp_unshield_to_invalid",
38884
+ "mcp_unshield_recipient_unread",
38881
38885
  "mcp_unshield_send_open",
38882
38886
  "mcp_shield_cap_exceeded",
38883
38887
  "mcp_shield_above_balance_cap",
@@ -49048,7 +49048,7 @@ function torChild(argv2, stdio) {
49048
49048
  if (!options.mode) throw new ProxyUsageError("torChild needs --tor");
49049
49049
  return proxiedChild(options.args, options.proxy, stdio);
49050
49050
  }
49051
- var relayKeyOf, READ_ONLY_METHOD, readOnlyPost, TOR_HTTP_TUNNEL, TOR_CHECK, PROOF_TIMEOUT_MS, LOCAL_PROOF_TIMEOUT_MS, LOCAL_PROOF_MAX_BYTES, torProvenAt, proxyProvenAt, MARK, TOR_RUN_STARTED_ENV, ownProxyRefused, ONION_V3, RETRY_AFTER_CAP_MS, RETRY_AFTER_FLOOR_MS, RETRY_AFTER_DEFAULT_MS, RPC_NO_ANSWER_LIMIT_MS, RPC_PACING_CAP_MS, PACING_NOTICE_EVERY_MS, PACING_RATE_WINDOW_MS, TOR_MAX_ROTATIONS, runStartedAt, rpcNotBefore, pacingWaiters, pacingSince, pacedMs, rpcAnswered, lastAnswerAt, readSteps, pacingNoticeAt, pacingSamples, torMoves, torCircuitId, torMovesRefused, pendingMove, inTorRunOf, inTorRun, runNetworkMode, isOnionOrigin, ProxyUsageError, isOnionHost, PROXY_REMOVED, ENV_PROXY_NAMES, OUTER_PROXY_ENV, DIRECT_RUN_MARK, USE_ENV_PROXY_FLAG, withoutEnvProxyFlag, TOR_MIN_VERSION, localTorProof, TOR_EXPERT_BUNDLE, TOR_EXPERT_BUNDLE_SHA256, TOR_EXPERT_BUNDLE_URL, TUNNEL_LINE, TOR_DEB_KEY, TOR_DEB_KEYRING, TOR_INSTALL, torStart, LOCAL_TUNNEL, torStartText, TOR_WINDOW, torNotRunningMessage, torUpdateHow, TOR_STOP_OLD_WINDOWS, torTooOldWhy, torTooOldMessage, NOTICE, TOR_NOTICE_LINE, ONION_DETAIL_LINE, withoutOnionDetail, QUIET_RUN_MARK, QUIET_RUNS, QUIET_TERMINAL_COMMANDS, INFER_SUBCOMMANDS, quietRun, TOR_TROUBLE_LINE, TOR_WAIT_PLAIN, TOR_TROUBLE_PLAIN, promptRedraw, TOR_TROUBLE_SAID, quietTorErr, withRunTag, proxyEnv, pacedSoFar, RESENDABLE_METHOD, torCircuit, GLOBAL_DISPATCHER4, laneDispatchers, laneOfDispatcher, PROXY_WARNING_FLAG, proxiedExecArgv, proxiedNodeOptions, TOR_FROM_CONFIG_ENV, TOR_FROM_CONFIG_HINT, TOR_FROM_CONFIG_SENTENCE, launcherPid, torStarter;
49051
+ var relayKeyOf, READ_ONLY_METHOD, readOnlyPost, TOR_HTTP_TUNNEL, TOR_CHECK, PROOF_TIMEOUT_MS, LOCAL_PROOF_TIMEOUT_MS, LOCAL_PROOF_MAX_BYTES, torProvenAt, proxyProvenAt, MARK, TOR_RUN_STARTED_ENV, ownProxyRefused, ONION_V3, RETRY_AFTER_CAP_MS, RETRY_AFTER_FLOOR_MS, RETRY_AFTER_DEFAULT_MS, RPC_NO_ANSWER_LIMIT_MS, RPC_PACING_CAP_MS, PACING_NOTICE_EVERY_MS, PACING_RATE_WINDOW_MS, TOR_MAX_ROTATIONS, runStartedAt, rpcNotBefore, pacingWaiters, pacingSince, pacedMs, rpcAnswered, lastAnswerAt, readSteps, pacingNoticeAt, pacingSamples, torMoves, torCircuitId, torMovesRefused, pendingMove, inTorRunOf, inTorRun, runNetworkMode, isOnionOrigin, ProxyUsageError, isOnionHost, PROXY_REMOVED, ENV_PROXY_NAMES, OUTER_PROXY_ENV, DIRECT_RUN_MARK, USE_ENV_PROXY_FLAG, withoutEnvProxyFlag, TOR_MIN_VERSION, localTorProof, TOR_EXPERT_BUNDLE, TOR_EXPERT_BUNDLE_SHA256, TOR_EXPERT_BUNDLE_URL, TUNNEL_LINE, TOR_DEB_KEY, TOR_DEB_KEYRING, TOR_INSTALL, torStart, LOCAL_TUNNEL, torStartText, TOR_WINDOW, torNotRunningMessage, torUpdateHow, TOR_STOP_OLD_WINDOWS, torTooOldWhy, torTooOldMessage, NOTICE, TOR_NOTICE_LINE, ONION_DETAIL_LINE, withoutOnionDetail, QUIET_RUN_MARK, QUIET_RUNS, QUIET_TERMINAL_COMMANDS, INFER_SUBCOMMANDS, quietRun, TOR_TROUBLE_LINE, TOR_WAIT_WORDS, TOR_WAIT_PLAIN, TOR_TROUBLE_PLAIN, promptRedraw, TOR_TROUBLE_SAID, quietTorErr, withRunTag, proxyEnv, pacedSoFar, RESENDABLE_METHOD, torCircuit, GLOBAL_DISPATCHER4, laneDispatchers, laneOfDispatcher, PROXY_WARNING_FLAG, proxiedExecArgv, proxiedNodeOptions, TOR_FROM_CONFIG_ENV, TOR_FROM_CONFIG_HINT, TOR_FROM_CONFIG_SENTENCE, launcherPid, torStarter;
49052
49052
  var init_proxy = __esm({
49053
49053
  "wallet/src/net/proxy.mjs"() {
49054
49054
  "use strict";
@@ -49193,7 +49193,8 @@ ${command}`;
49193
49193
  return quietCommand && process.stdout.isTTY && !args.includes("--json") ? "funds" : void 0;
49194
49194
  };
49195
49195
  TOR_TROUBLE_LINE = /\bno (?:other )?(?:history-proxy )?onion\b|\bgave no answer\b|\bstalled\b|\bHTTP 429\b|\bcannot move\b|\bspare onions\b/;
49196
- TOR_WAIT_PLAIN = "Tor is slow right now, so the wallet waits for it and tries again. This can take longer than usual.";
49196
+ TOR_WAIT_WORDS = "Tor is slow right now, so the wallet waits for it and tries again";
49197
+ TOR_WAIT_PLAIN = `${TOR_WAIT_WORDS}. This can take longer than usual.`;
49197
49198
  TOR_TROUBLE_PLAIN = [
49198
49199
  [/\bpublishes no onion\b/, "One server of this run has no Tor-only address, so the last Tor relay sees that server's name, but not what the wallet sends."],
49199
49200
  [/\bHTTP 429\b/, "A server asked the wallet to slow down, so the wallet waits as the server asks. This can add some time."],
@@ -70939,6 +70940,7 @@ var init_errorCodes = __esm({
70939
70940
  // p03_unshield_<reason> of the terminal's direct exit (cli/shinjukuWallet.mjs directExitRefusal).
70940
70941
  "received_payment_gone",
70941
70942
  "received_payment_too_small",
70943
+ "recipient_unread",
70942
70944
  "unshield_all_needs_several_sends",
70943
70945
  "recipient_encoding",
70944
70946
  "recipient_eta",
@@ -71712,6 +71714,7 @@ var init_errorCodes = __esm({
71712
71714
  "mcp_tool_disabled",
71713
71715
  "mcp_unshield_to_not_allowed",
71714
71716
  "mcp_unshield_to_invalid",
71717
+ "mcp_unshield_recipient_unread",
71715
71718
  "mcp_unshield_send_open",
71716
71719
  "mcp_shield_cap_exceeded",
71717
71720
  "mcp_shield_above_balance_cap",
@@ -115339,6 +115342,9 @@ function refusalSay(a, tool, again, npmVersion) {
115339
115342
  return a.alsoSetup === true ? "Nothing was paid or moved. To turn this on, remove a setting in this app's wallet settings, run setup again, then reconnect the wallet." : "Nothing was paid or moved. This app's wallet settings turn this off. To turn it on, remove that setting there, then reconnect the wallet.";
115340
115343
  }
115341
115344
  if (code2 === "mcp_tool_disabled") return "Nothing was paid or moved. This is off. To turn it on, run the setup command again in a terminal, then reconnect the wallet.";
115345
+ if (code2 === "mcp_unshield_recipient_unread") {
115346
+ return "Nothing was sent. The wallet could not read that address's USDC account, because Tor or the network did not answer. The wallet can try again in a moment.";
115347
+ }
115342
115348
  if (code2 === "mcp_unshield_to_invalid") {
115343
115349
  return "Not sent. That address cannot receive USDC yet. Ask for a Solana address that already holds USDC, like a Phantom address.";
115344
115350
  }
@@ -134271,6 +134277,40 @@ async function checkUnshieldRecipient({ connection, mint, owner }) {
134271
134277
  throw new Error("mcp_unshield_to_invalid: the USDC holder at this address is for another token or another owner, so it cannot take this payment; nothing was paid");
134272
134278
  }
134273
134279
  }
134280
+ async function readUnshieldRecipient({ connection, mint, owner, mark = () => {
134281
+ }, check = checkUnshieldRecipient, onSlow = () => {
134282
+ } }) {
134283
+ mark("unshield-recipient-read-start");
134284
+ const slow = setTimeout(() => {
134285
+ mark("unshield-recipient-read-slow");
134286
+ if (!slowReadSaid) progress(`${slowReadWords()}. This can take longer than usual.`);
134287
+ slowReadSaid = true;
134288
+ onSlow();
134289
+ }, RECIPIENT_READ_SLOW_MS);
134290
+ slow.unref?.();
134291
+ const deadline = Date.now() + RECIPIENT_READ_TOTAL_MS;
134292
+ try {
134293
+ for (let attempt = 1; ; attempt += 1) {
134294
+ try {
134295
+ await withTimeout(check({ connection, mint, owner }), Math.max(1, deadline - Date.now()));
134296
+ mark("unshield-recipient-read-done", `try${attempt}`);
134297
+ return;
134298
+ } catch (error) {
134299
+ if (/^mcp_unshield_to_invalid:/.test(String(error?.message))) {
134300
+ mark("unshield-recipient-read-done", "cannot_receive");
134301
+ throw error;
134302
+ }
134303
+ if (attempt >= 2 || error?.timedOut === true || Date.now() >= deadline) {
134304
+ mark("unshield-recipient-read-failed", error?.timedOut === true ? "timeout" : "no_answer");
134305
+ throw new Error("mcp_unshield_recipient_unread: the wallet could not read the recipient's USDC account, because Tor or the network did not answer; nothing was sent", { cause: error });
134306
+ }
134307
+ mark("unshield-recipient-read-retry", `try${attempt}`);
134308
+ }
134309
+ }
134310
+ } finally {
134311
+ clearTimeout(slow);
134312
+ }
134313
+ }
134274
134314
  async function walkBeforeLease(session, exitProofTools) {
134275
134315
  try {
134276
134316
  const store = session.openStore();
@@ -134383,7 +134423,9 @@ async function runUnshield({
134383
134423
  },
134384
134424
  walked,
134385
134425
  exitReads,
134386
- finalityWaits = 0
134426
+ finalityWaits = 0,
134427
+ recipientChecked = false,
134428
+ recipientFailure
134387
134429
  }) {
134388
134430
  const owner = new import_web3133.PublicKey(recipientOwner);
134389
134431
  let timing;
@@ -134432,12 +134474,38 @@ async function runUnshield({
134432
134474
  }));
134433
134475
  };
134434
134476
  const name = `self-pay-${unshieldId}`;
134477
+ let recipientRead = recipientChecked ? { ok: true } : recipientFailure ? { error: recipientFailure } : void 0;
134478
+ let slowed = false;
134479
+ if (!recipientRead && typeof session.openStore === "function") {
134480
+ try {
134481
+ const opened = session.openStore();
134482
+ if (!selfPayMayHaveSigned(opened, unshieldId)) {
134483
+ recipientRead = await readUnshieldRecipient({ connection: session.connection, mint: new import_web3133.PublicKey(opened.state.asset), owner, mark, onSlow: () => {
134484
+ slowed = true;
134485
+ onStage?.("slow_read");
134486
+ } }).then(() => ({ ok: true }), (error) => ({ error }));
134487
+ if (slowed) onStage?.("starting");
134488
+ }
134489
+ } catch {
134490
+ recipientRead = void 0;
134491
+ }
134492
+ }
134493
+ const checkRecipient = async (mint) => {
134494
+ if (recipientRead?.ok) return;
134495
+ await readUnshieldRecipient({ connection: session.connection, mint, owner, mark, onSlow: () => onStage?.("slow_read") });
134496
+ };
134435
134497
  const start = await lease(async (opened) => {
134436
134498
  mark("unshield-lease-self-pay");
134499
+ if (recipientRead?.error) {
134500
+ if (!selfPayMayHaveSigned(opened, unshieldId)) throw recipientRead.error;
134501
+ recipientRead = void 0;
134502
+ }
134437
134503
  const stop2 = await before(opened);
134438
134504
  if (stop2 !== void 0) return { stop: stop2 };
134505
+ mark("unshield-before-done");
134439
134506
  const store = await prepare(opened);
134440
134507
  use(store);
134508
+ mark("unshield-prepare-done");
134441
134509
  beforeSign(store, { direct: false });
134442
134510
  const mint = new import_web3133.PublicKey(store.state.asset);
134443
134511
  const recipient = getAssociatedTokenAddressSync(mint, owner, true, TOKEN_PROGRAM_ID);
@@ -134457,6 +134525,7 @@ async function runUnshield({
134457
134525
  };
134458
134526
  store.writeWal(name, record);
134459
134527
  }
134528
+ mark("unshield-choice-done", note ? "direct" : "self_pay");
134460
134529
  }
134461
134530
  if (record?.mode === DIRECT_EXIT_MODE) {
134462
134531
  beforeSign(store, { direct: true });
@@ -134472,6 +134541,7 @@ async function runUnshield({
134472
134541
  mint,
134473
134542
  recipient,
134474
134543
  exitProofTools,
134544
+ checkRecipient,
134475
134545
  facilitatorOrigin: facilitatorOrigin2,
134476
134546
  onStage,
134477
134547
  walk,
@@ -134484,7 +134554,7 @@ async function runUnshield({
134484
134554
  }
134485
134555
  if (record?.mode !== void 0) throw new Error("mcp_unshield_failed: this unshield's record names an exit mode this version does not know; nothing new was signed. Update the wallet");
134486
134556
  if (!selfPayMayHaveSigned(store, unshieldId)) {
134487
- await checkUnshieldRecipient({ connection: session.connection, mint, owner });
134557
+ await checkRecipient(mint);
134488
134558
  }
134489
134559
  const payerTools = session.proofTools;
134490
134560
  onStage("self-pay");
@@ -134660,6 +134730,7 @@ async function runDirectExit({
134660
134730
  mint,
134661
134731
  recipient,
134662
134732
  exitProofTools,
134733
+ checkRecipient,
134663
134734
  facilitatorOrigin: facilitatorOrigin2,
134664
134735
  onStage,
134665
134736
  walk,
@@ -134679,7 +134750,7 @@ async function runDirectExit({
134679
134750
  if (store.readWal(`${RESOURCE_PAYMENT_WAL_PREFIX2}${sha256Hex2(Buffer.from(selfPayRequestId(unshieldId), "utf8"))}`)) {
134680
134751
  throw new Error("mcp_unshield_failed: this unshield is a direct exit, but a self-payment with the same id exists (another command ran it); nothing new was signed, and the wallet keeps both records");
134681
134752
  }
134682
- if (!selfPayMayHaveSigned(store, unshieldId)) await checkUnshieldRecipient({ connection: session.connection, mint, owner });
134753
+ if (!selfPayMayHaveSigned(store, unshieldId)) await checkRecipient(mint);
134683
134754
  onStage("exit");
134684
134755
  mark("unshield-exit");
134685
134756
  const exitAmountAtomic = record.exitAmountAtomic === record.noteValueAtomic ? void 0 : record.exitAmountAtomic;
@@ -134743,6 +134814,8 @@ async function directExitUnshield({
134743
134814
  amountAtomic,
134744
134815
  recipientOwner,
134745
134816
  recipientTokenAccount,
134817
+ recipientChecked = false,
134818
+ recipientFailure,
134746
134819
  exitProofTools,
134747
134820
  facilitatorOrigin: facilitatorOrigin2,
134748
134821
  before = () => void 0,
@@ -134760,6 +134833,8 @@ async function directExitUnshield({
134760
134833
  lease,
134761
134834
  unshieldId,
134762
134835
  amountAtomic,
134836
+ recipientChecked,
134837
+ recipientFailure,
134763
134838
  recipientOwner,
134764
134839
  exitProofTools,
134765
134840
  facilitatorOrigin: facilitatorOrigin2,
@@ -141967,7 +142042,7 @@ ${canonical5}`;
141967
142042
  }
141968
142043
  return session.openStore();
141969
142044
  }
141970
- async function unshieldPart(job, unshieldId, amountAtomic, onStage, { before, beforeSign, stopBeforeSend, onAnswered, firstLease = underLease, yieldMs = UNSHIELD_WINDOW_YIELD_MS } = {}) {
142045
+ async function unshieldPart(job, unshieldId, amountAtomic, onStage, { before, beforeSign, stopBeforeSend, onAnswered, firstLease = underLease, yieldMs = UNSHIELD_WINDOW_YIELD_MS, recipientChecked = false } = {}) {
141971
142046
  const name = `self-pay-${unshieldId}`;
141972
142047
  let windows = 0;
141973
142048
  let backup2;
@@ -141977,6 +142052,7 @@ ${canonical5}`;
141977
142052
  unshieldId,
141978
142053
  amountAtomic,
141979
142054
  recipientOwner: job.to,
142055
+ recipientChecked,
141980
142056
  exitProofTools: money.exitProofTools,
141981
142057
  profile: money.profile,
141982
142058
  facilitatorOrigin: money.facilitatorOrigin,
@@ -142319,6 +142395,8 @@ ${canonical5}`;
142319
142395
  // Each part on one tag of its own (runShieldJob), in lease windows (unshieldPart).
142320
142396
  runPart: ({ part, index, total }) => onOwnTorTag(async () => {
142321
142397
  const result = await unshieldPart(job, part.unshieldId, part.amountAtomic, (stage) => onStage(`payment ${index}/${total}: ${stage}`), {
142398
+ // A plan that started earlier may have sent a part: a read never stops its finish. The exit reads the recipient itself.
142399
+ recipientChecked: true,
142322
142400
  before: (opened) => {
142323
142401
  store = opened;
142324
142402
  if (partCancelled(opened, sendId, part)) return { cancelled: true };
@@ -145425,7 +145503,7 @@ function createSetupTools({
145425
145503
  doneTool: sayOnRefusal(doneTool)
145426
145504
  };
145427
145505
  }
145428
- var import_web3133, X402_V1_NEXT, shownCaps, RELEASE_RETRY_MS, STAGE_WORDS, stageWords, INTERNAL_BALANCE_DETAIL, shownBreakdown, sessionLeftShown, RESOURCE_PAYMENT_WAL_PREFIX2, POOL_LAYOUT_CODE, POOL_LAYOUT_UPDATE, USEPOD_VIA_INFERENCE_CHAT, SEND_RUNS_ON, DEPOSIT_RUNS_ON, CLI_FUNDS_PLAN_PREFIX, CLI_FUNDS_SCHEMA, SELF_PAY_ORIGIN3, REQUEST_ID4, POSITIVE_ATOMIC6, PRIVATE_HOST3, FORBIDDEN_HEADERS3, MAX_BODY_BYTES2, PREVIEW_TIMEOUT_MS, PREVIEW_SELLER_READ_MS, CALL_BUDGET_MS, budgetLeft, PAY_ANSWER_MARGIN_MS, MONEY_FIRST_ANSWER_MS, BALANCE_AFTER_LANDING_MS, JOIN_CALL_MAX_MS, JOIN_CALL_ANSWER_MARGIN_S, PAY_AFTER_JOIN_MS, joinAnswerSeconds, JOIN_TIME_MS, JOIN_NUDGE_QUIET_MS, JOIN_STEP_MS, sleep2, PROGRESS_EVERY_MS2, READ_BUDGET_MS, UNPAID_TOR_TRY_MS, UNPAID_CLEAR_MS, READ_BUDGET_TOOLS, FLOAT_BUSY_CODES, RETRY_MARGIN_MS, ASK_PAY_CODES, runningNpmVersion, terminalCommand2, capPlaceWords, noLimitSetLine, CAP_NAMES, capName, entryPlaces, capRaiseText, runningLimits, payCapFlag, noPriceFits, cheaperText, limitNext, overLimitStep, SAFE_TEXT, causesLog, MCP_TOOL_ALIASES, POOL_SWITCH_WHY, POOL_SWITCH_NEXT, SWITCH_STATES, quietSwitch, switchKey, ATOMIC_TEXT, MAX_PAYMENT_ATOMIC_LEAST, movedTo, FLOAT_ID2, ANSWERED_EXIT_RETRY_MS, ANSWERED_EXIT_UNCONFIRMED_MS, ANSWERED_EXIT_RETRY_WINDOW_MS, ANSWERED_EXIT_CLOSED, switchAmount, switchEta, switchRows, OWNER_CAP_CODES, JOIN_END_MCP, JOIN_END_TERMINAL_LIBRARY, JOIN_RETRY_BACKOFF_MS, WALLET_CAP_FIX, ENTRY_CAP_CODES, MCP_CAP_FIX, capFix, ownerOnlyNext, mcpNext, CONFIDENTIAL_RETIRED, json4, answerResult, discoverTool, LAUNCH_CAP_CODES, dayCapKind, refuse11, newRequestIdFor, payCapName, limitQuestion, stableJson, requestPrint, publicOffer, FLOAT_PAID_CODES, FLOAT_NOT_CERTAIN_CODES, FLOAT_PRIVATE_LEG, SELLER_ONLY_HERE, outsideWalletRule, TOR_START_STEP, MONEY_ID2, toRecordId, linkKindOf, moneyId, REFUSED_CODES, SEND_STOPPED, SEND_STOP_NOT_SAVED, sendStoppedError, refusedCodeOf, PLAIN_REASONS, insufficientCause, INSUFFICIENT_REASONS, reasonOf, plainReason, KEPT_SEND_TRIES, shownId, isSplitSend, PROMISED_NEXT, partFailReason, sendAnswerOf, PUBLIC_READ_TIMEOUT_MS, RECIPIENT_CHECK_TIMEOUT_MS, withTimeout, ownKey, readFailure, OWN_KEY_TOKENS_MAX, tokenAmountText, elsewhereId, AGENT_ID_SCHEMA, agentIdName, minutesText2, ageWords2, DEPOSIT_SENT_STATES, depositLanded, usdcText3, walkWalletHistory, REFRESH_LEASE_WALK_MS, HOME_MARKS_SETTLED_MS2, AUTO_BACKUPS_KEPT, AUTO_BACKUP_NAME, AUTO_BACKUP_VERIFIED, FRONTED_SETTLE_MARGIN_SLOTS, UNSHIELD_WINDOW_YIELD_MS, NOT_FINAL_YET, FINISH_FINALITY_WAIT_MS, FINISH_FINALITY_WAITS, FINISH_FINALITY_RECENT_MS, walkStillCurrent, DIRECT_EXIT_GONE, BALANCE_REFRESH_WAIT_MS, BALANCE_REFRESH_GRACE_MS, BALANCE_REFRESH_LONG_MS, INBOUND_REFRESH_AGE_MS, SALE_VIEW_AGE_SECONDS, saleViewRead, balanceTextFields, changeFields, balanceAnswer, CAP_BALANCE_WAIT_MS, CAP_BALANCE_RETRY_MS, REFRESH_RETRY_MS, FINALITY_POLL_MS, FINALITY_WAIT_MS, FINALITY_REFRESH_LIMIT_MS, POOL_WATCH_MS, POOL_WATCH_POLL_MS, EARLY_BALANCE_DELAY_MS, FINALITY_SETTLE_WINDOW_SLOTS, PUBLIC_READ_ANSWER_MS, LINK_READ_ANSWER_MS, OWN_READS_AHEAD_MS, OWN_PUBLIC_KNOWN_MS, FLOAT_CORRECT_WAIT_MS, SWITCH_WAIT_MS, UNSHIELD_TO_NO_USDC_DETAIL, UNSHIELD_TO_INVALID_NEXT, INFERENCE_MIN_MAX_TOKENS, ELICIT_TIMEOUT_MS, ALLOW_BOX_HOSTS, ALLOW_BOX_PROGRESS_MS, ELICIT_UNSHOWN_MS, elicitUnshown, POLL_SECONDS2, TEMP_CLEAN_DELAY_MS, KEPT_ON_DISK, MAX_SHIELDED_BALANCE_ATOMIC, receiveGenerator, MCP_TOOL_NAMES, MCP_HIDDEN_TOOL_NAMES, setupTerminalNext, SETUP_RUNNING_SAY, SETUP_WAITING_SAY, ACCEPTED_NEXT, SETUP_RUNNING_NEXT, SETUP_ANSWER_WAIT_MS, SETUP_CONFIRMING_SAY, SETUP_CONFIRMING_NEXT, OWN_ADDRESS_QUESTION, OWN_ADDRESS_WHERE, OWN_ADDRESS_INVALID, HOST_CHAT_NOT_PRIVATE, PRIVATE_INFERENCE_WHY, RESTART_STEPS, HOST_BLOCKED_LINE, TOR_BROWSER_PORT, SETUP_TOR_TITLE, SETUP_TOR_WHY;
145506
+ var import_web3133, X402_V1_NEXT, shownCaps, RELEASE_RETRY_MS, STAGE_WORDS, slowReadWords, stageWords, INTERNAL_BALANCE_DETAIL, shownBreakdown, sessionLeftShown, RESOURCE_PAYMENT_WAL_PREFIX2, POOL_LAYOUT_CODE, POOL_LAYOUT_UPDATE, USEPOD_VIA_INFERENCE_CHAT, SEND_RUNS_ON, DEPOSIT_RUNS_ON, CLI_FUNDS_PLAN_PREFIX, CLI_FUNDS_SCHEMA, SELF_PAY_ORIGIN3, REQUEST_ID4, POSITIVE_ATOMIC6, PRIVATE_HOST3, FORBIDDEN_HEADERS3, MAX_BODY_BYTES2, PREVIEW_TIMEOUT_MS, PREVIEW_SELLER_READ_MS, CALL_BUDGET_MS, budgetLeft, PAY_ANSWER_MARGIN_MS, MONEY_FIRST_ANSWER_MS, BALANCE_AFTER_LANDING_MS, JOIN_CALL_MAX_MS, JOIN_CALL_ANSWER_MARGIN_S, PAY_AFTER_JOIN_MS, joinAnswerSeconds, JOIN_TIME_MS, JOIN_NUDGE_QUIET_MS, JOIN_STEP_MS, sleep2, PROGRESS_EVERY_MS2, READ_BUDGET_MS, UNPAID_TOR_TRY_MS, UNPAID_CLEAR_MS, READ_BUDGET_TOOLS, FLOAT_BUSY_CODES, RETRY_MARGIN_MS, ASK_PAY_CODES, runningNpmVersion, terminalCommand2, capPlaceWords, noLimitSetLine, CAP_NAMES, capName, entryPlaces, capRaiseText, runningLimits, payCapFlag, noPriceFits, cheaperText, limitNext, overLimitStep, SAFE_TEXT, causesLog, MCP_TOOL_ALIASES, POOL_SWITCH_WHY, POOL_SWITCH_NEXT, SWITCH_STATES, quietSwitch, switchKey, ATOMIC_TEXT, MAX_PAYMENT_ATOMIC_LEAST, movedTo, FLOAT_ID2, ANSWERED_EXIT_RETRY_MS, ANSWERED_EXIT_UNCONFIRMED_MS, ANSWERED_EXIT_RETRY_WINDOW_MS, ANSWERED_EXIT_CLOSED, switchAmount, switchEta, switchRows, OWNER_CAP_CODES, JOIN_END_MCP, JOIN_END_TERMINAL_LIBRARY, JOIN_RETRY_BACKOFF_MS, WALLET_CAP_FIX, ENTRY_CAP_CODES, MCP_CAP_FIX, capFix, ownerOnlyNext, mcpNext, CONFIDENTIAL_RETIRED, json4, answerResult, discoverTool, LAUNCH_CAP_CODES, dayCapKind, refuse11, newRequestIdFor, payCapName, limitQuestion, stableJson, requestPrint, publicOffer, FLOAT_PAID_CODES, FLOAT_NOT_CERTAIN_CODES, FLOAT_PRIVATE_LEG, SELLER_ONLY_HERE, outsideWalletRule, TOR_START_STEP, MONEY_ID2, toRecordId, linkKindOf, moneyId, REFUSED_CODES, SEND_STOPPED, SEND_STOP_NOT_SAVED, sendStoppedError, refusedCodeOf, PLAIN_REASONS, insufficientCause, INSUFFICIENT_REASONS, reasonOf, plainReason, KEPT_SEND_TRIES, shownId, isSplitSend, PROMISED_NEXT, partFailReason, sendAnswerOf, PUBLIC_READ_TIMEOUT_MS, RECIPIENT_CHECK_TIMEOUT_MS, withTimeout, ownKey, readFailure, OWN_KEY_TOKENS_MAX, tokenAmountText, elsewhereId, AGENT_ID_SCHEMA, agentIdName, minutesText2, ageWords2, DEPOSIT_SENT_STATES, depositLanded, usdcText3, walkWalletHistory, REFRESH_LEASE_WALK_MS, HOME_MARKS_SETTLED_MS2, AUTO_BACKUPS_KEPT, AUTO_BACKUP_NAME, AUTO_BACKUP_VERIFIED, FRONTED_SETTLE_MARGIN_SLOTS, RECIPIENT_READ_TOTAL_MS, RECIPIENT_READ_SLOW_MS, slowReadSaid, UNSHIELD_WINDOW_YIELD_MS, NOT_FINAL_YET, FINISH_FINALITY_WAIT_MS, FINISH_FINALITY_WAITS, FINISH_FINALITY_RECENT_MS, walkStillCurrent, DIRECT_EXIT_GONE, BALANCE_REFRESH_WAIT_MS, BALANCE_REFRESH_GRACE_MS, BALANCE_REFRESH_LONG_MS, INBOUND_REFRESH_AGE_MS, SALE_VIEW_AGE_SECONDS, saleViewRead, balanceTextFields, changeFields, balanceAnswer, CAP_BALANCE_WAIT_MS, CAP_BALANCE_RETRY_MS, REFRESH_RETRY_MS, FINALITY_POLL_MS, FINALITY_WAIT_MS, FINALITY_REFRESH_LIMIT_MS, POOL_WATCH_MS, POOL_WATCH_POLL_MS, EARLY_BALANCE_DELAY_MS, FINALITY_SETTLE_WINDOW_SLOTS, PUBLIC_READ_ANSWER_MS, LINK_READ_ANSWER_MS, OWN_READS_AHEAD_MS, OWN_PUBLIC_KNOWN_MS, FLOAT_CORRECT_WAIT_MS, SWITCH_WAIT_MS, UNSHIELD_TO_NO_USDC_DETAIL, UNSHIELD_TO_INVALID_NEXT, INFERENCE_MIN_MAX_TOKENS, ELICIT_TIMEOUT_MS, ALLOW_BOX_HOSTS, ALLOW_BOX_PROGRESS_MS, ELICIT_UNSHOWN_MS, elicitUnshown, POLL_SECONDS2, TEMP_CLEAN_DELAY_MS, KEPT_ON_DISK, MAX_SHIELDED_BALANCE_ATOMIC, receiveGenerator, MCP_TOOL_NAMES, MCP_HIDDEN_TOOL_NAMES, setupTerminalNext, SETUP_RUNNING_SAY, SETUP_WAITING_SAY, ACCEPTED_NEXT, SETUP_RUNNING_NEXT, SETUP_ANSWER_WAIT_MS, SETUP_CONFIRMING_SAY, SETUP_CONFIRMING_NEXT, OWN_ADDRESS_QUESTION, OWN_ADDRESS_WHERE, OWN_ADDRESS_INVALID, HOST_CHAT_NOT_PRIVATE, PRIVATE_INFERENCE_WHY, RESTART_STEPS, HOST_BLOCKED_LINE, TOR_BROWSER_PORT, SETUP_TOR_TITLE, SETUP_TOR_WHY;
145429
145507
  var init_tools = __esm({
145430
145508
  "wallet/src/mcp/tools.mjs"() {
145431
145509
  "use strict";
@@ -145532,7 +145610,8 @@ var init_tools = __esm({
145532
145610
  refreshing: "reading the chain",
145533
145611
  joining: "getting your balance ready to send"
145534
145612
  });
145535
- stageWords = (stage) => STAGE_WORDS[stage] ?? String(stage ?? "").replace(/self-pay/g, "preparing").replace(/^part (\d+\/\d+)/, "payment $1");
145613
+ slowReadWords = () => inTorRun() ? TOR_WAIT_WORDS : "The network is slow right now, so the wallet waits for it and tries again";
145614
+ stageWords = (stage) => (stage === "slow_read" ? slowReadWords() : void 0) ?? STAGE_WORDS[stage] ?? String(stage ?? "").replace(/self-pay/g, "preparing").replace(/^part (\d+\/\d+)/, "payment $1");
145536
145615
  INTERNAL_BALANCE_DETAIL = /* @__PURE__ */ new Set(["successionMovableAtomic", "unspentNotes", "fundedAccounts", "budget", "unspentAccounts"]);
145537
145616
  shownBreakdown = (breakdown) => breakdown && typeof breakdown === "object" ? Object.fromEntries(Object.entries(breakdown).filter(([name, value2]) => !(["setAsideAtomic", "refundsInFlightAtomic", "refundsNotCertainAtomic", "openPaymentsAtomic"].includes(name) && value2 === "0"))) : breakdown;
145538
145617
  sessionLeftShown = (policy, store) => {
@@ -145693,6 +145772,7 @@ var init_tools = __esm({
145693
145772
  mcp_unshield_stopped: "terminal",
145694
145773
  mcp_unshield_stop_not_saved: "terminal",
145695
145774
  // Can pass later by itself.
145775
+ mcp_unshield_recipient_unread: "retry",
145696
145776
  mcp_unshield_wait_for_deposit: "retry",
145697
145777
  mcp_balance_unknown: "retry",
145698
145778
  mcp_unshield_failed: "retry",
@@ -145929,6 +146009,9 @@ var init_tools = __esm({
145929
146009
  AUTO_BACKUP_NAME = /^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z(-\d+)?$/;
145930
146010
  AUTO_BACKUP_VERIFIED = ".verified";
145931
146011
  FRONTED_SETTLE_MARGIN_SLOTS = 20;
146012
+ RECIPIENT_READ_TOTAL_MS = 75e3;
146013
+ RECIPIENT_READ_SLOW_MS = 8e3;
146014
+ slowReadSaid = false;
145932
146015
  UNSHIELD_WINDOW_YIELD_MS = 1500;
145933
146016
  NOT_FINAL_YET = /confirmed note-exit is not finalized spent/;
145934
146017
  FINISH_FINALITY_WAIT_MS = 4e3;
@@ -157587,6 +157670,7 @@ init_recoveredPayment();
157587
157670
  init_recover();
157588
157671
  init_scheduler();
157589
157672
  init_balance();
157673
+ init_plan();
157590
157674
  init_secretFile();
157591
157675
  init_setup();
157592
157676
  init_serveRunner();
@@ -159034,10 +159118,12 @@ function shortText(short, options) {
159034
159118
  ${stepWords(short.addFundsOpen ? "To continue it" : "To add money", "add-funds", `${cli4()} add-funds`)}`;
159035
159119
  }
159036
159120
  var shortRefusal = (short, options) => new PublicFailure(`${EMPTY_BALANCE_CODE}: ${shortText(short, options)}`);
159037
- function savedWalkHoldsAccount(store) {
159121
+ function savedWalkOnlySelfPays(store) {
159038
159122
  try {
159039
159123
  const snapshot = readBalanceSnapshot(store).snapshot;
159040
- return snapshot?.pool === store.state.pool && Array.isArray(snapshot.outputs) && snapshot.outputs.some((output2) => output2.kind === "account" && output2.spendStatus === "unspent");
159124
+ if (snapshot?.pool !== store.state.pool || !Array.isArray(snapshot.outputs)) return false;
159125
+ const unspent = snapshot.outputs.filter((output2) => output2.spendStatus === "unspent");
159126
+ return unspent.some((output2) => output2.kind === "account") && notesBelowEveryAccount(unspent).length === 0;
159041
159127
  } catch {
159042
159128
  return false;
159043
159129
  }
@@ -159068,7 +159154,7 @@ async function stopWhenShort(values, deps, { needAtomic = 1n, costAtomic, paymen
159068
159154
  } catch {
159069
159155
  noWalk = false;
159070
159156
  }
159071
- if (!knownShortBalance(store, { needAtomic, payment }) && !noWalk && !(noAccount && !savedWalkHoldsAccount(store))) return false;
159157
+ if (!knownShortBalance(store, { needAtomic, payment }) && !noWalk && !(noAccount && !savedWalkOnlySelfPays(store))) return false;
159072
159158
  await checkFloatRefunds(store, values, deps, () => commandStore(values, deps));
159073
159159
  const read = await readBalanceFromChain(store, values, deps);
159074
159160
  if (read === "failed") deps.io.err(`Your private balance could not be read from the chain now; the ${payment ? "payment" : "send"} reads it again before it signs anything.
@@ -165054,6 +165140,7 @@ function directExitRefusal(error, { unshieldId }) {
165054
165140
  return unshieldRefusal("received_payment_gone", `the received payment this send chose is no longer in the wallet (another send used it, or the last balance read was old); nothing was sent. Run ${cli4()} balance, then ${cli4()} unshield again`);
165055
165141
  }
165056
165142
  if (code2 === "mcp_unshield_to_invalid") return unshieldRefusal("exit_recipient_invalid", UNSHIELD_TO_NO_USDC_TEXT);
165143
+ if (code2 === "mcp_unshield_recipient_unread") return unshieldRefusal("recipient_unread", RECIPIENT_UNREAD_TEXT());
165057
165144
  if (code2 === "mcp_request_id_reused" && /another amount/.test(message)) {
165058
165145
  return unshieldRefusal("id_reused_with_different_amount", `unshield ${unshieldId} started earlier with another amount, and one unshield id always sends the amount it started with; nothing new was sent. Run its first command again to finish it. If you still want a new send, leave out --unshield-id to start one`);
165059
165146
  }
@@ -165075,17 +165162,6 @@ function walletOwnAddress(store) {
165075
165162
  return void 0;
165076
165163
  }
165077
165164
  }
165078
- async function recipientHoldsUsdc({ connection, mint, owner }) {
165079
- const account = getAssociatedTokenAddressSync(mint, owner, true, TOKEN_PROGRAM_ID);
165080
- let info;
165081
- try {
165082
- info = await getAccount(connection, account, "finalized", TOKEN_PROGRAM_ID);
165083
- } catch (error) {
165084
- if (error instanceof TokenAccountNotFoundError) return false;
165085
- throw error;
165086
- }
165087
- return info.mint.equals(mint) && info.owner.equals(owner);
165088
- }
165089
165165
  async function askUnshield(args, values, deps, { read = false } = {}) {
165090
165166
  if (values.has("--amount") && values.has("--to")) return args;
165091
165167
  const command = COMMAND_BY_NAME.get("unshield");
@@ -165180,6 +165256,7 @@ async function runUnshieldCommand(args, values, deps, io) {
165180
165256
  throw error;
165181
165257
  }
165182
165258
  }
165259
+ var RECIPIENT_UNREAD_TEXT = () => `the wallet could not read the recipient's USDC account, because Tor or the network did not answer; nothing was sent. Run ${cli4()} unshield again in a minute`;
165183
165260
  async function runUnshieldRequest(args, values, deps, io) {
165184
165261
  const read = values.has("--unshield-id") ? false : await stopWhenShort(values, deps, { noAccount: true });
165185
165262
  args = await askUnshield(args, values, deps, { read });
@@ -165193,21 +165270,46 @@ async function runUnshieldRequest(args, values, deps, io) {
165193
165270
  let store;
165194
165271
  const openStore = () => store ??= (deps.openWalletStore ?? openWalletStore)(resolve40(values.get("--wallet")), payerPassphrase(values, deps));
165195
165272
  const owner = values.has("--recipient-owner") ? new import_web3137.PublicKey(values.get("--recipient-owner")) : new import_web3137.PublicKey(values.get("--to"));
165273
+ let recipientChecked = false;
165274
+ let recipientFailure;
165196
165275
  if (!values.has("--recipient-owner")) {
165197
165276
  const wallet = openStore();
165198
165277
  if (walletOwnAddress(wallet)?.equals(owner)) {
165199
165278
  throw unshieldRefusal("recipient_owner_is_deposit_key", `--to is this wallet's own public address (its own key): an exit there would show on chain that the money is yours, so this private wallet does not send there; nothing was sent. Send to another address (best: one that never sent USDC into this wallet), like ${UNSHIELD_EXAMPLE}`);
165200
165279
  }
165201
165280
  const mint = new import_web3137.PublicKey(wallet.state.asset);
165202
- const check = deps.unshieldRecipientHoldsUsdc ?? ((input) => recipientHoldsUsdc({ ...input, connection: connectRelay(spendRpcUrl(values, deps), "finalized") }));
165203
- let holds;
165281
+ let timing;
165204
165282
  try {
165205
- holds = await check({ mint, owner });
165283
+ timing = createTimingLog(`${resolve40(values.get("--wallet"))}.timing.log`, { component: "payer" }).start();
165206
165284
  } catch {
165207
- holds = void 0;
165285
+ timing = void 0;
165286
+ }
165287
+ const mark = (phase, outcome) => {
165288
+ try {
165289
+ timing?.(phase, outcome);
165290
+ } catch {
165291
+ }
165292
+ };
165293
+ const check = deps.unshieldRecipientHoldsUsdc ? async (input) => {
165294
+ if (await deps.unshieldRecipientHoldsUsdc(input) === false) throw new Error("mcp_unshield_to_invalid: no USDC account");
165295
+ } : void 0;
165296
+ try {
165297
+ await readUnshieldRecipient({ connection: deps.unshieldRecipientHoldsUsdc ? void 0 : connectRelay(spendRpcUrl(values, deps), "finalized"), mint, owner, mark, ...check ? { check } : {} });
165298
+ recipientChecked = true;
165299
+ } catch (error) {
165300
+ if (!values.has("--unshield-id")) {
165301
+ if (/^mcp_unshield_to_invalid:/.test(String(error?.message))) throw unshieldRefusal("exit_recipient_invalid", UNSHIELD_TO_NO_USDC_TEXT);
165302
+ throw unshieldRefusal("recipient_unread", RECIPIENT_UNREAD_TEXT());
165303
+ }
165304
+ let plan;
165305
+ try {
165306
+ plan = Boolean(wallet.readWal(privateSendPlanName(values.get("--unshield-id"))));
165307
+ } catch {
165308
+ plan = true;
165309
+ }
165310
+ if (plan) recipientChecked = true;
165311
+ else recipientFailure = error;
165208
165312
  }
165209
- if (holds === void 0) io.err("note: whether the recipient can receive USDC could not be checked (the RPC did not answer); the unshield goes on\n");
165210
- if (holds === false) throw unshieldRefusal("exit_recipient_invalid", UNSHIELD_TO_NO_USDC_TEXT);
165211
165313
  setArg("--to", getAssociatedTokenAddressSync(mint, owner, true, TOKEN_PROGRAM_ID).toBase58());
165212
165314
  setArg("--recipient-owner", owner.toBase58());
165213
165315
  }
@@ -165259,10 +165361,10 @@ async function runUnshieldRequest(args, values, deps, io) {
165259
165361
  io.err(joinsFirst ? "preparing the private send; the result shows here when the send is done\n" : "sending privately now; the result shows here when the send is done\n");
165260
165362
  }
165261
165363
  let answer;
165262
- let directExit = terminalDirectExit;
165364
+ let directExit = recipientChecked ? (input) => terminalDirectExit({ ...input, recipientChecked: true }) : recipientFailure ? (input) => terminalDirectExit({ ...input, recipientFailure }) : terminalDirectExit;
165263
165365
  try {
165264
165366
  const wallet = openStore();
165265
- if (!wallet.readWal(`self-pay-${id}`) && savedWalkHoldsAccount(wallet)) directExit = void 0;
165367
+ if (!recipientFailure && !wallet.readWal(`self-pay-${id}`) && savedWalkOnlySelfPays(wallet)) directExit = void 0;
165266
165368
  } catch {
165267
165369
  }
165268
165370
  let shown = false;
@@ -165433,6 +165535,19 @@ function unfinishedUnshields(store) {
165433
165535
  };
165434
165536
  }).sort((a, b) => a.startedAtMs - b.startedAtMs).map(({ startedAtMs: _at, ...one }) => one);
165435
165537
  }
165538
+ function unshieldIdLine(id, values, deps) {
165539
+ if (!id) return "";
165540
+ const line = `this unshield's id is ${id}: to rerun or finish it, run the same command with --unshield-id ${id} added (it never sends twice)
165541
+ `;
165542
+ try {
165543
+ const store = commandStore(values, deps);
165544
+ if (!store) return line;
165545
+ const record = store.readWal(`self-pay-${id}`);
165546
+ return terminalSendResumable(store, id, record, plannedPartIds(store)) || partMayHaveSigned(store, { unshieldId: id }) ? line : "";
165547
+ } catch {
165548
+ return line;
165549
+ }
165550
+ }
165436
165551
  var unfinishedUnshieldLine = ({ unshieldId, amountAtomic, answered: answered2, exitTransaction, resumable, to }) => {
165437
165552
  if (resumable) {
165438
165553
  return answered2 ? `${usdcOr(amountAtomic)} was sent to ${to ?? "your address"} (transaction ${exitTransaction}); run ${cli4()} unshield all to finish the wallet's own record of it.` : `${usdcOr(amountAtomic)} is still on its way${to ? ` to ${to}` : ""}; run ${cli4()} unshield all to finish it.`;
@@ -166596,6 +166711,9 @@ function insufficientWords(cause, parts, { selfJoin = false, send: send3 = false
166596
166711
  return `open work of this wallet (a payment, a send, or a fill) holds your whole private balance now, so none of it is free for this payment. Nothing was signed, and the quote was dropped. ${cli4()} balance --json lists that work (detail.inFlight); rerun this command once it finished`;
166597
166712
  default: {
166598
166713
  const words2 = balanceWords(parts);
166714
+ if (send3) {
166715
+ return `your private balance cannot send this amount now. Nothing was signed or sent. ${words2 ? `${words2}. ` : `${cli4()} balance shows what you can send. `}Send a smaller amount, or add funds (${cli4()} help add-funds), then run the command again`;
166716
+ }
166599
166717
  return `your private balance is less than this amount needs (price + fee). Nothing was signed, the quote was dropped, and its budget came back, so nothing blocks your next payment. ${words2 ? `${words2}. ` : `${cli4()} balance shows what you can spend. `}Add funds (${cli4()} help add-funds), then rerun this command`;
166600
166718
  }
166601
166719
  }
@@ -168202,8 +168320,7 @@ Next: fund that address, then rerun the same command; it continues where it stop
168202
168320
  if (hint && ["curl", "pay", "unshield"].includes(command?.name) && codes.some((code2) => /^p03_merchant_respend_(insufficient_recovered_value|accounts_split_merge_first)$/.test(code2))) {
168203
168321
  const made = command.name === "unshield" ? values?.get?.(UNSHIELD_MADE_ID) : void 0;
168204
168322
  io.err(`${hint[0].toUpperCase()}${hint.slice(1).replace(/[\s.;]+$/, "")}.
168205
- ` + (made ? `this unshield's id is ${made}: to rerun or finish it, run the same command with --unshield-id ${made} added (it never sends twice)
168206
- ` : ""));
168323
+ ${unshieldIdLine(made, values, deps)}`);
168207
168324
  return 1;
168208
168325
  }
168209
168326
  if (hint && ANCHOR_REFUSAL.test([...codes, reason].join(" "))) {
@@ -168230,8 +168347,7 @@ Next: fund that address, then rerun the same command; it continues where it stop
168230
168347
  ` : "";
168231
168348
  const madeId = /use_new_unshield_id|new --unshield-id/.test(`${reason} ${hint ?? ""}`) || UNSHIELD_ID_CLOSED.test(reason) ? void 0 : values?.get?.(UNSHIELD_MADE_ID);
168232
168349
  const inferId = values?.get?.(INFER_STOPPED_ID);
168233
- const idLine = madeId ? `this unshield's id is ${madeId}: to rerun or finish it, run the same command with --unshield-id ${madeId} added (it never sends twice)
168234
- ` : inferId ? `${inferStopLine(inferId, values, deps)}
168350
+ const idLine = madeId ? unshieldIdLine(madeId, values, deps) : inferId ? `${inferStopLine(inferId, values, deps)}
168235
168351
  ` : "";
168236
168352
  if (hint && (command?.name === "infer" || command?.name === "curl") && FLOAT_OUTCOME_CODE.test(reason)) {
168237
168353
  const runAgain = command.name !== "infer" || /the command below/.test(hint);