shinjuku-shield 0.3.198 → 0.3.199

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
@@ -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.198. The command is `shinjuku`.
8
+ This is version 0.3.199. The command is `shinjuku`.
9
9
 
10
10
  ## Set up
11
11
 
12
12
  ```sh
13
- npx -y shinjuku@0.3.198 setup
13
+ npx -y shinjuku@0.3.199 setup
14
14
  ```
15
15
 
16
16
  Setup does every step for you:
@@ -107,14 +107,14 @@ Add it yourself. The name of the wallet in your app is `shinjuku`.
107
107
  Claude Code:
108
108
 
109
109
  ```sh
110
- claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.198 mcp
110
+ claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.199 mcp
111
111
  ```
112
112
 
113
113
  In this test version only (not offered yet), the same entry for Claude Desktop
114
114
  (`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
115
115
 
116
116
  ```json
117
- { "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.198", "mcp"] } } }
117
+ { "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.199", "mcp"] } } }
118
118
  ```
119
119
 
120
120
  On Windows, if the app cannot find `npx`, use `"command": "cmd"` and put
@@ -126,7 +126,7 @@ CLI read `~/.codex/config.toml`):
126
126
  ```toml
127
127
  [mcp_servers.shinjuku]
128
128
  command = "npx"
129
- args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.198", "mcp"]
129
+ args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.199", "mcp"]
130
130
  startup_timeout_sec = 120
131
131
  tool_timeout_sec = 300
132
132
  ```
@@ -144,7 +144,7 @@ with the Releases table in
144
144
  Versions are published from GitHub Actions with npm provenance.
145
145
 
146
146
  `shinjuku-shield` is the package that holds the wallet. `shinjuku-shielded`
147
- 0.3.198, its older name, runs this package at the same version, so wallets
147
+ 0.3.199, its older name, runs this package at the same version, so wallets
148
148
  installed under that name keep updating. New installs use `shinjuku`.
149
149
 
150
150
  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": "30be98b75cc5bfe572442c64facdc78894536998dfbea14c4693f43d62c1c5f1",
5
- "bytes": 9454034,
6
- "sourceCommit": "0a316698ac7e36253592cb490289de91b229bb8d",
4
+ "sha256": "00e93f651c5151d2105472d1135cca61a9e68340553f742a990f0c3fa02d51d2",
5
+ "bytes": 9469183,
6
+ "sourceCommit": "8e3ed35aea4da0e4efd164bf30fc45467f669552",
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": "cd045567e7fc90c3bd8cbfae4ee3116f3d6edded634231dd34ab3fe1e5cc2aad",
1044
- "bytes": 3726154,
1043
+ "sha256": "59607c8bdbeb3c5f71a97c03079ca0d5943aca6a37240402dcf22fc1e6a7201d",
1044
+ "bytes": 3733801,
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-09T01:04:50.506Z"
1935
+ "publishedAt": "2026-11-09T02:19:02.096Z"
1936
1936
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "shinjuku-shield",
3
- "version": "0.3.198",
3
+ "version": "0.3.199",
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": "30be98b7",
7
- "shinjukuSha256": "30be98b75cc5bfe572442c64facdc78894536998dfbea14c4693f43d62c1c5f1",
6
+ "shinjukuRelease": "00e93f65",
7
+ "shinjukuSha256": "00e93f651c5151d2105472d1135cca61a9e68340553f742a990f0c3fa02d51d2",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "author": "Shinjuku Shield",
10
10
  "homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
@@ -34902,30 +34902,91 @@ ${Object.entries(params.headers ?? {}).filter(([name, value]) => value !== void
34902
34902
  `).join("")}\r
