shinjuku-shielded 0.3.34 → 0.3.36
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/manifest.json +3 -3
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +309 -143
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": "658897741c5d9bce482ff9d932f4ade7e51cf98f834e78c3f693da1e1771e547",
|
|
5
|
+
"bytes": 11193868,
|
|
6
|
+
"sourceCommit": "60ad77f63dbc238b88ee877a67ae54d30ebdbdfb",
|
|
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",
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shielded",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.36",
|
|
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": "65889774",
|
|
7
|
+
"shinjukuSha256": "658897741c5d9bce482ff9d932f4ade7e51cf98f834e78c3f693da1e1771e547",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shielded",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-mcp#readme",
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -18266,7 +18266,7 @@ var require_websocket = __commonJS({
|
|
|
18266
18266
|
var http2 = __require("http");
|
|
18267
18267
|
var net2 = __require("net");
|
|
18268
18268
|
var tls = __require("tls");
|
|
18269
|
-
var { randomBytes: randomBytes30, createHash:
|
|
18269
|
+
var { randomBytes: randomBytes30, createHash: createHash39 } = __require("crypto");
|
|
18270
18270
|
var { Duplex, Readable } = __require("stream");
|
|
18271
18271
|
var { URL: URL4 } = __require("url");
|
|
18272
18272
|
var PerMessageDeflate = require_permessage_deflate();
|
|
@@ -18934,7 +18934,7 @@ var require_websocket = __commonJS({
|
|
|
18934
18934
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
18935
18935
|
return;
|
|
18936
18936
|
}
|
|
18937
|
-
const digest2 =
|
|
18937
|
+
const digest2 = createHash39("sha1").update(key + GUID).digest("base64");
|
|
18938
18938
|
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
18939
18939
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
18940
18940
|
return;
|
|
@@ -19303,7 +19303,7 @@ var require_websocket_server = __commonJS({
|
|
|
19303
19303
|
var EventEmitter = __require("events");
|
|
19304
19304
|
var http2 = __require("http");
|
|
19305
19305
|
var { Duplex } = __require("stream");
|
|
19306
|
-
var { createHash:
|
|
19306
|
+
var { createHash: createHash39 } = __require("crypto");
|
|
19307
19307
|
var extension3 = require_extension();
|
|
19308
19308
|
var PerMessageDeflate = require_permessage_deflate();
|
|
19309
19309
|
var subprotocol = require_subprotocol();
|
|
@@ -19610,7 +19610,7 @@ var require_websocket_server = __commonJS({
|
|
|
19610
19610
|
);
|
|
19611
19611
|
}
|
|
19612
19612
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
19613
|
-
const digest2 =
|
|
19613
|
+
const digest2 = createHash39("sha1").update(key + GUID).digest("base64");
|
|
19614
19614
|
const headers = [
|
|
19615
19615
|
"HTTP/1.1 101 Switching Protocols",
|
|
19616
19616
|
"Upgrade: websocket",
|
|
@@ -49186,6 +49186,36 @@ var init_book = __esm({
|
|
|
49186
49186
|
}
|
|
49187
49187
|
});
|
|
49188
49188
|
|
|
49189
|
+
// wallet/src/fetch/keepAlive.mjs
|
|
49190
|
+
function proxiedRun() {
|
|
49191
|
+
const env = process.env;
|
|
49192
|
+
return Boolean(env.SHINJUKU_WALLET_PROXIED || env.NODE_USE_ENV_PROXY || env.HTTPS_PROXY || env.HTTP_PROXY || env.https_proxy || env.http_proxy);
|
|
49193
|
+
}
|
|
49194
|
+
function keepAliveDispatcher() {
|
|
49195
|
+
if (shared !== void 0) return shared;
|
|
49196
|
+
try {
|
|
49197
|
+
if (proxiedRun()) return void 0;
|
|
49198
|
+
const global2 = globalThis[GLOBAL_DISPATCHER];
|
|
49199
|
+
if (global2?.constructor?.name !== "Agent") return void 0;
|
|
49200
|
+
shared = new global2.constructor({ keepAliveTimeout: KEEP_ALIVE_MS, keepAliveMaxTimeout: KEEP_ALIVE_MS });
|
|
49201
|
+
return shared;
|
|
49202
|
+
} catch {
|
|
49203
|
+
return void 0;
|
|
49204
|
+
}
|
|
49205
|
+
}
|
|
49206
|
+
function keepAliveInit(init = {}) {
|
|
49207
|
+
const dispatcher = keepAliveDispatcher();
|
|
49208
|
+
return dispatcher === void 0 ? init : { ...init, dispatcher };
|
|
49209
|
+
}
|
|
49210
|
+
var GLOBAL_DISPATCHER, KEEP_ALIVE_MS, shared;
|
|
49211
|
+
var init_keepAlive = __esm({
|
|
49212
|
+
"wallet/src/fetch/keepAlive.mjs"() {
|
|
49213
|
+
"use strict";
|
|
49214
|
+
GLOBAL_DISPATCHER = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.1");
|
|
49215
|
+
KEEP_ALIVE_MS = 2e4;
|
|
49216
|
+
}
|
|
49217
|
+
});
|
|
49218
|
+
|
|
49189
49219
|
// wallet/vendor/shielded-x402-model/src/reference.mjs
|
|
49190
49220
|
import { dirname as dirname5, join as join6 } from "node:path";
|
|
49191
49221
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -49756,11 +49786,12 @@ var init_anchorClock = __esm({
|
|
|
49756
49786
|
// wallet/src/chain.mjs
|
|
49757
49787
|
import { createHash as createHash7, createPublicKey, randomInt, verify as verifySignature } from "node:crypto";
|
|
49758
49788
|
function connect2(rpcUrl, commitment = "finalized", { timeoutMs } = {}) {
|
|
49759
|
-
const
|
|
49789
|
+
const pooled = (input, init) => rpcFetch(input, keepAliveInit(init));
|
|
49790
|
+
const fetch2 = timeoutMs === void 0 ? pooled : async (input, init) => {
|
|
49760
49791
|
const circuit = torCircuit();
|
|
49761
49792
|
const timeout = AbortSignal.timeout(timeoutMs);
|
|
49762
49793
|
try {
|
|
49763
|
-
const response = await
|
|
49794
|
+
const response = await pooled(input, { ...init, signal: init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout });
|
|
49764
49795
|
const body = await response.text();
|
|
49765
49796
|
const headers = new Headers(response.headers);
|
|
49766
49797
|
headers.delete("content-encoding");
|
|
@@ -49771,7 +49802,23 @@ function connect2(rpcUrl, commitment = "finalized", { timeoutMs } = {}) {
|
|
|
49771
49802
|
throw error;
|
|
49772
49803
|
}
|
|
49773
49804
|
};
|
|
49774
|
-
|
|
49805
|
+
const connection = countRpcCalls(new import_web395.Connection(rpcUrl, { commitment, fetch: fetch2, disableRetryOnRateLimit: true }));
|
|
49806
|
+
let nextId = 0;
|
|
49807
|
+
Object.defineProperty(connection, "abortableRpcRequest", {
|
|
49808
|
+
value: async (method, params, signal) => {
|
|
49809
|
+
const response = await fetch2(rpcUrl, {
|
|
49810
|
+
method: "POST",
|
|
49811
|
+
signal,
|
|
49812
|
+
headers: { "content-type": "application/json" },
|
|
49813
|
+
body: JSON.stringify({ jsonrpc: "2.0", id: `abortable-${nextId += 1}`, method, params })
|
|
49814
|
+
});
|
|
49815
|
+
return response.json();
|
|
49816
|
+
},
|
|
49817
|
+
enumerable: false,
|
|
49818
|
+
writable: false,
|
|
49819
|
+
configurable: true
|
|
49820
|
+
});
|
|
49821
|
+
return connection;
|
|
49775
49822
|
}
|
|
49776
49823
|
function countRpcCalls(connection) {
|
|
49777
49824
|
const counters = Object.fromEntries(COUNTED_RPC_METHODS.map((name) => [name, 0]));
|
|
@@ -50040,11 +50087,11 @@ function connectSplit(own, historyUrl, commitment = "finalized", { pause: pause3
|
|
|
50040
50087
|
const now = Date.now();
|
|
50041
50088
|
if (behindSince === void 0) {
|
|
50042
50089
|
behindSince = now;
|
|
50043
|
-
notice(strictAfterSlot === void 0 ? `history: the history source is behind the chain (JSON-RPC -32016: it has not reached the slot your own RPC read the pool account at); asking again after 0.5 s, 1 s, 2 s, then every 5 s, for at most ${HISTORY_RPC_BEHIND_WAIT_MS / 1e3} s
|
|
50044
|
-
` : `history: the pool account changed after slot ${strictAfterSlot}, the newest slot the history source had reached (its history did not rebuild the pool account your own RPC reads); asking it again after 0.5 s, 1 s, 2 s, then every 5 s, for at most ${HISTORY_RPC_BEHIND_WAIT_MS / 1e3} s
|
|
50090
|
+
notice(strictAfterSlot === void 0 ? `history: the history source is behind the chain (JSON-RPC -32016: it has not reached the slot your own RPC read the pool account at); asking again every 0.15 s for about 2 s, then after 0.5 s, 1 s, 2 s, then every 5 s, for at most ${HISTORY_RPC_BEHIND_WAIT_MS / 1e3} s
|
|
50091
|
+
` : `history: the pool account changed after slot ${strictAfterSlot}, the newest slot the history source had reached (its history did not rebuild the pool account your own RPC reads); asking it again every 0.15 s for about 2 s, then after 0.5 s, 1 s, 2 s, then every 5 s, for at most ${HISTORY_RPC_BEHIND_WAIT_MS / 1e3} s
|
|
50045
50092
|
`);
|
|
50046
50093
|
}
|
|
50047
|
-
const delay3 = HISTORY_RPC_BEHIND_RETRY_STEPS_MS[Math.min(behindWaits, HISTORY_RPC_BEHIND_RETRY_STEPS_MS.length - 1)];
|
|
50094
|
+
const delay3 = behindWaits < HISTORY_RPC_BEHIND_FAST_TRIES ? HISTORY_RPC_BEHIND_FAST_MS : HISTORY_RPC_BEHIND_RETRY_STEPS_MS[Math.min(behindWaits - HISTORY_RPC_BEHIND_FAST_TRIES, HISTORY_RPC_BEHIND_RETRY_STEPS_MS.length - 1)];
|
|
50048
50095
|
if (now - behindSince + delay3 > HISTORY_RPC_BEHIND_WAIT_MS) return false;
|
|
50049
50096
|
behindWaits += 1;
|
|
50050
50097
|
await pause3(delay3);
|
|
@@ -50571,13 +50618,14 @@ function depositIntentAddress2({ programId, pool: pool2, depositPublicInputBytes
|
|
|
50571
50618
|
programId
|
|
50572
50619
|
)[0];
|
|
50573
50620
|
}
|
|
50574
|
-
var import_web395, POOL_STATE_LEN2, POOL_STATE_LEN_RING2, ANCHOR_MODE_RING2, ANCHOR_RING_SLOTS2, ANCHOR_RING_HEADER2, ANCHOR_RING_FIRST_SLOT2, ANCHOR_RING_SLOT_LEN2, POOL_STATE_LEN_V22, BUFFER_HEADER_LEN2, MEMO_BUNDLE_BYTES2, PAYLOAD_LENGTH2, PAYLOAD_LENGTH_V22, TRANSITION_KIND2, INSTRUCTION2, COUNTED_RPC_METHODS, HISTORY_RPC_METHODS, PINNED_HISTORY_PROXIES, PINNED_HISTORY_HTTPS, HISTORY_RPC_OWN, historyRpcErrors, HISTORY_RPC_BEHIND_WAIT_MS, HISTORY_RPC_REQUEST_TIMEOUT_MS, HISTORY_RPC_BEHIND_RETRY_STEPS_MS, HISTORY_RPC_BEHIND_CODE, ED25519_SPKI_PREFIX, SIGNATURE_BYTES, VERSION_1_PREFIX, HISTORY_CROSS_CHECK_COUNT, runTransactions, warmedSources, bytes323, MEMO_BATCH_MAX, MEMO_ATTEMPTS, MEMO_MAX_WAIT_SECONDS, MEMO_ANSWER_TIMEOUT_MS, MEMO_BODY_TIMEOUT_MS, pauseFor, noticeOnStderr, memoDigestHex, memoFailureText, prefetchedMemosByFetch, MEMO_PREFETCH_LIFE_MS;
|
|
50621
|
+
var import_web395, POOL_STATE_LEN2, POOL_STATE_LEN_RING2, ANCHOR_MODE_RING2, ANCHOR_RING_SLOTS2, ANCHOR_RING_HEADER2, ANCHOR_RING_FIRST_SLOT2, ANCHOR_RING_SLOT_LEN2, POOL_STATE_LEN_V22, BUFFER_HEADER_LEN2, MEMO_BUNDLE_BYTES2, PAYLOAD_LENGTH2, PAYLOAD_LENGTH_V22, TRANSITION_KIND2, INSTRUCTION2, COUNTED_RPC_METHODS, HISTORY_RPC_METHODS, PINNED_HISTORY_PROXIES, PINNED_HISTORY_HTTPS, HISTORY_RPC_OWN, historyRpcErrors, HISTORY_RPC_BEHIND_WAIT_MS, HISTORY_RPC_REQUEST_TIMEOUT_MS, HISTORY_RPC_BEHIND_FAST_MS, HISTORY_RPC_BEHIND_FAST_TRIES, HISTORY_RPC_BEHIND_RETRY_STEPS_MS, HISTORY_RPC_BEHIND_CODE, ED25519_SPKI_PREFIX, SIGNATURE_BYTES, VERSION_1_PREFIX, HISTORY_CROSS_CHECK_COUNT, runTransactions, warmedSources, bytes323, MEMO_BATCH_MAX, MEMO_ATTEMPTS, MEMO_MAX_WAIT_SECONDS, MEMO_ANSWER_TIMEOUT_MS, MEMO_BODY_TIMEOUT_MS, pauseFor, noticeOnStderr, memoDigestHex, memoFailureText, prefetchedMemosByFetch, MEMO_PREFETCH_LIFE_MS;
|
|
50575
50622
|
var init_chain2 = __esm({
|
|
50576
50623
|
"wallet/src/chain.mjs"() {
|
|
50577
50624
|
"use strict";
|
|
50578
50625
|
import_web395 = __toESM(require_index_cjs(), 1);
|
|
50579
50626
|
init_esm2();
|
|
50580
50627
|
init_proxy();
|
|
50628
|
+
init_keepAlive();
|
|
50581
50629
|
init_compressedReplay();
|
|
50582
50630
|
init_reference2();
|
|
50583
50631
|
init_anchorClock();
|
|
@@ -50660,6 +50708,8 @@ var init_chain2 = __esm({
|
|
|
50660
50708
|
historyRpcErrors = /* @__PURE__ */ new WeakSet();
|
|
50661
50709
|
HISTORY_RPC_BEHIND_WAIT_MS = 6e4;
|
|
50662
50710
|
HISTORY_RPC_REQUEST_TIMEOUT_MS = 2e4;
|
|
50711
|
+
HISTORY_RPC_BEHIND_FAST_MS = 150;
|
|
50712
|
+
HISTORY_RPC_BEHIND_FAST_TRIES = 12;
|
|
50663
50713
|
HISTORY_RPC_BEHIND_RETRY_STEPS_MS = Object.freeze([500, 1e3, 2e3, 5e3]);
|
|
50664
50714
|
HISTORY_RPC_BEHIND_CODE = -32016;
|
|
50665
50715
|
ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
|
|
@@ -52614,11 +52664,11 @@ async function refreshFinalizedP03HistorySnapshot({
|
|
|
52614
52664
|
if (authenticated.programId !== program.toBase58() || authenticated.pool !== poolKey.toBase58()) {
|
|
52615
52665
|
throw new Error("p03_history_refresh_binding_invalid");
|
|
52616
52666
|
}
|
|
52617
|
-
const snapshot = await
|
|
52618
|
-
if (snapshot.terminal !== authenticated.finalizedPoolSnapshot.terminal || snapshot.currentIndex !== authenticated.finalizedPoolSnapshot.currentIndex || snapshot.currentRoot !== authenticated.finalizedPoolSnapshot.currentRoot || !sameP03PoolPolicy(snapshot, authenticated.finalizedPoolSnapshot.policy) || !
|
|
52667
|
+
const snapshot = await readFinalizedPoolForRefresh(connection, program, poolKey);
|
|
52668
|
+
if (snapshot.terminal !== authenticated.finalizedPoolSnapshot.terminal || snapshot.currentIndex !== authenticated.finalizedPoolSnapshot.currentIndex || snapshot.currentRoot !== authenticated.finalizedPoolSnapshot.currentRoot || !sameP03PoolPolicy(snapshot, authenticated.finalizedPoolSnapshot.policy) || !sameE1TreeHeader(snapshot, authenticated.finalizedPoolSnapshot.e1Tree, program, poolKey)) {
|
|
52619
52669
|
throw Object.assign(
|
|
52620
52670
|
new Error("p03_history_refresh_transition_detected"),
|
|
52621
|
-
{ snapshot, snapshotBinding: { programId: program.toBase58(), pool: poolKey.toBase58() } }
|
|
52671
|
+
{ currentIndex: snapshot.currentIndex, snapshotBinding: { programId: program.toBase58(), pool: poolKey.toBase58() } }
|
|
52622
52672
|
);
|
|
52623
52673
|
}
|
|
52624
52674
|
const priorCoverage = authenticated.deploymentCoverage;
|
|
@@ -52704,6 +52754,26 @@ async function readFinalizedPool(connection, program, pool2) {
|
|
|
52704
52754
|
})
|
|
52705
52755
|
});
|
|
52706
52756
|
}
|
|
52757
|
+
async function readFinalizedPoolForRefresh(connection, program, pool2) {
|
|
52758
|
+
if (typeof connection.getMultipleAccountsInfoAndContext !== "function") return readFinalizedPool(connection, program, pool2);
|
|
52759
|
+
const tree = new import_web396.PublicKey(e1TreeAddress(pool2.toBase58(), program.toBase58()));
|
|
52760
|
+
const both = await retryTransientRpc(() => connection.getMultipleAccountsInfoAndContext(
|
|
52761
|
+
[pool2, tree],
|
|
52762
|
+
{ commitment: "finalized", dataSlice: { offset: 0, length: REFRESH_READ_BYTES } }
|
|
52763
|
+
));
|
|
52764
|
+
if (!Array.isArray(both?.value) || both.value.length !== 2) throw new Error("p03_history_e1_tree_read_invalid");
|
|
52765
|
+
const snapshot = parseFinalizedPool({ context: both.context, value: both.value[0] }, program);
|
|
52766
|
+
if (snapshot.replayStore !== REPLAY_STORE_INDEXED) return snapshot;
|
|
52767
|
+
const treeAccount = both.value[1];
|
|
52768
|
+
return Object.freeze({
|
|
52769
|
+
...snapshot,
|
|
52770
|
+
e1TreeHeader: Object.freeze({
|
|
52771
|
+
address: tree.toBase58(),
|
|
52772
|
+
ownerProgramId: treeAccount ? canonicalKey(treeAccount.owner, "e1_tree_owner").toBase58() : null,
|
|
52773
|
+
data: treeAccount ? Buffer.from(treeAccount.data) : null
|
|
52774
|
+
})
|
|
52775
|
+
});
|
|
52776
|
+
}
|
|
52707
52777
|
function parseFinalizedPool(response, program) {
|
|
52708
52778
|
const value = response?.value;
|
|
52709
52779
|
const slot3 = response?.context?.slot;
|
|
@@ -53257,6 +53327,7 @@ async function retryTransientRpc(operation, {
|
|
|
53257
53327
|
} catch (error) {
|
|
53258
53328
|
if (!isTransientRpcError(error)) throw error;
|
|
53259
53329
|
lastError = error;
|
|
53330
|
+
markPhase(`rpc-retry-${transientCause(error)}`);
|
|
53260
53331
|
if (attempt + 1 < attempts) {
|
|
53261
53332
|
await new Promise((resolve38) => setTimeout(resolve38, baseDelayMs * 2 ** attempt));
|
|
53262
53333
|
}
|
|
@@ -53274,6 +53345,10 @@ function reuseRefusalCause(error) {
|
|
|
53274
53345
|
if (status) return `http_${status}`;
|
|
53275
53346
|
return error instanceof import_web396.SolanaJSONRPCError ? "rpc_error" : "read_failed";
|
|
53276
53347
|
}
|
|
53348
|
+
function transientCause(error) {
|
|
53349
|
+
if (error instanceof import_web396.SolanaJSONRPCError) return String(-error.code);
|
|
53350
|
+
return reuseRefusalCause(error);
|
|
53351
|
+
}
|
|
53277
53352
|
function isTransientRpcError(error) {
|
|
53278
53353
|
if (error?.transientRpcError === true) return true;
|
|
53279
53354
|
if (error instanceof import_web396.SolanaJSONRPCError) return LAGGING_NODE_RPC_CODES.has(error.code);
|
|
@@ -53419,19 +53494,16 @@ function assertP03E1TreeComplete({ program, pool: pool2, poolSnapshot, settles,
|
|
|
53419
53494
|
if (Buffer.from(header.root).toString("hex") !== root) mismatch("root");
|
|
53420
53495
|
return Object.freeze({ state: "open", address: tree.address, slot: BigInt(poolSnapshot.slot), root, leaves });
|
|
53421
53496
|
}
|
|
53422
|
-
function
|
|
53497
|
+
function sameE1TreeHeader(snapshot, verified, program, pool2) {
|
|
53423
53498
|
if (verified === void 0) return snapshot.replayStore !== REPLAY_STORE_INDEXED;
|
|
53424
|
-
const tree = snapshot.
|
|
53499
|
+
const tree = snapshot.e1TreeHeader;
|
|
53425
53500
|
if (!tree || tree.address !== verified.address) return false;
|
|
53426
53501
|
const empty = tree.data === null || tree.ownerProgramId === null || tree.ownerProgramId === SYSTEM_PROGRAM && tree.data.every((byte) => byte === 0);
|
|
53427
53502
|
if (verified.state === "closed") return empty;
|
|
53428
|
-
if (empty || tree.data.length
|
|
53429
|
-
|
|
53430
|
-
|
|
53431
|
-
|
|
53432
|
-
} catch {
|
|
53433
|
-
return false;
|
|
53434
|
-
}
|
|
53503
|
+
if (empty || tree.ownerProgramId !== program.toBase58() || tree.data.length < E1_TREE_HEADER_BYTES || !Number.isSafeInteger(verified.leaves) || verified.leaves < 1) return false;
|
|
53504
|
+
const data = tree.data;
|
|
53505
|
+
if (data.subarray(0, 8).toString("latin1") !== "SX402T01" || !data.subarray(8, 40).equals(pool2.toBuffer()) || data[40] !== 1 || data[41] !== E1.depth || data.readUInt16LE(42) !== E1.bufferSize || data[44] !== E1.canopyDepth || data[45] !== 0 || data[46] !== 0 || data[47] !== 0) return false;
|
|
53506
|
+
return data.readBigUInt64LE(56) === BigInt(2 * verified.leaves - 1);
|
|
53435
53507
|
}
|
|
53436
53508
|
function assertIndexedSettlementCpis(cpis, kind) {
|
|
53437
53509
|
const exit = kind === "withdraw" || kind === "note-exit";
|
|
@@ -54207,7 +54279,7 @@ function base58Decode(value) {
|
|
|
54207
54279
|
while (zeros < value.length && value[zeros] === "1") zeros += 1;
|
|
54208
54280
|
return Uint8Array.from(Buffer.concat([Buffer.alloc(zeros), body]));
|
|
54209
54281
|
}
|
|
54210
|
-
var import_web396, REPLAY_STORE_INDEXED, CLOSE_REPLAY_TREE_TAG, EXTEND_ANCHOR_RING_TAG, LINK_SUCCESSOR_TAG, IMPORT_REPLAY_LEAVES_TAG, SETTLE_MOVE_TAG, SWEEP_PREDECESSOR_VAULT_TAG, RELINK_SUCCESSOR_TAG, ROTATE_PAYMENT_SETTLER_TAG, IMPORT_A_LEAF_BYTES, IMPORT_MEMBERSHIP_BYTES, IMPORT_PRESENT_SHIFT, IMPORT_MAX_ENTRIES, MOVE_HEAD_BYTES, MOVE_INSERTED_VALUES, DEFAULT_KEY, FIELD_BYTES2, PRIMARY_PROOF_BYTES, SUBTREE_LEAVES, PAGE_SIZE, FIELD_MODULUS3, BPF_LOADER_UPGRADEABLE_PROGRAM_ID, SYSTEM_PROGRAM, TEST_EXECUTABLES, reviewedExecutables, isProgramDataIdentityError, ASSUMED_ORIGINAL_EXECUTABLE, AUTHENTICATED_HISTORY_REPORTS, HISTORY_ATTESTATIONS, hasExecutableEvidence, P03_FINALIZED_HISTORY_SOURCE_MODEL, P03_PROGRAMDATA_COVERAGE_SOURCE_MODEL, P03_RUN_RECOVER_UNAVAILABLE_FROM_CHAIN, PROFILES, P03_SETTLEMENT_TAGS, P03_INLINE_SETTLEMENT_TAGS, P03_PAYMENT_REPLAY_INDICES, NO_CONTEXTS, HISTORY_FETCH_CONCURRENCY, HISTORY_BULK_TRANSACTIONS, HISTORY_BULK_ADDRESSES, TRANSIENT_RPC_ATTEMPTS, TRANSIENT_RPC_BASE_DELAY_MS, LAGGING_NODE_RPC_CODES;
|
|
54282
|
+
var import_web396, REPLAY_STORE_INDEXED, CLOSE_REPLAY_TREE_TAG, EXTEND_ANCHOR_RING_TAG, LINK_SUCCESSOR_TAG, IMPORT_REPLAY_LEAVES_TAG, SETTLE_MOVE_TAG, SWEEP_PREDECESSOR_VAULT_TAG, RELINK_SUCCESSOR_TAG, ROTATE_PAYMENT_SETTLER_TAG, IMPORT_A_LEAF_BYTES, IMPORT_MEMBERSHIP_BYTES, IMPORT_PRESENT_SHIFT, IMPORT_MAX_ENTRIES, MOVE_HEAD_BYTES, MOVE_INSERTED_VALUES, DEFAULT_KEY, FIELD_BYTES2, PRIMARY_PROOF_BYTES, SUBTREE_LEAVES, PAGE_SIZE, FIELD_MODULUS3, BPF_LOADER_UPGRADEABLE_PROGRAM_ID, SYSTEM_PROGRAM, TEST_EXECUTABLES, reviewedExecutables, isProgramDataIdentityError, ASSUMED_ORIGINAL_EXECUTABLE, AUTHENTICATED_HISTORY_REPORTS, HISTORY_ATTESTATIONS, hasExecutableEvidence, P03_FINALIZED_HISTORY_SOURCE_MODEL, P03_PROGRAMDATA_COVERAGE_SOURCE_MODEL, P03_RUN_RECOVER_UNAVAILABLE_FROM_CHAIN, PROFILES, P03_SETTLEMENT_TAGS, P03_INLINE_SETTLEMENT_TAGS, P03_PAYMENT_REPLAY_INDICES, NO_CONTEXTS, REFRESH_READ_BYTES, E1_TREE_HEADER_BYTES, HISTORY_FETCH_CONCURRENCY, HISTORY_BULK_TRANSACTIONS, HISTORY_BULK_ADDRESSES, TRANSIENT_RPC_ATTEMPTS, TRANSIENT_RPC_BASE_DELAY_MS, LAGGING_NODE_RPC_CODES;
|
|
54211
54283
|
var init_walk = __esm({
|
|
54212
54284
|
"wallet/src/history/walk.mjs"() {
|
|
54213
54285
|
"use strict";
|
|
@@ -54216,6 +54288,7 @@ var init_walk = __esm({
|
|
|
54216
54288
|
init_esm2();
|
|
54217
54289
|
init_chain2();
|
|
54218
54290
|
init_proxy();
|
|
54291
|
+
init_phaseTiming();
|
|
54219
54292
|
init_quote2();
|
|
54220
54293
|
init_compressedReplay();
|
|
54221
54294
|
init_p03E1Tree();
|
|
@@ -54442,6 +54515,8 @@ var init_walk = __esm({
|
|
|
54442
54515
|
P03_INLINE_SETTLEMENT_TAGS = Object.freeze([24, 25, 26, 32]);
|
|
54443
54516
|
P03_PAYMENT_REPLAY_INDICES = PROFILES[4].replayIndices;
|
|
54444
54517
|
NO_CONTEXTS = Object.freeze([]);
|
|
54518
|
+
REFRESH_READ_BYTES = POOL_STATE_LEN_RING2;
|
|
54519
|
+
E1_TREE_HEADER_BYTES = 80;
|
|
54445
54520
|
HISTORY_FETCH_CONCURRENCY = 4;
|
|
54446
54521
|
HISTORY_BULK_TRANSACTIONS = 256;
|
|
54447
54522
|
HISTORY_BULK_ADDRESSES = 256;
|
|
@@ -55357,10 +55432,15 @@ async function readCompactP03History({
|
|
|
55357
55432
|
// it verified. Both are bound again below like served ones.
|
|
55358
55433
|
served,
|
|
55359
55434
|
initialization: knownInitialization,
|
|
55360
|
-
// walletHistory.mjs: the
|
|
55361
|
-
//
|
|
55362
|
-
//
|
|
55363
|
-
//
|
|
55435
|
+
// walletHistory.mjs: the pool's current index that a refresh read on this same own RPC moments
|
|
55436
|
+
// ago and refused as moved (p03_history_refresh_transition_detected carries it; that read held
|
|
55437
|
+
// only the tree's header). The page request starts at once, beside the pool account read below,
|
|
55438
|
+
// unless the cached records already reach that index.
|
|
55439
|
+
knownIndex,
|
|
55440
|
+
// walletHistory.mjs compactFirst: the full pool account (readFinalizedPool, tree included) that
|
|
55441
|
+
// an earlier try of this same load read and folded nothing to because the source was behind
|
|
55442
|
+
// (p03_compact_history_source_behind carries it as behindSnapshot). Folded to again instead of
|
|
55443
|
+
// a second read of the pool account and its 386 KB tree; every check below runs on it as before.
|
|
55364
55444
|
knownSnapshot,
|
|
55365
55445
|
// compactP03HistoryReport: run beside the spot checks once the initialization is verified
|
|
55366
55446
|
// ({ snapshot, initialization, contexts }); its result comes back as `alongside`.
|
|
@@ -55380,8 +55460,9 @@ async function readCompactP03History({
|
|
|
55380
55460
|
throw refuse3("p03_compact_history_connection_invalid");
|
|
55381
55461
|
}
|
|
55382
55462
|
own = withBoundedOwnReads(own);
|
|
55383
|
-
const
|
|
55384
|
-
const
|
|
55463
|
+
const hintIndex = knownSnapshot?.currentIndex ?? knownIndex;
|
|
55464
|
+
const cachedReachesKnown = hintIndex !== void 0 && served !== void 0 && Array.isArray(served.records) && Boolean(served.initialization) && BigInt(served.records.length) * SUBTREE_LEAVES3 >= hintIndex;
|
|
55465
|
+
const first = served === void 0 || hintIndex !== void 0 && !cachedReachesKnown ? requestPage(source, poolString, 0) : void 0;
|
|
55385
55466
|
if (first !== void 0) markPhase("compact-page0-sent");
|
|
55386
55467
|
const snapshot = knownSnapshot ?? await readFinalizedPool(own, program, poolKey);
|
|
55387
55468
|
markPhase(knownSnapshot !== void 0 ? "compact-pool-reused" : "compact-pool");
|
|
@@ -55396,7 +55477,10 @@ async function readCompactP03History({
|
|
|
55396
55477
|
initialization: served.initialization,
|
|
55397
55478
|
syncedSlot: served.syncedSlot,
|
|
55398
55479
|
cached: true
|
|
55399
|
-
} : await readPages(source, poolString, count2, first, { wakeSlot: snapshot.slot })
|
|
55480
|
+
} : await readPages(source, poolString, count2, first, { wakeSlot: snapshot.slot }).catch((error) => {
|
|
55481
|
+
if (error?.compactHistoryRefusal === "p03_compact_history_source_behind") error.behindSnapshot = snapshot;
|
|
55482
|
+
throw error;
|
|
55483
|
+
});
|
|
55400
55484
|
markPhase(page.cached === true ? "compact-list-cached" : "compact-list");
|
|
55401
55485
|
const binding = {
|
|
55402
55486
|
programId: programString,
|
|
@@ -55521,6 +55605,7 @@ async function compactP03HistoryReport({
|
|
|
55521
55605
|
forceRead = false,
|
|
55522
55606
|
freshMs = 0,
|
|
55523
55607
|
priorAttestation,
|
|
55608
|
+
knownIndex,
|
|
55524
55609
|
knownSnapshot,
|
|
55525
55610
|
onList
|
|
55526
55611
|
}) {
|
|
@@ -55590,6 +55675,7 @@ async function compactP03HistoryReport({
|
|
|
55590
55675
|
programId,
|
|
55591
55676
|
pool: pool2,
|
|
55592
55677
|
alongside: attest,
|
|
55678
|
+
...knownIndex !== void 0 ? { knownIndex } : {},
|
|
55593
55679
|
...knownSnapshot !== void 0 ? { knownSnapshot } : {},
|
|
55594
55680
|
...onList !== void 0 ? { onList } : {},
|
|
55595
55681
|
...warm ? { served: cached.served } : {},
|
|
@@ -56364,8 +56450,9 @@ async function loadWalletP03HistoryNow({ store, connection: given, programId, po
|
|
|
56364
56450
|
const runKey = lastRunReportKey(store, programId, pool2, deploymentIdentity, cache);
|
|
56365
56451
|
const remembered = runKey === void 0 || forceRead ? void 0 : lastRunReports.get(runKey);
|
|
56366
56452
|
const earlier = remembered !== void 0 && Date.now() - remembered.at <= HISTORY_WARM_FRESH_MS ? remembered.report : void 0;
|
|
56367
|
-
let
|
|
56453
|
+
let movedIndex;
|
|
56368
56454
|
if (earlier !== void 0) {
|
|
56455
|
+
markPhase("refresh-start");
|
|
56369
56456
|
try {
|
|
56370
56457
|
const refreshed = await refreshFinalizedP03HistorySnapshot({ connection, programId, pool: pool2, history: earlier });
|
|
56371
56458
|
markPhase("walk-refreshed");
|
|
@@ -56374,8 +56461,8 @@ async function loadWalletP03HistoryNow({ store, connection: given, programId, po
|
|
|
56374
56461
|
return refreshed;
|
|
56375
56462
|
} catch (error) {
|
|
56376
56463
|
markPhase("refresh-missed");
|
|
56377
|
-
if (error?.message === "p03_history_refresh_transition_detected" && error.
|
|
56378
|
-
|
|
56464
|
+
if (error?.message === "p03_history_refresh_transition_detected" && typeof error.currentIndex === "bigint" && error.snapshotBinding?.programId === String(programId) && error.snapshotBinding?.pool === String(pool2)) {
|
|
56465
|
+
movedIndex = error.currentIndex;
|
|
56379
56466
|
}
|
|
56380
56467
|
floor?.reset();
|
|
56381
56468
|
if (strict) floor?.strict();
|
|
@@ -56390,7 +56477,7 @@ async function loadWalletP03HistoryNow({ store, connection: given, programId, po
|
|
|
56390
56477
|
pool: pool2,
|
|
56391
56478
|
deploymentIdentity,
|
|
56392
56479
|
forceRead,
|
|
56393
|
-
|
|
56480
|
+
knownIndex: movedIndex,
|
|
56394
56481
|
onCompactList
|
|
56395
56482
|
});
|
|
56396
56483
|
if (compact !== void 0) {
|
|
@@ -56432,7 +56519,7 @@ async function loadWalletP03HistoryNow({ store, connection: given, programId, po
|
|
|
56432
56519
|
if (runKey !== void 0) rememberRunReport(runKey, result.report);
|
|
56433
56520
|
return result.report;
|
|
56434
56521
|
}
|
|
56435
|
-
async function compactFirst({ store, connection, source, programId, pool: pool2, deploymentIdentity, forceRead,
|
|
56522
|
+
async function compactFirst({ store, connection, source, programId, pool: pool2, deploymentIdentity, forceRead, knownIndex, onCompactList }) {
|
|
56436
56523
|
const started = Date.now();
|
|
56437
56524
|
let behindNoticed = false;
|
|
56438
56525
|
let behindTries = 0;
|
|
@@ -56456,8 +56543,9 @@ async function compactFirst({ store, connection, source, programId, pool: pool2,
|
|
|
56456
56543
|
}
|
|
56457
56544
|
}
|
|
56458
56545
|
};
|
|
56546
|
+
let behindSnapshot;
|
|
56459
56547
|
for (let tries = 0; ; tries += 1) {
|
|
56460
|
-
const result = await tryCompactP03HistoryReport(tries === 0 &&
|
|
56548
|
+
const result = await tryCompactP03HistoryReport(behindSnapshot !== void 0 ? { ...options, knownSnapshot: behindSnapshot } : tries === 0 && knownIndex !== void 0 ? { ...options, knownIndex } : options);
|
|
56461
56549
|
if (result.ok) {
|
|
56462
56550
|
markPhase("walk-compact");
|
|
56463
56551
|
const who = source === "pinned" ? "the pinned history proxy" : "--history-rpc";
|
|
@@ -56471,12 +56559,13 @@ async function compactFirst({ store, connection, source, programId, pool: pool2,
|
|
|
56471
56559
|
if (result.reason === "p03_compact_history_source_behind" && Date.now() - started + behindDelay <= HISTORY_RPC_BEHIND_WAIT_MS) {
|
|
56472
56560
|
if (!behindNoticed) {
|
|
56473
56561
|
behindNoticed = true;
|
|
56474
|
-
writeStderr(`history: the history proxy has fewer transitions than the pool account your own RPC read (it is behind the chain); asking it again after 0.5 s, 1 s, 2 s, then every 5 s, for at most ${HISTORY_RPC_BEHIND_WAIT_MS / 1e3} s
|
|
56562
|
+
writeStderr(`history: the history proxy has fewer transitions than the pool account your own RPC read (it is behind the chain); asking it again the first time as soon as it reaches that slot (checked every 0.15 s) or after 0.5 s, then after 1 s, 2 s, then every 5 s, for at most ${HISTORY_RPC_BEHIND_WAIT_MS / 1e3} s
|
|
56475
56563
|
`);
|
|
56476
56564
|
}
|
|
56477
56565
|
markPhase("compact-behind-wait");
|
|
56478
56566
|
behindTries += 1;
|
|
56479
|
-
|
|
56567
|
+
behindSnapshot = result.error?.behindSnapshot;
|
|
56568
|
+
await waitForCompactSource(options.history, pool2, behindTries === 1 ? behindSnapshot?.slot : void 0, behindDelay);
|
|
56480
56569
|
continue;
|
|
56481
56570
|
}
|
|
56482
56571
|
writeStderr(`history: the compact transition list was refused (${result.reason}${result.detail ? `; cause ${result.detail}` : ""}); walking the pool history instead
|
|
@@ -56484,6 +56573,30 @@ async function compactFirst({ store, connection, source, programId, pool: pool2,
|
|
|
56484
56573
|
return void 0;
|
|
56485
56574
|
}
|
|
56486
56575
|
}
|
|
56576
|
+
async function waitForCompactSource(source, pool2, slot3, budgetMs) {
|
|
56577
|
+
const sleep5 = (ms) => new Promise((resolve38) => setTimeout(resolve38, ms));
|
|
56578
|
+
if (!Number.isSafeInteger(slot3) || typeof source?._rpcRequest !== "function") return sleep5(budgetMs);
|
|
56579
|
+
const until = Date.now() + budgetMs;
|
|
56580
|
+
for (; ; ) {
|
|
56581
|
+
const abort = new AbortController();
|
|
56582
|
+
const params = [pool2, { commitment: "finalized", fromOrdinal: 0, toOrdinal: 1, minContextSlot: slot3 }];
|
|
56583
|
+
const read = (typeof source.abortableRpcRequest === "function" ? source.abortableRpcRequest("getP03Transitions", params, abort.signal) : source._rpcRequest("getP03Transitions", params)).catch(() => ({ failed: true }));
|
|
56584
|
+
let timer;
|
|
56585
|
+
const answer = await Promise.race([read, new Promise((resolve38) => {
|
|
56586
|
+
timer = setTimeout(resolve38, Math.max(COMPACT_BEHIND_READ_MS, until - Date.now()));
|
|
56587
|
+
})]);
|
|
56588
|
+
clearTimeout(timer);
|
|
56589
|
+
if (answer === void 0) abort.abort();
|
|
56590
|
+
if (answer?.result !== void 0) {
|
|
56591
|
+
markPhase("compact-behind-caught-up");
|
|
56592
|
+
return void 0;
|
|
56593
|
+
}
|
|
56594
|
+
if (answer !== void 0 && answer?.error?.code !== -32016) return sleep5(Math.max(0, until - Date.now()));
|
|
56595
|
+
const left = until - Date.now();
|
|
56596
|
+
if (left <= 0) return void 0;
|
|
56597
|
+
await sleep5(Math.min(COMPACT_BEHIND_POLL_MS, left));
|
|
56598
|
+
}
|
|
56599
|
+
}
|
|
56487
56600
|
function lastRunReportKey(store, programId, pool2, deploymentIdentity, cache) {
|
|
56488
56601
|
if (cache !== void 0 || !store || typeof store !== "object" || !deploymentIdentity) return void 0;
|
|
56489
56602
|
if (typeof store.path !== "string" || store.path.length === 0) return void 0;
|
|
@@ -56533,7 +56646,7 @@ function reportHistoryRpc(split5, source, result, crossChecked) {
|
|
|
56533
56646
|
writeStderr(`history: ${who} answered ${list(split5.history)}; your own RPC answered ${list(split5.own)} (the pool account the history must match, and the cross-check)${window2}${integrity}
|
|
56534
56647
|
`);
|
|
56535
56648
|
}
|
|
56536
|
-
var strictScope, withStrictHistorySource, recentScope, withRecentWalletHistory, recentLoads, forgetRecentWalletHistory, historyCacheKey, HISTORY_PREWARM_JOIN_MS, prewarmedWalks, PREWARMED_REPORTS, isPrewarmedWalletHistory, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, announcedSources;
|
|
56649
|
+
var strictScope, withStrictHistorySource, recentScope, withRecentWalletHistory, recentLoads, forgetRecentWalletHistory, historyCacheKey, HISTORY_PREWARM_JOIN_MS, prewarmedWalks, PREWARMED_REPORTS, isPrewarmedWalletHistory, COMPACT_BEHIND_POLL_MS, COMPACT_BEHIND_READ_MS, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, announcedSources;
|
|
56537
56650
|
var init_walletHistory = __esm({
|
|
56538
56651
|
"wallet/src/history/walletHistory.mjs"() {
|
|
56539
56652
|
"use strict";
|
|
@@ -56558,6 +56671,8 @@ var init_walletHistory = __esm({
|
|
|
56558
56671
|
prewarmedWalks = /* @__PURE__ */ new Map();
|
|
56559
56672
|
PREWARMED_REPORTS = /* @__PURE__ */ new WeakSet();
|
|
56560
56673
|
isPrewarmedWalletHistory = (report) => report !== null && typeof report === "object" && PREWARMED_REPORTS.has(report);
|
|
56674
|
+
COMPACT_BEHIND_POLL_MS = 150;
|
|
56675
|
+
COMPACT_BEHIND_READ_MS = 1e3;
|
|
56561
56676
|
COMPACT_BEHIND_RETRY_MS = [500, 1e3, 2e3, 5e3];
|
|
56562
56677
|
lastRunReports = /* @__PURE__ */ new Map();
|
|
56563
56678
|
writeStderr = (text3) => {
|
|
@@ -59908,6 +60023,12 @@ function workerCount() {
|
|
|
59908
60023
|
}
|
|
59909
60024
|
return Math.max(1, Math.min(MAX_WORKERS, cores - 1));
|
|
59910
60025
|
}
|
|
60026
|
+
function warmMemoDecryptPool() {
|
|
60027
|
+
try {
|
|
60028
|
+
workers();
|
|
60029
|
+
} catch {
|
|
60030
|
+
}
|
|
60031
|
+
}
|
|
59911
60032
|
function workers() {
|
|
59912
60033
|
if (pool !== void 0) return pool.broken ? void 0 : pool;
|
|
59913
60034
|
pool = { list: [], pending: /* @__PURE__ */ new Map(), broken: false };
|
|
@@ -60198,15 +60319,28 @@ var init_successorHistories = __esm({
|
|
|
60198
60319
|
});
|
|
60199
60320
|
|
|
60200
60321
|
// wallet/src/recovery/recover.mjs
|
|
60322
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
60201
60323
|
import { join as join10, resolve as resolve10 } from "node:path";
|
|
60202
60324
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
60203
60325
|
function pinnedGenerator2(profileVector) {
|
|
60204
60326
|
if (profileVector?.payerKeys?.generator) return profileVector.payerKeys.generator;
|
|
60205
|
-
|
|
60206
|
-
|
|
60207
|
-
|
|
60208
|
-
|
|
60209
|
-
|
|
60327
|
+
if (!committedGenerator) {
|
|
60328
|
+
const committed2 = JSON.parse(readFileSync(
|
|
60329
|
+
join10(MODEL_DIR, "vectors", "rust-vectors.json"),
|
|
60330
|
+
"utf8"
|
|
60331
|
+
));
|
|
60332
|
+
committedGenerator = Object.freeze(committed2.payerKeys.generator);
|
|
60333
|
+
}
|
|
60334
|
+
return committedGenerator;
|
|
60335
|
+
}
|
|
60336
|
+
function replayValueOf(kind, poolDomain, commitment, eta, leafIndex) {
|
|
60337
|
+
const key = createHash15("sha256").update(kind === "account" ? `account|${String(commitment)}|${String(eta)}|${String(leafIndex)}` : `note|${String(poolDomain)}|${String(commitment)}|${String(eta)}|${String(leafIndex)}`).digest("base64");
|
|
60338
|
+
const known = REPLAY_VALUES.get(key);
|
|
60339
|
+
if (known !== void 0) return known;
|
|
60340
|
+
const value = kind === "account" ? accountNullifier(commitment, eta, leafIndex) : noteNullifier2(poolDomain, commitment, eta, leafIndex);
|
|
60341
|
+
if (REPLAY_VALUES.size >= REPLAY_VALUES_MAX) REPLAY_VALUES.clear();
|
|
60342
|
+
REPLAY_VALUES.set(key, value);
|
|
60343
|
+
return value;
|
|
60210
60344
|
}
|
|
60211
60345
|
function assertFinalizedRecoveryContext(context, digest2, programId, pool2) {
|
|
60212
60346
|
const kinds = Object.freeze({ deposit: 1, payment: 2, withdraw: 3, "note-exit": 4, move: 5 });
|
|
@@ -60394,6 +60528,7 @@ function prefetchRecoveryMemos({ store, finalizedHistory: finalizedHistory2, ser
|
|
|
60394
60528
|
if (pending.length === 0) return;
|
|
60395
60529
|
createMemoReader(serviceUrl2, { fetchImpl: deps.fetchImpl ?? fetch, notice: () => {
|
|
60396
60530
|
} }).prefetch(pending);
|
|
60531
|
+
warmMemoDecryptPool();
|
|
60397
60532
|
} catch {
|
|
60398
60533
|
}
|
|
60399
60534
|
}
|
|
@@ -60486,7 +60621,13 @@ async function runRecover({ store, connection, programId, digests, serviceUrl: s
|
|
|
60486
60621
|
const recovered = [];
|
|
60487
60622
|
for (const { digest: digest2, context, outputs } of read.entries) {
|
|
60488
60623
|
for (const output2 of outputs) {
|
|
60489
|
-
const replayValue =
|
|
60624
|
+
const replayValue = replayValueOf(
|
|
60625
|
+
output2.kind,
|
|
60626
|
+
context.poolDomain,
|
|
60627
|
+
output2.commitment,
|
|
60628
|
+
viewingAuthority.eta,
|
|
60629
|
+
output2.leafIndex
|
|
60630
|
+
);
|
|
60490
60631
|
recovered.push({ ...output2, digest: digest2, replayValue });
|
|
60491
60632
|
}
|
|
60492
60633
|
}
|
|
@@ -60521,7 +60662,7 @@ async function runRecover({ store, connection, programId, digests, serviceUrl: s
|
|
|
60521
60662
|
...Array.isArray(digests) && digests.length > 0 ? { narrowedByDigests: true } : {}
|
|
60522
60663
|
};
|
|
60523
60664
|
}
|
|
60524
|
-
var import_web3102, FIELD_MODULUS6, MODEL_DIR, seedBytes3, hexOf2;
|
|
60665
|
+
var import_web3102, FIELD_MODULUS6, MODEL_DIR, seedBytes3, committedGenerator, REPLAY_VALUES, REPLAY_VALUES_MAX, hexOf2;
|
|
60525
60666
|
var init_recover = __esm({
|
|
60526
60667
|
"wallet/src/recovery/recover.mjs"() {
|
|
60527
60668
|
"use strict";
|
|
@@ -60541,6 +60682,8 @@ var init_recover = __esm({
|
|
|
60541
60682
|
fileURLToPath5(new URL("../../vendor/shielded-x402-model/", new URL("__bundled_source__/wallet/src/recovery/recover.mjs", import.meta.url).href))
|
|
60542
60683
|
);
|
|
60543
60684
|
seedBytes3 = (state) => Uint8Array.from(Buffer.from(state.seedHex, "hex"));
|
|
60685
|
+
REPLAY_VALUES = /* @__PURE__ */ new Map();
|
|
60686
|
+
REPLAY_VALUES_MAX = 5e4;
|
|
60544
60687
|
hexOf2 = (value) => String(value).replace(/^0x/, "").toLowerCase();
|
|
60545
60688
|
}
|
|
60546
60689
|
});
|
|
@@ -61136,6 +61279,7 @@ var init_errorCodes = __esm({
|
|
|
61136
61279
|
"p03_merchant_respend_evidence_account_file_invalid_json",
|
|
61137
61280
|
"p03_merchant_respend_evidence_digests_invalid_json",
|
|
61138
61281
|
"p03_merchant_respend_accounts_split_merge_first",
|
|
61282
|
+
"walk_history_required",
|
|
61139
61283
|
"merge_id_invalid",
|
|
61140
61284
|
"merge_id_reserved",
|
|
61141
61285
|
"p03_merchant_respend_insufficient_recovered_value",
|
|
@@ -62916,6 +63060,7 @@ var init_errorCodes = __esm({
|
|
|
62916
63060
|
"absorb_note_ambiguous",
|
|
62917
63061
|
"p03_payer_float_absorb_pocket_mismatch",
|
|
62918
63062
|
"p03_payer_float_absorb_exit_failed",
|
|
63063
|
+
"p03_payer_float_absorb_merge_failed",
|
|
62919
63064
|
"reverted_payment",
|
|
62920
63065
|
"config_invalid",
|
|
62921
63066
|
"p03_payer_float_journal_unwritable",
|
|
@@ -68279,14 +68424,14 @@ var init_solana_ed255192 = __esm({
|
|
|
68279
68424
|
});
|
|
68280
68425
|
|
|
68281
68426
|
// spikes/shielded-x402-solana/scripts/verify-production-parameter-bundle.mjs
|
|
68282
|
-
import { createHash as
|
|
68427
|
+
import { createHash as createHash16 } from "node:crypto";
|
|
68283
68428
|
import { dirname as dirname12, isAbsolute as isAbsolute4, relative as relative5, resolve as resolve11 } from "node:path";
|
|
68284
68429
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
68285
68430
|
function fail13(message) {
|
|
68286
68431
|
throw new Error(`production parameter bundle rejected: ${message}`);
|
|
68287
68432
|
}
|
|
68288
68433
|
function sha2567(bytes2) {
|
|
68289
|
-
return
|
|
68434
|
+
return createHash16("sha256").update(bytes2).digest("hex");
|
|
68290
68435
|
}
|
|
68291
68436
|
function assertHex2(value, bytes2, label) {
|
|
68292
68437
|
if (typeof value !== "string" || !new RegExp(`^[0-9a-f]{${bytes2 * 2}}$`).test(value)) {
|
|
@@ -68760,7 +68905,7 @@ var init_production_proof_bundle2 = __esm({
|
|
|
68760
68905
|
|
|
68761
68906
|
// spikes/shielded-x402-wallet/lib/p03-recovered-exit.mjs
|
|
68762
68907
|
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
68763
|
-
import { createHash as
|
|
68908
|
+
import { createHash as createHash17 } from "node:crypto";
|
|
68764
68909
|
import { dirname as dirname13, isAbsolute as isAbsolute5, join as join11, relative as relative6, resolve as resolve13 } from "node:path";
|
|
68765
68910
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
68766
68911
|
function fail14(reason) {
|
|
@@ -69161,7 +69306,7 @@ var init_p03_recovered_exit = __esm({
|
|
|
69161
69306
|
init_pool_denomination();
|
|
69162
69307
|
TOOLS_SCHEMA2 = "carbon-shielded-wallet/p03-public-proof-tools/v1";
|
|
69163
69308
|
REQUEST_SCHEMA2 = "carbon-shielded-x402/p03-recovered-exit-request/v1";
|
|
69164
|
-
sha2568 = (value) =>
|
|
69309
|
+
sha2568 = (value) => createHash17("sha256").update(value).digest("hex");
|
|
69165
69310
|
jsonBytes2 = (value) => Buffer.from(`${JSON.stringify(value, null, 2)}
|
|
69166
69311
|
`, "utf8");
|
|
69167
69312
|
CHILD_MAX_BUFFER2 = 128 * 1024 * 1024;
|
|
@@ -69193,7 +69338,7 @@ var init_p03_recovered_exit = __esm({
|
|
|
69193
69338
|
});
|
|
69194
69339
|
|
|
69195
69340
|
// spikes/shielded-x402-wallet/bin/shielded-wallet.mjs
|
|
69196
|
-
import { createHash as
|
|
69341
|
+
import { createHash as createHash18 } from "node:crypto";
|
|
69197
69342
|
import { homedir } from "node:os";
|
|
69198
69343
|
import { join as join12, resolve as resolve14 } from "node:path";
|
|
69199
69344
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
@@ -69680,7 +69825,7 @@ function contextHoldsPrimary(context, primaryHex) {
|
|
|
69680
69825
|
const expected = contextPrimaryHex(context, primaryHex);
|
|
69681
69826
|
if (expected === void 0) return false;
|
|
69682
69827
|
if (context.primaryPayloadHex !== void 0) return context.primaryPayloadHex === expected;
|
|
69683
|
-
return context.historySource === "compact" && typeof context.primaryPayloadSha256 === "string" && context.primaryPayloadSha256 ===
|
|
69828
|
+
return context.historySource === "compact" && typeof context.primaryPayloadSha256 === "string" && context.primaryPayloadSha256 === createHash18("sha256").update(Buffer.from(expected, "hex")).digest("hex");
|
|
69684
69829
|
}
|
|
69685
69830
|
function releaseIfSpentByOtherPayment({ store, history, prior }) {
|
|
69686
69831
|
const authenticated = assertAuthenticatedFinalizedP03History(history);
|
|
@@ -71263,7 +71408,7 @@ var init_poseidon_params_t_6 = __esm({
|
|
|
71263
71408
|
});
|
|
71264
71409
|
|
|
71265
71410
|
// src/server/payments/shielded/ShieldedSolanaP03QuoteCrypto.ts
|
|
71266
|
-
import { createHash as
|
|
71411
|
+
import { createHash as createHash19 } from "node:crypto";
|
|
71267
71412
|
function serializePinnedJson(value) {
|
|
71268
71413
|
if (Array.isArray(value)) return `[${value.map(serializePinnedJson).join(", ")}]`;
|
|
71269
71414
|
if (value !== null && typeof value === "object") {
|
|
@@ -71302,7 +71447,7 @@ function parseMatrix(value, rows, columns, label) {
|
|
|
71302
71447
|
}
|
|
71303
71448
|
function assertParameterArtifact(artifact, expected) {
|
|
71304
71449
|
if (!isJsonValue(artifact)) throw new Error("p03_quote_crypto_parameter_artifact_invalid");
|
|
71305
|
-
const digest2 =
|
|
71450
|
+
const digest2 = createHash19("sha256").update(serializePinnedJson(artifact)).digest("hex");
|
|
71306
71451
|
if (digest2 !== expected.sha256) throw new Error("p03_quote_crypto_parameter_hash_mismatch");
|
|
71307
71452
|
if (!artifact || typeof artifact !== "object" || Array.isArray(artifact)) {
|
|
71308
71453
|
throw new Error("p03_quote_crypto_parameter_shape_invalid");
|
|
@@ -71958,6 +72103,26 @@ function startFinalizedChainTime(connection) {
|
|
|
71958
72103
|
return time + Math.floor(age / 1e3);
|
|
71959
72104
|
};
|
|
71960
72105
|
}
|
|
72106
|
+
async function everyAccountHeld({ store, connection, programId, serviceUrl: serviceUrl2, reservedReplayValues, deps = {} }) {
|
|
72107
|
+
if (typeof deps.walkHistory !== "function") fail15("walk_history_required");
|
|
72108
|
+
const viewing = deriveWalletViewingAuthority2({ seedBytes: seedBytes5(store.state), generator: pinnedGenerator4() });
|
|
72109
|
+
const history = assertAuthenticatedFinalizedP03History(await withRecentWalletHistory(() => deps.walkHistory()));
|
|
72110
|
+
const recovery = await (deps.recover ?? runRecover)({
|
|
72111
|
+
store,
|
|
72112
|
+
connection,
|
|
72113
|
+
programId: new import_web3106.PublicKey(programId),
|
|
72114
|
+
serviceUrl: serviceUrl2,
|
|
72115
|
+
deps: { fetchImpl: deps.fetchImpl, finalizedHistory: history, transitionContextFor: history.transitionContextFor }
|
|
72116
|
+
});
|
|
72117
|
+
return recovery.recovered.filter((entry) => entry.kind === "account" && entry.spendStatus === "unspent").every((entry) => {
|
|
72118
|
+
if (entry.leafIndex === void 0 || entry.leafIndex === null) return true;
|
|
72119
|
+
try {
|
|
72120
|
+
return reservedReplayValues.has(accountNullifier(entry.commitment, viewing.eta, entry.leafIndex).toString());
|
|
72121
|
+
} catch {
|
|
72122
|
+
return true;
|
|
72123
|
+
}
|
|
72124
|
+
});
|
|
72125
|
+
}
|
|
71961
72126
|
async function prepareRecoveredPayment({
|
|
71962
72127
|
store,
|
|
71963
72128
|
connection,
|
|
@@ -72315,7 +72480,7 @@ var init_prepareRecoveredPayment = __esm({
|
|
|
72315
72480
|
});
|
|
72316
72481
|
|
|
72317
72482
|
// wallet/src/pay/receiptTransaction.mjs
|
|
72318
|
-
import { createHash as
|
|
72483
|
+
import { createHash as createHash20 } from "node:crypto";
|
|
72319
72484
|
function sameQuoteCommitment(left, right) {
|
|
72320
72485
|
const parse4 = (value) => {
|
|
72321
72486
|
if (typeof value !== "string" || value.length > 77 || !/^(?:0|[1-9][0-9]*|0x[0-9a-f]{64})$/.test(value)) return void 0;
|
|
@@ -72339,7 +72504,7 @@ function contextPayloadMatches(context, payload2) {
|
|
|
72339
72504
|
else fail16("receipt_history_proof_form_invalid");
|
|
72340
72505
|
if (bytes2 === void 0) return false;
|
|
72341
72506
|
if (context.primaryPayloadHex !== void 0) return context.primaryPayloadHex === bytes2.toString("hex");
|
|
72342
|
-
return context.primaryPayloadSha256 ===
|
|
72507
|
+
return context.primaryPayloadSha256 === createHash20("sha256").update(bytes2).digest("hex");
|
|
72343
72508
|
}
|
|
72344
72509
|
function submittedPayload(paymentHeader) {
|
|
72345
72510
|
const payload2 = decodePaymentSignatureHeader(paymentHeader)?.payload;
|
|
@@ -91130,38 +91295,8 @@ var init_pay = __esm({
|
|
|
91130
91295
|
}
|
|
91131
91296
|
});
|
|
91132
91297
|
|
|
91133
|
-
// wallet/src/fetch/keepAlive.mjs
|
|
91134
|
-
function proxiedRun() {
|
|
91135
|
-
const env = process.env;
|
|
91136
|
-
return Boolean(env.SHINJUKU_WALLET_PROXIED || env.NODE_USE_ENV_PROXY || env.HTTPS_PROXY || env.HTTP_PROXY || env.https_proxy || env.http_proxy);
|
|
91137
|
-
}
|
|
91138
|
-
function keepAliveDispatcher() {
|
|
91139
|
-
if (shared !== void 0) return shared;
|
|
91140
|
-
try {
|
|
91141
|
-
if (proxiedRun()) return void 0;
|
|
91142
|
-
const global2 = globalThis[GLOBAL_DISPATCHER];
|
|
91143
|
-
if (global2?.constructor?.name !== "Agent") return void 0;
|
|
91144
|
-
shared = new global2.constructor({ keepAliveTimeout: KEEP_ALIVE_MS, keepAliveMaxTimeout: KEEP_ALIVE_MS });
|
|
91145
|
-
return shared;
|
|
91146
|
-
} catch {
|
|
91147
|
-
return void 0;
|
|
91148
|
-
}
|
|
91149
|
-
}
|
|
91150
|
-
function keepAliveInit(init = {}) {
|
|
91151
|
-
const dispatcher = keepAliveDispatcher();
|
|
91152
|
-
return dispatcher === void 0 ? init : { ...init, dispatcher };
|
|
91153
|
-
}
|
|
91154
|
-
var GLOBAL_DISPATCHER, KEEP_ALIVE_MS, shared;
|
|
91155
|
-
var init_keepAlive = __esm({
|
|
91156
|
-
"wallet/src/fetch/keepAlive.mjs"() {
|
|
91157
|
-
"use strict";
|
|
91158
|
-
GLOBAL_DISPATCHER = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.1");
|
|
91159
|
-
KEEP_ALIVE_MS = 2e4;
|
|
91160
|
-
}
|
|
91161
|
-
});
|
|
91162
|
-
|
|
91163
91298
|
// wallet/src/pay/floatPay.mjs
|
|
91164
|
-
import { createHash as
|
|
91299
|
+
import { createHash as createHash21, randomBytes as randomBytes11 } from "node:crypto";
|
|
91165
91300
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
91166
91301
|
function floatRecordOf(store, requestId) {
|
|
91167
91302
|
try {
|
|
@@ -91351,7 +91486,7 @@ function canonicalBody({ requestId, resourceUrl, requirement, refundTo }) {
|
|
|
91351
91486
|
const text3 = `{"requestId":${JSON.stringify(opaque)},"resourceUrl":${JSON.stringify(resourceUrl)},"requirement":${JSON.stringify(requirement)},"refundTo":${JSON.stringify(refundTo)}}`;
|
|
91352
91487
|
const bytes2 = Buffer.from(text3, "utf8");
|
|
91353
91488
|
if (bytes2.length > MAX_BODY_BYTES) fail18("p03_float_body_too_large");
|
|
91354
|
-
return { bodyBase64: bytes2.toString("base64"), floatId:
|
|
91489
|
+
return { bodyBase64: bytes2.toString("base64"), floatId: createHash21("sha256").update(bytes2).digest("hex") };
|
|
91355
91490
|
}
|
|
91356
91491
|
function floatAnswer(resultBase64, record, store) {
|
|
91357
91492
|
let answer;
|
|
@@ -91557,7 +91692,8 @@ async function payViaFloat({
|
|
|
91557
91692
|
method: "POST",
|
|
91558
91693
|
body: Buffer.from(record.bodyBase64, "base64"),
|
|
91559
91694
|
headers: { "content-type": "application/json" },
|
|
91560
|
-
|
|
91695
|
+
// settlePriorBeforeQuote: a prior answer that holds every input is settled before the leg-1 402 (one quote, one row).
|
|
91696
|
+
deps: { ...withoutCallerBody(deps), fetchImpl: floatFetch(fetchImpl, seen), settlePriorBeforeQuote: true }
|
|
91561
91697
|
});
|
|
91562
91698
|
} catch (error) {
|
|
91563
91699
|
if (seen.refusal) {
|
|
@@ -92076,6 +92212,7 @@ async function finalizePendingReceipt({ store, connection, programId, name, time
|
|
|
92076
92212
|
const deadline = now() + timeoutMs;
|
|
92077
92213
|
let gated = false;
|
|
92078
92214
|
let strict = false;
|
|
92215
|
+
let gateClock;
|
|
92079
92216
|
for (; ; ) {
|
|
92080
92217
|
const record = store.readWal(name);
|
|
92081
92218
|
if (!isPending(record)) return record;
|
|
@@ -92099,15 +92236,19 @@ async function finalizePendingReceipt({ store, connection, programId, name, time
|
|
|
92099
92236
|
const answeredLongAgo = Number.isSafeInteger(record.answeredAtMs) && Date.now() - record.answeredAtMs >= FINALITY_GATE_SKIP_AFTER_MS;
|
|
92100
92237
|
if (!answeredLongAgo) {
|
|
92101
92238
|
strict = true;
|
|
92102
|
-
const
|
|
92103
|
-
const
|
|
92104
|
-
|
|
92239
|
+
const [tipClock, finalClock] = await Promise.all([finalizedClock(connection, "confirmed"), finalizedClock(connection)]);
|
|
92240
|
+
const tip = tipClock.slot;
|
|
92241
|
+
const target = tip > finalClock.slot ? tip + FINALITY_GATE_MARGIN_SLOTS : tip;
|
|
92242
|
+
gateClock = finalClock;
|
|
92243
|
+
while (gateClock.slot < target && now() < deadline) {
|
|
92105
92244
|
await sleep5(Math.min(pollMs, FINALITY_GATE_POLL_MS));
|
|
92245
|
+
gateClock = await finalizedClock(connection);
|
|
92106
92246
|
}
|
|
92107
92247
|
}
|
|
92108
92248
|
markPhase("gate");
|
|
92109
92249
|
}
|
|
92110
|
-
const clock2 = await finalizedClock(connection);
|
|
92250
|
+
const clock2 = gateClock ?? await finalizedClock(connection);
|
|
92251
|
+
gateClock = void 0;
|
|
92111
92252
|
const history = assertAuthenticatedFinalizedP03History(
|
|
92112
92253
|
await (strict ? withStrictHistorySource(() => deps.walkHistory()) : deps.walkHistory())
|
|
92113
92254
|
);
|
|
@@ -92498,6 +92639,31 @@ async function payResourceOnce({
|
|
|
92498
92639
|
}
|
|
92499
92640
|
await settlePrior(name);
|
|
92500
92641
|
}
|
|
92642
|
+
const settleDeferred = async () => {
|
|
92643
|
+
const answeredAt = (name) => store.readWal(name)?.answeredAtMs ?? 0;
|
|
92644
|
+
const shared2 = {};
|
|
92645
|
+
for (const name of deferred.splice(0).sort((a, b) => answeredAt(b) - answeredAt(a))) await settlePrior(name, shared2);
|
|
92646
|
+
held.clear();
|
|
92647
|
+
};
|
|
92648
|
+
if (deps.settlePriorBeforeQuote === true && deferred.length > 0 && !record) {
|
|
92649
|
+
let first = false;
|
|
92650
|
+
try {
|
|
92651
|
+
first = await withPhaseScope(mark, "held", () => (deps.everyAccountHeld ?? everyAccountHeld)({
|
|
92652
|
+
store,
|
|
92653
|
+
connection,
|
|
92654
|
+
programId,
|
|
92655
|
+
serviceUrl: serviceUrl2,
|
|
92656
|
+
reservedReplayValues: held,
|
|
92657
|
+
deps: { fetchImpl: deps.fetchImpl, walkHistory: finality.walkHistory }
|
|
92658
|
+
}));
|
|
92659
|
+
} catch {
|
|
92660
|
+
first = false;
|
|
92661
|
+
}
|
|
92662
|
+
if (first === true) {
|
|
92663
|
+
mark("prior-finality-first");
|
|
92664
|
+
await settleDeferred();
|
|
92665
|
+
}
|
|
92666
|
+
}
|
|
92501
92667
|
if (!record?.paymentHeader && typeof deps.warmHistory === "function") {
|
|
92502
92668
|
if (walkedThisRun && deps.warmHistory === deps.walkHistory) {
|
|
92503
92669
|
mark("history-warm-reused");
|
|
@@ -92635,10 +92801,7 @@ async function payResourceOnce({
|
|
|
92635
92801
|
const noProof = store.readWal(`resource-proof-${requestKey}`)?.proved === void 0;
|
|
92636
92802
|
if (noProof && deferred.length > 0 && /^p03_merchant_respend_inputs_held_by_pending_payment/.test(message)) {
|
|
92637
92803
|
mark("prior-finality-fallback");
|
|
92638
|
-
|
|
92639
|
-
const shared2 = {};
|
|
92640
|
-
for (const name of deferred.splice(0).sort((a, b) => answeredAt(b) - answeredAt(a))) await settlePrior(name, shared2);
|
|
92641
|
-
held.clear();
|
|
92804
|
+
await settleDeferred();
|
|
92642
92805
|
continue;
|
|
92643
92806
|
}
|
|
92644
92807
|
if (!requoted && noProof && (/^p03_merchant_respend_quote_life_short_requote/.test(message) || /^p03_merchant_respend_quote_expired/.test(message))) {
|
|
@@ -92796,7 +92959,7 @@ var init_payResource = __esm({
|
|
|
92796
92959
|
});
|
|
92797
92960
|
|
|
92798
92961
|
// wallet/src/pay/cli.mjs
|
|
92799
|
-
import { createHash as
|
|
92962
|
+
import { createHash as createHash22 } from "node:crypto";
|
|
92800
92963
|
import { resolve as resolve16 } from "node:path";
|
|
92801
92964
|
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
92802
92965
|
async function main2(args = process.argv.slice(2)) {
|
|
@@ -92916,7 +93079,7 @@ function writePaidAnswer(path, resultBase64) {
|
|
|
92916
93079
|
} catch {
|
|
92917
93080
|
throw new Error("p03_resource_cli_out_unwritable_rerun_same_request");
|
|
92918
93081
|
}
|
|
92919
|
-
return { path, bytes: bytes2.length, sha256:
|
|
93082
|
+
return { path, bytes: bytes2.length, sha256: createHash22("sha256").update(bytes2).digest("hex") };
|
|
92920
93083
|
}
|
|
92921
93084
|
function describeCliError(error, options = {}) {
|
|
92922
93085
|
return describeError(error, { fallback: "p03_resource_cli_failed", nameUnknown: true, ...options });
|
|
@@ -94115,7 +94278,7 @@ var init_secp256k1 = __esm({
|
|
|
94115
94278
|
});
|
|
94116
94279
|
|
|
94117
94280
|
// src/server/storage/EncryptedJsonFile.ts
|
|
94118
|
-
import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, createHash as
|
|
94281
|
+
import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, createHash as createHash24, randomBytes as randomBytes16 } from "node:crypto";
|
|
94119
94282
|
import { mkdir as mkdir3, open as open2, readFile as readFile4, rename as rename3, writeFile as writeFile2 } from "node:fs/promises";
|
|
94120
94283
|
import { dirname as dirname18 } from "node:path";
|
|
94121
94284
|
var EncryptedJsonFile, renameReplacing, renameReplacingSync, retryableWindowsRename, isEncryptedPayload, isMissingFile, isUnsupportedDirectorySync;
|
|
@@ -94241,7 +94404,7 @@ var init_EncryptedJsonFile = __esm({
|
|
|
94241
94404
|
await pause3();
|
|
94242
94405
|
}
|
|
94243
94406
|
const text3 = parts.join("");
|
|
94244
|
-
return { text: text3, sha256:
|
|
94407
|
+
return { text: text3, sha256: createHash24("sha256").update(text3, "utf8").digest("hex") };
|
|
94245
94408
|
}
|
|
94246
94409
|
const iv = randomBytes16(12);
|
|
94247
94410
|
const cipher = createCipheriv3("aes-256-gcm", this.key(), iv);
|
|
@@ -94253,7 +94416,7 @@ var init_EncryptedJsonFile = __esm({
|
|
|
94253
94416
|
sealed.push(cipher.final());
|
|
94254
94417
|
const ciphertext = Buffer.concat(sealed);
|
|
94255
94418
|
const head = `{"version":1,"algorithm":"aes-256-gcm","iv":"${iv.toString("base64")}","tag":"${cipher.getAuthTag().toString("base64")}","ciphertext":"`;
|
|
94256
|
-
const hash12 =
|
|
94419
|
+
const hash12 = createHash24("sha256").update(head, "utf8");
|
|
94257
94420
|
const encoded = [head];
|
|
94258
94421
|
const window2 = 3 * 256 * 1024;
|
|
94259
94422
|
for (let offset = 0; offset < ciphertext.length; offset += window2) {
|
|
@@ -94353,7 +94516,7 @@ var init_EncryptedJsonFile = __esm({
|
|
|
94353
94516
|
if (decoded.length === 32) return decoded;
|
|
94354
94517
|
} catch {
|
|
94355
94518
|
}
|
|
94356
|
-
return
|
|
94519
|
+
return createHash24("sha256").update(value).digest();
|
|
94357
94520
|
}
|
|
94358
94521
|
};
|
|
94359
94522
|
renameReplacing = async (from, to) => {
|
|
@@ -94919,7 +95082,7 @@ var init_poseidon_params_t_3 = __esm({
|
|
|
94919
95082
|
});
|
|
94920
95083
|
|
|
94921
95084
|
// src/server/payments/shielded/ShieldedSolanaP03Poseidon.ts
|
|
94922
|
-
import { createHash as
|
|
95085
|
+
import { createHash as createHash25 } from "node:crypto";
|
|
94923
95086
|
function serializePinnedJson2(value) {
|
|
94924
95087
|
if (Array.isArray(value)) return `[${value.map(serializePinnedJson2).join(", ")}]`;
|
|
94925
95088
|
if (value !== null && typeof value === "object") {
|
|
@@ -94958,7 +95121,7 @@ function parseMatrix2(value, rows, columns, label) {
|
|
|
94958
95121
|
}
|
|
94959
95122
|
function assertShieldedSolanaP03PoseidonParameterArtifact(artifact) {
|
|
94960
95123
|
if (!isJsonValue2(artifact)) throw new Error("p03_poseidon_parameter_artifact_invalid");
|
|
94961
|
-
const digest2 =
|
|
95124
|
+
const digest2 = createHash25("sha256").update(serializePinnedJson2(artifact)).digest("hex");
|
|
94962
95125
|
if (digest2 !== SHIELDED_SOLANA_P03_POSEIDON_PARAMETERS_SHA256) {
|
|
94963
95126
|
throw new Error("p03_poseidon_parameter_hash_mismatch");
|
|
94964
95127
|
}
|
|
@@ -95817,7 +95980,7 @@ var init_shieldedSellerAcceptance = __esm({
|
|
|
95817
95980
|
});
|
|
95818
95981
|
|
|
95819
95982
|
// wallet/src/seller/config.mjs
|
|
95820
|
-
import { createHash as
|
|
95983
|
+
import { createHash as createHash26 } from "node:crypto";
|
|
95821
95984
|
var import_web3119, fail26, sha2;
|
|
95822
95985
|
var init_config = __esm({
|
|
95823
95986
|
"wallet/src/seller/config.mjs"() {
|
|
@@ -95828,7 +95991,7 @@ var init_config = __esm({
|
|
|
95828
95991
|
fail26 = (code) => {
|
|
95829
95992
|
throw new Error(`p03_seller_${code}`);
|
|
95830
95993
|
};
|
|
95831
|
-
sha2 = (bytes2) =>
|
|
95994
|
+
sha2 = (bytes2) => createHash26("sha256").update(bytes2).digest("hex");
|
|
95832
95995
|
}
|
|
95833
95996
|
});
|
|
95834
95997
|
|
|
@@ -112945,7 +113108,7 @@ __export(binding_exports, {
|
|
|
112945
113108
|
commitmentsOpen: () => commitmentsOpen,
|
|
112946
113109
|
transcript: () => transcript
|
|
112947
113110
|
});
|
|
112948
|
-
import { createHash as
|
|
113111
|
+
import { createHash as createHash32, randomBytes as randomBytes26 } from "node:crypto";
|
|
112949
113112
|
function transcript(t, contextCommitment, D5, T, cLo, cHi) {
|
|
112950
113113
|
for (const [name, b] of [["programId", t.programId], ["pool", t.pool], ["mint", t.mint], ["vault", t.vault], ["counterparty", t.counterparty], ["T", T], ["C_lo", cLo], ["C_hi", cHi]]) {
|
|
112951
113114
|
if (b.length !== 32) throw new Error(`transcript ${name} must be 32 bytes, got ${b.length}`);
|
|
@@ -113031,7 +113194,7 @@ var init_binding = __esm({
|
|
|
113031
113194
|
bindCommitment = (v, k, rho) => sponge2([BIND_DOMAIN, v, k, rho]);
|
|
113032
113195
|
TRANSCRIPT_LEN = 391;
|
|
113033
113196
|
FORCED_TRANSCRIPT_LEN = 423;
|
|
113034
|
-
challenge = (tr) => BigInt(`0x${
|
|
113197
|
+
challenge = (tr) => BigInt(`0x${createHash32("sha256").update(tr).digest().subarray(0, 24).toString("hex")}`);
|
|
113035
113198
|
}
|
|
113036
113199
|
});
|
|
113037
113200
|
|
|
@@ -113614,7 +113777,7 @@ __export(witness_exports, {
|
|
|
113614
113777
|
memoDigestHex: () => memoDigestHex2,
|
|
113615
113778
|
treeAppendRequest: () => treeAppendRequest
|
|
113616
113779
|
});
|
|
113617
|
-
import { createHash as
|
|
113780
|
+
import { createHash as createHash33 } from "node:crypto";
|
|
113618
113781
|
function depositRequest(p) {
|
|
113619
113782
|
if (p.account.b !== p.bind.v || p.account.i !== 0n) throw new Error("a deposit account has b = v and i = 0");
|
|
113620
113783
|
return {
|
|
@@ -113663,7 +113826,7 @@ var init_witness2 = __esm({
|
|
|
113663
113826
|
WITNESS_SCHEMA = "carbon-shielded-x402/ctvault-v0b-witness/v1";
|
|
113664
113827
|
dec = (x) => x.toString();
|
|
113665
113828
|
acct = (a) => ({ d: dec(a.d), pDX: dec(a.pDX), i: dec(a.i), b: dec(a.b) });
|
|
113666
|
-
memoDigestHex2 = (memo) => `0x${
|
|
113829
|
+
memoDigestHex2 = (memo) => `0x${createHash33("sha256").update(memo, "utf8").digest("hex")}`;
|
|
113667
113830
|
bindFields = (b) => ({
|
|
113668
113831
|
value: dec(b.v),
|
|
113669
113832
|
blinding: dec(b.k),
|
|
@@ -114409,7 +114572,7 @@ var init_service2 = __esm({
|
|
|
114409
114572
|
});
|
|
114410
114573
|
|
|
114411
114574
|
// wallet/src/v0b/prover.mjs
|
|
114412
|
-
import { createHash as
|
|
114575
|
+
import { createHash as createHash34 } from "node:crypto";
|
|
114413
114576
|
import { join as join33, resolve as resolve32 } from "node:path";
|
|
114414
114577
|
function parseParamsPins(text3) {
|
|
114415
114578
|
const pins = {};
|
|
@@ -114524,7 +114687,7 @@ var init_prover2 = __esm({
|
|
|
114524
114687
|
ExitCTV1: "carbon-shielded-exact/exit-ct-v1/CEREMONY-proof/v0b",
|
|
114525
114688
|
TreeAppendV1: "carbon-shielded-exact/tree-append-v1/CEREMONY-proof/v0b"
|
|
114526
114689
|
});
|
|
114527
|
-
sha256File = (path) =>
|
|
114690
|
+
sha256File = (path) => createHash34("sha256").update(readFileSync(path)).digest("hex");
|
|
114528
114691
|
DEPOSIT_ORDER = spec_exports.DEPOSIT_CT_PUBLIC;
|
|
114529
114692
|
EXIT_ORDER = spec_exports.EXIT_CT_PUBLIC;
|
|
114530
114693
|
}
|
|
@@ -116187,7 +116350,7 @@ var init_lib2 = __esm({
|
|
|
116187
116350
|
});
|
|
116188
116351
|
|
|
116189
116352
|
// wallet/src/laneb/keys.mjs
|
|
116190
|
-
import { createHash as
|
|
116353
|
+
import { createHash as createHash35, createHmac as createHmac9 } from "node:crypto";
|
|
116191
116354
|
function seedBytes7(state) {
|
|
116192
116355
|
const seed = Buffer.from(String(state?.seedHex ?? ""), "hex");
|
|
116193
116356
|
if (seed.length !== 32) fail50("seed_invalid");
|
|
@@ -116288,7 +116451,7 @@ var init_keys3 = __esm({
|
|
|
116288
116451
|
}
|
|
116289
116452
|
return out;
|
|
116290
116453
|
};
|
|
116291
|
-
sha5123 = (...parts) =>
|
|
116454
|
+
sha5123 = (...parts) => createHash35("sha512").update(Buffer.concat(parts.map((part) => Buffer.from(part)))).digest();
|
|
116292
116455
|
hashToScalar = (...parts) => mod9(leToBig(sha5123(...parts)));
|
|
116293
116456
|
nonZero = (scalar) => {
|
|
116294
116457
|
if (scalar === 0n) fail50("degenerate_scalar");
|
|
@@ -116308,7 +116471,7 @@ var init_keys3 = __esm({
|
|
|
116308
116471
|
});
|
|
116309
116472
|
|
|
116310
116473
|
// wallet/src/laneb/flows.mjs
|
|
116311
|
-
import { createHash as
|
|
116474
|
+
import { createHash as createHash36 } from "node:crypto";
|
|
116312
116475
|
import { resolve as resolve34 } from "node:path";
|
|
116313
116476
|
function serviceRefusal(error, what, fallbackNext) {
|
|
116314
116477
|
if (error?.message === "laneb_service_not_enabled") {
|
|
@@ -116971,7 +117134,7 @@ var init_flows3 = __esm({
|
|
|
116971
117134
|
};
|
|
116972
117135
|
sleep3 = (ms) => new Promise((done) => setTimeout(done, ms));
|
|
116973
117136
|
isAddress4 = (value) => typeof value === "string" && /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(value);
|
|
116974
|
-
sha256Hex3 = (text3) =>
|
|
117137
|
+
sha256Hex3 = (text3) => createHash36("sha256").update(text3).digest("hex");
|
|
116975
117138
|
AMOUNT_SENTENCE = "We know the quoted price; for scheme confidential we also check the payer's proof that the transfer equals it. We cannot decrypt a slot. The chain shows no amount.";
|
|
116976
117139
|
saveBook = (store, book) => store.writeWal(BOOK, book);
|
|
116977
117140
|
planRpc = (rpc2) => ({
|
|
@@ -116981,7 +117144,7 @@ var init_flows3 = __esm({
|
|
|
116981
117144
|
});
|
|
116982
117145
|
|
|
116983
117146
|
// wallet/src/laneb/amountProof.mjs
|
|
116984
|
-
import { createHash as
|
|
117147
|
+
import { createHash as createHash37, randomBytes as randomBytes27 } from "node:crypto";
|
|
116985
117148
|
function readValidityContext(transactions) {
|
|
116986
117149
|
if (!Array.isArray(transactions) || transactions.length === 0) refuse13("the plan carries no transactions");
|
|
116987
117150
|
let validity;
|
|
@@ -117014,7 +117177,7 @@ function readValidityContext(transactions) {
|
|
|
117014
117177
|
return { sourcePubkey: data.slice(1, 33), destinationPubkey: data.slice(33, 65), auditorPubkey: data.slice(65, 97), lo: half(97), hi: half(225) };
|
|
117015
117178
|
}
|
|
117016
117179
|
function challenge2({ nonce, half, sourcePubkey, sourceHandle, R: R2, A1, A2, commitment }) {
|
|
117017
|
-
const digest2 =
|
|
117180
|
+
const digest2 = createHash37("sha512").update(Buffer.from(AMOUNT_PROOF_DOMAIN, "utf8")).update(nonce).update(Buffer.from(half, "utf8")).update(sourcePubkey).update(H2.toBytes()).update(sourceHandle).update(R2).update(A1).update(A2).update(commitment).digest();
|
|
117018
117181
|
return leToBig2(digest2) % L3;
|
|
117019
117182
|
}
|
|
117020
117183
|
function nonceBytes(nonce) {
|
|
@@ -117129,7 +117292,7 @@ var init_amountProof = __esm({
|
|
|
117129
117292
|
});
|
|
117130
117293
|
|
|
117131
117294
|
// wallet/src/laneb/x402pay.mjs
|
|
117132
|
-
import { createHash as
|
|
117295
|
+
import { createHash as createHash38, randomBytes as randomBytes28 } from "node:crypto";
|
|
117133
117296
|
import { resolve as resolve35 } from "node:path";
|
|
117134
117297
|
async function call2(promise, what, fallbackNext) {
|
|
117135
117298
|
try {
|
|
@@ -117601,7 +117764,7 @@ var init_x402pay = __esm({
|
|
|
117601
117764
|
}
|
|
117602
117765
|
};
|
|
117603
117766
|
sleep4 = (ms) => new Promise((done) => setTimeout(done, ms));
|
|
117604
|
-
sha256Hex4 = (bytes2) =>
|
|
117767
|
+
sha256Hex4 = (bytes2) => createHash38("sha256").update(bytes2).digest("hex");
|
|
117605
117768
|
isAddress5 = (value) => typeof value === "string" && /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(value);
|
|
117606
117769
|
isSignature2 = (value) => typeof value === "string" && /^[1-9A-HJ-NP-Za-km-z]{64,100}$/.test(value);
|
|
117607
117770
|
usdc5 = (atomic3) => {
|
|
@@ -118312,14 +118475,15 @@ function startHistoryPrewarm(session, store, mark) {
|
|
|
118312
118475
|
// for them after the walk, M). The same set the recovery asks (every listed transition
|
|
118313
118476
|
// its cache lacks); it takes an answer only for a transition of the verified report
|
|
118314
118477
|
// (chain.mjs createMemoReader prefetch; recover.mjs checks each bundle's digest).
|
|
118315
|
-
onCompactList: (
|
|
118316
|
-
markPhase("memo-prefetch");
|
|
118317
|
-
prefetchRecoveryMemos({ store, finalizedHistory: { contexts }, serviceUrl: session.memoServiceUrl, programId: session.programId });
|
|
118318
|
-
}
|
|
118478
|
+
onCompactList: memoPrefetchOnList(session, store)
|
|
118319
118479
|
}));
|
|
118320
118480
|
} catch {
|
|
118321
118481
|
}
|
|
118322
118482
|
}
|
|
118483
|
+
var memoPrefetchOnList = (session, store) => (contexts) => {
|
|
118484
|
+
markPhase("memo-prefetch");
|
|
118485
|
+
prefetchRecoveryMemos({ store, finalizedHistory: { contexts }, serviceUrl: session.memoServiceUrl, programId: session.programId });
|
|
118486
|
+
};
|
|
118323
118487
|
var lazyProofTools = (session) => new Proxy({}, { get: (_target, key) => session.proofTools[key] });
|
|
118324
118488
|
async function paidCall({ session, target, method, headers, body, cap, requestId, price, challenge: challenge3, timing, mark }) {
|
|
118325
118489
|
if (session.closed) fail20("fetch_session_closed", "this payer session is closed; open a new one");
|
|
@@ -118372,7 +118536,8 @@ async function paidCall({ session, target, method, headers, body, cap, requestId
|
|
|
118372
118536
|
connection: connectSplit(session.connection, session.historyUrl),
|
|
118373
118537
|
programId: session.programId,
|
|
118374
118538
|
pool: store.state.pool,
|
|
118375
|
-
deploymentIdentity: session.proofTools.deploymentIdentity
|
|
118539
|
+
deploymentIdentity: session.proofTools.deploymentIdentity,
|
|
118540
|
+
onCompactList: memoPrefetchOnList(session, store)
|
|
118376
118541
|
})
|
|
118377
118542
|
}
|
|
118378
118543
|
});
|
|
@@ -118399,7 +118564,7 @@ async function paidCall({ session, target, method, headers, body, cap, requestId
|
|
|
118399
118564
|
// wallet/src/mcp/stdioServer.mjs
|
|
118400
118565
|
init_fs();
|
|
118401
118566
|
var import_web3131 = __toESM(require_index_cjs(), 1);
|
|
118402
|
-
import { createHash as
|
|
118567
|
+
import { createHash as createHash30 } from "node:crypto";
|
|
118403
118568
|
import { dirname as dirname24, join as join27, resolve as resolve25, sep as sep4 } from "node:path";
|
|
118404
118569
|
import { fileURLToPath as fileURLToPath17 } from "node:url";
|
|
118405
118570
|
init_proxy();
|
|
@@ -118678,7 +118843,7 @@ function addToJsonHost(file, entry, { now = /* @__PURE__ */ new Date(), force =
|
|
|
118678
118843
|
// wallet/src/setup/proofTools.mjs
|
|
118679
118844
|
init_fs();
|
|
118680
118845
|
init_rpcDefault();
|
|
118681
|
-
import { createHash as
|
|
118846
|
+
import { createHash as createHash23 } from "node:crypto";
|
|
118682
118847
|
import { dirname as dirname17, join as join17, sep as sep3 } from "node:path";
|
|
118683
118848
|
|
|
118684
118849
|
// wallet/src/setup/channel.mjs
|
|
@@ -118913,7 +119078,7 @@ var LIMITS = Object.freeze({ release: 64 * 1024, sums: 64 * 1024, file: 200 * 10
|
|
|
118913
119078
|
var RELEASE_TIMEOUT_MS = 3e4;
|
|
118914
119079
|
var FILE_TIMEOUT_MS = 15 * 6e4;
|
|
118915
119080
|
var REQUIRED_FILES = Object.freeze(["proof-tools.json", "exit-proof-tools.json", "public-profile.json"]);
|
|
118916
|
-
var sha2569 = (bytes2) =>
|
|
119081
|
+
var sha2569 = (bytes2) => createHash23("sha256").update(bytes2).digest("hex");
|
|
118917
119082
|
var fail22 = (code, detail) => new Error(`${code}: ${detail}`);
|
|
118918
119083
|
async function getBytes(fetchImpl, url, timeoutMs, label, maxBytes, budget) {
|
|
118919
119084
|
const limit = budget ? Math.min(maxBytes, budget.left) : maxBytes;
|
|
@@ -119954,7 +120119,7 @@ init_shielded_wallet();
|
|
|
119954
120119
|
|
|
119955
120120
|
// wallet/src/mcp/autoPockets.mjs
|
|
119956
120121
|
init_http();
|
|
119957
|
-
import { createHash as
|
|
120122
|
+
import { createHash as createHash27 } from "node:crypto";
|
|
119958
120123
|
|
|
119959
120124
|
// wallet/src/pocket/auto.mjs
|
|
119960
120125
|
var import_web3126 = __toESM(require_index_cjs(), 1);
|
|
@@ -121285,7 +121450,7 @@ var REST_OF_FILL_SECONDS = Object.freeze({
|
|
|
121285
121450
|
});
|
|
121286
121451
|
var REFILLING_CODE = "wallet_refilling_retry_same_request";
|
|
121287
121452
|
var firstCode3 = (error) => String(error?.message ?? error ?? "").split(/[\s:;(]/, 1)[0];
|
|
121288
|
-
var sha25610 = (text3) =>
|
|
121453
|
+
var sha25610 = (text3) => createHash27("sha256").update(text3, "utf8").digest("hex");
|
|
121289
121454
|
function requestFingerprint({ url, method = "GET", headers = {}, body }) {
|
|
121290
121455
|
const sorted = Object.entries(headers ?? {}).map(([name, value]) => [name.toLowerCase(), String(value)]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
121291
121456
|
return sha25610(JSON.stringify([String(url), String(method).toUpperCase(), sorted, body ?? null]));
|
|
@@ -124481,7 +124646,7 @@ function createOneTimeAdopter({ session, log = () => {
|
|
|
124481
124646
|
|
|
124482
124647
|
// wallet/src/mcp/answer.mjs
|
|
124483
124648
|
init_fs();
|
|
124484
|
-
import { createHash as
|
|
124649
|
+
import { createHash as createHash28 } from "node:crypto";
|
|
124485
124650
|
import { join as join24 } from "node:path";
|
|
124486
124651
|
var DEFAULT_MAX_INLINE_BYTES = 4e6;
|
|
124487
124652
|
var DEFAULT_MAX_TEXT_CHARS = 64 * 1024;
|
|
@@ -124645,7 +124810,7 @@ function extractEmbeddedImages(json2, { saveDir, now, maxInlineBytes = DEFAULT_M
|
|
|
124645
124810
|
return NOT_AN_IMAGE;
|
|
124646
124811
|
}
|
|
124647
124812
|
const sniffed = sniffImage(decoded);
|
|
124648
|
-
const sha3 =
|
|
124813
|
+
const sha3 = createHash28("sha256").update(decoded).digest("hex");
|
|
124649
124814
|
if (!sniffed) {
|
|
124650
124815
|
const svg = claimedMime === "image/svg+xml" || looksLikeSvg(decoded);
|
|
124651
124816
|
const saved2 = save(decoded, svg ? "svg" : "bin", saveDir, now, sha3);
|
|
@@ -124711,7 +124876,7 @@ function paidAnswerContent({
|
|
|
124711
124876
|
bytes: data.length,
|
|
124712
124877
|
...truncated ? { answerTruncated: true } : {}
|
|
124713
124878
|
};
|
|
124714
|
-
const sha25612 =
|
|
124879
|
+
const sha25612 = createHash28("sha256").update(data).digest("hex");
|
|
124715
124880
|
const sniffed = sniffImage(data);
|
|
124716
124881
|
if (sniffed && (declared === "" || declared.startsWith("image/") || declared === "application/octet-stream")) {
|
|
124717
124882
|
const saved2 = save(data, RASTER[sniffed], saveDir, now, sha25612);
|
|
@@ -124792,7 +124957,7 @@ function paidAnswerContent({
|
|
|
124792
124957
|
|
|
124793
124958
|
// wallet/src/mcp/discover.mjs
|
|
124794
124959
|
init_fs();
|
|
124795
|
-
import { createHash as
|
|
124960
|
+
import { createHash as createHash29 } from "node:crypto";
|
|
124796
124961
|
import { join as join25 } from "node:path";
|
|
124797
124962
|
var SOLANA_MAINNET = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
124798
124963
|
var SOLANA_USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
@@ -125263,7 +125428,7 @@ function clip(text3, max) {
|
|
|
125263
125428
|
return text3.length > max ? `${text3.slice(0, max - 1)}\u2026` : text3;
|
|
125264
125429
|
}
|
|
125265
125430
|
function cachePath(key, cacheDir) {
|
|
125266
|
-
return join25(cacheDir, `x402-discover-${
|
|
125431
|
+
return join25(cacheDir, `x402-discover-${createHash29("sha256").update(key).digest("hex").slice(0, 24)}.json`);
|
|
125267
125432
|
}
|
|
125268
125433
|
function readCache(key, ctx, maxAge) {
|
|
125269
125434
|
const age = (record) => ctx.clock() - Number(record?.fetchedAt);
|
|
@@ -125554,6 +125719,7 @@ var withTimeout = (promise, ms) => Promise.race([
|
|
|
125554
125719
|
})
|
|
125555
125720
|
]);
|
|
125556
125721
|
var ownKey = (store) => import_web3130.Keypair.fromSecretKey(Uint8Array.from(store.state.solanaSecretKey)).publicKey;
|
|
125722
|
+
var readFailure = (error) => [error?.name ?? "Error", error?.cause?.code, String(error?.message ?? "").replace(/[a-z][a-z0-9+.-]*:\/\/\S+/gi, "<url>").replace(/api[-_]?key=\S+/gi, "<key>").slice(0, 160)].filter(Boolean).join(" ");
|
|
125557
125723
|
async function readOwnPublicBalance({ session, store }) {
|
|
125558
125724
|
const owner = ownKey(store);
|
|
125559
125725
|
const tokenAccount = getAssociatedTokenAddressSync(new import_web3130.PublicKey(store.state.asset), owner, false, TOKEN_PROGRAM_ID);
|
|
@@ -126602,7 +126768,7 @@ function createWalletTools({
|
|
|
126602
126768
|
]);
|
|
126603
126769
|
if (answered.reading) {
|
|
126604
126770
|
publicRead.then(({ error: late2 }) => {
|
|
126605
|
-
if (late2) log(`MCP_PUBLIC_READ_FAILED_LATE ${late2
|
|
126771
|
+
if (late2) log(`MCP_PUBLIC_READ_FAILED_LATE ${readFailure(late2)}`);
|
|
126606
126772
|
});
|
|
126607
126773
|
}
|
|
126608
126774
|
const { read, error } = answered;
|
|
@@ -126621,7 +126787,7 @@ function createWalletTools({
|
|
|
126621
126787
|
unshieldedSolLamports: read.solLamports
|
|
126622
126788
|
};
|
|
126623
126789
|
} else {
|
|
126624
|
-
log(`MCP_PUBLIC_READ_FAILED ${error
|
|
126790
|
+
log(`MCP_PUBLIC_READ_FAILED ${readFailure(error)}`);
|
|
126625
126791
|
unshielded = {
|
|
126626
126792
|
unshieldedAtomic: null,
|
|
126627
126793
|
unshielded: null,
|
|
@@ -128050,7 +128216,7 @@ function runningBundleFile({ moduleUrl = new URL("__bundled_source__/wallet/src/
|
|
|
128050
128216
|
function runningReleaseSha256({ bundleFile = runningBundleFile() } = {}) {
|
|
128051
128217
|
if (!bundleFile) return Promise.resolve(void 0);
|
|
128052
128218
|
return new Promise((done) => {
|
|
128053
|
-
readFile(bundleFile, (error, bytes2) => done(error ? void 0 :
|
|
128219
|
+
readFile(bundleFile, (error, bytes2) => done(error ? void 0 : createHash30("sha256").update(bytes2).digest("hex")));
|
|
128054
128220
|
});
|
|
128055
128221
|
}
|
|
128056
128222
|
async function checkWalletUpdate({ facilitator, ownSha256 = runningReleaseSha256, fetchReleaseImpl = fetchRelease } = {}) {
|
|
@@ -130125,7 +130291,7 @@ init_chain2();
|
|
|
130125
130291
|
init_proxy();
|
|
130126
130292
|
init_sealedCache();
|
|
130127
130293
|
init_reference2();
|
|
130128
|
-
import { createHash as
|
|
130294
|
+
import { createHash as createHash31, createPublicKey as createPublicKey6, verify as verify3 } from "node:crypto";
|
|
130129
130295
|
var PROGRAM_ID = new import_web3133.PublicKey("9fhQBbumKEFuXtMBDw8AaQyAjCorLGJQiS3skWZdQyQD");
|
|
130130
130296
|
var USDC_MINT = new import_web3133.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
130131
130297
|
var TREE_ACCOUNT = import_web3133.PublicKey.findProgramAddressSync([Buffer.from("merkle_tree"), USDC_MINT.toBuffer()], PROGRAM_ID)[0];
|
|
@@ -130134,7 +130300,7 @@ var TREE_ACCOUNT_BYTES = 4136;
|
|
|
130134
130300
|
var NEXT_INDEX_OFFSET = 40;
|
|
130135
130301
|
var ROOT_HISTORY_OFFSET = 912;
|
|
130136
130302
|
var ROOT_HISTORY_SIZE_OFFSET = 4129;
|
|
130137
|
-
var EVENT_DISCRIMINATOR =
|
|
130303
|
+
var EVENT_DISCRIMINATOR = createHash31("sha256").update("event:SplCommitmentData").digest().subarray(0, 8);
|
|
130138
130304
|
var EVENT_HEADER_BYTES = 84;
|
|
130139
130305
|
var LOG_DATA = "Program data: ";
|
|
130140
130306
|
var SIGNATURE_PAGE = 1e3;
|
|
@@ -132968,7 +133134,7 @@ var rpcFlags = [
|
|
|
132968
133134
|
var HISTORY_RPC_FLAG = flag2(
|
|
132969
133135
|
"--history-rpc",
|
|
132970
133136
|
"<own|url>",
|
|
132971
|
-
`where the pool's public history comes from (the history walk: its signature lists, transactions, and block signature lists). Default with --tor: the history proxy onion this wallet pins for the pool (the pool ${GUIDE.pool} has one; a pool without one uses your own RPC), so your RPC provider does not see that you read this pool; Default without --tor: the same history proxy over https on the facilitator's pay host (that host already serves your memos and payments), so a first walk takes seconds, not minutes of rate-limited RPC calls; a pool without one uses your own RPC. A line on stderr says which source the run uses. own: your own RPC serves it, with or without --tor, so your RPC provider sees that you read this pool. An https URL, or an http://<v3 onion>/ origin with --tor, serves it instead. That source sees that a client read this pool's public history (and your IP address unless you add --tor), not who; every wallet of the pool makes the same reads. A refresh asks it for every record of a fixed 256-record bucket of the pool's list and the newer ones, not only what is newer than your last refresh, so it sees that refresh only to the bucket (more reads than your own RPC needs). Your own RPC still serves the pool account that the history must match, and every read that names your wallet (your own payment, deposit, and pocket reads). If the source is a little behind the chain, the walk continues at once with the history up to the slot the source has reached, which matches when the pool did not change after that slot; only when it did, the walk asks the source again after 0.5 s, 1 s, 2 s, then every 5 s, for at most 60 s. The wallet checks the signatures of every transaction the source serves, and each refresh reads 3 of them, drawn at random, again on your own RPC (so your RPC provider sees 3 pool reads per refresh). If the source fails, stays behind, or serves history that does not match (a bad signature or a cross-check mismatch), the command stops and says so. It never falls back to your own RPC. A URL that holds an API key shows in the process list and shell history`,
|
|
133137
|
+
`where the pool's public history comes from (the history walk: its signature lists, transactions, and block signature lists). Default with --tor: the history proxy onion this wallet pins for the pool (the pool ${GUIDE.pool} has one; a pool without one uses your own RPC), so your RPC provider does not see that you read this pool; Default without --tor: the same history proxy over https on the facilitator's pay host (that host already serves your memos and payments), so a first walk takes seconds, not minutes of rate-limited RPC calls; a pool without one uses your own RPC. A line on stderr says which source the run uses. own: your own RPC serves it, with or without --tor, so your RPC provider sees that you read this pool. An https URL, or an http://<v3 onion>/ origin with --tor, serves it instead. That source sees that a client read this pool's public history (and your IP address unless you add --tor), not who; every wallet of the pool makes the same reads. A refresh asks it for every record of a fixed 256-record bucket of the pool's list and the newer ones, not only what is newer than your last refresh, so it sees that refresh only to the bucket (more reads than your own RPC needs). Your own RPC still serves the pool account that the history must match, and every read that names your wallet (your own payment, deposit, and pocket reads). If the source is a little behind the chain, the walk continues at once with the history up to the slot the source has reached, which matches when the pool did not change after that slot; only when it did, the walk asks the source again every 0.15 s for about 2 s, then after 0.5 s, 1 s, 2 s, then every 5 s, for at most 60 s. The wallet checks the signatures of every transaction the source serves, and each refresh reads 3 of them, drawn at random, again on your own RPC (so your RPC provider sees 3 pool reads per refresh). If the source fails, stays behind, or serves history that does not match (a bad signature or a cross-check mismatch), the command stops and says so. It never falls back to your own RPC. A URL that holds an API key shows in the process list and shell history`,
|
|
132972
133138
|
{ check: "history-rpc" }
|
|
132973
133139
|
);
|
|
132974
133140
|
var recoverFlags = (options = {}) => [
|