shinjuku-shield 0.3.134 → 0.3.136
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 +5 -5
- package/manifest.json +4 -4
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +202 -91
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.136. 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.136
|
|
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.136 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.136 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.136", "mcp"] } } }
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
On native Windows, if the host cannot find `npx`, use `"command": "cmd"` and
|
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": "24c033c4a5ba30b63911674d18a731e7ad32c2bb22f660dc451dd2af6258a275",
|
|
5
|
+
"bytes": 8900675,
|
|
6
|
+
"sourceCommit": "edde08b7e130bd8905165c8868af9f52ec7817b5",
|
|
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",
|
|
@@ -1037,5 +1037,5 @@
|
|
|
1037
1037
|
"version": "1.8.0"
|
|
1038
1038
|
}
|
|
1039
1039
|
],
|
|
1040
|
-
"publishedAt": "2026-10-
|
|
1040
|
+
"publishedAt": "2026-10-31T17:35:38.949Z"
|
|
1041
1041
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shield",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.136",
|
|
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": "24c033c4",
|
|
7
|
+
"shinjukuSha256": "24c033c4a5ba30b63911674d18a731e7ad32c2bb22f660dc451dd2af6258a275",
|
|
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
|
@@ -60100,10 +60100,19 @@ function prewarmWalletP03History(args) {
|
|
|
60100
60100
|
const runKey = lastRunReportKey(args.store, args.programId, args.pool, args.deploymentIdentity, args.cache);
|
|
60101
60101
|
if (runKey === void 0) return false;
|
|
60102
60102
|
const prior = prewarmedWalks.get(runKey);
|
|
60103
|
-
|
|
60103
|
+
const recheck = prior !== void 0 && prior.settled === true && Number.isFinite(args.paymentStartedAt) && prior.startedAt < args.paymentStartedAt;
|
|
60104
|
+
if (prior !== void 0 && !recheck && Date.now() - prior.startedAt <= HISTORY_PREWARM_JOIN_MS) {
|
|
60104
60105
|
latestPrewarm = prior.promise;
|
|
60105
60106
|
return true;
|
|
60106
60107
|
}
|
|
60108
|
+
if (recheck && Date.now() - prior.startedAt <= HISTORY_PREWARM_JOIN_MS) {
|
|
60109
|
+
const kept2 = prior.report;
|
|
60110
|
+
const recent = recentLoads.get(runKey);
|
|
60111
|
+
if (kept2 !== null && typeof kept2 === "object" && prior.startedAt >= proofBuiltAt && !PAYMENT_TAKEN_REPORTS.has(kept2) && (recent === void 0 || recentAgeStart(recent) < prior.startedAt)) {
|
|
60112
|
+
recentLoads.set(runKey, { startedAt: prior.startedAt, report: kept2, ageFrom: prior.startedAt });
|
|
60113
|
+
}
|
|
60114
|
+
markPhase("prewarm-recheck");
|
|
60115
|
+
}
|
|
60107
60116
|
const shared2 = sharedWalks.get(runKey);
|
|
60108
60117
|
if (shared2 !== void 0 && Date.now() - shared2.startedAt <= HISTORY_PREWARM_JOIN_MS) {
|
|
60109
60118
|
shared2.joined = true;
|
|
@@ -60136,12 +60145,14 @@ function prewarmWalletP03History(args) {
|
|
|
60136
60145
|
}
|
|
60137
60146
|
const marks = walletHistoryHomeMarks(args.store);
|
|
60138
60147
|
const entry = { startedAt: Date.now(), settled: false, marks };
|
|
60139
|
-
|
|
60148
|
+
const { paymentStartedAt: _paymentStartedAt, ...walkArgs } = args;
|
|
60149
|
+
entry.promise = loadWalletP03HistoryNow({ ...walkArgs, forceRead: false, onListed: () => {
|
|
60140
60150
|
entry.listedAt ??= Date.now();
|
|
60141
60151
|
} });
|
|
60142
60152
|
entry.promise.then(prepareReport).catch(() => {
|
|
60143
60153
|
});
|
|
60144
|
-
entry.promise.then(() => {
|
|
60154
|
+
entry.promise.then((report) => {
|
|
60155
|
+
entry.report = report;
|
|
60145
60156
|
entry.settled = true;
|
|
60146
60157
|
}, () => {
|
|
60147
60158
|
entry.settled = true;
|
|
@@ -60682,7 +60693,7 @@ var init_walletHistory = __esm({
|
|
|
60682
60693
|
recentScope = new AsyncLocalStorage3();
|
|
60683
60694
|
withRecentWalletHistory = (fn, { accept } = {}) => recentScope.run({ accept }, fn);
|
|
60684
60695
|
recentLoads = /* @__PURE__ */ new Map();
|
|
60685
|
-
recentAgeStart = (recent) => poolReadAtOf(recent.report) ?? recent.startedAt;
|
|
60696
|
+
recentAgeStart = (recent) => recent.ageFrom ?? poolReadAtOf(recent.report) ?? recent.startedAt;
|
|
60686
60697
|
forgetRecentWalletHistory = () => {
|
|
60687
60698
|
recentLoads.clear();
|
|
60688
60699
|
proofBuiltAt = Date.now();
|
|
@@ -110041,6 +110052,7 @@ function onOwnTorCircuit(pay) {
|
|
|
110041
110052
|
}
|
|
110042
110053
|
async function payTurn({ session, target, method, headers, body, maxPrice, policy, cap, requestId, memoryOnly, opts }) {
|
|
110043
110054
|
if (session.closed) fail25("fetch_session_closed", "this payer session is closed; open a new one");
|
|
110055
|
+
const paymentStartedAt = Date.now();
|
|
110044
110056
|
const timing = typeof opts?.timing === "function" ? opts.timing : session.timing();
|
|
110045
110057
|
const mark = (phase) => {
|
|
110046
110058
|
try {
|
|
@@ -110057,7 +110069,7 @@ async function payTurn({ session, target, method, headers, body, maxPrice, polic
|
|
|
110057
110069
|
let askLeg1;
|
|
110058
110070
|
if (!rerun) {
|
|
110059
110071
|
if (store !== void 0) {
|
|
110060
|
-
startHistoryPrewarm(session, store, mark);
|
|
110072
|
+
startHistoryPrewarm(session, store, mark, paymentStartedAt);
|
|
110061
110073
|
warmFloatPay({ store, connection: session.connection });
|
|
110062
110074
|
warmFloatConfig({ origin: new URL(session.memoServiceUrl).origin, timing: mark });
|
|
110063
110075
|
startRecoveredPaymentTools(lazyProofTools(session));
|
|
@@ -110142,6 +110154,7 @@ async function payTurn({ session, target, method, headers, body, maxPrice, polic
|
|
|
110142
110154
|
timing,
|
|
110143
110155
|
mark,
|
|
110144
110156
|
memoryOnly,
|
|
110157
|
+
paymentStartedAt,
|
|
110145
110158
|
answerByMs: opts?.answerByMs,
|
|
110146
110159
|
paidFrom: opts?.paidFrom
|
|
110147
110160
|
}).finally(rotateTorCircuit));
|
|
@@ -110239,10 +110252,11 @@ function warmPaymentHistory(session) {
|
|
|
110239
110252
|
} catch {
|
|
110240
110253
|
}
|
|
110241
110254
|
}
|
|
110242
|
-
function startHistoryPrewarm(session, store, mark) {
|
|
110255
|
+
function startHistoryPrewarm(session, store, mark, paymentStartedAt) {
|
|
110243
110256
|
try {
|
|
110244
110257
|
withPhaseScope(mark, "prewarm", () => prewarmWalletP03History({
|
|
110245
110258
|
store,
|
|
110259
|
+
paymentStartedAt,
|
|
110246
110260
|
connection: connectSplit(session.connection, session.historyUrl),
|
|
110247
110261
|
programId: session.programId,
|
|
110248
110262
|
pool: store.state.pool,
|
|
@@ -110356,7 +110370,7 @@ function startedIds(policy) {
|
|
|
110356
110370
|
if (ids === void 0) startedUnder.set(policy, ids = /* @__PURE__ */ new Set());
|
|
110357
110371
|
return ids;
|
|
110358
110372
|
}
|
|
110359
|
-
async function paidCall({ session, target, method, headers, body, cap, maxPrice, requestId, price, challenge, timing, mark, memoryOnly = false, answerByMs, paidFrom }) {
|
|
110373
|
+
async function paidCall({ session, target, method, headers, body, cap, maxPrice, requestId, price, challenge, timing, mark, memoryOnly = false, paymentStartedAt, answerByMs, paidFrom }) {
|
|
110360
110374
|
if (session.closed) fail25("fetch_session_closed", "this payer session is closed; open a new one");
|
|
110361
110375
|
const floatConfig = price?.floatConfig;
|
|
110362
110376
|
const release = await paymentLease(session);
|
|
@@ -110383,7 +110397,7 @@ async function paidCall({ session, target, method, headers, body, cap, maxPrice,
|
|
|
110383
110397
|
throw error;
|
|
110384
110398
|
}
|
|
110385
110399
|
}
|
|
110386
|
-
if (own?.kind !== "pocket" && !replayOnly) startHistoryPrewarm(session, store, mark);
|
|
110400
|
+
if (own?.kind !== "pocket" && !replayOnly) startHistoryPrewarm(session, store, mark, paymentStartedAt);
|
|
110387
110401
|
const policy = session.spendPolicy;
|
|
110388
110402
|
const prepared = preparedOnly(own, store);
|
|
110389
110403
|
const askPrepared = prepared && sendsKeptBytes(own, {
|
|
@@ -112472,6 +112486,142 @@ var init_publicRead = __esm({
|
|
|
112472
112486
|
}
|
|
112473
112487
|
});
|
|
112474
112488
|
|
|
112489
|
+
// wallet/src/pay/floatRefundCheck.mjs
|
|
112490
|
+
function floatNeverLanded(store, float, requestId) {
|
|
112491
|
+
try {
|
|
112492
|
+
if (!float || float.state === "cancelled") return false;
|
|
112493
|
+
const inner = typeof float.innerRequestId === "string" && float.innerRequestId ? float.innerRequestId : typeof requestId === "string" ? floatInnerRequestId(requestId) : void 0;
|
|
112494
|
+
return floatLegNeverLanded(store, inner);
|
|
112495
|
+
} catch {
|
|
112496
|
+
return false;
|
|
112497
|
+
}
|
|
112498
|
+
}
|
|
112499
|
+
function staleFloatRefundNames(store, now = Date.now()) {
|
|
112500
|
+
const names = [];
|
|
112501
|
+
for (const name of store.listWal()) {
|
|
112502
|
+
if (!name.startsWith(FLOAT_PAYMENT_WAL_PREFIX2)) continue;
|
|
112503
|
+
let record;
|
|
112504
|
+
try {
|
|
112505
|
+
record = store.readWal(name);
|
|
112506
|
+
} catch {
|
|
112507
|
+
continue;
|
|
112508
|
+
}
|
|
112509
|
+
if (floatRecordState(record) === "submitted") {
|
|
112510
|
+
const age = Number.isSafeInteger(floatEndedAtMs(record)) ? now - floatEndedAtMs(record) : NaN;
|
|
112511
|
+
if (age > SUBMITTED_READ_AFTER_MS && (age < 2 * STALE_FLOAT_REFUND_MS || record.ambiguous === true)) names.push(name);
|
|
112512
|
+
continue;
|
|
112513
|
+
}
|
|
112514
|
+
if (floatRecordState(record) !== "refund_pending" || record.refundOutcome === "refund_arrived" || !Number.isSafeInteger(record.refundPendingAtMs)) continue;
|
|
112515
|
+
if (now - record.refundPendingAtMs > STALE_FLOAT_REFUND_MS || floatRefundReadDue(record, now)) names.push(name);
|
|
112516
|
+
}
|
|
112517
|
+
return names;
|
|
112518
|
+
}
|
|
112519
|
+
async function readFloatRefunds(store, names, { fetchImpl = fetch, untilMs = Date.now() + 3e3, now = Date.now() } = {}) {
|
|
112520
|
+
const due = [];
|
|
112521
|
+
for (const name of names) {
|
|
112522
|
+
if (!name.startsWith(FLOAT_PAYMENT_WAL_PREFIX2)) continue;
|
|
112523
|
+
let record;
|
|
112524
|
+
try {
|
|
112525
|
+
record = store.readWal(name);
|
|
112526
|
+
} catch {
|
|
112527
|
+
continue;
|
|
112528
|
+
}
|
|
112529
|
+
if (!FLOAT_ID.test(String(record?.floatId)) || floatNeverLanded(store, record)) continue;
|
|
112530
|
+
const state = floatRecordState(record);
|
|
112531
|
+
if (state !== "refund_pending" && state !== "submitted") continue;
|
|
112532
|
+
if (state === "submitted" && record.memoryOnly === true && !memoryRequestHeld(record)) continue;
|
|
112533
|
+
if (!(now - floatEndedAtMs(record) < FLOAT_REFUND_READ_AGE_MS)) continue;
|
|
112534
|
+
due.push({ name, record, state });
|
|
112535
|
+
}
|
|
112536
|
+
due.sort((left, right) => floatEndedAtMs(right.record) - floatEndedAtMs(left.record));
|
|
112537
|
+
const proven = [];
|
|
112538
|
+
let refunded = 0;
|
|
112539
|
+
const reads = due.slice(0, FLOAT_REFUND_READS).map(({ name, record, state }) => readFloatTransferState(record, fetchImpl).then((read) => {
|
|
112540
|
+
if (read?.state === "final") proven.push({ name, from: record.state, verdict: "final", transaction: read.transaction });
|
|
112541
|
+
else if (read?.state === "cancelled") proven.push({ name, from: record.state, verdict: "cancelled" });
|
|
112542
|
+
else if (read?.state === "dead" && typeof read.floatState === "string") {
|
|
112543
|
+
if (read.floatState === "refunded" && read.refundTransaction) refunded += 1;
|
|
112544
|
+
if (state === "submitted") proven.push({ name, from: record.state, verdict: "dead", refundDueAtMs: read.refundDueAtMs });
|
|
112545
|
+
}
|
|
112546
|
+
}, () => void 0));
|
|
112547
|
+
const wait2 = new Promise((resolve35) => {
|
|
112548
|
+
const timer = setTimeout(resolve35, Math.max(0, untilMs - Date.now()));
|
|
112549
|
+
timer.unref?.();
|
|
112550
|
+
});
|
|
112551
|
+
await Promise.race([Promise.all(reads), wait2]);
|
|
112552
|
+
return { proven: [...proven], refunded };
|
|
112553
|
+
}
|
|
112554
|
+
async function checkFloatRefundsNow({ store, reopen, lockPath: lockPath2, fetchImpl = fetch, now = Date.now(), acquireLease = acquireWalletProcessLease }) {
|
|
112555
|
+
let names;
|
|
112556
|
+
try {
|
|
112557
|
+
names = staleFloatRefundNames(store, now);
|
|
112558
|
+
} catch {
|
|
112559
|
+
return { written: 0, refunded: 0 };
|
|
112560
|
+
}
|
|
112561
|
+
if (!names.length) return { written: 0, refunded: 0 };
|
|
112562
|
+
const { proven, refunded } = await readFloatRefunds(store, names, { fetchImpl, untilMs: Date.now() + 3e3, now });
|
|
112563
|
+
if (!proven.length) return { written: 0, refunded };
|
|
112564
|
+
let release;
|
|
112565
|
+
try {
|
|
112566
|
+
release = await acquireLease(lockPath2);
|
|
112567
|
+
} catch {
|
|
112568
|
+
return { written: 0, refunded };
|
|
112569
|
+
}
|
|
112570
|
+
try {
|
|
112571
|
+
return { written: writeProvenFloatStates(reopen(), proven), refunded };
|
|
112572
|
+
} catch {
|
|
112573
|
+
return { written: 0, refunded };
|
|
112574
|
+
} finally {
|
|
112575
|
+
try {
|
|
112576
|
+
await release();
|
|
112577
|
+
} catch {
|
|
112578
|
+
}
|
|
112579
|
+
}
|
|
112580
|
+
}
|
|
112581
|
+
function writeProvenFloatStates(store, proven) {
|
|
112582
|
+
let written = 0;
|
|
112583
|
+
for (const { name, from, verdict, transaction, refundDueAtMs, fill } of proven) {
|
|
112584
|
+
const record = store.readWal(name);
|
|
112585
|
+
if (record?.state !== from) continue;
|
|
112586
|
+
const { ambiguous: _settled, refundDueAtMs: _due, ...rest } = record;
|
|
112587
|
+
const landed = SIGNATURE_TEXT.test(String(transaction ?? "")) ? { landedTransaction: transaction } : {};
|
|
112588
|
+
if (fill) {
|
|
112589
|
+
if (knownSellerTransfer(record) !== null || !landed.landedTransaction) continue;
|
|
112590
|
+
store.writeWal(name, { ...record, ...landed });
|
|
112591
|
+
} else if (verdict === "dead" && floatRecordState(record) === "submitted") {
|
|
112592
|
+
store.writeWal(name, {
|
|
112593
|
+
...rest,
|
|
112594
|
+
state: "refund_pending",
|
|
112595
|
+
refundPendingAtMs: record.refundPendingAtMs ?? Date.now(),
|
|
112596
|
+
...Number.isSafeInteger(refundDueAtMs) ? { refundDueAtMs } : {}
|
|
112597
|
+
});
|
|
112598
|
+
} else if (verdict === "final") {
|
|
112599
|
+
store.writeWal(name, { ...rest, state: "seller_kept", sellerKeptAtMs: record.sellerKeptAtMs ?? Date.now(), ...landed });
|
|
112600
|
+
} else if (verdict === "cancelled") {
|
|
112601
|
+
store.writeWal(name, { ...rest, state: "cancelled", cancelledAtMs: record.cancelledAtMs ?? Date.now() });
|
|
112602
|
+
} else continue;
|
|
112603
|
+
written += 1;
|
|
112604
|
+
}
|
|
112605
|
+
return written;
|
|
112606
|
+
}
|
|
112607
|
+
var FLOAT_REFUND_READS, FLOAT_REFUND_READ_AGE_MS, STALE_FLOAT_REFUND_MS, SUBMITTED_READ_AFTER_MS, FLOAT_ID, SIGNATURE_TEXT, floatEndedAtMs, knownSellerTransfer;
|
|
112608
|
+
var init_floatRefundCheck = __esm({
|
|
112609
|
+
"wallet/src/pay/floatRefundCheck.mjs"() {
|
|
112610
|
+
"use strict";
|
|
112611
|
+
init_floatPay();
|
|
112612
|
+
init_memoryOnly();
|
|
112613
|
+
init_processLease();
|
|
112614
|
+
FLOAT_REFUND_READS = 5;
|
|
112615
|
+
FLOAT_REFUND_READ_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
112616
|
+
STALE_FLOAT_REFUND_MS = 2 * FLOAT_REFUND_ETA_SECONDS * 1e3;
|
|
112617
|
+
SUBMITTED_READ_AFTER_MS = 6e4;
|
|
112618
|
+
FLOAT_ID = /^[0-9a-f]{64}$/;
|
|
112619
|
+
SIGNATURE_TEXT = /^[1-9A-HJ-NP-Za-km-z]{64,90}$/;
|
|
112620
|
+
floatEndedAtMs = (record) => Number.isSafeInteger(record.refundPendingAtMs) ? record.refundPendingAtMs : record.submittedAtMs;
|
|
112621
|
+
knownSellerTransfer = (record) => [record?.receipt?.transaction, record?.landedTransaction].find((one) => SIGNATURE_TEXT.test(String(one ?? ""))) ?? null;
|
|
112622
|
+
}
|
|
112623
|
+
});
|
|
112624
|
+
|
|
112475
112625
|
// wallet/src/unshield/cli.mjs
|
|
112476
112626
|
import { randomBytes as randomBytes20 } from "node:crypto";
|
|
112477
112627
|
import { resolve as resolve18 } from "node:path";
|
|
@@ -128256,15 +128406,6 @@ function leg1Transaction(store, float, requestId) {
|
|
|
128256
128406
|
return null;
|
|
128257
128407
|
}
|
|
128258
128408
|
}
|
|
128259
|
-
function floatNeverLanded(store, float, requestId) {
|
|
128260
|
-
try {
|
|
128261
|
-
if (!float || float.state === "cancelled") return false;
|
|
128262
|
-
const inner = typeof float.innerRequestId === "string" && float.innerRequestId ? float.innerRequestId : typeof requestId === "string" ? floatInnerRequestId(requestId) : void 0;
|
|
128263
|
-
return floatLegNeverLanded(store, inner);
|
|
128264
|
-
} catch {
|
|
128265
|
-
return false;
|
|
128266
|
-
}
|
|
128267
|
-
}
|
|
128268
128409
|
function bindUnshieldRecipient(store, unshieldId, amountAtomic, to, requestId) {
|
|
128269
128410
|
const name = `self-pay-${unshieldId}`;
|
|
128270
128411
|
const record = store.readWal(name);
|
|
@@ -131015,10 +131156,10 @@ ${canonical5}`;
|
|
|
131015
131156
|
// force-live 5r, 2026-10-22: the answer gave no id, so nobody could look the refund up).
|
|
131016
131157
|
// refundAtomic and refundEtaSeconds (Shinjuku's time) for a proven refund; an unproven send carries ambiguous: true.
|
|
131017
131158
|
...paidBack ? {
|
|
131018
|
-
...
|
|
131159
|
+
...FLOAT_ID2.test(String(error?.floatId)) ? { floatId: error.floatId } : {},
|
|
131019
131160
|
refundAtomic: error?.paidAtomic ?? null,
|
|
131020
131161
|
...arrived ? { refundArrived: true } : Number.isSafeInteger(error?.refundEtaSeconds) && error.refundEtaSeconds > 0 ? { refundEtaSeconds: error.refundEtaSeconds } : {}
|
|
131021
|
-
} : ambiguous ? { ambiguous: true, ...
|
|
131162
|
+
} : ambiguous ? { ambiguous: true, ...FLOAT_ID2.test(String(error?.floatId)) ? { floatId: error.floatId } : {} } : {},
|
|
131022
131163
|
...balanceAnswer(one)
|
|
131023
131164
|
});
|
|
131024
131165
|
}
|
|
@@ -132154,37 +132295,12 @@ ${canonical5}`;
|
|
|
132154
132295
|
return REQUEST_ID4.test(id) && sha256Hex2(Buffer.from(id, "utf8")) === key ? id : void 0;
|
|
132155
132296
|
};
|
|
132156
132297
|
const finalRefundStates = /* @__PURE__ */ new Map();
|
|
132157
|
-
const
|
|
132158
|
-
const REFUND_STATUS_READ_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
132159
|
-
const floatEndedAtMs = (record) => Number.isSafeInteger(record.refundPendingAtMs) ? record.refundPendingAtMs : record.submittedAtMs;
|
|
132160
|
-
const SIGNATURE_TEXT = /^[1-9A-HJ-NP-Za-km-z]{64,90}$/;
|
|
132161
|
-
const knownSellerTransfer = (record) => [record?.receipt?.transaction, record?.landedTransaction].find((one) => SIGNATURE_TEXT.test(String(one ?? ""))) ?? null;
|
|
132298
|
+
const SIGNATURE_TEXT2 = /^[1-9A-HJ-NP-Za-km-z]{64,90}$/;
|
|
132162
132299
|
const finalTransfers = /* @__PURE__ */ new Map();
|
|
132163
132300
|
const transferMisses = /* @__PURE__ */ new Set();
|
|
132164
132301
|
const sellerTransferUnknown = (record) => ["receipt", "seller_kept"].includes(floatRecordState(record)) && knownSellerTransfer(record) === null;
|
|
132165
132302
|
const floatAnsweredAtMs = (record) => [record.answeredAtMs, record.sellerKeptAtMs, record.submittedAtMs].find(Number.isSafeInteger);
|
|
132166
|
-
const
|
|
132167
|
-
const SUBMITTED_READ_AFTER_MS = 6e4;
|
|
132168
|
-
function staleRefundNames(store) {
|
|
132169
|
-
const names = [];
|
|
132170
|
-
for (const name of store.listWal()) {
|
|
132171
|
-
if (!name.startsWith(FLOAT_PAYMENT_WAL_PREFIX2)) continue;
|
|
132172
|
-
let record;
|
|
132173
|
-
try {
|
|
132174
|
-
record = store.readWal(name);
|
|
132175
|
-
} catch {
|
|
132176
|
-
continue;
|
|
132177
|
-
}
|
|
132178
|
-
if (floatRecordState(record) === "submitted") {
|
|
132179
|
-
const age = Number.isSafeInteger(floatEndedAtMs(record)) ? Date.now() - floatEndedAtMs(record) : NaN;
|
|
132180
|
-
if (age > SUBMITTED_READ_AFTER_MS && (age < 2 * STALE_REFUND_MS || record.ambiguous === true)) names.push(name);
|
|
132181
|
-
continue;
|
|
132182
|
-
}
|
|
132183
|
-
if (floatRecordState(record) !== "refund_pending" || record.refundOutcome === "refund_arrived" || !Number.isSafeInteger(record.refundPendingAtMs)) continue;
|
|
132184
|
-
if (Date.now() - record.refundPendingAtMs > STALE_REFUND_MS || floatRefundReadDue(record)) names.push(name);
|
|
132185
|
-
}
|
|
132186
|
-
return names;
|
|
132187
|
-
}
|
|
132303
|
+
const staleRefundNames = (store) => staleFloatRefundNames(store);
|
|
132188
132304
|
async function correctFloatRecords(store, names, untilMs, started = floatCorrectionReads(store, names)) {
|
|
132189
132305
|
const { states, proven, settled } = started;
|
|
132190
132306
|
if (settled === void 0) return { states, written: 0 };
|
|
@@ -132194,7 +132310,7 @@ ${canonical5}`;
|
|
|
132194
132310
|
});
|
|
132195
132311
|
await Promise.race([settled, until(untilMs)]);
|
|
132196
132312
|
if (!proven.length) return { states, written: 0 };
|
|
132197
|
-
const writing = underLease((leased) => Date.now() >= untilMs ? 0 :
|
|
132313
|
+
const writing = underLease((leased) => Date.now() >= untilMs ? 0 : writeProvenFloatStates(leased, proven));
|
|
132198
132314
|
const written = await Promise.race([writing.catch(() => 0), until(untilMs).then(() => 0)]);
|
|
132199
132315
|
if (written > 0) log(`MCP_FLOAT_RECORDS_CORRECTED records=${written}`);
|
|
132200
132316
|
return { states, written };
|
|
@@ -132211,10 +132327,10 @@ ${canonical5}`;
|
|
|
132211
132327
|
} catch {
|
|
132212
132328
|
continue;
|
|
132213
132329
|
}
|
|
132214
|
-
if (!
|
|
132330
|
+
if (!FLOAT_ID2.test(String(record?.floatId))) continue;
|
|
132215
132331
|
if (floatNeverLanded(store, record)) continue;
|
|
132216
132332
|
if (sellerTransferUnknown(record)) {
|
|
132217
|
-
if (!finalTransfers.has(record.floatId) && !transferMisses.has(record.floatId) && now - floatAnsweredAtMs(record) <
|
|
132333
|
+
if (!finalTransfers.has(record.floatId) && !transferMisses.has(record.floatId) && now - floatAnsweredAtMs(record) < FLOAT_REFUND_READ_AGE_MS) {
|
|
132218
132334
|
transfers.push({ name, record });
|
|
132219
132335
|
}
|
|
132220
132336
|
continue;
|
|
@@ -132222,7 +132338,7 @@ ${canonical5}`;
|
|
|
132222
132338
|
if (!["refund_pending", "submitted"].includes(floatRecordState(record))) continue;
|
|
132223
132339
|
if (floatRecordState(record) === "submitted" && record.memoryOnly === true && !memoryRequestHeld(record)) continue;
|
|
132224
132340
|
if (finalRefundStates.has(record.floatId)) continue;
|
|
132225
|
-
if (!(now - floatEndedAtMs(record) <
|
|
132341
|
+
if (!(now - floatEndedAtMs(record) < FLOAT_REFUND_READ_AGE_MS)) continue;
|
|
132226
132342
|
due.push({ name, record });
|
|
132227
132343
|
}
|
|
132228
132344
|
const states = new Map(finalRefundStates);
|
|
@@ -132232,7 +132348,7 @@ ${canonical5}`;
|
|
|
132232
132348
|
due.sort((left, right) => floatEndedAtMs(right.record) - floatEndedAtMs(left.record));
|
|
132233
132349
|
transfers.sort((left, right) => floatAnsweredAtMs(right.record) - floatAnsweredAtMs(left.record));
|
|
132234
132350
|
const fetchImpl = ops.fetch ?? fetch;
|
|
132235
|
-
const reads = due.slice(0,
|
|
132351
|
+
const reads = due.slice(0, FLOAT_REFUND_READS).map(({ name, record }) => readFloatTransferState(record, fetchImpl).then((read) => {
|
|
132236
132352
|
const state = floatRecordState(record);
|
|
132237
132353
|
if (state === "submitted" && read?.state === "landed" || read?.state === "final") {
|
|
132238
132354
|
states.set(record.floatId, { floatState: read.state, ...read.transaction ? { transaction: read.transaction } : {} });
|
|
@@ -132249,10 +132365,10 @@ ${canonical5}`;
|
|
|
132249
132365
|
if (refund.floatState === "refunded" && refund.refundTransaction) finalRefundStates.set(record.floatId, refund);
|
|
132250
132366
|
if (state === "submitted") proven.push({ name, from: record.state, verdict: "dead", refundDueAtMs: read.refundDueAtMs });
|
|
132251
132367
|
}));
|
|
132252
|
-
for (const { name, record } of transfers.slice(0,
|
|
132368
|
+
for (const { name, record } of transfers.slice(0, FLOAT_REFUND_READS)) {
|
|
132253
132369
|
reads.push(readFloatTransferState(record, fetchImpl).then((read) => {
|
|
132254
|
-
if (read?.unserved || read?.state === "dead" || read?.state === "final" && !
|
|
132255
|
-
if (read?.state !== "final" && read?.state !== "landed" || !
|
|
132370
|
+
if (read?.unserved || read?.state === "dead" || read?.state === "final" && !SIGNATURE_TEXT2.test(String(read.transaction ?? ""))) transferMisses.add(record.floatId);
|
|
132371
|
+
if (read?.state !== "final" && read?.state !== "landed" || !SIGNATURE_TEXT2.test(String(read.transaction ?? ""))) return;
|
|
132256
132372
|
states.set(record.floatId, { floatState: read.state, transaction: read.transaction });
|
|
132257
132373
|
if (read.state !== "final") return;
|
|
132258
132374
|
finalTransfers.set(record.floatId, read.transaction);
|
|
@@ -132277,32 +132393,6 @@ ${canonical5}`;
|
|
|
132277
132393
|
return void 0;
|
|
132278
132394
|
}
|
|
132279
132395
|
}
|
|
132280
|
-
function writeProven(store, proven) {
|
|
132281
|
-
let written = 0;
|
|
132282
|
-
for (const { name, from, verdict, transaction, refundDueAtMs, fill } of proven) {
|
|
132283
|
-
const record = store.readWal(name);
|
|
132284
|
-
if (record?.state !== from) continue;
|
|
132285
|
-
const { ambiguous: _settled, refundDueAtMs: _due, ...rest } = record;
|
|
132286
|
-
const landed = SIGNATURE_TEXT.test(String(transaction ?? "")) ? { landedTransaction: transaction } : {};
|
|
132287
|
-
if (fill) {
|
|
132288
|
-
if (knownSellerTransfer(record) !== null || !landed.landedTransaction) continue;
|
|
132289
|
-
store.writeWal(name, { ...record, ...landed });
|
|
132290
|
-
} else if (verdict === "dead" && floatRecordState(record) === "submitted") {
|
|
132291
|
-
store.writeWal(name, {
|
|
132292
|
-
...rest,
|
|
132293
|
-
state: "refund_pending",
|
|
132294
|
-
refundPendingAtMs: record.refundPendingAtMs ?? Date.now(),
|
|
132295
|
-
...Number.isSafeInteger(refundDueAtMs) ? { refundDueAtMs } : {}
|
|
132296
|
-
});
|
|
132297
|
-
} else if (verdict === "final") {
|
|
132298
|
-
store.writeWal(name, { ...rest, state: "seller_kept", sellerKeptAtMs: record.sellerKeptAtMs ?? Date.now(), ...landed });
|
|
132299
|
-
} else if (verdict === "cancelled") {
|
|
132300
|
-
store.writeWal(name, { ...rest, state: "cancelled", cancelledAtMs: record.cancelledAtMs ?? Date.now() });
|
|
132301
|
-
} else continue;
|
|
132302
|
-
written += 1;
|
|
132303
|
-
}
|
|
132304
|
-
return written;
|
|
132305
|
-
}
|
|
132306
132396
|
const refundStateWords = (floatState) => ({
|
|
132307
132397
|
dead: "sure: the transfer to the seller expired, so Shinjuku sends the refund",
|
|
132308
132398
|
refund_queued: "sure: Shinjuku is sending the refund",
|
|
@@ -132454,13 +132544,13 @@ ${canonical5}`;
|
|
|
132454
132544
|
const refund = !refunded ? {} : {
|
|
132455
132545
|
refundAtomic: paid,
|
|
132456
132546
|
refund: told.refund,
|
|
132457
|
-
...
|
|
132547
|
+
...FLOAT_ID2.test(String(record.floatId)) ? { floatId: record.floatId } : {},
|
|
132458
132548
|
...shinjuku?.floatState ? { refundState: refundStateWords(shinjuku.floatState) } : {},
|
|
132459
132549
|
...shinjuku?.refundTransaction ? { refundTransaction: shinjuku.refundTransaction } : {},
|
|
132460
132550
|
note: told.note
|
|
132461
132551
|
};
|
|
132462
132552
|
const landedTransaction = knownSellerTransfer(record) ?? (!refunded ? refundReads.get(record.floatId)?.transaction : void 0);
|
|
132463
|
-
const keptTransaction = !refunded &&
|
|
132553
|
+
const keptTransaction = !refunded && SIGNATURE_TEXT2.test(String(landedTransaction ?? "")) ? landedTransaction : null;
|
|
132464
132554
|
row(
|
|
132465
132555
|
name.slice(FLOAT_PAYMENT_WAL_PREFIX2.length),
|
|
132466
132556
|
{ ...record, answeredAtMs: at },
|
|
@@ -132486,7 +132576,7 @@ ${canonical5}`;
|
|
|
132486
132576
|
if (state !== "receipt") continue;
|
|
132487
132577
|
const view2 = viewOf(record);
|
|
132488
132578
|
const read = refundReads.get(record.floatId)?.transaction;
|
|
132489
|
-
const sellerTransaction = view2.sellerTransaction ?? knownSellerTransfer(record) ?? (
|
|
132579
|
+
const sellerTransaction = view2.sellerTransaction ?? knownSellerTransfer(record) ?? (SIGNATURE_TEXT2.test(String(read ?? "")) ? read : null);
|
|
132490
132580
|
row(name.slice(FLOAT_PAYMENT_WAL_PREFIX2.length), record, { ...view2, sellerTransaction }, {
|
|
132491
132581
|
scheme: "exact",
|
|
132492
132582
|
// RC1 (mcp56 pass of 0.3.102, hypernatt): this said "a later wallet_receipts shows it", but Shinjuku drops a final
|
|
@@ -133025,7 +133115,7 @@ ${canonical5}`;
|
|
|
133025
133115
|
refund,
|
|
133026
133116
|
refundAtomic: float.paidAtomic ?? null,
|
|
133027
133117
|
...read?.refundTransaction ? { refundTransaction: read.refundTransaction } : {},
|
|
133028
|
-
...
|
|
133118
|
+
...FLOAT_ID2.test(String(float.floatId)) ? { floatId: float.floatId } : {},
|
|
133029
133119
|
detail: `${words2}; there is nothing to cancel`,
|
|
133030
133120
|
next: `Tell the user: ${words2}. Nothing was changed; wallet_receipts lists it`
|
|
133031
133121
|
});
|
|
@@ -133055,7 +133145,7 @@ ${canonical5}`;
|
|
|
133055
133145
|
finished: false,
|
|
133056
133146
|
state: floatState,
|
|
133057
133147
|
ambiguous: true,
|
|
133058
|
-
...
|
|
133148
|
+
...FLOAT_ID2.test(String(float.floatId)) ? { floatId: float.floatId } : {},
|
|
133059
133149
|
detail: "this payment through Shinjuku is paid, and it is not certain yet whether the seller kept it; a payment sent to Shinjuku cannot be cancelled; nothing was changed",
|
|
133060
133150
|
next: "Tell the user it is not certain yet whether the seller kept the payment, and nothing was changed. wallet_receipts shows the result (a refund, or that the seller kept it) when Shinjuku's transfer to the seller is final or can no longer land. Do not pay again with a NEW request_id until then"
|
|
133061
133151
|
});
|
|
@@ -138771,7 +138861,7 @@ function createSetupTools({
|
|
|
138771
138861
|
doneTool: sayOnRefusal(doneTool)
|
|
138772
138862
|
};
|
|
138773
138863
|
}
|
|
138774
|
-
var import_web3133, shownCaps, RELEASE_RETRY_MS, STAGE_WORDS, stageWords, INTERNAL_BALANCE_DETAIL, shownBreakdown, sessionLeftShown, TOKEN_UNIT_TOOLS, 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,
|
|
138864
|
+
var import_web3133, shownCaps, RELEASE_RETRY_MS, STAGE_WORDS, stageWords, INTERNAL_BALANCE_DETAIL, shownBreakdown, sessionLeftShown, TOKEN_UNIT_TOOLS, 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, json3, answerResult, discoverTool, LAUNCH_CAP_CODES, dayCapKind, refuse12, newRequestIdFor, payCapName, publicOffer, FLOAT_PAID_CODES, FLOAT_NOT_CERTAIN_CODES, FLOAT_PRIVATE_LEG, SELLER_ONLY_HERE, outsideWalletRule, proxyStartStep, MONEY_ID2, toRecordId, linkKindOf, moneyId, REFUSED_CODES, 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, 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, ELICIT_UNSHOWN_MS, elicitUnshown, POLL_SECONDS2, TRANSFER_CHANGE_READ_MS, TEMP_CLEAN_DELAY_MS, KEPT_ON_DISK, MAX_SHIELDED_BALANCE_ATOMIC, receiveGenerator, MCP_TOOL_NAMES, MCP_HIDDEN_TOOL_NAMES, setupTerminalNext, SETUP_RUNNING_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, PRIVATE_INFERENCE_WHY, RESTART_STEPS, HOST_BLOCKED_LINE, TOR_BROWSER_PORT, SETUP_TOR_TITLE, SETUP_TOR_WHY;
|
|
138775
138865
|
var init_tools = __esm({
|
|
138776
138866
|
"wallet/src/mcp/tools.mjs"() {
|
|
138777
138867
|
"use strict";
|
|
@@ -138796,6 +138886,7 @@ var init_tools = __esm({
|
|
|
138796
138886
|
init_publicRead();
|
|
138797
138887
|
init_floatPay();
|
|
138798
138888
|
init_floatWords();
|
|
138889
|
+
init_floatRefundCheck();
|
|
138799
138890
|
init_sellerInput();
|
|
138800
138891
|
init_prepareRecoveredPayment();
|
|
138801
138892
|
init_walletHistory();
|
|
@@ -138977,7 +139068,7 @@ var init_tools = __esm({
|
|
|
138977
139068
|
return void 0;
|
|
138978
139069
|
}
|
|
138979
139070
|
};
|
|
138980
|
-
|
|
139071
|
+
FLOAT_ID2 = /^[0-9a-f]{64}$/;
|
|
138981
139072
|
ANSWERED_EXIT_RETRY_MS = 3e4;
|
|
138982
139073
|
ANSWERED_EXIT_UNCONFIRMED_MS = 10 * 6e4;
|
|
138983
139074
|
ANSWERED_EXIT_RETRY_WINDOW_MS = 30 * 6e4;
|
|
@@ -142795,7 +142886,7 @@ async function runChat({ io, values, deps = {} }) {
|
|
|
142795
142886
|
}
|
|
142796
142887
|
};
|
|
142797
142888
|
let parts = readParts();
|
|
142798
|
-
if (parts?.spendableAtomic == null) {
|
|
142889
|
+
if (parts?.spendableAtomic == null || /^[1-9][0-9]*$/.test(String(parts?.refundsNotCertainAtomic ?? ""))) {
|
|
142799
142890
|
let read;
|
|
142800
142891
|
if (typeof deps.readChainBalance === "function") {
|
|
142801
142892
|
say3("Reading your private balance from the chain (the same read as shinjuku balance) ...");
|
|
@@ -147162,6 +147253,7 @@ init_qr();
|
|
|
147162
147253
|
init_rpcDefault();
|
|
147163
147254
|
init_usdcWords();
|
|
147164
147255
|
init_processLease();
|
|
147256
|
+
init_floatRefundCheck();
|
|
147165
147257
|
init_secretFile();
|
|
147166
147258
|
var FUNDS_SCHEMA = "carbon-shielded-wallet/add-funds/v1";
|
|
147167
147259
|
var FUNDS_ROUTES = Object.freeze(["exchange", "changenow", "privacy-cash"]);
|
|
@@ -148267,8 +148359,10 @@ async function fundsStatus(values, deps) {
|
|
|
148267
148359
|
const pool2 = values.get("--pool");
|
|
148268
148360
|
const passphrase2 = values.has("--passphrase-file") ? readPrivateLine(resolve31(values.get("--passphrase-file")), "--passphrase-file") : deps.env[PASSPHRASE_ENV];
|
|
148269
148361
|
const walletFile = resolve31(deps.walletPath(pool2));
|
|
148270
|
-
|
|
148362
|
+
let store = deps.openWalletStore(walletFile, passphrase2);
|
|
148271
148363
|
if (store.state.pool !== pool2) throw failure("wallet_pool_mismatch", "the wallet file for this --pool belongs to another pool; check --pool and SHIELDED_WALLET_HOME");
|
|
148364
|
+
const reopen = () => deps.openWalletStore(walletFile, passphrase2);
|
|
148365
|
+
if ((await checkFloatRefundsNow({ store, reopen, lockPath: walletLockPath(walletFile), fetchImpl: deps.fetch ?? fetch, now: deps.now() })).written > 0) store = reopen();
|
|
148272
148366
|
const plans = fundsPlans(store);
|
|
148273
148367
|
const wanted = values.get("--funds-id");
|
|
148274
148368
|
const plan = wanted === void 0 ? plans.at(-1) : plans.find((entry) => entry.fundsId === wanted);
|
|
@@ -148300,6 +148394,7 @@ async function fundsMain(command, values, deps) {
|
|
|
148300
148394
|
// wallet/src/cli/shinjukuWallet.mjs
|
|
148301
148395
|
init_store();
|
|
148302
148396
|
init_processLease();
|
|
148397
|
+
init_floatRefundCheck();
|
|
148303
148398
|
init_notes2();
|
|
148304
148399
|
init_proxy();
|
|
148305
148400
|
init_autoJoin();
|
|
@@ -150233,6 +150328,7 @@ async function stopWhenShort(values, deps, { needAtomic = 1n, costAtomic, paymen
|
|
|
150233
150328
|
noWalk = false;
|
|
150234
150329
|
}
|
|
150235
150330
|
if (!knownShortBalance(store, { needAtomic, payment }) && !noWalk && !(noAccount && !savedWalkHoldsAccount(store))) return false;
|
|
150331
|
+
await checkFloatRefunds(store, values, deps, () => commandStore(values, deps));
|
|
150236
150332
|
const read = await readBalanceFromChain(store, values, deps);
|
|
150237
150333
|
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.
|
|
150238
150334
|
`);
|
|
@@ -151155,7 +151251,9 @@ var localAiAppsLines = (answer) => [
|
|
|
151155
151251
|
` base_url = "${answer.baseUrl}"`,
|
|
151156
151252
|
' env_key = "SHINJUKU_AI_KEY"',
|
|
151157
151253
|
' wire_api = "responses"',
|
|
151158
|
-
|
|
151254
|
+
// CX3 (live, npm 0.3.134, 2026-10-31): Codex pays once per model call, and one turn makes several (PrivAI: a turn with 2 tool
|
|
151255
|
+
// calls made 4 paid calls, 0.0208 USDC, 2 min 28 s over Tor; mcp66: a one-sentence turn with no tool made 2, 0.009792 USDC).
|
|
151256
|
+
"Set SHINJUKU_AI_KEY to the api key above, then start it with: codex --profile shinjuku. Codex pays once per model call, and one turn can make several: about 0.005 USDC each with the fee on qwen3-8-flash (a short turn paid about 0.01 USDC; a turn with 2 tool calls paid about 0.021 USDC). Your other Codex sessions stay as they are."
|
|
151159
151257
|
];
|
|
151160
151258
|
var localAiCodexHint = () => `For a Codex session on this address, run: ${cli2()} infer status --verbose`;
|
|
151161
151259
|
var LOCAL_AI_CAP_SOURCE = { setup: "from your limits", default: "default", flag: "given at start" };
|
|
@@ -156086,9 +156184,12 @@ async function runBalance(args, values, deps, io) {
|
|
|
156086
156184
|
} else {
|
|
156087
156185
|
store = openPoolWallet(values, deps);
|
|
156088
156186
|
}
|
|
156187
|
+
const refunds = await checkFloatRefunds(store, values, deps);
|
|
156188
|
+
if (refunds.written > 0) store = openPoolWallet(values, deps);
|
|
156089
156189
|
const parts = balanceNow(store, { source: values.has("--refresh") ? "refresh" : "local", now: deps.now() });
|
|
156090
156190
|
const report = parts?.report;
|
|
156091
|
-
const
|
|
156191
|
+
const current = (report?.status === "current" || report?.status === "empty") && !(refunds.refunded > 0 && refunds.written > 0);
|
|
156192
|
+
const refreshArgs = values.has("--refresh") || current ? void 0 : homeRefreshArgs(store, deps);
|
|
156092
156193
|
if (refreshArgs) {
|
|
156093
156194
|
io.err("reading your private balance from the chain\n");
|
|
156094
156195
|
const shownFlags = ["--json", "--verbose"].filter((name) => values.has(name));
|
|
@@ -156157,6 +156258,16 @@ async function runBalance(args, values, deps, io) {
|
|
|
156157
156258
|
`);
|
|
156158
156259
|
mark("balance-printed");
|
|
156159
156260
|
}
|
|
156261
|
+
function checkFloatRefunds(store, values, deps, open4 = () => openPoolWallet(values, deps)) {
|
|
156262
|
+
return checkFloatRefundsNow({
|
|
156263
|
+
store,
|
|
156264
|
+
reopen: open4,
|
|
156265
|
+
lockPath: walletLockPath(commandWalletPath(values, deps)),
|
|
156266
|
+
fetchImpl: deps.fetch,
|
|
156267
|
+
now: deps.now(),
|
|
156268
|
+
...deps.acquireLease ? { acquireLease: deps.acquireLease } : {}
|
|
156269
|
+
});
|
|
156270
|
+
}
|
|
156160
156271
|
function homeRefreshArgs(store, deps) {
|
|
156161
156272
|
let config;
|
|
156162
156273
|
try {
|