34903
34903
  `;
34904
34904
  const sent = [];
34905
+ let keptBytes = 0;
34906
+ let tooBigToReplay = false;
34905
34907
  let socket;
34906
34908
  let ready = false;
34909
+ let waitFor200 = false;
34907
34910
  let open2 = false;
34908
34911
  let reply = Buffer.alloc(0);
34912
+ let endPending;
34913
+ let ended2 = false;
34914
+ let firstDone = false;
34915
+ let flushing = Promise.resolve();
34909
34916
  let pendingReject;
34917
+ const destroyedError = () => Object.assign(new Error("the Tor tunnel closed before its bytes were sent"), { code: "ERR_STREAM_DESTROYED" });
34918
+ const flushKept = async (to) => {
34919
+ for (let index = 0; index < sent.length; index += 1) {
34920
+ if (to !== socket || to.destroyed) return;
34921
+ const entry = sent[index];
34922
+ const done = entry.done;
34923
+ entry.done = void 0;
34924
+ if (!to.write(entry.bytes, done)) {
34925
+ await new Promise((resolve17) => {
34926
+ const go = () => {
34927
+ to.off("drain", go);
34928
+ to.off("close", go);
34929
+ resolve17();
34930
+ };
34931
+ to.on("drain", go);
34932
+ to.on("close", go);
34933
+ });
34934
+ }
34935
+ }
34936
+ if (to !== socket || to.destroyed) return;
34937
+ ready = true;
34938
+ if (ended2) {
34939
+ to.end();
34940
+ const done = endPending;
34941
+ endPending = void 0;
34942
+ done?.();
34943
+ }
34944
+ };
34910
34945
  const stream = new Duplex({
34911
34946
  // Backpressure (Codex review): the tunnel socket pauses when this buffer is full and resumes when TLS reads.
34912
34947
  read() {
34913
34948
  if (socket && !socket.destroyed && socket.isPaused()) socket.resume();
34914
34949
  },
34915
34950
  write(chunk, encoding, done) {
34916
- if (!open2) sent.push(Buffer.from(chunk, encoding));
34917
- if (!ready || socket.destroyed) {
34951
+ const bytes2 = Buffer.from(chunk, encoding);
34952
+ if (!ready) {
34953
+ sent.push({ bytes: bytes2, done });
34954
+ keptBytes += bytes2.length;
34955
+ if (keptBytes > REPLAY_LIMIT) tooBigToReplay = true;
34956
+ return;
34957
+ }
34958
+ if (!open2 && !tooBigToReplay) {
34959
+ if (keptBytes + bytes2.length > REPLAY_LIMIT) tooBigToReplay = true;
34960
+ else {
34961
+ sent.push({ bytes: bytes2, done: void 0 });
34962
+ keptBytes += bytes2.length;
34963
+ }
34964
+ }
34965
+ if (socket.destroyed) {
34918
34966
  done();
34919
34967
  return;
34920
34968
  }
34921
- socket.write(chunk, encoding, done);
34969
+ socket.write(bytes2, done);
34922
34970
  },
34923
34971
  final(done) {
34972
+ ended2 = true;
34973
+ if (!ready) {
34974
+ endPending = done;
34975
+ return;
34976
+ }
34924
34977
  socket?.end();
34925
34978
  done();
34926
34979
  },
34927
34980
  destroy(error, done) {
34928
34981
  socket?.destroy();
34982
+ for (const entry of sent) {
34983
+ const held = entry.done;
34984
+ entry.done = void 0;
34985
+ held?.(error ?? destroyedError());
34986
+ }
34987
+ const end = endPending;
34988
+ endPending = void 0;
34989
+ end?.(error ?? destroyedError());
34929
34990
  done(error);
34930
34991
  }
34931
34992
  });
@@ -34934,21 +34995,23 @@ ${Object.entries(params.headers ?? {}).filter(([name, value]) => value !== void
34934
34995
  const abortReason = () => params.signal?.reason ?? Object.assign(new Error("This operation was aborted"), { name: "AbortError", code: "ABORT_ERR" });
34935
34996
  if (params.signal?.aborted) return Promise.reject(abortReason());
34936
34997
  const onAbort = () => {
34937
- if (pendingReject) {
34938
- const reject = pendingReject;
34939
- pendingReject = void 0;
34998
+ const reject = pendingReject;
34999
+ pendingReject = void 0;
35000
+ if (reject && !firstDone) {
34940
35001
  socket?.destroy();
34941
35002
  stream.destroy();
34942
35003
  reject(abortReason());
34943
35004
  return;
34944
35005
  }
35006
+ reject?.(abortReason());
34945
35007
  stream.destroy(abortReason());
34946
35008
  };
34947
35009
  params.signal?.addEventListener?.("abort", onAbort, { once: true });
34948
35010
  const dial = (first) => new Promise((resolve17, reject) => {
34949
- if (first) pendingReject = reject;
35011
+ pendingReject = reject;
34950
35012
  reply = Buffer.alloc(0);
34951
35013
  ready = false;
35014
+ waitFor200 = !first;
34952
35015
  dials += 1;
34953
35016
  socket = net.connect(proxyPort, proxyHost);
34954
35017
  socket.setNoDelay(true);
@@ -34956,10 +35019,10 @@ ${Object.entries(params.headers ?? {}).filter(([name, value]) => value !== void
34956
35019
  socket.once("connect", () => {
34957
35020
  connected = true;
34958
35021
  socket.write(head);
34959
- for (const chunk of sent) socket.write(chunk);
34960
- ready = true;
34961
- mark("tunnel-sent", `dial${dials}`);
34962
- if (first) pendingReject = void 0;
35022
+ if (!waitFor200) flushing = flushKept(socket);
35023
+ mark("tunnel-sent", waitFor200 ? `dial${dials}_wait` : `dial${dials}`);
35024
+ pendingReject = void 0;
35025
+ if (first) firstDone = true;
34963
35026
  resolve17();
34964
35027
  });
34965
35028
  socket.on("data", (chunk) => {
@@ -34978,20 +35041,24 @@ ${Object.entries(params.headers ?? {}).filter(([name, value]) => value !== void
34978
35041
  }
34979
35042
  mark("tunnel-200", `ms${Date.now() - startedAt}_dial${dials}`);
34980
35043
  open2 = true;
34981
- sent.length = 0;
34982
35044
  closedInRow.delete(target);
34983
35045
  const rest = reply.subarray(end + 4);
34984
35046
  reply = Buffer.alloc(0);
34985
35047
  if (rest.length && !stream.push(rest)) socket.pause();
35048
+ const to = socket;
35049
+ (waitFor200 ? flushKept(to) : flushing).then(() => {
35050
+ if (to === socket) {
35051
+ sent.length = 0;
35052
+ keptBytes = 0;
35053
+ }
35054
+ });
34986
35055
  });
34987
35056
  socket.on("error", (error) => {
34988
35057
  if (!connected) {
34989
- if (first) {
34990
- if (pendingReject) {
34991
- pendingReject = void 0;
34992
- reject(error);
34993
- }
34994
- } else stream.destroy(error);
35058
+ if (pendingReject === reject) {
35059
+ pendingReject = void 0;
35060
+ reject(error);
35061
+ }
34995
35062
  return;
34996
35063
  }
34997
35064
  if (open2) stream.destroy(error);
@@ -35004,6 +35071,14 @@ ${Object.entries(params.headers ?? {}).filter(([name, value]) => value !== void
35004
35071
  }
35005
35072
  const closed2 = (closedInRow.get(target) ?? 0) + 1;
35006
35073
  mark("tunnel-closed", `n${closed2}`);
35074
+ if (tooBigToReplay) {
35075
+ closedInRow.delete(target);
35076
+ stream.destroy(Object.assign(
35077
+ new Error(`the local Tor tunnel closed with no answer after more than ${REPLAY_LIMIT} bytes were sent, so it is not tried again`),
35078
+ { code: "ERR_TUNNEL_REPLAY_TOO_LARGE" }
35079
+ ));
35080
+ return;
35081
+ }
35007
35082
  if (closed2 < TUNNEL_CLOSED_TRIES) {
35008
35083
  closedInRow.set(target, closed2);
35009
35084
  dial(false).catch((error) => stream.destroy(error));
@@ -35022,7 +35097,7 @@ ${Object.entries(params.headers ?? {}).filter(([name, value]) => value !== void
35022
35097
  throw error;
35023
35098
  });
35024
35099
  }
35025
- var RUN_MARK, TUNNEL_CLOSED_TRIES;
35100
+ var RUN_MARK, TUNNEL_CLOSED_TRIES, REPLAY_LIMIT;
35026
35101
  var init_tunnelGuard = __esm({
35027
35102
  "wallet/src/net/tunnelGuard.mjs"() {
35028
35103
  "use strict";
@@ -35030,6 +35105,7 @@ var init_tunnelGuard = __esm({
35030
35105
  init_phaseTiming();
35031
35106
  RUN_MARK = "SHINJUKU_WALLET_PROXIED";
35032
35107
  TUNNEL_CLOSED_TRIES = 3;
35108
+ REPLAY_LIMIT = 8 * 1024;
35033
35109
  }
35034
35110
  });
35035
35111
 
@@ -38939,6 +39015,7 @@ var init_errorCodes = __esm({
38939
39015
  "received_payment_gone",
38940
39016
  "received_payment_too_small",
38941
39017
  "recipient_unread",
39018
+ "recipient_refused",
38942
39019
  "unshield_all_needs_several_sends",
38943
39020
  "recipient_encoding",
38944
39021
  "recipient_eta",
@@ -39211,6 +39288,12 @@ var init_errorCodes = __esm({
39211
39288
  "rpc_relay_limit",
39212
39289
  // The unified CLI's name for a call that got no answer (no code along the chain; shinjukuWallet.mjs failureReason).
39213
39290
  "rpc_unreachable",
39291
+ // An RPC that answered with a refusal the same request is unlikely to pass (net/rpcRefusal.mjs rpcRefusalCode): the
39292
+ // unified CLI (failureReason), and p03_deposit_ / p03_pocket_payment_ of the balance reads. A proven kind: the RPC
39293
+ // accepts only listed IP addresses, or it refused the key.
39294
+ "rpc_refused",
39295
+ "rpc_refused_ip_allowlist",
39296
+ "rpc_refused_key",
39214
39297
  // The unified CLI's name for a call whose answer failed its TLS (certificate) check (shinjukuWallet.mjs failureReason).
39215
39298
  "server_tls_failed",
39216
39299
  "wallet_join_failed",
@@ -39714,6 +39797,7 @@ var init_errorCodes = __esm({
39714
39797
  "mcp_unshield_to_not_allowed",
39715
39798
  "mcp_unshield_to_invalid",
39716
39799
  "mcp_unshield_recipient_unread",
39800
+ "mcp_unshield_recipient_refused",
39717
39801
  "mcp_unshield_send_open",
39718
39802
  "mcp_shield_cap_exceeded",
39719
39803
  "mcp_shield_above_balance_cap",
@@ -48550,6 +48634,92 @@ var init_anchorClock = __esm({
48550
48634
  }
48551
48635
  });
48552
48636
 
48637
+ // wallet/src/net/rpcRefusal.mjs
48638
+ function jsonRpcError(body) {
48639
+ try {
48640
+ const error = JSON.parse(body)?.error;
48641
+ if (error && typeof error === "object") return { code: Number.isSafeInteger(error.code) ? error.code : void 0, text: String(error.message ?? "") };
48642
+ if (typeof error === "string") return { text: error };
48643
+ } catch {
48644
+ }
48645
+ return void 0;
48646
+ }
48647
+ function kindOf(body, status) {
48648
+ const refusalStatus = status === 401 || status === 403;
48649
+ if (!refusalStatus && status !== void 0) return void 0;
48650
+ if (PASSING_TEXT.test(body)) return void 0;
48651
+ if (ALLOWLIST_TEXT.test(body)) return "ip_allowlist";
48652
+ if (KEY_TEXT.test(body) || refusalStatus && AUTH_TEXT.test(body)) return "key";
48653
+ return void 0;
48654
+ }
48655
+ function verdict({ status, code, body }) {
48656
+ const kind = kindOf(String(body ?? ""), status);
48657
+ const lasting = kind !== void 0;
48658
+ const refusing4xx = status !== void 0 && status >= 400 && status <= 499 && !PASSING_4XX.has(status);
48659
+ const requestError = JSON_RPC_REQUEST_ERRORS.has(code) && (status === void 0 || refusing4xx);
48660
+ const unlikely = lasting || refusing4xx || requestError;
48661
+ return {
48662
+ ...status !== void 0 ? { status } : {},
48663
+ ...code !== void 0 ? { code } : {},
48664
+ ...lasting ? { kind } : {},
48665
+ lasting,
48666
+ unlikely
48667
+ };
48668
+ }
48669
+ function rpcRefusalOf(error) {
48670
+ for (let item = error, depth = 0; item && depth < 6; item = item.cause, depth += 1) {
48671
+ const message = String(item?.message ?? "");
48672
+ const http3 = HTTP_ANSWER.exec(message);
48673
+ if (http3) {
48674
+ const status = Number(http3[1]);
48675
+ if (status >= 400 && status <= 599) {
48676
+ const inner = jsonRpcError(http3[3]);
48677
+ return verdict({ status, code: inner?.code, body: inner?.text ?? http3[3] });
48678
+ }
48679
+ }
48680
+ if (item?.name === "SolanaJSONRPCError" && Number.isSafeInteger(item.code)) return verdict({ code: item.code, body: message });
48681
+ const wrapped = /SolanaJSONRPCError: ([^\n]*)$/.exec(message);
48682
+ if (wrapped) {
48683
+ const code = REQUEST_ERROR_TEXT.test(wrapped[1]) ? /method not found/i.test(wrapped[1]) ? -32601 : /invalid request/i.test(wrapped[1]) ? -32600 : -32602 : void 0;
48684
+ return verdict({ code, body: wrapped[1] });
48685
+ }
48686
+ }
48687
+ return void 0;
48688
+ }
48689
+ function rpcAnswerWords(refusal) {
48690
+ const http3 = refusal.status !== void 0 ? `HTTP ${refusal.status}` : void 0;
48691
+ const rpc = refusal.code !== void 0 ? `JSON-RPC error ${refusal.code}` : void 0;
48692
+ if (http3 && rpc) return `${http3} (${rpc})`;
48693
+ return http3 ?? rpc ?? "an error";
48694
+ }
48695
+ function rpcRefusalWords(refusal) {
48696
+ const answered = `the RPC answered ${rpcAnswerWords(refusal)}`;
48697
+ if (refusal.lasting) return `${answered}: ${KIND_WORDS[refusal.kind]}`;
48698
+ return refusal.unlikely ? `${answered}; a retry is unlikely to pass` : answered;
48699
+ }
48700
+ function rpcRefusalCode(refusal) {
48701
+ return refusal.lasting ? `rpc_refused_${refusal.kind}` : "rpc_refused";
48702
+ }
48703
+ var JSON_RPC_REQUEST_ERRORS, PASSING_4XX, HTTP_ANSWER, REQUEST_ERROR_TEXT, PASSING_TEXT, ALLOWLIST_TEXT, KEY_TEXT, AUTH_TEXT, KIND_WORDS, RPC_REFUSAL_HINT;
48704
+ var init_rpcRefusal = __esm({
48705
+ "wallet/src/net/rpcRefusal.mjs"() {
48706
+ "use strict";
48707
+ JSON_RPC_REQUEST_ERRORS = /* @__PURE__ */ new Set([-32600, -32601, -32602]);
48708
+ PASSING_4XX = /* @__PURE__ */ new Set([408, 425, 429]);
48709
+ HTTP_ANSWER = /(?:^|:\s)(?:Error:\s)?(\d{3}) ([^:{}\n]{0,60}): ?(\{[\s\S]*\}|[^\n]*)\s*$/;
48710
+ REQUEST_ERROR_TEXT = /\b(?:invalid request|method not found|invalid params?)\b/i;
48711
+ PASSING_TEXT = /temporar|unavailable|try again|\bretry|\blater\b|time ?out|timed out|overload|maintenance|\bbusy\b|rate.?limit/i;
48712
+ ALLOWLIST_TEXT = /\b(?:white|allow)-?list(?:ed)?\b|\bip\b[^.\n]{0,60}\bnot allowed\b|\bnot allowed\b[^.\n]{0,60}\bip\b/i;
48713
+ KEY_TEXT = /\binvalid api[ -]?key\b|\b(?:missing|revoked|expired|disabled) api[ -]?key\b|\bapi[ -]?key\b[^.\n]{0,20}\b(?:invalid|not valid|missing|required|revoked|disabled|expired|not found)\b/i;
48714
+ AUTH_TEXT = /\bunauthori[sz]ed\b|\bmust be authenticated\b|\bauthentication (?:failed|required)\b/i;
48715
+ KIND_WORDS = {
48716
+ ip_allowlist: "this RPC accepts only listed IP addresses, so the same command cannot pass from an address it does not list",
48717
+ key: "this RPC refused the key, so the same command cannot pass with this key"
48718
+ };
48719
+ RPC_REFUSAL_HINT = "Some RPC providers refuse Tor or accept only listed IP addresses; use an RPC that accepts this connection";
48720
+ }
48721
+ });
48722
+
48553
48723
  // wallet/src/chain.mjs
48554
48724
  import { createHash as createHash9, createPublicKey, randomInt, randomUUID as randomUUID2, verify as verifySignature } from "node:crypto";
48555
48725
  function poolLayoutForLength(length) {
@@ -49141,7 +49311,7 @@ async function retryRpc2(operation, { attempts = 5, baseDelayMs = 500 } = {}) {
49141
49311
  return await operation();
49142
49312
  } catch (error) {
49143
49313
  lastError = error;
49144
- if (proxyRefusedConnection(error) || isRelayLimitError(error) || runEnded()) break;
49314
+ if (proxyRefusedConnection(error) || isRelayLimitError(error) || rpcRefusalOf(error)?.unlikely || runEnded()) break;
49145
49315
  if (attempt + 1 < attempts) {
49146
49316
  await runSleep(baseDelayMs * 2 ** attempt);
49147
49317
  }
@@ -49608,6 +49778,7 @@ var init_chain2 = __esm({
49608
49778
  init_rpcDefault();
49609
49779
  init_runEnd();
49610
49780
  init_relayLimit();
49781
+ init_rpcRefusal();
49611
49782
  POOL_STATE_LEN2 = 312;
49612
49783
  POOL_STATE_LEN_RING2 = 1664;
49613
49784
  POOL_STATE_LEN_RING_642 = 3904;
@@ -57855,7 +58026,9 @@ async function tokenAccount(connection, address2, commitment = "finalized") {
57855
58026
  });
57856
58027
  } catch (error) {
57857
58028
  if (isRelayLimitError(error)) throw error;
57858
- fail13("token_balance_unreadable");
58029
+ const refusal = rpcRefusalOf(error);
58030
+ if (refusal?.unlikely) fail13(`${rpcRefusalCode(refusal)}: the USDC balance read failed: ${rpcRefusalWords(refusal)}. ${RPC_REFUSAL_HINT}`);
58031
+ fail13(refusal ? `token_balance_unreadable: ${rpcRefusalWords(refusal)}` : "token_balance_unreadable");
57859
58032
  }
57860
58033
  }
57861
58034
  async function tokenAmount(connection, address2, commitment = "finalized") {
@@ -59624,6 +59797,7 @@ var init_deposit = __esm({
59624
59797
  init_serviceUrl();
59625
59798
  init_proxy();
59626
59799
  init_relayLimit();
59800
+ init_rpcRefusal();
59627
59801
  init_approveInBuffer();
59628
59802
  init_processLease();
59629
59803
  init_witness();
@@ -60952,7 +61126,7 @@ var init_errorLine = __esm({
60952
61126
  "wallet/src/errorLine.mjs"() {
60953
61127
  "use strict";
60954
61128
  init_errorCodes();
60955
- SELF_TEACHING_CODES = /^(wallet_backup_out_[a-z_]+|wallet_recovery_file_[a-z_]+|wallet_passphrase_too_short|init_flags_required|restore_flags_required|recover_proof_tools_required|recipient_owner_(required|invalid)|broadcaster_key_file_(invalid|unreadable)|p03_agent_(deposit|unshield)_not_pool_denomination|exit_note_not_pool_denomination|inference_(tor_required|ceiling_over_cap|model_unknown|max_tokens_required|messages_invalid|stream_unsupported|temperature_invalid|max_payment_invalid|upstream_failed|response_invalid)|rpc_relay_limit)$/;
61129
+ SELF_TEACHING_CODES = /^(wallet_backup_out_[a-z_]+|wallet_recovery_file_[a-z_]+|wallet_passphrase_too_short|init_flags_required|restore_flags_required|recover_proof_tools_required|recipient_owner_(required|invalid)|broadcaster_key_file_(invalid|unreadable)|p03_agent_(deposit|unshield)_not_pool_denomination|exit_note_not_pool_denomination|inference_(tor_required|ceiling_over_cap|model_unknown|max_tokens_required|messages_invalid|stream_unsupported|temperature_invalid|max_payment_invalid|upstream_failed|response_invalid)|rpc_relay_limit|p03_deposit_(?:token_balance_unreadable|rpc_refused(?:_ip_allowlist|_key)?)|p03_pocket_payment_(?:pocket_balance_unreadable|rpc_refused(?:_ip_allowlist|_key)?))$/;
60956
61130
  redact = (text2) => String(text2).replace(/[a-z][a-z0-9+.-]*:\/\/\S+/gi, "<url>").replace(/(api[-_]?key|token|secret|password|auth)=\S+/gi, "$1=<redacted>").replace(/0x[0-9a-f]{16,}/gi, "<hex>").replace(/\b\d{20,}\b/g, "<number>").replace(/[A-Za-z0-9+/=_-]{40,}/g, (token) => /^p03_[a-z0-9_]+$/.test(token) ? token : "<blob>").replace(/\s+/g, " ").trim();
60957
61131
  SYSTEM_CODE = /^E[A-Z0-9_]{1,40}$/;
60958
61132
  SELLER_REFUSED = "seller_refused";
@@ -67165,7 +67339,7 @@ function proveFromProfile({ binding, profileDir }) {
67165
67339
  [proved.payment, PROVER_BINARIES.payment, proved.paymentArtifactPath],
67166
67340
  ...proved.append ? [[proved.append, PROVER_BINARIES.treeAppend, proved.appendArtifactPath]] : []
67167
67341
  ]) {
67168
- const verdict = verifyPayload({
67342
+ const verdict2 = verifyPayload({
67169
67343
  modelDir: MODEL_DIR2,
67170
67344
  binary,
67171
67345
  proofBytesHex: artifact.proofBytesHex,
@@ -67176,7 +67350,7 @@ function proveFromProfile({ binding, profileDir }) {
67176
67350
  // when proving under the production parameter bundle.
67177
67351
  verifierArtifactPath
67178
67352
  });
67179
- if (!verdict.verified) throw new Error(`generated proof failed verification: ${binary}`);
67353
+ if (!verdict2.verified) throw new Error(`generated proof failed verification: ${binary}`);
67180
67354
  }
67181
67355
  return { ...proved, memoBundleHex: vector.memo.bundleHex };
67182
67356
  }