shinjuku-shield 0.3.187 → 0.3.189
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 +6 -6
- package/package.json +3 -3
- package/shinjuku-seller.mjs +35 -4
- package/shinjuku-wallet.mjs +137 -64
package/README.md
CHANGED
|
@@ -6,8 +6,8 @@ answers privately, in a terminal chat or for your agent app. Its `mcp`
|
|
|
6
6
|
command runs a local MCP server (stdio) for your agent. Your keys never
|
|
7
7
|
leave your machine.
|
|
8
8
|
|
|
9
|
-
This is version 0.3.
|
|
10
|
-
is the one package that holds the wallet. `shinjuku-shielded` 0.3.
|
|
9
|
+
This is version 0.3.189. The command is `shinjuku`. `shinjuku-shield`
|
|
10
|
+
is the one package that holds the wallet. `shinjuku-shielded` 0.3.189,
|
|
11
11
|
its older npm name, is a small package that runs this package at the same
|
|
12
12
|
version, so wallets installed under it keep updating (0.3.186 and earlier
|
|
13
13
|
versions of `shinjuku-shielded` hold the same files as this package). New
|
|
@@ -16,7 +16,7 @@ installs use `shinjuku`.
|
|
|
16
16
|
## Set up
|
|
17
17
|
|
|
18
18
|
```sh
|
|
19
|
-
npx -y shinjuku@0.3.
|
|
19
|
+
npx -y shinjuku@0.3.189 setup
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Setup offers to install the `shinjuku` command and, on Windows, adds npm's
|
|
@@ -39,13 +39,13 @@ Every wallet command works after `shinjuku`, for example `shinjuku balance`,
|
|
|
39
39
|
Claude Code:
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
|
-
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.
|
|
42
|
+
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.189 mcp
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Claude Desktop (`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
|
|
46
46
|
|
|
47
47
|
```json
|
|
48
|
-
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.
|
|
48
|
+
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.189", "mcp"] } } }
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
On native Windows, if the host cannot find `npx`, use `"command": "cmd"` and
|
|
@@ -58,7 +58,7 @@ Codex (the Codex app and Codex CLI read the same file, `~/.codex/config.toml`):
|
|
|
58
58
|
```toml
|
|
59
59
|
[mcp_servers.shinjuku]
|
|
60
60
|
command = "npx"
|
|
61
|
-
args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.
|
|
61
|
+
args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.189", "mcp"]
|
|
62
62
|
startup_timeout_sec = 120
|
|
63
63
|
tool_timeout_sec = 300
|
|
64
64
|
```
|
package/manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": "carbon-shielded-wallet/bundle-manifest/v1",
|
|
3
3
|
"file": "shinjuku-wallet.mjs",
|
|
4
|
-
"sha256": "
|
|
5
|
-
"bytes":
|
|
6
|
-
"sourceCommit": "
|
|
4
|
+
"sha256": "6b2545a2de92f5fb8df1feebbf9543948db4f8d72ec205d3a1d07ebe89e79f48",
|
|
5
|
+
"bytes": 9341379,
|
|
6
|
+
"sourceCommit": "8112ec6417bea57e21fca6dcd9de0a819b58eb68",
|
|
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": "
|
|
1044
|
-
"bytes":
|
|
1043
|
+
"sha256": "63aba369f3634380a640989582cc4cfee5e6924d92ae21abaedbe15e8a4d69df",
|
|
1044
|
+
"bytes": 3659828,
|
|
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-
|
|
1935
|
+
"publishedAt": "2026-11-07T18:23:33.051Z"
|
|
1936
1936
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shield",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.189",
|
|
4
4
|
"mcpName": "io.github.ShinjukuStaition/shinjuku-shield",
|
|
5
5
|
"description": "Shinjuku Shield, private x402 payments on Solana: the self-custody wallet CLI and its MCP server. Shield, pay, and unshield USDC from any MCP agent, under caps you set.",
|
|
6
|
-
"shinjukuRelease": "
|
|
7
|
-
"shinjukuSha256": "
|
|
6
|
+
"shinjukuRelease": "6b2545a2",
|
|
7
|
+
"shinjukuSha256": "6b2545a2de92f5fb8df1feebbf9543948db4f8d72ec205d3a1d07ebe89e79f48",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shield",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
|
package/shinjuku-seller.mjs
CHANGED
|
@@ -38105,6 +38105,7 @@ var init_errorCodes = __esm({
|
|
|
38105
38105
|
// p03_unshield_<reason> of the terminal's direct exit (cli/shinjukuWallet.mjs directExitRefusal).
|
|
38106
38106
|
"received_payment_gone",
|
|
38107
38107
|
"received_payment_too_small",
|
|
38108
|
+
"unshield_all_needs_several_sends",
|
|
38108
38109
|
"recipient_encoding",
|
|
38109
38110
|
"recipient_eta",
|
|
38110
38111
|
"recipient_owner_invalid",
|
|
@@ -61553,11 +61554,11 @@ function getNullableEncoder(item, config = {}) {
|
|
|
61553
61554
|
(variant) => Number(variant !== null)
|
|
61554
61555
|
);
|
|
61555
61556
|
}
|
|
61556
|
-
function getPatternMatchEncoder(
|
|
61557
|
+
function getPatternMatchEncoder(patterns2) {
|
|
61557
61558
|
return getUnionEncoder(
|
|
61558
|
-
|
|
61559
|
+
patterns2.map(([, encoder]) => encoder),
|
|
61559
61560
|
(value) => {
|
|
61560
|
-
const index =
|
|
61561
|
+
const index = patterns2.findIndex(([predicate]) => predicate(value));
|
|
61561
61562
|
if (index === -1) {
|
|
61562
61563
|
throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_VALUE);
|
|
61563
61564
|
}
|
|
@@ -69047,9 +69048,32 @@ var init_config2 = __esm({
|
|
|
69047
69048
|
});
|
|
69048
69049
|
|
|
69049
69050
|
// wallet/src/mcp/amounts.mjs
|
|
69051
|
+
function usdcPattern(decimals) {
|
|
69052
|
+
if (!Number.isSafeInteger(decimals) || decimals < 0 || decimals > 18) throw new Error("usdc_decimals_invalid: decimals must be a whole number from 0 to 18");
|
|
69053
|
+
let pattern = patterns.get(decimals);
|
|
69054
|
+
if (!pattern) {
|
|
69055
|
+
pattern = new RegExp(decimals === 0 ? "^(0|[1-9][0-9]{0,12})$" : `^(0|[1-9][0-9]{0,12})(\\.[0-9]{1,${decimals}})?$`);
|
|
69056
|
+
patterns.set(decimals, pattern);
|
|
69057
|
+
}
|
|
69058
|
+
return pattern;
|
|
69059
|
+
}
|
|
69060
|
+
function formatUsdc(atomic3, decimals = 6) {
|
|
69061
|
+
usdcPattern(decimals);
|
|
69062
|
+
const text2 = typeof atomic3 === "bigint" ? atomic3.toString() : typeof atomic3 === "string" ? atomic3 : void 0;
|
|
69063
|
+
if (text2 === void 0 || !ANY_ATOMIC.test(text2)) return void 0;
|
|
69064
|
+
const digits = text2.replace(/^0+/, "") || "0";
|
|
69065
|
+
if (decimals === 0) return digits;
|
|
69066
|
+
const padded = digits.padStart(decimals + 1, "0");
|
|
69067
|
+
const whole = padded.slice(0, -decimals);
|
|
69068
|
+
const fraction = padded.slice(-decimals).replace(/0+$/, "");
|
|
69069
|
+
return fraction ? `${whole}.${fraction}` : whole;
|
|
69070
|
+
}
|
|
69071
|
+
var ANY_ATOMIC, patterns;
|
|
69050
69072
|
var init_amounts = __esm({
|
|
69051
69073
|
"wallet/src/mcp/amounts.mjs"() {
|
|
69052
69074
|
"use strict";
|
|
69075
|
+
ANY_ATOMIC = /^[0-9]{1,31}$/;
|
|
69076
|
+
patterns = /* @__PURE__ */ new Map();
|
|
69053
69077
|
}
|
|
69054
69078
|
});
|
|
69055
69079
|
|
|
@@ -69947,6 +69971,10 @@ Or run ${cli()} seller setup again and choose no Tor.`
|
|
|
69947
69971
|
})
|
|
69948
69972
|
};
|
|
69949
69973
|
}
|
|
69974
|
+
var usdc = (atomic3) => {
|
|
69975
|
+
const text2 = formatUsdc(String(atomic3));
|
|
69976
|
+
return text2 === void 0 ? "?" : text2.includes(".") ? text2 : `${text2}.00`;
|
|
69977
|
+
};
|
|
69950
69978
|
var PROXY_FLAGS = Object.freeze(["--upstream", "--public-origin", "--port"]);
|
|
69951
69979
|
|
|
69952
69980
|
// wallet/src/seller/exact/index.mjs
|
|
@@ -69979,7 +70007,7 @@ async function checkRoutes(routes, { scheme, network, inbound }) {
|
|
|
69979
70007
|
}
|
|
69980
70008
|
const amount = BigInt(parsed.amount);
|
|
69981
70009
|
if (amount < inbound.minimumAtomic || amount > inbound.maximumAtomic) {
|
|
69982
|
-
fail20(`route_price_out_of_range: ${key2} must cost from ${inbound.minimumAtomic} to ${inbound.maximumAtomic}
|
|
70010
|
+
fail20(`route_price_out_of_range: ${key2} must cost from ${usdc(inbound.minimumAtomic)} to ${usdc(inbound.maximumAtomic)} USDC`);
|
|
69983
70011
|
}
|
|
69984
70012
|
options.set(key2, { key: key2, asset: parsed.asset, price: { amount: String(parsed.amount), asset: parsed.asset }, description, mimeType, maxTimeoutSeconds });
|
|
69985
70013
|
}
|
|
@@ -70167,6 +70195,9 @@ async function createShinjukuSeller({ home, passphraseFile, routes, fetchImpl =
|
|
|
70167
70195
|
await sweeper?.close();
|
|
70168
70196
|
await tor?.close();
|
|
70169
70197
|
await release?.();
|
|
70198
|
+
if (tor) await new Promise((resolve17) => {
|
|
70199
|
+
setTimeout(resolve17, 200);
|
|
70200
|
+
});
|
|
70170
70201
|
throw error;
|
|
70171
70202
|
}
|
|
70172
70203
|
}
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -64750,15 +64750,19 @@ function usdcWords(atomic5) {
|
|
|
64750
64750
|
const fraction = padded.slice(-6).replace(/0+$/, "");
|
|
64751
64751
|
return `${fraction ? `${whole}.${fraction}` : whole} USDC`;
|
|
64752
64752
|
}
|
|
64753
|
-
function spendNowForms(spendableAtomic, largestAtomic, { surface } = {}) {
|
|
64753
|
+
function spendNowForms(spendableAtomic, largestAtomic, { surface, belowAtomic, readyAtomic } = {}) {
|
|
64754
64754
|
const spendable = String(spendableAtomic ?? "");
|
|
64755
64755
|
if (!ATOMIC.test(spendable)) return [];
|
|
64756
64756
|
const largest = String(largestAtomic ?? "");
|
|
64757
64757
|
const total = usdcWords(spendable);
|
|
64758
|
+
const below2 = ATOMIC.test(String(belowAtomic ?? "")) ? BigInt(belowAtomic) : 0n;
|
|
64759
|
+
if (below2 > 0n && below2 < BigInt(spendable) && ATOMIC.test(largest)) {
|
|
64760
|
+
return [`${usdcWords(largest)} in one payment now; ${usdcWords(below2.toString())} more can only be sent out, one per send, until you add funds`];
|
|
64761
|
+
}
|
|
64758
64762
|
if (BigInt(spendable) === 0n || ATOMIC.test(largest) && BigInt(largest) >= BigInt(spendable)) return [`${total} now`];
|
|
64759
64763
|
if (!ATOMIC.test(largest)) return [`${total} in total now`];
|
|
64760
64764
|
const limit = `${total}, up to ${usdcWords(largest)} in one payment now`;
|
|
64761
|
-
return surface === "cli" ? [limit] : [`${total} (a payment above ${usdcWords(largest)} first gets the balance ready)`, limit];
|
|
64765
|
+
return surface === "cli" || String(readyAtomic ?? "") !== spendable ? [limit] : [`${total} (a payment above ${usdcWords(largest)} first gets the balance ready)`, limit];
|
|
64762
64766
|
}
|
|
64763
64767
|
function spendHeads(spendableAtomic, largestAtomic, change = {}, options = {}) {
|
|
64764
64768
|
const spendable = String(spendableAtomic ?? "");
|
|
@@ -64809,11 +64813,11 @@ function spendHeads(spendableAtomic, largestAtomic, change = {}, options = {}) {
|
|
|
64809
64813
|
}
|
|
64810
64814
|
return [`You have ${total}; no payment can use it yet`, `You have ${total}, not ready to pay yet`];
|
|
64811
64815
|
}
|
|
64812
|
-
return spendNowForms(spendableAtomic, largestAtomic, options).map((form) => `You can spend ${form}`);
|
|
64816
|
+
return spendNowForms(spendableAtomic, largestAtomic, { ...options, belowAtomic: change?.belowAccountsAtomic, readyAtomic: change?.paymentReadyAtomic }).map((form) => `You can spend ${form}`);
|
|
64813
64817
|
}
|
|
64814
64818
|
function receivedOnlyOf(report) {
|
|
64815
64819
|
const detail = report?.detail;
|
|
64816
|
-
return detail?.unspentAccounts === 0 && Number.isSafeInteger(detail?.unspentNotes) && detail.unspentNotes > 0;
|
|
64820
|
+
return (detail?.unspentAccounts === 0 || detail?.stuckOnly === true) && Number.isSafeInteger(detail?.unspentNotes) && detail.unspentNotes > 0;
|
|
64817
64821
|
}
|
|
64818
64822
|
function emptyBalanceWords({ surface, publicAtomic, addFundsCommand, canShield = true }) {
|
|
64819
64823
|
const pub = String(publicAtomic ?? "");
|
|
@@ -70935,6 +70939,7 @@ var init_errorCodes = __esm({
|
|
|
70935
70939
|
// p03_unshield_<reason> of the terminal's direct exit (cli/shinjukuWallet.mjs directExitRefusal).
|
|
70936
70940
|
"received_payment_gone",
|
|
70937
70941
|
"received_payment_too_small",
|
|
70942
|
+
"unshield_all_needs_several_sends",
|
|
70938
70943
|
"recipient_encoding",
|
|
70939
70944
|
"recipient_eta",
|
|
70940
70945
|
"recipient_owner_invalid",
|
|
@@ -82036,11 +82041,13 @@ function selectSpendAccount({ accounts, notes, outputIndex, amountAtomic }) {
|
|
|
82036
82041
|
best = fit2 ?? best;
|
|
82037
82042
|
return best === void 0 ? Object.freeze({ account: void 0, blockedReason: firstReason }) : Object.freeze({ account: best, blockedReason: void 0 });
|
|
82038
82043
|
}
|
|
82039
|
-
var MAX_RESPEND_NOTES;
|
|
82044
|
+
var MAX_RESPEND_NOTES, noteFitsAccount, notesAccountsCanTake;
|
|
82040
82045
|
var init_accountSelection = __esm({
|
|
82041
82046
|
"wallet/src/pay/accountSelection.mjs"() {
|
|
82042
82047
|
"use strict";
|
|
82043
82048
|
MAX_RESPEND_NOTES = 3;
|
|
82049
|
+
noteFitsAccount = (account, note) => account.account?.i === void 0 || note.leafIndex === void 0 || note.leafIndex === null || BigInt(note.leafIndex) >= BigInt(account.account.i);
|
|
82050
|
+
notesAccountsCanTake = (accounts, notes) => accounts.length === 0 ? notes : notes.filter((note) => accounts.some((account) => noteFitsAccount(account, note)));
|
|
82044
82051
|
}
|
|
82045
82052
|
});
|
|
82046
82053
|
|
|
@@ -107391,6 +107398,7 @@ __export(files_exports, {
|
|
|
107391
107398
|
SALE_LANE_FILE: () => SALE_LANE_FILE,
|
|
107392
107399
|
SALE_MOVING_STATES: () => SALE_MOVING_STATES,
|
|
107393
107400
|
SALE_WAIT_TEXT: () => SALE_WAIT_TEXT,
|
|
107401
|
+
newestSalePaidAt: () => newestSalePaidAt,
|
|
107394
107402
|
openSaleBook: () => openSaleBook,
|
|
107395
107403
|
readSaleLane: () => readSaleLane,
|
|
107396
107404
|
readSaleLastRefusal: () => readSaleLastRefusal,
|
|
@@ -107399,6 +107407,7 @@ __export(files_exports, {
|
|
|
107399
107407
|
saleLaneText: () => saleLaneText,
|
|
107400
107408
|
saleViewPath: () => saleViewPath,
|
|
107401
107409
|
saleViewTotals: () => saleViewTotals,
|
|
107410
|
+
sellsOnSalePath: () => sellsOnSalePath,
|
|
107402
107411
|
writeSaleView: () => writeSaleView
|
|
107403
107412
|
});
|
|
107404
107413
|
import { randomBytes as randomBytes17 } from "node:crypto";
|
|
@@ -107523,6 +107532,13 @@ function writeSaleView(walletPath2, answer, now = nowSeconds2()) {
|
|
|
107523
107532
|
writeJson(saleViewPath(walletPath2), view2);
|
|
107524
107533
|
return view2;
|
|
107525
107534
|
}
|
|
107535
|
+
function sellsOnSalePath(walletPath2) {
|
|
107536
|
+
return existsSync(join21(dirname21(dirname21(walletPath2)), "seller", SALE_LANE_FILE)) || existsSync(saleViewPath(walletPath2));
|
|
107537
|
+
}
|
|
107538
|
+
function newestSalePaidAt(walletPath2) {
|
|
107539
|
+
const paid = (readSaleView(walletPath2)?.rows ?? []).map((row) => row.paidAt).filter(isSeconds);
|
|
107540
|
+
return paid.length ? Math.max(...paid) : void 0;
|
|
107541
|
+
}
|
|
107526
107542
|
function readSaleView(walletPath2) {
|
|
107527
107543
|
const view2 = readJson(saleViewPath(walletPath2));
|
|
107528
107544
|
return view2?.schema === VIEW_SCHEMA && Array.isArray(view2.rows) && isSeconds(view2.at) ? view2 : void 0;
|
|
@@ -107598,12 +107614,19 @@ function nextMergeId(store, commitment) {
|
|
|
107598
107614
|
if (unsent !== void 0) return unsent;
|
|
107599
107615
|
fail24("attempts_exhausted");
|
|
107600
107616
|
}
|
|
107617
|
+
function notesBelowEveryAccount(outputs) {
|
|
107618
|
+
const accounts = outputs.filter((output2) => output2.kind === "account");
|
|
107619
|
+
if (accounts.length === 0 || !accounts.every(knownI)) return [];
|
|
107620
|
+
const lowest = accounts.reduce((low, account) => accountI(account) < low ? accountI(account) : low, accountI(accounts[0]));
|
|
107621
|
+
return outputs.filter((output2) => output2.kind === "note" && leaf(output2) < lowest);
|
|
107622
|
+
}
|
|
107601
107623
|
function largestOneSpend(outputs) {
|
|
107602
107624
|
const accounts = outputs.filter((output2) => output2.kind === "account");
|
|
107603
107625
|
const notes = outputs.filter((output2) => output2.kind === "note");
|
|
107604
107626
|
const most = (iOf) => accounts.reduce((largest2, account) => {
|
|
107605
107627
|
const fits = notes.filter((output2) => leaf(output2) >= iOf(account));
|
|
107606
|
-
|
|
107628
|
+
const reached = notes.filter((output2) => accounts.some((other) => leaf(output2) >= iOf(other))).length;
|
|
107629
|
+
if (reached <= MAX_RESPEND_NOTES && fits.length < reached) return largest2;
|
|
107607
107630
|
const drawn = fits.sort(byValue).slice(0, MAX_RESPEND_NOTES).reduce((sum2, output2) => sum2 + value(output2), value(account));
|
|
107608
107631
|
return drawn > largest2 ? drawn : largest2;
|
|
107609
107632
|
}, 0n);
|
|
@@ -107644,6 +107667,17 @@ function planMerge({ snapshot, exitReserved = /* @__PURE__ */ new Set(), held: h
|
|
|
107644
107667
|
totalAtomic: [...accounts, ...notes].reduce((sum2, output2) => sum2 + value(output2), 0n).toString()
|
|
107645
107668
|
};
|
|
107646
107669
|
}
|
|
107670
|
+
function largestAfterJoin(outputs) {
|
|
107671
|
+
const below2 = new Set(notesBelowEveryAccount(outputs));
|
|
107672
|
+
const reach = outputs.filter((output2) => !below2.has(output2));
|
|
107673
|
+
const now = largestOneSpend(reach);
|
|
107674
|
+
const plan = planMerge({ snapshot: { outputs: reach } });
|
|
107675
|
+
if (plan.keep === void 0 || plan.steps.length === 0 || plan.later.length > 0) return now;
|
|
107676
|
+
const taken = new Set(plan.steps.flatMap((step) => step.notes));
|
|
107677
|
+
const left = plan.notes.filter((output2) => value(output2) > 0n && !taken.has(output2));
|
|
107678
|
+
if (left.length + plan.steps.length > MAX_RESPEND_NOTES || left.some((output2) => leaf(output2) < accountI(plan.keep))) return now;
|
|
107679
|
+
return BigInt(plan.totalAtomic);
|
|
107680
|
+
}
|
|
107647
107681
|
var MERGE_RECORD, MAX_ATTEMPTS, DEAD, fail24, mergeId, leaf, value, byLeaf, byValue, knownI, accountI;
|
|
107648
107682
|
var init_plan = __esm({
|
|
107649
107683
|
"wallet/src/merge/plan.mjs"() {
|
|
@@ -107987,6 +108021,7 @@ function computeBalance({ store, snapshotRead, source = "local", now = Date.now(
|
|
|
107987
108021
|
let spareMost = 0n;
|
|
107988
108022
|
const report = (status, gross, next2, cause, largest2, change, changes) => {
|
|
107989
108023
|
const atomic5 = gross === null || privateSendPending === null ? null : gross > privateSendPending ? gross - privateSendPending : 0n;
|
|
108024
|
+
if (atomic5 !== null && BigInt(detail.belowAccountsAtomic ?? "0") > atomic5) detail.belowAccountsAtomic = atomic5.toString();
|
|
107990
108025
|
const built = {
|
|
107991
108026
|
// The one number: shielded + pockets. Null when either part is unknown.
|
|
107992
108027
|
total: atomic5 === null || !pockets ? null : formatAtomic(atomic5 + BigInt(pockets.availableAtomic), decimals),
|
|
@@ -108037,7 +108072,7 @@ function computeBalance({ store, snapshotRead, source = "local", now = Date.now(
|
|
|
108037
108072
|
if (!couldHoldValue && !state2.restoredFromRecoveryText && !snapshotRead?.unreadable) {
|
|
108038
108073
|
const proved = pendingDeposits.find((entry) => entry.state === "proved");
|
|
108039
108074
|
const awaiting = pendingDeposits.find((entry) => entry.state === "awaiting_funds");
|
|
108040
|
-
if (records.every(planOnly)) {
|
|
108075
|
+
if (records.every(planOnly) && !(store.path && sellsOnSalePath(store.path))) {
|
|
108041
108076
|
Object.assign(detail, { unspentAtomic: "0", reservedAtomic: "0", balanceSource: "new_wallet_nothing_received" });
|
|
108042
108077
|
return report(
|
|
108043
108078
|
"empty",
|
|
@@ -108050,7 +108085,7 @@ It asks the amount, then gives a one-time address and its QR code: send USDC to
|
|
|
108050
108085
|
0n
|
|
108051
108086
|
);
|
|
108052
108087
|
}
|
|
108053
|
-
reasons.push("this wallet has a deposit, add-funds or payment record but no balance walk yet: its balance is not known until the first read");
|
|
108088
|
+
reasons.push("this wallet has a deposit, add-funds, sale or payment record but no balance walk yet: its balance is not known until the first read");
|
|
108054
108089
|
return report("unknown", null, proved ? byAddFunds(proved.depositId) ? `deposit ${proved.depositId} of add-funds is proved but not sent yet. ${continueAddFunds}` : `deposit ${proved.depositId} is proved but not sent: back up (${commandLine("help backup-export")}), then rerun the same deposit command with --submit --service <server URL>` : awaiting ? byAddFunds(awaiting.depositId) ? `deposit ${awaiting.depositId} of add-funds waits for USDC at its one-time address; add-funds shows the address again. ${continueAddFunds}` : `deposit ${awaiting.depositId} waits for USDC at its one-time address: fund it, then rerun the same deposit --relay command (it prints the address)` : refreshCommand(state2));
|
|
108055
108090
|
}
|
|
108056
108091
|
const valueRecords = records.filter((entry) => !NO_VALUE_TYPES.has(entry.type) && !(entry.type === "deposit" && (entry.phase === "pre-chain" || entry.phase === "void")));
|
|
@@ -108083,6 +108118,7 @@ It asks the amount, then gives a one-time address and its QR code: send USDC to
|
|
|
108083
108118
|
detail.successionMovableAtomic = successionMovableAtomic.toString();
|
|
108084
108119
|
detail.unspentAccounts = [...unspent.values()].filter((output2) => output2.kind === "account").length;
|
|
108085
108120
|
detail.unspentNotes = [...unspent.values()].filter((output2) => output2.kind === "note").length;
|
|
108121
|
+
detail.stuckOnly = detail.unspentAccounts > 0 && detail.unspentNotes > 0 && [...unspent.values()].every((output2) => output2.kind !== "account" || BigInt(output2.valueAtomic) === 0n) && notesBelowEveryAccount([...unspent.values()]).length === detail.unspentNotes;
|
|
108086
108122
|
detail.lastRefresh = {
|
|
108087
108123
|
at: snapshot.refreshedAt,
|
|
108088
108124
|
slot: snapshot.slot,
|
|
@@ -108292,6 +108328,16 @@ It asks the amount, then gives a one-time address and its QR code: send USDC to
|
|
|
108292
108328
|
}
|
|
108293
108329
|
const openLargest = sendHold === null ? void 0 : largestOneSpend(open5);
|
|
108294
108330
|
const largest = openLargest === void 0 || openLargest >= spareMost ? openLargest : spareMost;
|
|
108331
|
+
if (sendHold !== null) {
|
|
108332
|
+
const belowAccounts = notesBelowEveryAccount(free).filter((output2) => !isHeld(output2));
|
|
108333
|
+
const belowGross = sum2(belowAccounts.map((output2) => output2.valueAtomic));
|
|
108334
|
+
const uncovered = sum2(sendHold.unpacked.map((part) => part.amountAtomic));
|
|
108335
|
+
detail.belowAccountsAtomic = (belowGross > uncovered ? belowGross - uncovered : 0n).toString();
|
|
108336
|
+
detail.belowAccountsNotes = belowAccounts.length;
|
|
108337
|
+
detail.belowAccountsLargestAtomic = belowAccounts.reduce((top, output2) => BigInt(output2.valueAtomic) > top ? BigInt(output2.valueAtomic) : top, 0n).toString();
|
|
108338
|
+
const afterJoin = largestAfterJoin(open5);
|
|
108339
|
+
if (afterJoin !== void 0) detail.paymentReadyAtomic = afterJoin.toString();
|
|
108340
|
+
}
|
|
108295
108341
|
if (settling.some((payment) => payment.inputs.some((commitment) => reserved.has(commitment) || joining.has(commitment))) || unknownInputs && settling.length) {
|
|
108296
108342
|
reasons.push(...settlingReasons);
|
|
108297
108343
|
return report("stale", null, refreshCommand(state2, snapshot.programId));
|
|
@@ -108338,6 +108384,11 @@ If a payment to this wallet settled, read the chain again with:
|
|
|
108338
108384
|
settling.length
|
|
108339
108385
|
);
|
|
108340
108386
|
}
|
|
108387
|
+
const newestSale = store.path ? newestSalePaidAt(store.path) : void 0;
|
|
108388
|
+
if (newestSale !== void 0 && newestSale * 1e3 > Date.parse(snapshot.refreshedAt)) {
|
|
108389
|
+
reasons.push("Shinjuku paid a sale after the last balance read");
|
|
108390
|
+
return report("stale", spendable + successionMovableAtomic, next ?? refreshCommand(state2, snapshot.programId), void 0, largest);
|
|
108391
|
+
}
|
|
108341
108392
|
return report("current", spendable + successionMovableAtomic, next, void 0, largest);
|
|
108342
108393
|
}
|
|
108343
108394
|
function savedSendHold({ store, snapshotRead }) {
|
|
@@ -111402,7 +111453,7 @@ async function runPrivateSend({
|
|
|
111402
111453
|
await finish();
|
|
111403
111454
|
return privateSendStatus(store, current(), now);
|
|
111404
111455
|
}
|
|
111405
|
-
var PRIVATE_SEND_WAL_SCHEMA, PRIVATE_SEND_WAL_PREFIX, OVERDUE_GRACE_MS, WAIT_SLICE_MS, fail27, ID, CODE, privateSendPlanName, DIRECT_EXIT_MODE, directExitGone,
|
|
111456
|
+
var PRIVATE_SEND_WAL_SCHEMA, PRIVATE_SEND_WAL_PREFIX, OVERDUE_GRACE_MS, WAIT_SLICE_MS, fail27, ID, CODE, privateSendPlanName, DIRECT_EXIT_MODE, directExitGone, bySendPart, OLD_TRANSFER_TOOL, namedSend, cancelledPart, partCancelled;
|
|
111406
111457
|
var init_privateSend = __esm({
|
|
111407
111458
|
"wallet/src/unshield/privateSend.mjs"() {
|
|
111408
111459
|
"use strict";
|
|
@@ -111421,7 +111472,6 @@ var init_privateSend = __esm({
|
|
|
111421
111472
|
privateSendPlanName = (sendId) => `${PRIVATE_SEND_WAL_PREFIX}${sendId}`;
|
|
111422
111473
|
DIRECT_EXIT_MODE = "direct-exit";
|
|
111423
111474
|
directExitGone = (record) => record?.mode === DIRECT_EXIT_MODE && record.state === "abandoned";
|
|
111424
|
-
noteFitsAccount = (account, note) => account.account?.i === void 0 || note.leafIndex === void 0 || note.leafIndex === null || BigInt(note.leafIndex) >= BigInt(account.account.i);
|
|
111425
111475
|
bySendPart = (left, right) => left.plan.sendId < right.plan.sendId ? -1 : left.plan.sendId > right.plan.sendId ? 1 : left.part.index - right.part.index;
|
|
111426
111476
|
OLD_TRANSFER_TOOL = "old_transfer";
|
|
111427
111477
|
namedSend = (plan) => ({
|
|
@@ -111770,11 +111820,11 @@ async function everyAccountHeld({ store, connection, programId, serviceUrl: serv
|
|
|
111770
111820
|
const largest = freeAccounts.reduce((max, entry) => BigInt(entry.account.b) > BigInt(max.account.b) ? entry : max);
|
|
111771
111821
|
if (!anyHeld) {
|
|
111772
111822
|
if (!unheldAccounts.some((entry) => (heldSpareAtomic(sendHold, entry) ?? 0n) >= BigInt(amountAtomic))) {
|
|
111773
|
-
assertAccountsNotSplit({ accounts: freeAccounts, account: largest, notes: freeNotes.filter(free), amountAtomic });
|
|
111823
|
+
assertAccountsNotSplit({ accounts: freeAccounts, account: largest, notes: notesAccountsCanTake(freeAccounts, freeNotes.filter(free)), amountAtomic });
|
|
111774
111824
|
}
|
|
111775
111825
|
return false;
|
|
111776
111826
|
}
|
|
111777
|
-
const notesValue = freeNotes.reduce((sum2, entry) => sum2 + BigInt(entry.note.b), 0n);
|
|
111827
|
+
const notesValue = notesAccountsCanTake(freeAccounts, freeNotes).reduce((sum2, entry) => sum2 + BigInt(entry.note.b), 0n);
|
|
111778
111828
|
return BigInt(largest.account.b) + notesValue < BigInt(amountAtomic);
|
|
111779
111829
|
}
|
|
111780
111830
|
function assertAccountsNotSplit({ accounts, account, notes, allNotes = notes, amountAtomic }) {
|
|
@@ -111949,6 +111999,8 @@ async function prepareRecoveredPayment({
|
|
|
111949
111999
|
return false;
|
|
111950
112000
|
}
|
|
111951
112001
|
};
|
|
112002
|
+
const namedAccounts = selection?.accountCommitment === void 0 ? accounts : accounts.filter((entry) => BigInt(entry.commitment) === BigInt(selection.accountCommitment));
|
|
112003
|
+
const reachableNotes = selection?.accountFile !== void 0 || typeof deps.keptNote === "function" ? notes : notesAccountsCanTake(namedAccounts, notes);
|
|
111952
112004
|
let wantedNotes = selection?.noteCommitments !== void 0 ? selection.noteCommitments.map((commitment) => {
|
|
111953
112005
|
const wanted = BigInt(commitment);
|
|
111954
112006
|
const found = notes.find((entry) => BigInt(entry.commitment) === wanted);
|
|
@@ -111959,13 +112011,13 @@ async function prepareRecoveredPayment({
|
|
|
111959
112011
|
if (!found && unspentNotes.some((entry) => BigInt(entry.commitment) === wanted)) heldInputsWait();
|
|
111960
112012
|
if (!found) fail28("requested_note_not_spendable");
|
|
111961
112013
|
return found;
|
|
111962
|
-
}) : selection?.accountFile === void 0 &&
|
|
111963
|
-
accounts:
|
|
111964
|
-
notes,
|
|
112014
|
+
}) : selection?.accountFile === void 0 && reachableNotes.length > MAX_RESPEND_NOTES ? respendNoteSubset({
|
|
112015
|
+
accounts: namedAccounts,
|
|
112016
|
+
notes: reachableNotes,
|
|
111965
112017
|
outputIndex: anchor.index,
|
|
111966
112018
|
amountAtomic: witnessQuote.amountAtomic,
|
|
111967
112019
|
refusedInput
|
|
111968
|
-
}) ??
|
|
112020
|
+
}) ?? reachableNotes : reachableNotes;
|
|
111969
112021
|
const accountFile = selection?.accountFile;
|
|
111970
112022
|
let account;
|
|
111971
112023
|
let accountPath;
|
|
@@ -112053,7 +112105,7 @@ async function prepareRecoveredPayment({
|
|
|
112053
112105
|
account = spare ?? underAnchor ?? accounts[0];
|
|
112054
112106
|
sendShort = spare === void 0 && (sendHold.accounts.size > 0 || sendHold.notes.size > 0) && !pays(underAnchor);
|
|
112055
112107
|
}
|
|
112056
|
-
if (account) assertAccountsNotSplit({ accounts, account, notes: wantedNotes, allNotes:
|
|
112108
|
+
if (account) assertAccountsNotSplit({ accounts, account, notes: wantedNotes, allNotes: reachableNotes, amountAtomic: witnessQuote.amountAtomic });
|
|
112057
112109
|
if (sendShort && (accounts.length === 0 || [...accounts.map((entry) => entry.account.b), ...freeNotes.map((entry) => entry.note.b)].reduce((sum2, value2) => sum2 + BigInt(value2), heldAccounts.reduce((sum2, entry) => sum2 + heldSpareAtomic(sendHold, entry), 0n)) >= BigInt(witnessQuote.amountAtomic))) {
|
|
112058
112110
|
heldByPrivateSend(sendHold.sends);
|
|
112059
112111
|
}
|
|
@@ -115113,7 +115165,7 @@ function refusalSay(a, tool, again, npmVersion) {
|
|
|
115113
115165
|
}
|
|
115114
115166
|
if (code2 === "mcp_unshield_received_payment_too_small") {
|
|
115115
115167
|
const largest = usdcText2(a.largestReceivedAtomic);
|
|
115116
|
-
return largest ? `Nothing was sent. One
|
|
115168
|
+
return largest ? `Nothing was sent. One send moves one part of your balance; the largest is ${largest} USDC. Send that much or less.` : "Nothing was sent. One send moves one part of your balance, up to its amount. Send a smaller amount.";
|
|
115117
115169
|
}
|
|
115118
115170
|
if (code2 === "mcp_unshield_received_payment_gone") {
|
|
115119
115171
|
return "Nothing was sent. The received payment this unshield chose is no longer available. Check your balance, then start a new unshield.";
|
|
@@ -119843,6 +119895,8 @@ function partsOf(report, store, snapshot) {
|
|
|
119843
119895
|
spendableAtomic: spendable.toString(),
|
|
119844
119896
|
spendable: formatAtomic(spendable, Number(store.state.decimals)),
|
|
119845
119897
|
largestPaymentAtomic: largestPaymentOf(report) ?? null,
|
|
119898
|
+
belowAccountsAtomic: report?.detail?.belowAccountsAtomic ?? "0",
|
|
119899
|
+
paymentReadyAtomic: report?.detail?.paymentReadyAtomic ?? null,
|
|
119846
119900
|
changeSettling,
|
|
119847
119901
|
changeReadyInSeconds: changeSettling ? changeReadyInSeconds() : null,
|
|
119848
119902
|
changeUpToAtomic: changeSettling ? changeUpToOf(report) ?? null : null,
|
|
@@ -134113,11 +134167,16 @@ function selfPayMayHaveSigned(store, unshieldId) {
|
|
|
134113
134167
|
}
|
|
134114
134168
|
function chooseDirectExitNote(store, amountAtomic, unshieldId) {
|
|
134115
134169
|
let unspent;
|
|
134170
|
+
let hasAccount;
|
|
134171
|
+
let stuck;
|
|
134116
134172
|
try {
|
|
134117
134173
|
const snapshot = readBalanceSnapshot(store).snapshot;
|
|
134118
134174
|
if (snapshot?.pool !== store.state.pool || !Array.isArray(snapshot.outputs)) return void 0;
|
|
134119
134175
|
unspent = snapshot.outputs.filter((output2) => output2.spendStatus === "unspent");
|
|
134120
|
-
|
|
134176
|
+
hasAccount = unspent.some((output2) => output2.kind === "account");
|
|
134177
|
+
stuck = notesBelowEveryAccount(unspent);
|
|
134178
|
+
if (hasAccount && stuck.length === 0 || shieldedUnknown(store)) return void 0;
|
|
134179
|
+
if (hasAccount && (largestOneSpend(unspent) ?? 0n) >= BigInt(amountAtomic)) return void 0;
|
|
134121
134180
|
} catch {
|
|
134122
134181
|
return void 0;
|
|
134123
134182
|
}
|
|
@@ -134129,7 +134188,7 @@ function chooseDirectExitNote(store, amountAtomic, unshieldId) {
|
|
|
134129
134188
|
reserved.add(BigInt(other.noteCommitment).toString());
|
|
134130
134189
|
}
|
|
134131
134190
|
}
|
|
134132
|
-
const notes = unspent.filter((output2) => output2.kind === "note" && ATOMIC_TEXT.test(String(output2.valueAtomic)) && ATOMIC_TEXT.test(String(output2.leafIndex)) && /^[0-9]{1,90}$/.test(String(output2.commitment)) && /^[0-9a-f]{64}$/.test(String(output2.digest)) && !reserved.has(BigInt(output2.commitment).toString()));
|
|
134191
|
+
const notes = (hasAccount ? stuck : unspent).filter((output2) => output2.kind === "note" && ATOMIC_TEXT.test(String(output2.valueAtomic)) && ATOMIC_TEXT.test(String(output2.leafIndex)) && /^[0-9]{1,90}$/.test(String(output2.commitment)) && /^[0-9a-f]{64}$/.test(String(output2.digest)) && !reserved.has(BigInt(output2.commitment).toString()));
|
|
134133
134192
|
if (notes.length === 0) return void 0;
|
|
134134
134193
|
const want = BigInt(amountAtomic);
|
|
134135
134194
|
const fits = notes.filter((note) => BigInt(note.valueAtomic) >= want).sort((left, right) => {
|
|
@@ -134137,8 +134196,9 @@ function chooseDirectExitNote(store, amountAtomic, unshieldId) {
|
|
|
134137
134196
|
return value2 !== 0n ? value2 < 0n ? -1 : 1 : BigInt(left.leafIndex) < BigInt(right.leafIndex) ? -1 : 1;
|
|
134138
134197
|
});
|
|
134139
134198
|
if (fits.length > 0) return fits[0];
|
|
134140
|
-
const
|
|
134141
|
-
|
|
134199
|
+
const oneSpend = hasAccount ? largestOneSpend(unspent) ?? 0n : 0n;
|
|
134200
|
+
const largest = notes.reduce((top, note) => BigInt(note.valueAtomic) > top ? BigInt(note.valueAtomic) : top, oneSpend);
|
|
134201
|
+
throw Object.assign(new Error(`mcp_unshield_received_payment_too_small: one unshield sends one part of the balance, and the largest part it holds is ${floatAmountText(largest.toString(), "smaller than this amount")}; nothing was moved`), { largestReceivedAtomic: largest.toString() });
|
|
134142
134202
|
}
|
|
134143
134203
|
function leg1SettleSlot(store, float, requestId) {
|
|
134144
134204
|
try {
|
|
@@ -134773,11 +134833,7 @@ function refreshSaleView(store, serviceUrl2, fetchImpl) {
|
|
|
134773
134833
|
function balanceFields(parts) {
|
|
134774
134834
|
if (!parts) return null;
|
|
134775
134835
|
return {
|
|
134776
|
-
balanceAtomic: parts.spendableAtomic,
|
|
134777
|
-
largestPaymentAtomic: parts.largestPaymentAtomic ?? null,
|
|
134778
|
-
...changeFields(parts),
|
|
134779
|
-
...receivedOnlyOf(parts.report) ? { receivedOnly: true } : {},
|
|
134780
|
-
balance: parts.spendable,
|
|
134836
|
+
...balanceTextFields({ ...parts, balanceAtomic: parts.spendableAtomic, balance: parts.spendable, receivedOnly: receivedOnlyOf(parts.report) }),
|
|
134781
134837
|
breakdown: {
|
|
134782
134838
|
shieldedAtomic: parts.spendableAtomic,
|
|
134783
134839
|
refundsInFlightAtomic: parts.refundsInFlightAtomic,
|
|
@@ -138193,7 +138249,8 @@ ${canonical5}`;
|
|
|
138193
138249
|
else if (unshielded.unshieldedAtomic && unshielded.unshieldedAtomic !== "0" && shieldEnabled) next = 'to make the public USDC private, call wallet_shield with amount (like "0.37")';
|
|
138194
138250
|
else if (one.balanceAtomic === "0" && shieldEnabled) {
|
|
138195
138251
|
next = elsewhereEnabled ? `the private balance is 0, so nothing can be paid yet. To add funds, call wallet_add_funds: it gives a one-time address; USDC sent there on Solana (at least ${usdcText3(PAY_ME_MIN_ATOMIC)} USDC) becomes private by itself after it arrives, and wallet_balance shows it then (add funds fills the private balance up to ${usdcText3(MAX_SHIELDED_BALANCE_ATOMIC)} USDC)` : `the private balance is 0, so nothing can be paid yet. This server has no private deposit address, so the only way in is a deposit from this wallet's public address (ownAddress): the chain then shows that this wallet's public address added that amount; later payments stay private. Tell the user this BEFORE they send. To add funds that way: send USDC on Solana to ownAddress, then call wallet_shield with amount (any amount from ${usdcText3(10000n)} to ${usdcText3(MAX_SHIELDED_BALANCE_ATOMIC)} USDC)`;
|
|
138196
|
-
} else next = "
|
|
138252
|
+
} else if (one.receivedOnly === true) next = "received payments only: pay_for_service can use them after the user adds funds once or sends part of one out; wallet_unshield sends one received payment at a time";
|
|
138253
|
+
else next = "nothing to do; pay_for_service and wallet_unshield spend from balanceAtomic";
|
|
138197
138254
|
const lastRead = one.balanceAtomic === null && refresh.refreshing === true && !firstRead && ATOMIC_TEXT.test(String(report.detail?.unspentAtomic ?? "")) && Number.isFinite(report.detail?.lastRefresh?.ageSeconds) ? { privateAtomic: String(report.detail.unspentAtomic), ageMinutes: Math.max(1, Math.round(report.detail.lastRefresh.ageSeconds / 60)) } : void 0;
|
|
138198
138255
|
if (lastRead) {
|
|
138199
138256
|
next = `${next}. Meanwhile tell the user: the last full read, ${ageWords2(lastRead.ageMinutes)} ago, showed ${usdcText3(lastRead.privateAtomic)} USDC private (lastRead); a payment or a refund since then is not in it, so it is not the balance now`;
|
|
@@ -138438,11 +138495,7 @@ ${canonical5}`;
|
|
|
138438
138495
|
ok: true,
|
|
138439
138496
|
...reportPublic,
|
|
138440
138497
|
...firstRead ? { status: "reading" } : {},
|
|
138441
|
-
|
|
138442
|
-
largestPaymentAtomic: one.largestPaymentAtomic,
|
|
138443
|
-
...changeFields(one),
|
|
138444
|
-
...one.receivedOnly === true ? { receivedOnly: true } : {},
|
|
138445
|
-
balance: one.balance,
|
|
138498
|
+
...balanceTextFields(one),
|
|
138446
138499
|
card: walletCard({ one, unshielded, landingAtomic, landingSalesAtomic: landingParts.salesAtomic, sales, store, lastRead, refundNotices: notices.refundNotices, refresh }),
|
|
138447
138500
|
...lastRead ? { lastRead } : {},
|
|
138448
138501
|
// joinSteps: the joins, one after another (autoJoin.mjs joinParts joins), when the wallet gets the balance ready by
|
|
@@ -139998,13 +140051,7 @@ ${canonical5}`;
|
|
|
139998
140051
|
const store = session.openStore();
|
|
139999
140052
|
if (landedNotCounted(store) > 0n) return {};
|
|
140000
140053
|
const one = readBalance(store);
|
|
140001
|
-
return ATOMIC_TEXT.test(String(one?.balanceAtomic ?? "")) ? {
|
|
140002
|
-
balanceAtomic: one.balanceAtomic,
|
|
140003
|
-
largestPaymentAtomic: one.largestPaymentAtomic,
|
|
140004
|
-
...changeFields(one),
|
|
140005
|
-
...one.receivedOnly === true ? { receivedOnly: true } : {},
|
|
140006
|
-
balance: one.balance
|
|
140007
|
-
} : {};
|
|
140054
|
+
return ATOMIC_TEXT.test(String(one?.balanceAtomic ?? "")) ? balanceTextFields(one) : {};
|
|
140008
140055
|
} catch {
|
|
140009
140056
|
return {};
|
|
140010
140057
|
}
|
|
@@ -144629,11 +144676,7 @@ ${canonical5}`;
|
|
|
144629
144676
|
ok: true,
|
|
144630
144677
|
stillReading: true,
|
|
144631
144678
|
refreshing: true,
|
|
144632
|
-
|
|
144633
|
-
largestPaymentAtomic: one?.largestPaymentAtomic ?? null,
|
|
144634
|
-
...changeFields(one),
|
|
144635
|
-
...one?.receivedOnly === true ? { receivedOnly: true } : {},
|
|
144636
|
-
balance: one?.balance ?? null,
|
|
144679
|
+
...balanceTextFields(one),
|
|
144637
144680
|
...one?.breakdown ? { breakdown: one.breakdown } : {},
|
|
144638
144681
|
// Never an absent token list (a live check 0.3.106 gate item 10): null is not read (never "none"); no words about it (UX128-7).
|
|
144639
144682
|
ownKeyTokens: null,
|
|
@@ -145382,7 +145425,7 @@ function createSetupTools({
|
|
|
145382
145425
|
doneTool: sayOnRefusal(doneTool)
|
|
145383
145426
|
};
|
|
145384
145427
|
}
|
|
145385
|
-
var import_web3133, X402_V1_NEXT, shownCaps, RELEASE_RETRY_MS, STAGE_WORDS, stageWords, INTERNAL_BALANCE_DETAIL, shownBreakdown, sessionLeftShown, RESOURCE_PAYMENT_WAL_PREFIX2, POOL_LAYOUT_CODE, POOL_LAYOUT_UPDATE, USEPOD_VIA_INFERENCE_CHAT, SEND_RUNS_ON, DEPOSIT_RUNS_ON, CLI_FUNDS_PLAN_PREFIX, CLI_FUNDS_SCHEMA, SELF_PAY_ORIGIN3, REQUEST_ID4, POSITIVE_ATOMIC6, PRIVATE_HOST3, FORBIDDEN_HEADERS3, MAX_BODY_BYTES2, PREVIEW_TIMEOUT_MS, PREVIEW_SELLER_READ_MS, CALL_BUDGET_MS, budgetLeft, PAY_ANSWER_MARGIN_MS, MONEY_FIRST_ANSWER_MS, BALANCE_AFTER_LANDING_MS, JOIN_CALL_MAX_MS, JOIN_CALL_ANSWER_MARGIN_S, PAY_AFTER_JOIN_MS, joinAnswerSeconds, JOIN_TIME_MS, JOIN_NUDGE_QUIET_MS, JOIN_STEP_MS, sleep2, PROGRESS_EVERY_MS2, READ_BUDGET_MS, UNPAID_TOR_TRY_MS, UNPAID_CLEAR_MS, READ_BUDGET_TOOLS, FLOAT_BUSY_CODES, RETRY_MARGIN_MS, ASK_PAY_CODES, runningNpmVersion, terminalCommand2, capPlaceWords, noLimitSetLine, CAP_NAMES, capName, entryPlaces, capRaiseText, runningLimits, payCapFlag, noPriceFits, cheaperText, limitNext, overLimitStep, SAFE_TEXT, causesLog, MCP_TOOL_ALIASES, POOL_SWITCH_WHY, POOL_SWITCH_NEXT, SWITCH_STATES, quietSwitch, switchKey, ATOMIC_TEXT, MAX_PAYMENT_ATOMIC_LEAST, movedTo, FLOAT_ID2, ANSWERED_EXIT_RETRY_MS, ANSWERED_EXIT_UNCONFIRMED_MS, ANSWERED_EXIT_RETRY_WINDOW_MS, ANSWERED_EXIT_CLOSED, switchAmount, switchEta, switchRows, OWNER_CAP_CODES, JOIN_END_MCP, JOIN_END_TERMINAL_LIBRARY, JOIN_RETRY_BACKOFF_MS, WALLET_CAP_FIX, ENTRY_CAP_CODES, MCP_CAP_FIX, capFix, ownerOnlyNext, mcpNext, CONFIDENTIAL_RETIRED, json4, answerResult, discoverTool, LAUNCH_CAP_CODES, dayCapKind, refuse11, newRequestIdFor, payCapName, limitQuestion, stableJson, requestPrint, publicOffer, FLOAT_PAID_CODES, FLOAT_NOT_CERTAIN_CODES, FLOAT_PRIVATE_LEG, SELLER_ONLY_HERE, outsideWalletRule, TOR_START_STEP, MONEY_ID2, toRecordId, linkKindOf, moneyId, REFUSED_CODES, SEND_STOPPED, SEND_STOP_NOT_SAVED, sendStoppedError, refusedCodeOf, PLAIN_REASONS, insufficientCause, INSUFFICIENT_REASONS, reasonOf, plainReason, KEPT_SEND_TRIES, shownId, isSplitSend, PROMISED_NEXT, partFailReason, sendAnswerOf, PUBLIC_READ_TIMEOUT_MS, RECIPIENT_CHECK_TIMEOUT_MS, withTimeout, ownKey, readFailure, OWN_KEY_TOKENS_MAX, tokenAmountText, elsewhereId, AGENT_ID_SCHEMA, agentIdName, minutesText2, ageWords2, DEPOSIT_SENT_STATES, depositLanded, usdcText3, walkWalletHistory, REFRESH_LEASE_WALK_MS, HOME_MARKS_SETTLED_MS2, AUTO_BACKUPS_KEPT, AUTO_BACKUP_NAME, AUTO_BACKUP_VERIFIED, FRONTED_SETTLE_MARGIN_SLOTS, UNSHIELD_WINDOW_YIELD_MS, NOT_FINAL_YET, FINISH_FINALITY_WAIT_MS, FINISH_FINALITY_WAITS, FINISH_FINALITY_RECENT_MS, walkStillCurrent, DIRECT_EXIT_GONE, BALANCE_REFRESH_WAIT_MS, BALANCE_REFRESH_GRACE_MS, BALANCE_REFRESH_LONG_MS, INBOUND_REFRESH_AGE_MS, SALE_VIEW_AGE_SECONDS, saleViewRead, changeFields, balanceAnswer, CAP_BALANCE_WAIT_MS, CAP_BALANCE_RETRY_MS, REFRESH_RETRY_MS, FINALITY_POLL_MS, FINALITY_WAIT_MS, FINALITY_REFRESH_LIMIT_MS, POOL_WATCH_MS, POOL_WATCH_POLL_MS, EARLY_BALANCE_DELAY_MS, FINALITY_SETTLE_WINDOW_SLOTS, PUBLIC_READ_ANSWER_MS, LINK_READ_ANSWER_MS, OWN_READS_AHEAD_MS, OWN_PUBLIC_KNOWN_MS, FLOAT_CORRECT_WAIT_MS, SWITCH_WAIT_MS, UNSHIELD_TO_NO_USDC_DETAIL, UNSHIELD_TO_INVALID_NEXT, INFERENCE_MIN_MAX_TOKENS, ELICIT_TIMEOUT_MS, ALLOW_BOX_HOSTS, ALLOW_BOX_PROGRESS_MS, ELICIT_UNSHOWN_MS, elicitUnshown, POLL_SECONDS2, TEMP_CLEAN_DELAY_MS, KEPT_ON_DISK, MAX_SHIELDED_BALANCE_ATOMIC, receiveGenerator, MCP_TOOL_NAMES, MCP_HIDDEN_TOOL_NAMES, setupTerminalNext, SETUP_RUNNING_SAY, SETUP_WAITING_SAY, ACCEPTED_NEXT, SETUP_RUNNING_NEXT, SETUP_ANSWER_WAIT_MS, SETUP_CONFIRMING_SAY, SETUP_CONFIRMING_NEXT, OWN_ADDRESS_QUESTION, OWN_ADDRESS_WHERE, OWN_ADDRESS_INVALID, HOST_CHAT_NOT_PRIVATE, PRIVATE_INFERENCE_WHY, RESTART_STEPS, HOST_BLOCKED_LINE, TOR_BROWSER_PORT, SETUP_TOR_TITLE, SETUP_TOR_WHY;
|
|
145428
|
+
var import_web3133, X402_V1_NEXT, shownCaps, RELEASE_RETRY_MS, STAGE_WORDS, stageWords, INTERNAL_BALANCE_DETAIL, shownBreakdown, sessionLeftShown, RESOURCE_PAYMENT_WAL_PREFIX2, POOL_LAYOUT_CODE, POOL_LAYOUT_UPDATE, USEPOD_VIA_INFERENCE_CHAT, SEND_RUNS_ON, DEPOSIT_RUNS_ON, CLI_FUNDS_PLAN_PREFIX, CLI_FUNDS_SCHEMA, SELF_PAY_ORIGIN3, REQUEST_ID4, POSITIVE_ATOMIC6, PRIVATE_HOST3, FORBIDDEN_HEADERS3, MAX_BODY_BYTES2, PREVIEW_TIMEOUT_MS, PREVIEW_SELLER_READ_MS, CALL_BUDGET_MS, budgetLeft, PAY_ANSWER_MARGIN_MS, MONEY_FIRST_ANSWER_MS, BALANCE_AFTER_LANDING_MS, JOIN_CALL_MAX_MS, JOIN_CALL_ANSWER_MARGIN_S, PAY_AFTER_JOIN_MS, joinAnswerSeconds, JOIN_TIME_MS, JOIN_NUDGE_QUIET_MS, JOIN_STEP_MS, sleep2, PROGRESS_EVERY_MS2, READ_BUDGET_MS, UNPAID_TOR_TRY_MS, UNPAID_CLEAR_MS, READ_BUDGET_TOOLS, FLOAT_BUSY_CODES, RETRY_MARGIN_MS, ASK_PAY_CODES, runningNpmVersion, terminalCommand2, capPlaceWords, noLimitSetLine, CAP_NAMES, capName, entryPlaces, capRaiseText, runningLimits, payCapFlag, noPriceFits, cheaperText, limitNext, overLimitStep, SAFE_TEXT, causesLog, MCP_TOOL_ALIASES, POOL_SWITCH_WHY, POOL_SWITCH_NEXT, SWITCH_STATES, quietSwitch, switchKey, ATOMIC_TEXT, MAX_PAYMENT_ATOMIC_LEAST, movedTo, FLOAT_ID2, ANSWERED_EXIT_RETRY_MS, ANSWERED_EXIT_UNCONFIRMED_MS, ANSWERED_EXIT_RETRY_WINDOW_MS, ANSWERED_EXIT_CLOSED, switchAmount, switchEta, switchRows, OWNER_CAP_CODES, JOIN_END_MCP, JOIN_END_TERMINAL_LIBRARY, JOIN_RETRY_BACKOFF_MS, WALLET_CAP_FIX, ENTRY_CAP_CODES, MCP_CAP_FIX, capFix, ownerOnlyNext, mcpNext, CONFIDENTIAL_RETIRED, json4, answerResult, discoverTool, LAUNCH_CAP_CODES, dayCapKind, refuse11, newRequestIdFor, payCapName, limitQuestion, stableJson, requestPrint, publicOffer, FLOAT_PAID_CODES, FLOAT_NOT_CERTAIN_CODES, FLOAT_PRIVATE_LEG, SELLER_ONLY_HERE, outsideWalletRule, TOR_START_STEP, MONEY_ID2, toRecordId, linkKindOf, moneyId, REFUSED_CODES, SEND_STOPPED, SEND_STOP_NOT_SAVED, sendStoppedError, refusedCodeOf, PLAIN_REASONS, insufficientCause, INSUFFICIENT_REASONS, reasonOf, plainReason, KEPT_SEND_TRIES, shownId, isSplitSend, PROMISED_NEXT, partFailReason, sendAnswerOf, PUBLIC_READ_TIMEOUT_MS, RECIPIENT_CHECK_TIMEOUT_MS, withTimeout, ownKey, readFailure, OWN_KEY_TOKENS_MAX, tokenAmountText, elsewhereId, AGENT_ID_SCHEMA, agentIdName, minutesText2, ageWords2, DEPOSIT_SENT_STATES, depositLanded, usdcText3, walkWalletHistory, REFRESH_LEASE_WALK_MS, HOME_MARKS_SETTLED_MS2, AUTO_BACKUPS_KEPT, AUTO_BACKUP_NAME, AUTO_BACKUP_VERIFIED, FRONTED_SETTLE_MARGIN_SLOTS, UNSHIELD_WINDOW_YIELD_MS, NOT_FINAL_YET, FINISH_FINALITY_WAIT_MS, FINISH_FINALITY_WAITS, FINISH_FINALITY_RECENT_MS, walkStillCurrent, DIRECT_EXIT_GONE, BALANCE_REFRESH_WAIT_MS, BALANCE_REFRESH_GRACE_MS, BALANCE_REFRESH_LONG_MS, INBOUND_REFRESH_AGE_MS, SALE_VIEW_AGE_SECONDS, saleViewRead, balanceTextFields, changeFields, balanceAnswer, CAP_BALANCE_WAIT_MS, CAP_BALANCE_RETRY_MS, REFRESH_RETRY_MS, FINALITY_POLL_MS, FINALITY_WAIT_MS, FINALITY_REFRESH_LIMIT_MS, POOL_WATCH_MS, POOL_WATCH_POLL_MS, EARLY_BALANCE_DELAY_MS, FINALITY_SETTLE_WINDOW_SLOTS, PUBLIC_READ_ANSWER_MS, LINK_READ_ANSWER_MS, OWN_READS_AHEAD_MS, OWN_PUBLIC_KNOWN_MS, FLOAT_CORRECT_WAIT_MS, SWITCH_WAIT_MS, UNSHIELD_TO_NO_USDC_DETAIL, UNSHIELD_TO_INVALID_NEXT, INFERENCE_MIN_MAX_TOKENS, ELICIT_TIMEOUT_MS, ALLOW_BOX_HOSTS, ALLOW_BOX_PROGRESS_MS, ELICIT_UNSHOWN_MS, elicitUnshown, POLL_SECONDS2, TEMP_CLEAN_DELAY_MS, KEPT_ON_DISK, MAX_SHIELDED_BALANCE_ATOMIC, receiveGenerator, MCP_TOOL_NAMES, MCP_HIDDEN_TOOL_NAMES, setupTerminalNext, SETUP_RUNNING_SAY, SETUP_WAITING_SAY, ACCEPTED_NEXT, SETUP_RUNNING_NEXT, SETUP_ANSWER_WAIT_MS, SETUP_CONFIRMING_SAY, SETUP_CONFIRMING_NEXT, OWN_ADDRESS_QUESTION, OWN_ADDRESS_WHERE, OWN_ADDRESS_INVALID, HOST_CHAT_NOT_PRIVATE, PRIVATE_INFERENCE_WHY, RESTART_STEPS, HOST_BLOCKED_LINE, TOR_BROWSER_PORT, SETUP_TOR_TITLE, SETUP_TOR_WHY;
|
|
145386
145429
|
var init_tools = __esm({
|
|
145387
145430
|
"wallet/src/mcp/tools.mjs"() {
|
|
145388
145431
|
"use strict";
|
|
@@ -145410,6 +145453,7 @@ var init_tools = __esm({
|
|
|
145410
145453
|
init_payResource();
|
|
145411
145454
|
init_memoryOnly();
|
|
145412
145455
|
init_balanceNow();
|
|
145456
|
+
init_plan();
|
|
145413
145457
|
init_emptyBalance();
|
|
145414
145458
|
init_knownZero();
|
|
145415
145459
|
init_publicRead();
|
|
@@ -145897,6 +145941,19 @@ var init_tools = __esm({
|
|
|
145897
145941
|
BALANCE_REFRESH_LONG_MS = 6e4;
|
|
145898
145942
|
INBOUND_REFRESH_AGE_MS = 6e4;
|
|
145899
145943
|
SALE_VIEW_AGE_SECONDS = 15;
|
|
145944
|
+
balanceTextFields = (one) => {
|
|
145945
|
+
const ready = String(one?.paymentReadyAtomic ?? "");
|
|
145946
|
+
const largest = String(one?.largestPaymentAtomic ?? "");
|
|
145947
|
+
return {
|
|
145948
|
+
balanceAtomic: one?.balanceAtomic ?? null,
|
|
145949
|
+
largestPaymentAtomic: one?.largestPaymentAtomic ?? null,
|
|
145950
|
+
.../^0*[1-9][0-9]*$/.test(String(one?.belowAccountsAtomic ?? "")) ? { belowAccountsAtomic: one.belowAccountsAtomic } : {},
|
|
145951
|
+
...ATOMIC_TEXT.test(ready) && ATOMIC_TEXT.test(largest) && BigInt(ready) > BigInt(largest) ? { paymentReadyAtomic: ready } : {},
|
|
145952
|
+
...changeFields(one),
|
|
145953
|
+
...one?.receivedOnly === true ? { receivedOnly: true } : {},
|
|
145954
|
+
balance: one?.balance ?? null
|
|
145955
|
+
};
|
|
145956
|
+
};
|
|
145900
145957
|
changeFields = (one) => {
|
|
145901
145958
|
if (one?.changeSettling !== true) return {};
|
|
145902
145959
|
const shown = String(one.balanceAtomic ?? one.spendableAtomic ?? "");
|
|
@@ -145909,14 +145966,7 @@ var init_tools = __esm({
|
|
|
145909
145966
|
...Number.isSafeInteger(one.changeCount) && one.changeCount >= 2 ? { changeCount: one.changeCount } : {}
|
|
145910
145967
|
};
|
|
145911
145968
|
};
|
|
145912
|
-
balanceAnswer = (one, { shown = true } = {}) => one ? {
|
|
145913
|
-
balanceAtomic: one.balanceAtomic,
|
|
145914
|
-
largestPaymentAtomic: one.largestPaymentAtomic ?? null,
|
|
145915
|
-
...changeFields(one),
|
|
145916
|
-
...one.receivedOnly === true ? { receivedOnly: true } : {},
|
|
145917
|
-
balance: one.balance,
|
|
145918
|
-
breakdown: shown ? shownBreakdown(one.breakdown) : one.breakdown
|
|
145919
|
-
} : {};
|
|
145969
|
+
balanceAnswer = (one, { shown = true } = {}) => one ? { ...balanceTextFields(one), breakdown: shown ? shownBreakdown(one.breakdown) : one.breakdown } : {};
|
|
145920
145970
|
CAP_BALANCE_WAIT_MS = 35e3;
|
|
145921
145971
|
CAP_BALANCE_RETRY_MS = 5e3;
|
|
145922
145972
|
REFRESH_RETRY_MS = 6e4;
|
|
@@ -154933,7 +154983,8 @@ async function main5(args = process.argv.slice(2), { output: output2 = (result)
|
|
|
154933
154983
|
later: plan.later.map(shown)
|
|
154934
154984
|
};
|
|
154935
154985
|
const nothing = merges.length === 0;
|
|
154936
|
-
const
|
|
154986
|
+
const below2 = notesBelowEveryAccount(snapshotRead.snapshot.outputs.filter((output3) => output3.spendStatus === "unspent"));
|
|
154987
|
+
const why = !plan.keep || plan.steps.length + plan.later.length === 0 ? below2.length === 0 ? "nothing to do: one funded deposit (or none) holds the private balance, so one payment already draws it all (with up to 3 notes)" : `nothing to do: joining cannot help. One payment already draws all it can reach, and ${below2.length} received ${below2.length === 1 ? "payment" : "payments"} of ${usdc5(below2.reduce((sum2, output3) => sum2 + BigInt(output3.valueAtomic), 0n).toString())} USDC can only be sent out, one per send (${commandLine("unshield")}), until you add funds` : nothing ? `nothing to do this round: the last steps are final and the saved balance is older; run ${commandLine("balance --refresh")}, then ${commandLine("prepare")} again` : void 0;
|
|
154937
154988
|
if (dryRun || nothing) {
|
|
154938
154989
|
output2({ dryRun, ...summary, ...why ? { next: why } : {
|
|
154939
154990
|
next: "run the same command without --dry-run (after setup it needs no flags; without setup add --proof-tools, --profile and --facilitator); nothing was signed or sent"
|
|
@@ -157536,6 +157587,7 @@ init_recoveredPayment();
|
|
|
157536
157587
|
init_recover();
|
|
157537
157588
|
init_scheduler();
|
|
157538
157589
|
init_balance();
|
|
157590
|
+
init_plan();
|
|
157539
157591
|
init_secretFile();
|
|
157540
157592
|
init_setup();
|
|
157541
157593
|
init_serveRunner();
|
|
@@ -158983,10 +159035,12 @@ function shortText(short, options) {
|
|
|
158983
159035
|
${stepWords(short.addFundsOpen ? "To continue it" : "To add money", "add-funds", `${cli4()} add-funds`)}`;
|
|
158984
159036
|
}
|
|
158985
159037
|
var shortRefusal = (short, options) => new PublicFailure(`${EMPTY_BALANCE_CODE}: ${shortText(short, options)}`);
|
|
158986
|
-
function
|
|
159038
|
+
function savedWalkOnlySelfPays(store) {
|
|
158987
159039
|
try {
|
|
158988
159040
|
const snapshot = readBalanceSnapshot(store).snapshot;
|
|
158989
|
-
|
|
159041
|
+
if (snapshot?.pool !== store.state.pool || !Array.isArray(snapshot.outputs)) return false;
|
|
159042
|
+
const unspent = snapshot.outputs.filter((output2) => output2.spendStatus === "unspent");
|
|
159043
|
+
return unspent.some((output2) => output2.kind === "account") && notesBelowEveryAccount(unspent).length === 0;
|
|
158990
159044
|
} catch {
|
|
158991
159045
|
return false;
|
|
158992
159046
|
}
|
|
@@ -159017,7 +159071,7 @@ async function stopWhenShort(values, deps, { needAtomic = 1n, costAtomic, paymen
|
|
|
159017
159071
|
} catch {
|
|
159018
159072
|
noWalk = false;
|
|
159019
159073
|
}
|
|
159020
|
-
if (!knownShortBalance(store, { needAtomic, payment }) && !noWalk && !(noAccount && !
|
|
159074
|
+
if (!knownShortBalance(store, { needAtomic, payment }) && !noWalk && !(noAccount && !savedWalkOnlySelfPays(store))) return false;
|
|
159021
159075
|
await checkFloatRefunds(store, values, deps, () => commandStore(values, deps));
|
|
159022
159076
|
const read = await readBalanceFromChain(store, values, deps);
|
|
159023
159077
|
if (read === "failed") deps.io.err(`Your private balance could not be read from the chain now; the ${payment ? "payment" : "send"} reads it again before it signs anything.
|
|
@@ -164997,7 +165051,7 @@ function directExitRefusal(error, { unshieldId }) {
|
|
|
164997
165051
|
const code2 = /^(mcp_[a-z_]+):/.exec(message)?.[1];
|
|
164998
165052
|
if (code2 === "mcp_unshield_received_payment_too_small") {
|
|
164999
165053
|
const largest = /^[0-9]{1,31}$/.test(String(error.largestReceivedAtomic ?? "")) ? usdcOr(error.largestReceivedAtomic) : void 0;
|
|
165000
|
-
return unshieldRefusal("received_payment_too_small", `
|
|
165054
|
+
return unshieldRefusal("received_payment_too_small", `one send moves one part of your balance${largest ? ` (the largest is ${largest})` : ""}; nothing was sent. Run ${cli4()} unshield again with ${largest ? `${largest} or less` : "a smaller amount"}`);
|
|
165001
165055
|
}
|
|
165002
165056
|
if (code2 === "mcp_unshield_received_payment_gone") {
|
|
165003
165057
|
return unshieldRefusal("received_payment_gone", `the received payment this send chose is no longer in the wallet (another send used it, or the last balance read was old); nothing was sent. Run ${cli4()} balance, then ${cli4()} unshield again`);
|
|
@@ -165211,7 +165265,7 @@ async function runUnshieldRequest(args, values, deps, io) {
|
|
|
165211
165265
|
let directExit = terminalDirectExit;
|
|
165212
165266
|
try {
|
|
165213
165267
|
const wallet = openStore();
|
|
165214
|
-
if (!wallet.readWal(`self-pay-${id}`) &&
|
|
165268
|
+
if (!wallet.readWal(`self-pay-${id}`) && savedWalkOnlySelfPays(wallet)) directExit = void 0;
|
|
165215
165269
|
} catch {
|
|
165216
165270
|
}
|
|
165217
165271
|
let shown = false;
|
|
@@ -165382,6 +165436,19 @@ function unfinishedUnshields(store) {
|
|
|
165382
165436
|
};
|
|
165383
165437
|
}).sort((a, b) => a.startedAtMs - b.startedAtMs).map(({ startedAtMs: _at, ...one }) => one);
|
|
165384
165438
|
}
|
|
165439
|
+
function unshieldIdLine(id, values, deps) {
|
|
165440
|
+
if (!id) return "";
|
|
165441
|
+
const line = `this unshield's id is ${id}: to rerun or finish it, run the same command with --unshield-id ${id} added (it never sends twice)
|
|
165442
|
+
`;
|
|
165443
|
+
try {
|
|
165444
|
+
const store = commandStore(values, deps);
|
|
165445
|
+
if (!store) return line;
|
|
165446
|
+
const record = store.readWal(`self-pay-${id}`);
|
|
165447
|
+
return terminalSendResumable(store, id, record, plannedPartIds(store)) || partMayHaveSigned(store, { unshieldId: id }) ? line : "";
|
|
165448
|
+
} catch {
|
|
165449
|
+
return line;
|
|
165450
|
+
}
|
|
165451
|
+
}
|
|
165385
165452
|
var unfinishedUnshieldLine = ({ unshieldId, amountAtomic, answered: answered2, exitTransaction, resumable, to }) => {
|
|
165386
165453
|
if (resumable) {
|
|
165387
165454
|
return answered2 ? `${usdcOr(amountAtomic)} was sent to ${to ?? "your address"} (transaction ${exitTransaction}); run ${cli4()} unshield all to finish the wallet's own record of it.` : `${usdcOr(amountAtomic)} is still on its way${to ? ` to ${to}` : ""}; run ${cli4()} unshield all to finish it.`;
|
|
@@ -165488,6 +165555,11 @@ async function sendAllAtomic(values, deps, io, openStore, ensureId) {
|
|
|
165488
165555
|
const short = knownShortBalance(openStore());
|
|
165489
165556
|
throw short ? shortRefusal(short) : new PublicFailure(`${EMPTY_BALANCE_CODE}: ${emptyBalanceWords({ surface: "cli", addFundsCommand: stepName("add-funds", `${cli4()} add-funds`) })}`);
|
|
165490
165557
|
}
|
|
165558
|
+
const below2 = BigInt(report.detail?.belowAccountsAtomic ?? "0");
|
|
165559
|
+
if (report.status === "current" && below2 > 0n && !(report.detail.belowAccountsNotes === 1 && below2 === BigInt(report.atomic))) {
|
|
165560
|
+
const oneSend = String(largestPaymentOf(report) ?? "0");
|
|
165561
|
+
throw new PublicFailure(`unshield_all_needs_several_sends: your private balance of ${usdcOr(report.atomic)} cannot go in one send; nothing was sent. ${BigInt(oneSend) > 0n ? `${usdcOr(oneSend)} can go as one send, and ` : ""}${report.detail.belowAccountsNotes} received ${report.detail.belowAccountsNotes === 1 ? "payment needs its own send" : "payments need a send each"} (the largest is ${usdcOr(report.detail.belowAccountsLargestAtomic)}). Run ${cli4()} unshield --amount <USDC> --to <your wallet address> for each one`);
|
|
165562
|
+
}
|
|
165491
165563
|
const parts = joinParts(store);
|
|
165492
165564
|
const join49 = parts?.joining > 0 || parts?.parts > 1 && report.status === "current";
|
|
165493
165565
|
if (join49) report = await joinForSendAll(report, parts, store, values, deps, io, ensureId);
|
|
@@ -166540,6 +166612,9 @@ function insufficientWords(cause, parts, { selfJoin = false, send: send3 = false
|
|
|
166540
166612
|
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`;
|
|
166541
166613
|
default: {
|
|
166542
166614
|
const words2 = balanceWords(parts);
|
|
166615
|
+
if (send3) {
|
|
166616
|
+
return `your private balance cannot send this amount now. Nothing was signed or sent. ${words2 ? `${words2}. ` : `${cli4()} balance shows what you can send. `}Send a smaller amount, or add funds (${cli4()} help add-funds), then run the command again`;
|
|
166617
|
+
}
|
|
166543
166618
|
return `your private balance is less than this amount needs (price + fee). Nothing was signed, the quote was dropped, and its budget came back, so nothing blocks your next payment. ${words2 ? `${words2}. ` : `${cli4()} balance shows what you can spend. `}Add funds (${cli4()} help add-funds), then rerun this command`;
|
|
166544
166619
|
}
|
|
166545
166620
|
}
|
|
@@ -168146,8 +168221,7 @@ Next: fund that address, then rerun the same command; it continues where it stop
|
|
|
168146
168221
|
if (hint && ["curl", "pay", "unshield"].includes(command?.name) && codes.some((code2) => /^p03_merchant_respend_(insufficient_recovered_value|accounts_split_merge_first)$/.test(code2))) {
|
|
168147
168222
|
const made = command.name === "unshield" ? values?.get?.(UNSHIELD_MADE_ID) : void 0;
|
|
168148
168223
|
io.err(`${hint[0].toUpperCase()}${hint.slice(1).replace(/[\s.;]+$/, "")}.
|
|
168149
|
-
|
|
168150
|
-
` : ""));
|
|
168224
|
+
${unshieldIdLine(made, values, deps)}`);
|
|
168151
168225
|
return 1;
|
|
168152
168226
|
}
|
|
168153
168227
|
if (hint && ANCHOR_REFUSAL.test([...codes, reason].join(" "))) {
|
|
@@ -168174,8 +168248,7 @@ Next: fund that address, then rerun the same command; it continues where it stop
|
|
|
168174
168248
|
` : "";
|
|
168175
168249
|
const madeId = /use_new_unshield_id|new --unshield-id/.test(`${reason} ${hint ?? ""}`) || UNSHIELD_ID_CLOSED.test(reason) ? void 0 : values?.get?.(UNSHIELD_MADE_ID);
|
|
168176
168250
|
const inferId = values?.get?.(INFER_STOPPED_ID);
|
|
168177
|
-
const idLine = madeId ?
|
|
168178
|
-
` : inferId ? `${inferStopLine(inferId, values, deps)}
|
|
168251
|
+
const idLine = madeId ? unshieldIdLine(madeId, values, deps) : inferId ? `${inferStopLine(inferId, values, deps)}
|
|
168179
168252
|
` : "";
|
|
168180
168253
|
if (hint && (command?.name === "infer" || command?.name === "curl") && FLOAT_OUTCOME_CODE.test(reason)) {
|
|
168181
168254
|
const runAgain = command.name !== "infer" || /the command below/.test(hint);
|