shinjuku-shield 0.3.147 → 0.3.149
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 +6 -6
- package/manifest.json +4 -4
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +234 -44
package/README.md
CHANGED
|
@@ -6,19 +6,19 @@ 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.
|
|
9
|
+
This is version 0.3.149. The npm packages `shinjuku-shield` and
|
|
10
10
|
`shinjuku-shielded` hold the same files. The command is `shinjuku`.
|
|
11
11
|
|
|
12
12
|
## Set up
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
|
-
npm install -g shinjuku@0.3.
|
|
15
|
+
npm install -g shinjuku@0.3.149
|
|
16
16
|
shinjuku setup
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Type the two lines as they are. `npx install shinjuku` does not work: npx
|
|
20
20
|
reads `install` as the name of another npm package. To set up without
|
|
21
|
-
installing, type `npx shinjuku@0.3.
|
|
21
|
+
installing, type `npx shinjuku@0.3.149 setup`.
|
|
22
22
|
|
|
23
23
|
Setup makes the wallet on this machine, a private passphrase file, and the
|
|
24
24
|
checked proof tools (about 191 MB), and writes `config.json`. It also writes
|
|
@@ -36,13 +36,13 @@ Every wallet command works after `shinjuku`, for example `shinjuku balance`,
|
|
|
36
36
|
Claude Code:
|
|
37
37
|
|
|
38
38
|
```sh
|
|
39
|
-
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.
|
|
39
|
+
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.149 mcp
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
Claude Desktop (`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
|
|
43
43
|
|
|
44
44
|
```json
|
|
45
|
-
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.
|
|
45
|
+
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.149", "mcp"] } } }
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
On native Windows, if the host cannot find `npx`, use `"command": "cmd"` and
|
|
@@ -55,7 +55,7 @@ Codex (the Codex app and Codex CLI read the same file, `~/.codex/config.toml`):
|
|
|
55
55
|
```toml
|
|
56
56
|
[mcp_servers.shinjuku]
|
|
57
57
|
command = "npx"
|
|
58
|
-
args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.
|
|
58
|
+
args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.149", "mcp"]
|
|
59
59
|
startup_timeout_sec = 120
|
|
60
60
|
tool_timeout_sec = 300
|
|
61
61
|
```
|
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": "fe9d8f3d2b651457cd793f78e205b8b21398eb2b77fb5174c2181dfa996b6b51",
|
|
5
|
+
"bytes": 8996422,
|
|
6
|
+
"sourceCommit": "ed2ee2fdc74fe51cb346ea784641c19f3ad80ef7",
|
|
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",
|
|
@@ -1038,5 +1038,5 @@
|
|
|
1038
1038
|
"version": "1.8.0"
|
|
1039
1039
|
}
|
|
1040
1040
|
],
|
|
1041
|
-
"publishedAt": "2026-11-
|
|
1041
|
+
"publishedAt": "2026-11-01T17:50:11.140Z"
|
|
1042
1042
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shield",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.149",
|
|
4
4
|
"mcpName": "io.github.ShinjukuStaition/shinjuku-mcp",
|
|
5
5
|
"description": "Shinjuku Shielded, the private x402 facilitator 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": "fe9d8f3d",
|
|
7
|
+
"shinjukuSha256": "fe9d8f3d2b651457cd793f78e205b8b21398eb2b77fb5174c2181dfa996b6b51",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shielded",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -61891,18 +61891,15 @@ function usdcWords(atomic4) {
|
|
|
61891
61891
|
const fraction = padded.slice(-6).replace(/0+$/, "");
|
|
61892
61892
|
return `${fraction ? `${whole}.${fraction}` : whole} USDC`;
|
|
61893
61893
|
}
|
|
61894
|
-
function spendNowForms(spendableAtomic, largestAtomic, { surface
|
|
61894
|
+
function spendNowForms(spendableAtomic, largestAtomic, { surface } = {}) {
|
|
61895
61895
|
const spendable = String(spendableAtomic ?? "");
|
|
61896
61896
|
if (!ATOMIC.test(spendable)) return [];
|
|
61897
61897
|
const largest = String(largestAtomic ?? "");
|
|
61898
61898
|
const total = usdcWords(spendable);
|
|
61899
61899
|
if (BigInt(spendable) === 0n || ATOMIC.test(largest) && BigInt(largest) >= BigInt(spendable)) return [`${total} now`];
|
|
61900
61900
|
if (!ATOMIC.test(largest)) return [`${total} in total now`];
|
|
61901
|
-
const
|
|
61902
|
-
return [
|
|
61903
|
-
`${total} (a payment above ${usdcWords(largest)} ${step})`,
|
|
61904
|
-
`${total}, up to ${usdcWords(largest)} in one payment now`
|
|
61905
|
-
];
|
|
61901
|
+
const limit = `${total}, up to ${usdcWords(largest)} in one payment now`;
|
|
61902
|
+
return surface === "cli" ? [limit] : [`${total} (a payment above ${usdcWords(largest)} first gets the balance ready)`, limit];
|
|
61906
61903
|
}
|
|
61907
61904
|
function spendHeads(spendableAtomic, largestAtomic, change = {}, options = {}) {
|
|
61908
61905
|
const spendable = String(spendableAtomic ?? "");
|
|
@@ -66862,6 +66859,8 @@ var init_errorCodes = __esm({
|
|
|
66862
66859
|
"inference_out_of_tokens",
|
|
66863
66860
|
// wallet_unshield of a balance in several accounts: the stage code while the automatic join runs (mcp/tools.mjs joiningStage).
|
|
66864
66861
|
"unshield_joining_accounts",
|
|
66862
|
+
// unshield of a fixed amount in a terminal: its own join (joinForFixedSend, AB186) did not get the balance ready.
|
|
66863
|
+
"unshield_balance_not_ready",
|
|
66865
66864
|
"inference_response_invalid",
|
|
66866
66865
|
"inference_route_unknown",
|
|
66867
66866
|
"inference_serve_unauthorized",
|
|
@@ -69226,6 +69225,8 @@ var init_errorCodes = __esm({
|
|
|
69226
69225
|
// The no-flag terminal (0.3.97, shinjukuWallet.mjs): a terminal question that ended with no change, or a no to a money move.
|
|
69227
69226
|
"add_funds_no_amount",
|
|
69228
69227
|
"curl_payment_declined",
|
|
69228
|
+
// curl in a terminal: its own join (joinForCurlPayment, AB185) did not get the balance ready.
|
|
69229
|
+
"curl_balance_not_ready",
|
|
69229
69230
|
// curl in a terminal: a price the user's own limits cannot let pass, refused before the question (runCurl).
|
|
69230
69231
|
"curl_over_your_limits",
|
|
69231
69232
|
"limits_not_changed",
|
|
@@ -111812,7 +111813,8 @@ async function installProofTools({
|
|
|
111812
111813
|
for (const entry of entries) {
|
|
111813
111814
|
try {
|
|
111814
111815
|
const old = localPath(partial, entry.path);
|
|
111815
|
-
|
|
111816
|
+
const info = lstatSync(old);
|
|
111817
|
+
if (!info.isFile() || info.size > LIMITS.file) continue;
|
|
111816
111818
|
const bytes2 = readFileSync(old);
|
|
111817
111819
|
if (sha2569(bytes2) === entry.sha256) kept2.push({ entry, bytes: bytes2 });
|
|
111818
111820
|
} catch {
|
|
@@ -111891,6 +111893,9 @@ async function installProofTools({
|
|
|
111891
111893
|
}
|
|
111892
111894
|
};
|
|
111893
111895
|
for (const { entry, bytes: bytes2 } of kept2) {
|
|
111896
|
+
if (bytes2.length > budget.left) {
|
|
111897
|
+
throw fail27("setup_download_too_large", `the setup files are larger than ${LIMITS.total} bytes (the most setup accepts), so they were not kept`);
|
|
111898
|
+
}
|
|
111894
111899
|
write(entry, bytes2);
|
|
111895
111900
|
budget.left -= bytes2.length;
|
|
111896
111901
|
}
|
|
@@ -113019,10 +113024,9 @@ function openPaymentWords(parts) {
|
|
|
113019
113024
|
const rerun = one?.requestId ? `run the same command again with --request-id ${one.requestId}` : "run the same command again with its --request-id";
|
|
113020
113025
|
return `To finish ${which}, ${rerun} (it never pays twice); if the seller never takes it, Shinjuku sends it back to your private balance by itself within about ${Math.round(FLOAT_REFUND_ETA_SECONDS / 60)} minutes.`;
|
|
113021
113026
|
}
|
|
113022
|
-
function balanceWords(parts
|
|
113023
|
-
const
|
|
113024
|
-
const
|
|
113025
|
-
const spend = afterSend ? heads.find((head) => !head.includes(prepareCommand)) ?? heads[0] : heads[0];
|
|
113027
|
+
function balanceWords(parts) {
|
|
113028
|
+
const heads = parts && parts.spendableAtomic !== null ? spendHeads(parts.spendableAtomic, parts.largestPaymentAtomic, parts, { surface: "cli" }) : [];
|
|
113029
|
+
const spend = heads[0];
|
|
113026
113030
|
if (spend === void 0) return void 0;
|
|
113027
113031
|
const positive2 = (atomic4) => POSITIVE2.test(String(atomic4 ?? ""));
|
|
113028
113032
|
const notes = [
|
|
@@ -113039,7 +113043,6 @@ var init_balanceNow = __esm({
|
|
|
113039
113043
|
init_book();
|
|
113040
113044
|
init_store();
|
|
113041
113045
|
init_usdcWords();
|
|
113042
|
-
init_commandName();
|
|
113043
113046
|
init_floatPay();
|
|
113044
113047
|
init_prepareRecoveredPayment();
|
|
113045
113048
|
init_balance();
|
|
@@ -151803,6 +151806,10 @@ var NOT_SET_UP_CODE = "wallet_not_set_up";
|
|
|
151803
151806
|
var EMPTY_BALANCE_CODE = "no_spendable_account";
|
|
151804
151807
|
var OVER_LIMITS_CODE = "curl_over_your_limits";
|
|
151805
151808
|
var CEILING_OVER_CAP_CODE = "inference_ceiling_over_cap";
|
|
151809
|
+
var BALANCE_NOT_READY_CODE = "curl_balance_not_ready";
|
|
151810
|
+
var SEND_NOT_READY_CODE = "unshield_balance_not_ready";
|
|
151811
|
+
var SPLIT_CODE = "p03_merchant_respend_accounts_split_merge_first";
|
|
151812
|
+
var JOIN_SKIPPED = /* @__PURE__ */ Symbol("join skipped");
|
|
151806
151813
|
var flag2 = (name, value2, about, options = {}) => ({ name, value: value2, about, ...options });
|
|
151807
151814
|
var bool2 = (name, about, options = {}) => ({ name, boolean: true, about, ...options });
|
|
151808
151815
|
var RPC_DEFAULT_TEXT = `default: Shinjuku's relay <server>${FACILITATOR_RPC_PATH} (the server this command names, else ${GUIDE.facilitator}), which sees which addresses this wallet reads; your own RPC wins and keeps those reads away from Shinjuku`;
|
|
@@ -152278,14 +152285,26 @@ async function runCurlPaid(values, deps, { requestId: probeId } = {}) {
|
|
|
152278
152285
|
io.err(`request-id ${requestId}${given ? "" : ` (if this run stops, rerun with --request-id ${requestId}: it never pays twice)`}
|
|
152279
152286
|
`);
|
|
152280
152287
|
await poolSwitchGate({ session, amountAtomic: values.get("--max-payment"), again: ` with --request-id ${requestId}`, deps, io });
|
|
152281
|
-
|
|
152282
|
-
|
|
152283
|
-
|
|
152284
|
-
|
|
152285
|
-
|
|
152288
|
+
for (let joined = false; ; ) {
|
|
152289
|
+
try {
|
|
152290
|
+
response = await (deps.payAndFetch ?? payAndFetch)(session, values.get("--url"), { method, headers, ...body === void 0 ? {} : { body } }, { requestId });
|
|
152291
|
+
break;
|
|
152292
|
+
} catch (error) {
|
|
152293
|
+
if (/^inference_tor_required: /.test(error instanceof Error ? error.message : "")) {
|
|
152294
|
+
throw new PublicFailure(`${error.message}
|
|
152286
152295
|
${CURL_USEPOD_NEXT}`, { cause: error });
|
|
152296
|
+
}
|
|
152297
|
+
if (!joined && localErrorCodes(error).includes(SPLIT_CODE)) {
|
|
152298
|
+
joined = true;
|
|
152299
|
+
const outcome = await joinForCurlPayment(session, values, deps, io, requestId);
|
|
152300
|
+
if (outcome === true) continue;
|
|
152301
|
+
if (outcome === "stale") {
|
|
152302
|
+
throw new PublicFailure(`${BALANCE_NOT_READY_CODE}: your private balance covers this payment in total, but the wallet's saved balance is not up to date, so it could not get the balance ready for one payment. Nothing was signed or paid. Run ${cli4()} balance --refresh, then the same command again: it never pays twice`);
|
|
152303
|
+
}
|
|
152304
|
+
if (outcome === "files") values.set(JOIN_SKIPPED, true);
|
|
152305
|
+
}
|
|
152306
|
+
throw curlFailure(error);
|
|
152287
152307
|
}
|
|
152288
|
-
throw curlFailure(error);
|
|
152289
152308
|
}
|
|
152290
152309
|
sessionMark(session)("curl-paid-returned");
|
|
152291
152310
|
return await curlOutput(response, values, deps, requestId);
|
|
@@ -155151,7 +155170,7 @@ var COMMANDS = [
|
|
|
155151
155170
|
"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).",
|
|
155152
155171
|
"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).",
|
|
155153
155172
|
"shinjukuShielded is null when the last walk is missing, stale, or incomplete. reasons says why; next shows the command to run.",
|
|
155154
|
-
`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
|
|
155173
|
+
`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).`,
|
|
155155
155174
|
"Payments that others send to this wallet appear only after a refresh.",
|
|
155156
155175
|
"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.",
|
|
155157
155176
|
"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."
|
|
@@ -156814,10 +156833,30 @@ async function runUnshieldRequest(args, values, deps, io) {
|
|
|
156814
156833
|
io.out(terminal ? unshieldDoneText(result, owner.toBase58()) : `${JSON.stringify(result)}
|
|
156815
156834
|
`);
|
|
156816
156835
|
};
|
|
156817
|
-
|
|
156818
|
-
|
|
156819
|
-
|
|
156820
|
-
|
|
156836
|
+
let returned;
|
|
156837
|
+
for (let joined = false; ; ) {
|
|
156838
|
+
try {
|
|
156839
|
+
returned = await deps.unshieldMain(gated, { output: (result) => {
|
|
156840
|
+
answer = result;
|
|
156841
|
+
show(result);
|
|
156842
|
+
}, directExit });
|
|
156843
|
+
break;
|
|
156844
|
+
} catch (error) {
|
|
156845
|
+
if (joined || shown || recorded?.inParts === true || !(localErrorCodes(error).includes(SPLIT_CODE) || String(error?.message ?? "").includes(SPLIT_CODE))) {
|
|
156846
|
+
if (recorded?.inParts === true) values.set(JOIN_SKIPPED, true);
|
|
156847
|
+
throw error;
|
|
156848
|
+
}
|
|
156849
|
+
joined = true;
|
|
156850
|
+
const sendWallet = gated.includes("--wallet") ? gated[gated.indexOf("--wallet") + 1] : values.get("--wallet");
|
|
156851
|
+
const outcome = await joinForFixedSend(new Map([...values, ["--wallet", sendWallet]]), deps, io);
|
|
156852
|
+
if (outcome === true) continue;
|
|
156853
|
+
if (outcome === "stale") {
|
|
156854
|
+
throw new PublicFailure(`${SEND_NOT_READY_CODE}: your private balance covers this send in total, but the wallet's saved balance is not up to date, so it could not get the balance ready for one send. Nothing was signed or sent. Run ${cli4()} balance --refresh, then the same command again with --unshield-id ${id}: it never sends twice`);
|
|
156855
|
+
}
|
|
156856
|
+
if (outcome === "files") values.set(JOIN_SKIPPED, true);
|
|
156857
|
+
throw error;
|
|
156858
|
+
}
|
|
156859
|
+
}
|
|
156821
156860
|
answer ??= returned;
|
|
156822
156861
|
if (!answer || typeof answer !== "object") return;
|
|
156823
156862
|
show(answer);
|
|
@@ -156838,7 +156877,7 @@ async function runUnshieldRequest(args, values, deps, io) {
|
|
|
156838
156877
|
} catch {
|
|
156839
156878
|
parts = void 0;
|
|
156840
156879
|
}
|
|
156841
|
-
io.out(`${[privateBalanceLine(parts
|
|
156880
|
+
io.out(`${[privateBalanceLine(parts), ...unfinished.map(unfinishedUnshieldLine)].join("\n")}
|
|
156842
156881
|
`);
|
|
156843
156882
|
} finally {
|
|
156844
156883
|
stopWatch();
|
|
@@ -156982,8 +157021,8 @@ var STALE_WORDS = Object.freeze({
|
|
|
156982
157021
|
pool_move: "money is moving to Shinjuku's new pool"
|
|
156983
157022
|
});
|
|
156984
157023
|
var balanceNotCurrentWhy = (report) => STALE_WORDS[staleCauseOf(report)] ?? (report?.status === "unknown" ? "this wallet has no balance walk yet" : "a payment, deposit, or send finished after the last balance walk");
|
|
156985
|
-
function privateBalanceLine(parts
|
|
156986
|
-
const words2 = balanceWords(parts
|
|
157024
|
+
function privateBalanceLine(parts) {
|
|
157025
|
+
const words2 = balanceWords(parts);
|
|
156987
157026
|
const report = parts?.report;
|
|
156988
157027
|
if (words2 === void 0) {
|
|
156989
157028
|
const why = report && report.status !== "current" && report.status !== "empty" ? ` (${balanceNotCurrentWhy(report)})` : "";
|
|
@@ -157077,14 +157116,6 @@ async function joinForSendAll(report, parts, store, values, deps, io, ensureId)
|
|
|
157077
157116
|
io.err(`The wallet first gets your private balance${known ? `, ${usdcOr(report.atomic)},` : ""} ready to send (a private step inside this wallet: no fee, nothing leaves it), then sends all of it. It does this here, in rounds, each one final before the next; Ctrl+C stops it, and the same command again goes on where it stopped and never pays or sends twice
|
|
157078
157117
|
`);
|
|
157079
157118
|
ensureId();
|
|
157080
|
-
if (parts.joining === 0) {
|
|
157081
|
-
const waitMs = Math.floor((deps.random ?? Math.random)() * (JOIN_SOON_MAX_MS + 1));
|
|
157082
|
-
io.err(`getting your balance ready starts in ${Math.round(waitMs / 1e3)} s (a random wait, so the chain does not link this step to your request)
|
|
157083
|
-
`);
|
|
157084
|
-
await (deps.sleep ?? ((ms) => new Promise((done) => {
|
|
157085
|
-
setTimeout(done, ms);
|
|
157086
|
-
})))(waitMs);
|
|
157087
|
-
}
|
|
157088
157119
|
const history = values.get("--history-rpc");
|
|
157089
157120
|
const mergeArgs = [
|
|
157090
157121
|
"--wallet",
|
|
@@ -157102,6 +157133,23 @@ async function joinForSendAll(report, parts, store, values, deps, io, ensureId)
|
|
|
157102
157133
|
...values.has("--rpc-file") ? ["--rpc-file", values.get("--rpc-file")] : [],
|
|
157103
157134
|
...history ? ["--history-rpc", history] : []
|
|
157104
157135
|
];
|
|
157136
|
+
return joinRounds(parts, store, values, deps, io, {
|
|
157137
|
+
mergeArgs,
|
|
157138
|
+
stopped: "note: getting your balance ready stopped, so the send did not start; nothing was sent\n",
|
|
157139
|
+
ready: (read, took) => `your balance is ready to send (it took ${took}); sending all ${usdcOr(read.atomic)} now
|
|
157140
|
+
`,
|
|
157141
|
+
failure: ({ remaining, read, keep }) => new PublicFailure("unshield_joining_accounts: the wallet did not finish getting your private balance ready to send" + (remaining > 1 ? "" : read ? " (the balance read after this step is not current yet)" : " (the balance could not be read after this step)") + `; nothing was sent. Send ${keep ? `up to ${usdcOr(keep)} (the amount ready now)` : "a smaller fixed amount"} now, like ${UNSHIELD_EXAMPLE}, or run ${cli4()} unshield --amount all --to <your wallet address> again after the next pool anchor: it goes on getting the balance ready and never pays or sends twice`)
|
|
157142
|
+
});
|
|
157143
|
+
}
|
|
157144
|
+
async function joinRounds(parts, store, values, deps, io, { mergeArgs, stopped, ready, failure: failure2 }) {
|
|
157145
|
+
if (parts.joining === 0) {
|
|
157146
|
+
const waitMs = Math.floor((deps.random ?? Math.random)() * (JOIN_SOON_MAX_MS + 1));
|
|
157147
|
+
io.err(`getting your balance ready starts in ${Math.round(waitMs / 1e3)} s (a random wait, so the chain does not link this step to your request)
|
|
157148
|
+
`);
|
|
157149
|
+
await (deps.sleep ?? ((ms) => new Promise((done) => {
|
|
157150
|
+
setTimeout(done, ms);
|
|
157151
|
+
})))(waitMs);
|
|
157152
|
+
}
|
|
157105
157153
|
const startedAt = deps.now();
|
|
157106
157154
|
let left = parts;
|
|
157107
157155
|
let keep;
|
|
@@ -157113,7 +157161,7 @@ async function joinForSendAll(report, parts, store, values, deps, io, ensureId)
|
|
|
157113
157161
|
answer = result;
|
|
157114
157162
|
} });
|
|
157115
157163
|
} catch (error) {
|
|
157116
|
-
io.err(
|
|
157164
|
+
io.err(stopped);
|
|
157117
157165
|
throw error;
|
|
157118
157166
|
}
|
|
157119
157167
|
const merged = (answer?.merged ?? answer?.resumed ?? []).filter((entry) => entry?.state === "merged").length;
|
|
@@ -157122,16 +157170,145 @@ async function joinForSendAll(report, parts, store, values, deps, io, ensureId)
|
|
|
157122
157170
|
left = joinParts(store);
|
|
157123
157171
|
if (read?.status === "current" && left?.parts <= 1 && left.joining === 0) {
|
|
157124
157172
|
const seconds2 = Math.max(0, Math.round((deps.now() - startedAt) / 1e3));
|
|
157125
|
-
io.err(
|
|
157126
|
-
`);
|
|
157173
|
+
io.err(ready(read, `${Math.floor(seconds2 / 60)} min ${seconds2 % 60} s`));
|
|
157127
157174
|
return read;
|
|
157128
157175
|
}
|
|
157129
157176
|
if (!read || read.status !== "current" || merged === 0) break;
|
|
157130
157177
|
if (round < SEND_ALL_JOIN_ROUNDS) io.err(`getting your balance ready: round ${round} is final; the next round starts now
|
|
157131
157178
|
`);
|
|
157132
157179
|
}
|
|
157133
|
-
|
|
157134
|
-
|
|
157180
|
+
throw failure2({ remaining: left ? left.parts + left.joining : void 0, read, keep });
|
|
157181
|
+
}
|
|
157182
|
+
async function joinForCurlPayment(session, values, deps, io, requestId) {
|
|
157183
|
+
let config;
|
|
157184
|
+
let home;
|
|
157185
|
+
try {
|
|
157186
|
+
home = setupHome(deps.env);
|
|
157187
|
+
config = setupConfigOf(home);
|
|
157188
|
+
} catch {
|
|
157189
|
+
config = void 0;
|
|
157190
|
+
}
|
|
157191
|
+
const proofTools = values.get("--proof-tools");
|
|
157192
|
+
let walletPath2;
|
|
157193
|
+
try {
|
|
157194
|
+
walletPath2 = typeof config?.pool === "string" ? deps.walletPath(config.pool) : void 0;
|
|
157195
|
+
} catch {
|
|
157196
|
+
walletPath2 = void 0;
|
|
157197
|
+
}
|
|
157198
|
+
const passphraseFile = values.get("--passphrase-file") ?? config?.passphraseFile;
|
|
157199
|
+
const same2 = (one, two) => process.platform === "win32" ? resolve37(one).toLowerCase() === resolve37(two).toLowerCase() : resolve37(one) === resolve37(two);
|
|
157200
|
+
if (!config?.profile || !passphraseFile || !proofTools || !values.get("--memo-service") || typeof deps.mergeMain !== "function" || typeof walletPath2 !== "string" || typeof session.walletPath !== "string" || !same2(session.walletPath, walletPath2) || ![passphraseFile, config.profile, proofTools, walletPath2].every((file) => existsSync(resolve37(file)))) return "files";
|
|
157201
|
+
let store;
|
|
157202
|
+
try {
|
|
157203
|
+
store = session.openStore();
|
|
157204
|
+
} catch {
|
|
157205
|
+
return "files";
|
|
157206
|
+
}
|
|
157207
|
+
const parts = joinParts(store);
|
|
157208
|
+
if (!parts || parts.parts <= 1 && parts.joining === 0) return "busy";
|
|
157209
|
+
let report;
|
|
157210
|
+
try {
|
|
157211
|
+
report = computeBalance({ store, snapshotRead: readBalanceSnapshot(store), source: "local", now: deps.now() });
|
|
157212
|
+
} catch {
|
|
157213
|
+
return "stale";
|
|
157214
|
+
}
|
|
157215
|
+
if ((report.detail?.inFlight ?? []).some((item) => item.kind !== "merge")) return "busy";
|
|
157216
|
+
if (parts.joining === 0 && report.status !== "current") return "stale";
|
|
157217
|
+
const service = new URL(values.get("--memo-service")).origin;
|
|
157218
|
+
const joinValues = new Map([
|
|
157219
|
+
...values,
|
|
157220
|
+
["--wallet", walletPath2],
|
|
157221
|
+
["--facilitator", service],
|
|
157222
|
+
["--payer-proof-tools", proofTools],
|
|
157223
|
+
["--passphrase-file", passphraseFile],
|
|
157224
|
+
["--profile", config.profile]
|
|
157225
|
+
]);
|
|
157226
|
+
io.err("Your private balance covers this payment, but not yet in one payment. The wallet first gets it ready (a private step inside this wallet: no fee, nothing leaves it), then pays. Ctrl+C stops it; the same command again with this request-id goes on and never pays twice\n");
|
|
157227
|
+
const history = values.get("--history-rpc");
|
|
157228
|
+
const mergeArgs = [
|
|
157229
|
+
"--wallet",
|
|
157230
|
+
walletPath2,
|
|
157231
|
+
"--passphrase-file",
|
|
157232
|
+
passphraseFile,
|
|
157233
|
+
"--program",
|
|
157234
|
+
values.get("--program"),
|
|
157235
|
+
"--proof-tools",
|
|
157236
|
+
proofTools,
|
|
157237
|
+
"--profile",
|
|
157238
|
+
config.profile,
|
|
157239
|
+
"--facilitator",
|
|
157240
|
+
service,
|
|
157241
|
+
...values.has("--rpc-file") ? ["--rpc-file", values.get("--rpc-file")] : [],
|
|
157242
|
+
...history ? ["--history-rpc", history] : []
|
|
157243
|
+
];
|
|
157244
|
+
await joinRounds(parts, store, joinValues, deps, io, {
|
|
157245
|
+
mergeArgs,
|
|
157246
|
+
stopped: "note: getting your balance ready stopped, so nothing was paid\n",
|
|
157247
|
+
ready: (_read, took) => `your balance is ready (it took ${took}); paying now
|
|
157248
|
+
`,
|
|
157249
|
+
failure: () => new PublicFailure(`${BALANCE_NOT_READY_CODE}: the wallet did not finish getting your private balance ready for this payment, so nothing was paid. Run the same command again in a minute with --request-id ${requestId}: it goes on where it stopped and never pays twice`)
|
|
157250
|
+
});
|
|
157251
|
+
return true;
|
|
157252
|
+
}
|
|
157253
|
+
async function joinForFixedSend(values, deps, io) {
|
|
157254
|
+
const walletFile = values.get("--wallet");
|
|
157255
|
+
const pool2 = typeof walletFile === "string" ? /([1-9A-HJ-NP-Za-km-z]{32,44})[\\/]wallet\.json$/.exec(resolve37(walletFile))?.[1] : void 0;
|
|
157256
|
+
let homeWallet;
|
|
157257
|
+
try {
|
|
157258
|
+
homeWallet = pool2 ? deps.walletPath(pool2) : void 0;
|
|
157259
|
+
} catch {
|
|
157260
|
+
homeWallet = void 0;
|
|
157261
|
+
}
|
|
157262
|
+
if (typeof homeWallet !== "string" || resolve37(homeWallet) !== resolve37(walletFile) || typeof deps.mergeMain !== "function") return "files";
|
|
157263
|
+
const files = ["--passphrase-file", "--profile", "--payer-proof-tools"].map((name) => values.get(name));
|
|
157264
|
+
if (!values.get("--facilitator") || !values.get("--program") || ![...files, walletFile].every((file) => typeof file === "string" && existsSync(resolve37(file)))) return "files";
|
|
157265
|
+
let store;
|
|
157266
|
+
try {
|
|
157267
|
+
store = (deps.openWalletStore ?? openWalletStore)(resolve37(walletFile), payerPassphrase(values, deps));
|
|
157268
|
+
} catch {
|
|
157269
|
+
return "files";
|
|
157270
|
+
}
|
|
157271
|
+
let parts = joinParts(store);
|
|
157272
|
+
let report;
|
|
157273
|
+
try {
|
|
157274
|
+
report = computeBalance({ store, snapshotRead: readBalanceSnapshot(store), source: "local", now: deps.now() });
|
|
157275
|
+
} catch {
|
|
157276
|
+
return "stale";
|
|
157277
|
+
}
|
|
157278
|
+
if (parts && parts.joining === 0 && report.status !== "current") {
|
|
157279
|
+
report = await refreshAfterUnshield(walletFile, values, deps, io) ?? report;
|
|
157280
|
+
if (report.status !== "current") return "stale";
|
|
157281
|
+
parts = joinParts(store);
|
|
157282
|
+
if (parts && parts.parts <= 1 && parts.joining === 0) return true;
|
|
157283
|
+
}
|
|
157284
|
+
if (!parts || parts.parts <= 1 && parts.joining === 0) return "busy";
|
|
157285
|
+
if ((report.detail?.inFlight ?? []).some((item) => item.kind !== "merge")) return "busy";
|
|
157286
|
+
io.err("Your private balance covers this send, but not yet in one payment. The wallet first gets it ready (a private step inside this wallet: no fee, nothing leaves it), then sends. Ctrl+C stops it; nothing is sent before it is ready\n");
|
|
157287
|
+
const history = values.get("--history-rpc");
|
|
157288
|
+
const mergeArgs = [
|
|
157289
|
+
"--wallet",
|
|
157290
|
+
walletFile,
|
|
157291
|
+
"--passphrase-file",
|
|
157292
|
+
values.get("--passphrase-file"),
|
|
157293
|
+
"--program",
|
|
157294
|
+
values.get("--program"),
|
|
157295
|
+
"--proof-tools",
|
|
157296
|
+
values.get("--payer-proof-tools"),
|
|
157297
|
+
"--profile",
|
|
157298
|
+
values.get("--profile"),
|
|
157299
|
+
"--facilitator",
|
|
157300
|
+
new URL(values.get("--facilitator")).origin,
|
|
157301
|
+
...values.has("--rpc-file") ? ["--rpc-file", values.get("--rpc-file")] : [],
|
|
157302
|
+
...history ? ["--history-rpc", history] : []
|
|
157303
|
+
];
|
|
157304
|
+
await joinRounds(parts, store, values, deps, io, {
|
|
157305
|
+
mergeArgs,
|
|
157306
|
+
stopped: "note: getting your balance ready stopped, so nothing was sent\n",
|
|
157307
|
+
ready: (_read, took) => `your balance is ready (it took ${took}); sending now
|
|
157308
|
+
`,
|
|
157309
|
+
failure: () => new PublicFailure(`${SEND_NOT_READY_CODE}: the wallet did not finish getting your private balance ready for this send, so nothing was sent. Run the same command again in a minute with --unshield-id ${values.get("--unshield-id")}: it goes on where it stopped and never sends twice`)
|
|
157310
|
+
});
|
|
157311
|
+
return true;
|
|
157135
157312
|
}
|
|
157136
157313
|
async function runUnshieldCancel(values, deps, io) {
|
|
157137
157314
|
const walletFile = resolve37(values.get("--wallet"));
|
|
@@ -157967,7 +158144,7 @@ async function runBalance(args, values, deps, io) {
|
|
|
157967
158144
|
...Number.isSafeInteger(parts.changeReadyInSeconds) ? { changeReadyInSeconds: parts.changeReadyInSeconds } : {},
|
|
157968
158145
|
.../^[0-9]+$/.test(String(parts.changeUpToAtomic ?? "")) && BigInt(parts.changeUpToAtomic) < BigInt(parts.spendableAtomic) ? { changeUpToAtomic: parts.changeUpToAtomic } : {}
|
|
157969
158146
|
} : {},
|
|
157970
|
-
spend: spendHeads(parts.spendableAtomic, parts.largestPaymentAtomic, parts, { surface: "cli"
|
|
158147
|
+
spend: spendHeads(parts.spendableAtomic, parts.largestPaymentAtomic, parts, { surface: "cli" })[0] ?? null,
|
|
157971
158148
|
refundsInFlightAtomic: parts.refundsInFlightAtomic,
|
|
157972
158149
|
refundsNotCertainAtomic: parts.refundsNotCertainAtomic,
|
|
157973
158150
|
openPaymentsAtomic: parts.openPaymentsAtomic,
|
|
@@ -158118,11 +158295,14 @@ function insufficientCause2(reason, parts) {
|
|
|
158118
158295
|
if (/p03_merchant_respend_accounts_split_merge_first/.test(reason)) return "split";
|
|
158119
158296
|
return parts?.spendableAtomic === "0" && /^[1-9][0-9]*$/.test(String(parts.report?.detail?.reservedAtomic ?? "")) ? "held" : "short";
|
|
158120
158297
|
}
|
|
158121
|
-
function insufficientWords(cause, parts) {
|
|
158298
|
+
function insufficientWords(cause, parts, { selfJoin = false, send: send3 = false } = {}) {
|
|
158122
158299
|
const anchor = "after the next pool anchor";
|
|
158123
158300
|
switch (cause) {
|
|
158124
158301
|
case "split":
|
|
158125
|
-
|
|
158302
|
+
if (selfJoin) {
|
|
158303
|
+
return `your private balance covers this amount in total, but part of it is not ready to spend yet (another payment or send of this wallet, or its change, is not final yet), so it cannot ${send3 ? "send" : "pay"} this in one payment now. Nothing was signed or ${send3 ? "sent" : "paid"}. ${/^[0-9]+$/.test(String(parts?.spendableAtomic ?? "")) ? `You can spend ${usdcOr(parts.spendableAtomic)} in total. ` : ""}Run the same command again in a minute: it gets your balance ready by itself when it needs to, and never ${send3 ? "sends" : "pays"} twice`;
|
|
158304
|
+
}
|
|
158305
|
+
return "your private balance covers this amount in total, but it is not ready to pay in one payment yet. Nothing was signed, and the quote was dropped. " + (balanceWords(parts) ? `${balanceWords(parts)}. ` : "") + `Get it ready first: run ${cli4()} prepare (after setup it needs no flags; ${cli4()} help prepare shows them otherwise; --dry-run shows the plan). It runs one round in this terminal and never pays twice; its answer says whether another round is due. Then rerun this ${send3 ? "send" : "payment"} ${anchor}`;
|
|
158126
158306
|
case "held":
|
|
158127
158307
|
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`;
|
|
158128
158308
|
default: {
|
|
@@ -158467,7 +158647,10 @@ function failureHint(command, reason, deps, values, floatError) {
|
|
|
158467
158647
|
}
|
|
158468
158648
|
if (/p03_merchant_respend_(insufficient_recovered_value|accounts_split_merge_first)/.test(reason)) {
|
|
158469
158649
|
const parts = runBalanceParts(values, deps);
|
|
158470
|
-
return insufficientWords(insufficientCause2(reason, parts), parts
|
|
158650
|
+
return insufficientWords(insufficientCause2(reason, parts), parts, {
|
|
158651
|
+
selfJoin: ["curl", "unshield"].includes(command?.name) && values?.get?.(JOIN_SKIPPED) !== true,
|
|
158652
|
+
send: command?.name === "unshield"
|
|
158653
|
+
});
|
|
158471
158654
|
}
|
|
158472
158655
|
if (/p03_unshield_anchor_settler_underfunded/.test(reason)) {
|
|
158473
158656
|
return "Shinjuku cannot take this step now (its own account for it is low on funds), so nothing was sent. Run the same command again later; it goes on where it stopped";
|
|
@@ -159420,7 +159603,7 @@ This copy: ${walletVersionLine(deps.walletVersion())}
|
|
|
159420
159603
|
const reason = failureReason(command, error, values);
|
|
159421
159604
|
const codes = failureCodes(error, reason);
|
|
159422
159605
|
writeRunResult(deps, command, 1, error, codes);
|
|
159423
|
-
const plainCode = [NOT_SET_UP_CODE, EMPTY_BALANCE_CODE, OVER_LIMITS_CODE, CEILING_OVER_CAP_CODE, CAP_ABOVE_LIMIT_CODE].find((code2) => reason.startsWith(`${code2}: `));
|
|
159606
|
+
const plainCode = [NOT_SET_UP_CODE, EMPTY_BALANCE_CODE, OVER_LIMITS_CODE, CEILING_OVER_CAP_CODE, CAP_ABOVE_LIMIT_CODE, BALANCE_NOT_READY_CODE, SEND_NOT_READY_CODE].find((code2) => reason.startsWith(`${code2}: `));
|
|
159424
159607
|
if (plainCode) {
|
|
159425
159608
|
const plain = reason.slice(plainCode.length + 2);
|
|
159426
159609
|
io.err(`${plain[0].toUpperCase()}${plain.slice(1)}
|
|
@@ -159490,6 +159673,13 @@ Next: fund that address, then rerun the same command; it continues where it stop
|
|
|
159490
159673
|
`);
|
|
159491
159674
|
return 1;
|
|
159492
159675
|
}
|
|
159676
|
+
if (hint && ["curl", "pay", "unshield"].includes(command?.name) && codes.some((code2) => /^p03_merchant_respend_(insufficient_recovered_value|accounts_split_merge_first)$/.test(code2))) {
|
|
159677
|
+
const made = command.name === "unshield" ? values?.get?.(UNSHIELD_MADE_ID) : void 0;
|
|
159678
|
+
io.err(`${hint[0].toUpperCase()}${hint.slice(1).replace(/[\s.;]+$/, "")}.
|
|
159679
|
+
` + (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)
|
|
159680
|
+
` : ""));
|
|
159681
|
+
return 1;
|
|
159682
|
+
}
|
|
159493
159683
|
if (hint && ANCHOR_REFUSAL.test([...codes, reason].join(" "))) {
|
|
159494
159684
|
io.err(`${hint[0].toUpperCase()}${hint.slice(1).replace(/[\s.;]+$/, "")}.
|
|
159495
159685
|
`);
|