shinjuku-shield 0.3.148 → 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 +229 -43
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",
|
|
@@ -113023,10 +113024,9 @@ function openPaymentWords(parts) {
|
|
|
113023
113024
|
const rerun = one?.requestId ? `run the same command again with --request-id ${one.requestId}` : "run the same command again with its --request-id";
|
|
113024
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.`;
|
|
113025
113026
|
}
|
|
113026
|
-
function balanceWords(parts
|
|
113027
|
-
const
|
|
113028
|
-
const
|
|
113029
|
-
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];
|
|
113030
113030
|
if (spend === void 0) return void 0;
|
|
113031
113031
|
const positive2 = (atomic4) => POSITIVE2.test(String(atomic4 ?? ""));
|
|
113032
113032
|
const notes = [
|
|
@@ -113043,7 +113043,6 @@ var init_balanceNow = __esm({
|
|
|
113043
113043
|
init_book();
|
|
113044
113044
|
init_store();
|
|
113045
113045
|
init_usdcWords();
|
|
113046
|
-
init_commandName();
|
|
113047
113046
|
init_floatPay();
|
|
113048
113047
|
init_prepareRecoveredPayment();
|
|
113049
113048
|
init_balance();
|
|
@@ -151807,6 +151806,10 @@ var NOT_SET_UP_CODE = "wallet_not_set_up";
|
|
|
151807
151806
|
var EMPTY_BALANCE_CODE = "no_spendable_account";
|
|
151808
151807
|
var OVER_LIMITS_CODE = "curl_over_your_limits";
|
|
151809
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");
|
|
151810
151813
|
var flag2 = (name, value2, about, options = {}) => ({ name, value: value2, about, ...options });
|
|
151811
151814
|
var bool2 = (name, about, options = {}) => ({ name, boolean: true, about, ...options });
|
|
151812
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`;
|
|
@@ -152282,14 +152285,26 @@ async function runCurlPaid(values, deps, { requestId: probeId } = {}) {
|
|
|
152282
152285
|
io.err(`request-id ${requestId}${given ? "" : ` (if this run stops, rerun with --request-id ${requestId}: it never pays twice)`}
|
|
152283
152286
|
`);
|
|
152284
152287
|
await poolSwitchGate({ session, amountAtomic: values.get("--max-payment"), again: ` with --request-id ${requestId}`, deps, io });
|
|
152285
|
-
|
|
152286
|
-
|
|
152287
|
-
|
|
152288
|
-
|
|
152289
|
-
|
|
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}
|
|
152290
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);
|
|
152291
152307
|
}
|
|
152292
|
-
throw curlFailure(error);
|
|
152293
152308
|
}
|
|
152294
152309
|
sessionMark(session)("curl-paid-returned");
|
|
152295
152310
|
return await curlOutput(response, values, deps, requestId);
|
|
@@ -155155,7 +155170,7 @@ var COMMANDS = [
|
|
|
155155
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).",
|
|
155156
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).",
|
|
155157
155172
|
"shinjukuShielded is null when the last walk is missing, stale, or incomplete. reasons says why; next shows the command to run.",
|
|
155158
|
-
`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).`,
|
|
155159
155174
|
"Payments that others send to this wallet appear only after a refresh.",
|
|
155160
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.",
|
|
155161
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."
|
|
@@ -156818,10 +156833,30 @@ async function runUnshieldRequest(args, values, deps, io) {
|
|
|
156818
156833
|
io.out(terminal ? unshieldDoneText(result, owner.toBase58()) : `${JSON.stringify(result)}
|
|
156819
156834
|
`);
|
|
156820
156835
|
};
|
|
156821
|
-
|
|
156822
|
-
|
|
156823
|
-
|
|
156824
|
-
|
|
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
|
+
}
|
|
156825
156860
|
answer ??= returned;
|
|
156826
156861
|
if (!answer || typeof answer !== "object") return;
|
|
156827
156862
|
show(answer);
|
|
@@ -156842,7 +156877,7 @@ async function runUnshieldRequest(args, values, deps, io) {
|
|
|
156842
156877
|
} catch {
|
|
156843
156878
|
parts = void 0;
|
|
156844
156879
|
}
|
|
156845
|
-
io.out(`${[privateBalanceLine(parts
|
|
156880
|
+
io.out(`${[privateBalanceLine(parts), ...unfinished.map(unfinishedUnshieldLine)].join("\n")}
|
|
156846
156881
|
`);
|
|
156847
156882
|
} finally {
|
|
156848
156883
|
stopWatch();
|
|
@@ -156986,8 +157021,8 @@ var STALE_WORDS = Object.freeze({
|
|
|
156986
157021
|
pool_move: "money is moving to Shinjuku's new pool"
|
|
156987
157022
|
});
|
|
156988
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");
|
|
156989
|
-
function privateBalanceLine(parts
|
|
156990
|
-
const words2 = balanceWords(parts
|
|
157024
|
+
function privateBalanceLine(parts) {
|
|
157025
|
+
const words2 = balanceWords(parts);
|
|
156991
157026
|
const report = parts?.report;
|
|
156992
157027
|
if (words2 === void 0) {
|
|
156993
157028
|
const why = report && report.status !== "current" && report.status !== "empty" ? ` (${balanceNotCurrentWhy(report)})` : "";
|
|
@@ -157081,14 +157116,6 @@ async function joinForSendAll(report, parts, store, values, deps, io, ensureId)
|
|
|
157081
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
|
|
157082
157117
|
`);
|
|
157083
157118
|
ensureId();
|
|
157084
|
-
if (parts.joining === 0) {
|
|
157085
|
-
const waitMs = Math.floor((deps.random ?? Math.random)() * (JOIN_SOON_MAX_MS + 1));
|
|
157086
|
-
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)
|
|
157087
|
-
`);
|
|
157088
|
-
await (deps.sleep ?? ((ms) => new Promise((done) => {
|
|
157089
|
-
setTimeout(done, ms);
|
|
157090
|
-
})))(waitMs);
|
|
157091
|
-
}
|
|
157092
157119
|
const history = values.get("--history-rpc");
|
|
157093
157120
|
const mergeArgs = [
|
|
157094
157121
|
"--wallet",
|
|
@@ -157106,6 +157133,23 @@ async function joinForSendAll(report, parts, store, values, deps, io, ensureId)
|
|
|
157106
157133
|
...values.has("--rpc-file") ? ["--rpc-file", values.get("--rpc-file")] : [],
|
|
157107
157134
|
...history ? ["--history-rpc", history] : []
|
|
157108
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
|
+
}
|
|
157109
157153
|
const startedAt = deps.now();
|
|
157110
157154
|
let left = parts;
|
|
157111
157155
|
let keep;
|
|
@@ -157117,7 +157161,7 @@ async function joinForSendAll(report, parts, store, values, deps, io, ensureId)
|
|
|
157117
157161
|
answer = result;
|
|
157118
157162
|
} });
|
|
157119
157163
|
} catch (error) {
|
|
157120
|
-
io.err(
|
|
157164
|
+
io.err(stopped);
|
|
157121
157165
|
throw error;
|
|
157122
157166
|
}
|
|
157123
157167
|
const merged = (answer?.merged ?? answer?.resumed ?? []).filter((entry) => entry?.state === "merged").length;
|
|
@@ -157126,16 +157170,145 @@ async function joinForSendAll(report, parts, store, values, deps, io, ensureId)
|
|
|
157126
157170
|
left = joinParts(store);
|
|
157127
157171
|
if (read?.status === "current" && left?.parts <= 1 && left.joining === 0) {
|
|
157128
157172
|
const seconds2 = Math.max(0, Math.round((deps.now() - startedAt) / 1e3));
|
|
157129
|
-
io.err(
|
|
157130
|
-
`);
|
|
157173
|
+
io.err(ready(read, `${Math.floor(seconds2 / 60)} min ${seconds2 % 60} s`));
|
|
157131
157174
|
return read;
|
|
157132
157175
|
}
|
|
157133
157176
|
if (!read || read.status !== "current" || merged === 0) break;
|
|
157134
157177
|
if (round < SEND_ALL_JOIN_ROUNDS) io.err(`getting your balance ready: round ${round} is final; the next round starts now
|
|
157135
157178
|
`);
|
|
157136
157179
|
}
|
|
157137
|
-
|
|
157138
|
-
|
|
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;
|
|
157139
157312
|
}
|
|
157140
157313
|
async function runUnshieldCancel(values, deps, io) {
|
|
157141
157314
|
const walletFile = resolve37(values.get("--wallet"));
|
|
@@ -157971,7 +158144,7 @@ async function runBalance(args, values, deps, io) {
|
|
|
157971
158144
|
...Number.isSafeInteger(parts.changeReadyInSeconds) ? { changeReadyInSeconds: parts.changeReadyInSeconds } : {},
|
|
157972
158145
|
.../^[0-9]+$/.test(String(parts.changeUpToAtomic ?? "")) && BigInt(parts.changeUpToAtomic) < BigInt(parts.spendableAtomic) ? { changeUpToAtomic: parts.changeUpToAtomic } : {}
|
|
157973
158146
|
} : {},
|
|
157974
|
-
spend: spendHeads(parts.spendableAtomic, parts.largestPaymentAtomic, parts, { surface: "cli"
|
|
158147
|
+
spend: spendHeads(parts.spendableAtomic, parts.largestPaymentAtomic, parts, { surface: "cli" })[0] ?? null,
|
|
157975
158148
|
refundsInFlightAtomic: parts.refundsInFlightAtomic,
|
|
157976
158149
|
refundsNotCertainAtomic: parts.refundsNotCertainAtomic,
|
|
157977
158150
|
openPaymentsAtomic: parts.openPaymentsAtomic,
|
|
@@ -158122,11 +158295,14 @@ function insufficientCause2(reason, parts) {
|
|
|
158122
158295
|
if (/p03_merchant_respend_accounts_split_merge_first/.test(reason)) return "split";
|
|
158123
158296
|
return parts?.spendableAtomic === "0" && /^[1-9][0-9]*$/.test(String(parts.report?.detail?.reservedAtomic ?? "")) ? "held" : "short";
|
|
158124
158297
|
}
|
|
158125
|
-
function insufficientWords(cause, parts) {
|
|
158298
|
+
function insufficientWords(cause, parts, { selfJoin = false, send: send3 = false } = {}) {
|
|
158126
158299
|
const anchor = "after the next pool anchor";
|
|
158127
158300
|
switch (cause) {
|
|
158128
158301
|
case "split":
|
|
158129
|
-
|
|
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}`;
|
|
158130
158306
|
case "held":
|
|
158131
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`;
|
|
158132
158308
|
default: {
|
|
@@ -158471,7 +158647,10 @@ function failureHint(command, reason, deps, values, floatError) {
|
|
|
158471
158647
|
}
|
|
158472
158648
|
if (/p03_merchant_respend_(insufficient_recovered_value|accounts_split_merge_first)/.test(reason)) {
|
|
158473
158649
|
const parts = runBalanceParts(values, deps);
|
|
158474
|
-
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
|
+
});
|
|
158475
158654
|
}
|
|
158476
158655
|
if (/p03_unshield_anchor_settler_underfunded/.test(reason)) {
|
|
158477
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";
|
|
@@ -159424,7 +159603,7 @@ This copy: ${walletVersionLine(deps.walletVersion())}
|
|
|
159424
159603
|
const reason = failureReason(command, error, values);
|
|
159425
159604
|
const codes = failureCodes(error, reason);
|
|
159426
159605
|
writeRunResult(deps, command, 1, error, codes);
|
|
159427
|
-
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}: `));
|
|
159428
159607
|
if (plainCode) {
|
|
159429
159608
|
const plain = reason.slice(plainCode.length + 2);
|
|
159430
159609
|
io.err(`${plain[0].toUpperCase()}${plain.slice(1)}
|
|
@@ -159494,6 +159673,13 @@ Next: fund that address, then rerun the same command; it continues where it stop
|
|
|
159494
159673
|
`);
|
|
159495
159674
|
return 1;
|
|
159496
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
|
+
}
|
|
159497
159683
|
if (hint && ANCHOR_REFUSAL.test([...codes, reason].join(" "))) {
|
|
159498
159684
|
io.err(`${hint[0].toUpperCase()}${hint.slice(1).replace(/[\s.;]+$/, "")}.
|
|
159499
159685
|
`);
|