shinjuku-shield 0.3.199 → 0.3.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/manifest.json +6 -6
- package/package.json +3 -3
- package/shinjuku-seller.mjs +7 -2
- package/shinjuku-wallet.mjs +309 -36
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@ web services and AI answers from your private balance, so the payment does
|
|
|
5
5
|
not show who paid. It works inside your AI app (Claude, Cursor, Codex) and in
|
|
6
6
|
a terminal. Only you hold the keys: they never leave your computer.
|
|
7
7
|
|
|
8
|
-
This is version 0.3.
|
|
8
|
+
This is version 0.3.200. The command is `shinjuku`.
|
|
9
9
|
|
|
10
10
|
## Set up
|
|
11
11
|
|
|
12
12
|
```sh
|
|
13
|
-
npx -y shinjuku@0.3.
|
|
13
|
+
npx -y shinjuku@0.3.200 setup
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Setup does every step for you:
|
|
@@ -107,14 +107,14 @@ Add it yourself. The name of the wallet in your app is `shinjuku`.
|
|
|
107
107
|
Claude Code:
|
|
108
108
|
|
|
109
109
|
```sh
|
|
110
|
-
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.
|
|
110
|
+
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.200 mcp
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
In this test version only (not offered yet), the same entry for Claude Desktop
|
|
114
114
|
(`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
|
|
115
115
|
|
|
116
116
|
```json
|
|
117
|
-
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.
|
|
117
|
+
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.200", "mcp"] } } }
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
On Windows, if the app cannot find `npx`, use `"command": "cmd"` and put
|
|
@@ -126,7 +126,7 @@ CLI read `~/.codex/config.toml`):
|
|
|
126
126
|
```toml
|
|
127
127
|
[mcp_servers.shinjuku]
|
|
128
128
|
command = "npx"
|
|
129
|
-
args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.
|
|
129
|
+
args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.200", "mcp"]
|
|
130
130
|
startup_timeout_sec = 120
|
|
131
131
|
tool_timeout_sec = 300
|
|
132
132
|
```
|
|
@@ -144,7 +144,7 @@ with the Releases table in
|
|
|
144
144
|
Versions are published from GitHub Actions with npm provenance.
|
|
145
145
|
|
|
146
146
|
`shinjuku-shield` is the package that holds the wallet. `shinjuku-shielded`
|
|
147
|
-
0.3.
|
|
147
|
+
0.3.200, its older name, runs this package at the same version, so wallets
|
|
148
148
|
installed under that name keep updating. New installs use `shinjuku`.
|
|
149
149
|
|
|
150
150
|
The full guide is
|
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": "373e47b02351671d49cb9b32f4c6d10d7695f424e8db567275ae4d7223dde2d3",
|
|
5
|
+
"bytes": 9484585,
|
|
6
|
+
"sourceCommit": "8b293fb3683ac967662bd6c19ad7bce6c222bf0d",
|
|
7
7
|
"sourceDirty": false,
|
|
8
8
|
"installRecordMatchesLockfile": true,
|
|
9
9
|
"releaseRule": "valid only when two fresh npm ci --ignore-scripts builds on different OSes give the same sha256; installRecordMatchesLockfile true means every entry npm installed equals its package-lock.json entry and every entry not marked optional, devOptional included, is installed: an optional entry (a package for another platform) may be absent",
|
|
@@ -1040,8 +1040,8 @@
|
|
|
1040
1040
|
],
|
|
1041
1041
|
"seller": {
|
|
1042
1042
|
"file": "shinjuku-seller.mjs",
|
|
1043
|
-
"sha256": "
|
|
1044
|
-
"bytes":
|
|
1043
|
+
"sha256": "79f96952a80005f96522abcb4a8fa1fc64ca08d9d435cd71c53f76ed513f7644",
|
|
1044
|
+
"bytes": 3734101,
|
|
1045
1045
|
"entry": "wallet/src/seller/exact/index.mjs",
|
|
1046
1046
|
"external": [
|
|
1047
1047
|
"@x402/core/http",
|
|
@@ -1932,5 +1932,5 @@
|
|
|
1932
1932
|
}
|
|
1933
1933
|
]
|
|
1934
1934
|
},
|
|
1935
|
-
"publishedAt": "2026-11-
|
|
1935
|
+
"publishedAt": "2026-11-09T04:12:35.618Z"
|
|
1936
1936
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shield",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.200",
|
|
4
4
|
"mcpName": "io.github.ShinjukuStaition/shinjuku-shield",
|
|
5
5
|
"description": "Shinjuku Shield, private x402 payments on Solana: the self-custody wallet CLI and its MCP server. Shield, pay, and unshield USDC from any MCP agent, under caps you set.",
|
|
6
|
-
"shinjukuRelease": "
|
|
7
|
-
"shinjukuSha256": "
|
|
6
|
+
"shinjukuRelease": "373e47b0",
|
|
7
|
+
"shinjukuSha256": "373e47b02351671d49cb9b32f4c6d10d7695f424e8db567275ae4d7223dde2d3",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shield",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
|
package/shinjuku-seller.mjs
CHANGED
|
@@ -48700,6 +48700,9 @@ function rpcRefusalWords(refusal) {
|
|
|
48700
48700
|
function rpcRefusalCode(refusal) {
|
|
48701
48701
|
return refusal.lasting ? `rpc_refused_${refusal.kind}` : "rpc_refused";
|
|
48702
48702
|
}
|
|
48703
|
+
function rpcRefusalTail(refusal) {
|
|
48704
|
+
return refusal.unlikely ? `${rpcRefusalCode(refusal)}: ${rpcRefusalWords(refusal)}` : rpcRefusalWords(refusal);
|
|
48705
|
+
}
|
|
48703
48706
|
var JSON_RPC_REQUEST_ERRORS, PASSING_4XX, HTTP_ANSWER, REQUEST_ERROR_TEXT, PASSING_TEXT, ALLOWLIST_TEXT, KEY_TEXT, AUTH_TEXT, KIND_WORDS, RPC_REFUSAL_HINT;
|
|
48704
48707
|
var init_rpcRefusal = __esm({
|
|
48705
48708
|
"wallet/src/net/rpcRefusal.mjs"() {
|
|
@@ -56349,7 +56352,8 @@ async function walkWalletP03HistoryNow({
|
|
|
56349
56352
|
}
|
|
56350
56353
|
} catch (error) {
|
|
56351
56354
|
if (split3 && (historyRpcFailed(error) || /^p03_history_/.test(String(error?.message)))) {
|
|
56352
|
-
|
|
56355
|
+
const answered = rpcRefusalOf(error);
|
|
56356
|
+
throw new Error(answered ? `history_rpc_failed: ${rpcRefusalTail(answered)}` : "history_rpc_failed", { cause: error });
|
|
56353
56357
|
}
|
|
56354
56358
|
throw error;
|
|
56355
56359
|
}
|
|
@@ -56621,6 +56625,7 @@ var init_walletHistory = __esm({
|
|
|
56621
56625
|
init_phaseTiming();
|
|
56622
56626
|
init_recoveryPath();
|
|
56623
56627
|
init_runEnd();
|
|
56628
|
+
init_rpcRefusal();
|
|
56624
56629
|
init_store();
|
|
56625
56630
|
strictScope = new AsyncLocalStorage3();
|
|
56626
56631
|
recentScope = new AsyncLocalStorage3();
|
|
@@ -61126,7 +61131,7 @@ var init_errorLine = __esm({
|
|
|
61126
61131
|
"wallet/src/errorLine.mjs"() {
|
|
61127
61132
|
"use strict";
|
|
61128
61133
|
init_errorCodes();
|
|
61129
|
-
SELF_TEACHING_CODES = /^(wallet_backup_out_[a-z_]+|wallet_recovery_file_[a-z_]+|wallet_passphrase_too_short|init_flags_required|restore_flags_required|recover_proof_tools_required|recipient_owner_(required|invalid)|broadcaster_key_file_(invalid|unreadable)|p03_agent_(deposit|unshield)_not_pool_denomination|exit_note_not_pool_denomination|inference_(tor_required|ceiling_over_cap|model_unknown|max_tokens_required|messages_invalid|stream_unsupported|temperature_invalid|max_payment_invalid|upstream_failed|response_invalid)|rpc_relay_limit|p03_deposit_(?:token_balance_unreadable|rpc_refused(?:_ip_allowlist|_key)?)|p03_pocket_payment_(?:pocket_balance_unreadable|rpc_refused(?:_ip_allowlist|_key)?))$/;
|
|
61134
|
+
SELF_TEACHING_CODES = /^(wallet_backup_out_[a-z_]+|wallet_recovery_file_[a-z_]+|wallet_passphrase_too_short|init_flags_required|restore_flags_required|recover_proof_tools_required|recipient_owner_(required|invalid)|broadcaster_key_file_(invalid|unreadable)|p03_agent_(deposit|unshield)_not_pool_denomination|exit_note_not_pool_denomination|inference_(tor_required|ceiling_over_cap|model_unknown|max_tokens_required|messages_invalid|stream_unsupported|temperature_invalid|max_payment_invalid|upstream_failed|response_invalid)|rpc_relay_limit|history_rpc_failed|p03_deposit_(?:token_balance_unreadable|rpc_refused(?:_ip_allowlist|_key)?)|p03_pocket_payment_(?:pocket_balance_unreadable|rpc_refused(?:_ip_allowlist|_key)?))$/;
|
|
61130
61135
|
redact = (text2) => String(text2).replace(/[a-z][a-z0-9+.-]*:\/\/\S+/gi, "<url>").replace(/(api[-_]?key|token|secret|password|auth)=\S+/gi, "$1=<redacted>").replace(/0x[0-9a-f]{16,}/gi, "<hex>").replace(/\b\d{20,}\b/g, "<number>").replace(/[A-Za-z0-9+/=_-]{40,}/g, (token) => /^p03_[a-z0-9_]+$/.test(token) ? token : "<blob>").replace(/\s+/g, " ").trim();
|
|
61131
61136
|
SYSTEM_CODE = /^E[A-Z0-9_]{1,40}$/;
|
|
61132
61137
|
SELLER_REFUSED = "seller_refused";
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -53347,6 +53347,9 @@ function rpcRefusalWords(refusal3) {
|
|
|
53347
53347
|
function rpcRefusalCode(refusal3) {
|
|
53348
53348
|
return refusal3.lasting ? `rpc_refused_${refusal3.kind}` : "rpc_refused";
|
|
53349
53349
|
}
|
|
53350
|
+
function rpcRefusalTail(refusal3) {
|
|
53351
|
+
return refusal3.unlikely ? `${rpcRefusalCode(refusal3)}: ${rpcRefusalWords(refusal3)}` : rpcRefusalWords(refusal3);
|
|
53352
|
+
}
|
|
53350
53353
|
function rpcRefusalHint(codes) {
|
|
53351
53354
|
const kind = /(?:^|[\s_])rpc_refused(?:_(ip_allowlist|key))?(?![a-z_])/.exec(String(codes ?? ""));
|
|
53352
53355
|
if (!kind) return void 0;
|
|
@@ -53519,7 +53522,10 @@ function walletRpcName(rpcUrl) {
|
|
|
53519
53522
|
if (typeof rpcUrl !== "string") return "the wallet's RPC (Shinjuku's relay, unless --rpc-file names your own)";
|
|
53520
53523
|
return isShinjukuRelayUrl(rpcUrl) ? "Shinjuku's relay" : "your RPC";
|
|
53521
53524
|
}
|
|
53522
|
-
function historyRpcHint(reason, { signsNothing: signsNothing2 = false } = {}) {
|
|
53525
|
+
function historyRpcHint(reason, { signsNothing: signsNothing2 = false, ownHistory = false } = {}) {
|
|
53526
|
+
if (/\bhistory_rpc_failed\b/.test(reason) && ownHistory) {
|
|
53527
|
+
return `the pool's public history from your own RPC (--rpc-file with --history-rpc own) could not be used: it did not answer, answered an error (for example JSON-RPC -32016: it stayed behind the chain for ${HISTORY_RPC_BEHIND_WAIT_MS / 1e3} s), served history that does not match the pool state it reads, or a transaction whose Ed25519 signatures do not verify (a code after history_rpc_failed names the check). ` + (signsNothing2 ? "This run signs nothing, so nothing changed on chain. " : "A rerun of the same command continues where it stopped and never pays twice. ") + "Rerun later, and if it keeps failing, check that RPC or name another one in your --rpc-file file";
|
|
53528
|
+
}
|
|
53523
53529
|
if (/\bhistory_rpc_failed\b/.test(reason)) {
|
|
53524
53530
|
return `the pool's public history from the history source (--history-rpc, or the history proxy this wallet pins for this pool: its onion in a --tor run, else its https origin) could not be used: the source did not answer, answered an error (for example JSON-RPC -32016: it stayed behind the chain for ${HISTORY_RPC_BEHIND_WAIT_MS / 1e3} s), or served history that does not match the pool state that ${walletRpcName()} reads, a transaction whose Ed25519 signatures do not verify, or a transaction that differs from that RPC's copy (a code after history_rpc_failed names the check). The wallet never reads the history from that RPC by itself. ` + (signsNothing2 ? "This run signs nothing, so nothing changed on chain. " : "A rerun of the same command continues where it stopped and never pays twice. ") + "Rerun later, or give your own Solana RPC with --rpc-file <file> (a private file whose first line is its URL) and add --history-rpc own (your RPC then serves the history and sees that you read this pool)";
|
|
53525
53531
|
}
|
|
@@ -65131,7 +65137,8 @@ async function walkWalletP03HistoryNow({
|
|
|
65131
65137
|
}
|
|
65132
65138
|
} catch (error) {
|
|
65133
65139
|
if (split4 && (historyRpcFailed(error) || /^p03_history_/.test(String(error?.message)))) {
|
|
65134
|
-
|
|
65140
|
+
const answered2 = rpcRefusalOf(error);
|
|
65141
|
+
throw new Error(answered2 ? `history_rpc_failed: ${rpcRefusalTail(answered2)}` : "history_rpc_failed", { cause: error });
|
|
65135
65142
|
}
|
|
65136
65143
|
throw error;
|
|
65137
65144
|
}
|
|
@@ -65412,6 +65419,7 @@ var init_walletHistory = __esm({
|
|
|
65412
65419
|
init_phaseTiming();
|
|
65413
65420
|
init_recoveryPath();
|
|
65414
65421
|
init_runEnd();
|
|
65422
|
+
init_rpcRefusal();
|
|
65415
65423
|
init_store();
|
|
65416
65424
|
prepareReport = (report) => {
|
|
65417
65425
|
prewarmFinalizedP03OuterTreeOnWorker(report);
|
|
@@ -73807,7 +73815,7 @@ var init_errorLine = __esm({
|
|
|
73807
73815
|
"use strict";
|
|
73808
73816
|
init_errorCodes();
|
|
73809
73817
|
INSUFFICIENT_CODE = /^p03_merchant_respend_insufficient_recovered_value$|^(p03_payer_)?insufficient(_recovered)?_value$/;
|
|
73810
|
-
SELF_TEACHING_CODES = /^(wallet_backup_out_[a-z_]+|wallet_recovery_file_[a-z_]+|wallet_passphrase_too_short|init_flags_required|restore_flags_required|recover_proof_tools_required|recipient_owner_(required|invalid)|broadcaster_key_file_(invalid|unreadable)|p03_agent_(deposit|unshield)_not_pool_denomination|exit_note_not_pool_denomination|inference_(tor_required|ceiling_over_cap|model_unknown|max_tokens_required|messages_invalid|stream_unsupported|temperature_invalid|max_payment_invalid|upstream_failed|response_invalid)|rpc_relay_limit|p03_deposit_(?:token_balance_unreadable|rpc_refused(?:_ip_allowlist|_key)?)|p03_pocket_payment_(?:pocket_balance_unreadable|rpc_refused(?:_ip_allowlist|_key)?))$/;
|
|
73818
|
+
SELF_TEACHING_CODES = /^(wallet_backup_out_[a-z_]+|wallet_recovery_file_[a-z_]+|wallet_passphrase_too_short|init_flags_required|restore_flags_required|recover_proof_tools_required|recipient_owner_(required|invalid)|broadcaster_key_file_(invalid|unreadable)|p03_agent_(deposit|unshield)_not_pool_denomination|exit_note_not_pool_denomination|inference_(tor_required|ceiling_over_cap|model_unknown|max_tokens_required|messages_invalid|stream_unsupported|temperature_invalid|max_payment_invalid|upstream_failed|response_invalid)|rpc_relay_limit|history_rpc_failed|p03_deposit_(?:token_balance_unreadable|rpc_refused(?:_ip_allowlist|_key)?)|p03_pocket_payment_(?:pocket_balance_unreadable|rpc_refused(?:_ip_allowlist|_key)?))$/;
|
|
73811
73819
|
redact = (text3) => String(text3).replace(/[a-z][a-z0-9+.-]*:\/\/\S+/gi, "<url>").replace(/(api[-_]?key|token|secret|password|auth)=\S+/gi, "$1=<redacted>").replace(/0x[0-9a-f]{16,}/gi, "<hex>").replace(/\b\d{20,}\b/g, "<number>").replace(/[A-Za-z0-9+/=_-]{40,}/g, (token) => /^p03_[a-z0-9_]+$/.test(token) ? token : "<blob>").replace(/\s+/g, " ").trim();
|
|
73812
73820
|
SYSTEM_CODE = /^E[A-Z0-9_]{1,40}$/;
|
|
73813
73821
|
SELLER_REFUSED = "seller_refused";
|
|
@@ -107835,6 +107843,14 @@ function floatOutcomeWords(code2, error, t) {
|
|
|
107835
107843
|
// DEAD_CHECK_AFTER_MS, DEAD_GRACE_MS); production 2026-10-29 landed three such refunds 108-113 s after the payment, and
|
|
107836
107844
|
// a refund that waits for the next pool anchor takes up to about 7 minutes (FLOAT_REFUND_ETA_SECONDS).
|
|
107837
107845
|
case "p03_float_transfer_expired": {
|
|
107846
|
+
if (error?.stallResignWait === true) {
|
|
107847
|
+
const wait2 = stallResignWaitWords(p.the);
|
|
107848
|
+
return [
|
|
107849
|
+
code2,
|
|
107850
|
+
`PAID ${totalText(error)} to Shinjuku (${t.privateLeg}); ${wait2.say.charAt(0).toLowerCase()}${wait2.say.slice(1)}`,
|
|
107851
|
+
`${wait2.next}. ${t.again} in about 2 minutes for the result (the fresh transfer's answer, or the refund); it never pays twice. Do not pay again with ${t.newId} until then`
|
|
107852
|
+
];
|
|
107853
|
+
}
|
|
107838
107854
|
const data = t.ai ? "an answer" : "the data";
|
|
107839
107855
|
const what = typeof error?.httpStatus === "number" ? answeredInstead(p, error.httpStatus, data) : `an earlier send of this payment to ${p.the} got no ${t.ai ? "answer" : "data"} back`;
|
|
107840
107856
|
return [
|
|
@@ -107974,12 +107990,21 @@ function floatOutcomeWords(code2, error, t) {
|
|
|
107974
107990
|
}
|
|
107975
107991
|
}
|
|
107976
107992
|
function stallResentWords(p, error) {
|
|
107977
|
-
return error?.stallResent === true ? `; the Tor connection to ${p?.the ?? "the seller"} stalled, so the wallet sent this
|
|
107993
|
+
return error?.stallResent === true ? `; the Tor connection to ${p?.the ?? "the seller"} stalled, so the wallet sent this payment once more on a new Tor route${STALL_FRESH}: it is still one payment, not a second one` : "";
|
|
107978
107994
|
}
|
|
107979
107995
|
function stallResentLine(payee = "the seller") {
|
|
107980
|
-
return `The Tor connection to ${payee} stalled, so the wallet sent this
|
|
107996
|
+
return `The Tor connection to ${payee} stalled, so the wallet sent this payment once more on a new Tor route${STALL_FRESH}: it is still one payment, not a second one.`;
|
|
107981
107997
|
}
|
|
107982
|
-
|
|
107998
|
+
function stallResignWaitWords(payee = "the seller") {
|
|
107999
|
+
return {
|
|
108000
|
+
// At most 25 words (say.mjs SAY_MAX_WORDS): 20 for "the seller", 22 for "the AI provider". Codex round 1 on bb3f9197
|
|
108001
|
+
// item 3: no re-sign is asked yet, and it is asked only by a wallet that still runs when Shinjuku proves the first
|
|
108002
|
+
// transfer dead (Shinjuku waits 30 s for it, then refunds); so the line names that condition and the refund.
|
|
108003
|
+
say: `Connection to ${payee} stalled. If the wallet stays open, it sends a fresh transfer; else the money comes back.`,
|
|
108004
|
+
next: `The wallet does this by itself only while it keeps running: Shinjuku first proves the first transfer can no longer land (about 2 minutes after the payment), then signs a fresh one of the same payment, and the wallet sends it to ${payee} on a new Tor connection. If the app stops the wallet before that, or it does not work, the whole amount comes back to the private balance by itself (usually within 5 minutes of the payment, at most about 7). Nothing more is paid either way`
|
|
108005
|
+
};
|
|
108006
|
+
}
|
|
108007
|
+
var ATOMIC4, TRANSFER_DEAD_WORDS, payeeOf, floatSellerCanBeFixed, withoutProviderText, floatSeller4xx, answeredInstead, floatStillSettling, floatChargeTooLate, amountText, withTransaction, PAID_SELLER_FAILED_CODE, stillWants, AI_SERVER_WRONG, QUOTE_REFUSED_WHY, STALL_FRESH;
|
|
107983
108008
|
var init_floatWords = __esm({
|
|
107984
108009
|
"wallet/src/pay/floatWords.mjs"() {
|
|
107985
108010
|
"use strict";
|
|
@@ -108013,6 +108038,7 @@ var init_floatWords = __esm({
|
|
|
108013
108038
|
exact_fee_payer_missing: "its payment offer names no fee payer, which every standard x402 offer needs",
|
|
108014
108039
|
exact_seller_memo: "it asks for its own text to be written on the public chain with the payment, and this wallet pays only privately"
|
|
108015
108040
|
});
|
|
108041
|
+
STALL_FRESH = " (with a fresh transfer from Shinjuku when the first one had run out)";
|
|
108016
108042
|
}
|
|
108017
108043
|
});
|
|
108018
108044
|
|
|
@@ -109537,9 +109563,16 @@ function sellerAnswerInit(url, init, ms) {
|
|
|
109537
109563
|
if (target() === void 0) return init;
|
|
109538
109564
|
return { ...init, dispatcher: { dispatch: (options, handler) => target().dispatch({ ...options, headersTimeout: ms, bodyTimeout: ms }, handler) } };
|
|
109539
109565
|
}
|
|
109540
|
-
async function sendWatchingStall(fetchImpl, url, init, waitMs, {
|
|
109541
|
-
|
|
109542
|
-
},
|
|
109566
|
+
async function sendWatchingStall(fetchImpl, url, init, waitMs, {
|
|
109567
|
+
mark = () => {
|
|
109568
|
+
},
|
|
109569
|
+
onResend = () => {
|
|
109570
|
+
},
|
|
109571
|
+
resentBefore = false,
|
|
109572
|
+
sameBytesAlive,
|
|
109573
|
+
onDeadStall = () => {
|
|
109574
|
+
}
|
|
109575
|
+
} = {}) {
|
|
109543
109576
|
const global2 = globalThis[GLOBAL_DISPATCHER5];
|
|
109544
109577
|
const proxy = process.env.HTTPS_PROXY;
|
|
109545
109578
|
const watched = !resentBefore && inTorRun() && init.dispatcher === void 0 && routeDispatcherOf(url) === void 0 && global2?.constructor?.name === "EnvHttpProxyAgent" && typeof proxy === "string" && proxy !== "";
|
|
@@ -109603,6 +109636,13 @@ async function sendWatchingStall(fetchImpl, url, init, waitMs, { mark = () => {
|
|
|
109603
109636
|
if (outcome.error !== void 0) throw outcome.error;
|
|
109604
109637
|
return { response: outcome.response, stallResent: false };
|
|
109605
109638
|
}
|
|
109639
|
+
if (sameBytesAlive !== void 0 && !await Promise.resolve().then(sameBytesAlive).catch(() => false)) {
|
|
109640
|
+
mark("seller-stall-dead-bytes");
|
|
109641
|
+
onDeadStall();
|
|
109642
|
+
const kept3 = await firstSend;
|
|
109643
|
+
if (kept3.error !== void 0) throw kept3.error;
|
|
109644
|
+
return { response: kept3.response, stallResent: false };
|
|
109645
|
+
}
|
|
109606
109646
|
const replacementProxy = freshTorCircuitProxy();
|
|
109607
109647
|
let fresh;
|
|
109608
109648
|
try {
|
|
@@ -109891,6 +109931,73 @@ async function transferWindow(record, connection, deps = {}) {
|
|
|
109891
109931
|
const ageMs = Number.isSafeInteger(answeredAtMs) ? Date.now() - answeredAtMs : void 0;
|
|
109892
109932
|
return { open: ageMs !== void 0 && ageMs < TRANSFER_FRESH_MS, ...ageMs === void 0 ? {} : { ageMs } };
|
|
109893
109933
|
}
|
|
109934
|
+
async function askFloatResign({ record, store, walName: walName2, fetchImpl, sleep: sleep5, mark }) {
|
|
109935
|
+
const header = store.readWal(`resource-payment-${hash7(record.innerRequestId)}`)?.paymentHeader;
|
|
109936
|
+
if (typeof header !== "string" || header.length === 0 || typeof record.payUrlPrefix !== "string") {
|
|
109937
|
+
mark("float-resign-skipped", "no_payment_header");
|
|
109938
|
+
return { record, resigned: false };
|
|
109939
|
+
}
|
|
109940
|
+
const asked = { ...record, floatResignAskedAtMs: Date.now() };
|
|
109941
|
+
store.writeWal(walName2, asked);
|
|
109942
|
+
mark("float-resign-asked");
|
|
109943
|
+
const until = Date.now() + RESIGN_ASK_WINDOW_MS;
|
|
109944
|
+
for (; ; ) {
|
|
109945
|
+
let response;
|
|
109946
|
+
try {
|
|
109947
|
+
response = await fetchImpl(`${record.payUrlPrefix}${record.floatId}`, floatInit({
|
|
109948
|
+
method: "POST",
|
|
109949
|
+
redirect: "error",
|
|
109950
|
+
headers: { "content-type": "application/json", "PAYMENT-SIGNATURE": header },
|
|
109951
|
+
body: Buffer.from(record.bodyBase64, "base64"),
|
|
109952
|
+
signal: AbortSignal.timeout(Math.max(1e3, Math.min(RESIGN_ASK_TIMEOUT_MS, until - Date.now())))
|
|
109953
|
+
}));
|
|
109954
|
+
} catch {
|
|
109955
|
+
mark("float-resign-refused", "no_answer");
|
|
109956
|
+
return { record: asked, resigned: false };
|
|
109957
|
+
}
|
|
109958
|
+
if (response.status === 200) {
|
|
109959
|
+
let bytes2;
|
|
109960
|
+
try {
|
|
109961
|
+
bytes2 = Buffer.from(await response.arrayBuffer());
|
|
109962
|
+
} catch {
|
|
109963
|
+
bytes2 = void 0;
|
|
109964
|
+
}
|
|
109965
|
+
if (bytes2 === void 0 || bytes2.length > RESIGN_ANSWER_MAX_BYTES) {
|
|
109966
|
+
mark("float-resign-refused", "answer_unread");
|
|
109967
|
+
return { record: asked, resigned: false };
|
|
109968
|
+
}
|
|
109969
|
+
let answer;
|
|
109970
|
+
try {
|
|
109971
|
+
answer = floatAnswer(bytes2.toString("base64"), asked, store);
|
|
109972
|
+
} catch {
|
|
109973
|
+
mark("float-resign-refused", "answer_invalid");
|
|
109974
|
+
return { record: asked, resigned: false };
|
|
109975
|
+
}
|
|
109976
|
+
if (hash7(answer.xPayment) === asked.headerSha256) {
|
|
109977
|
+
mark("float-resign-refused", "same_transfer");
|
|
109978
|
+
return { record: asked, resigned: false };
|
|
109979
|
+
}
|
|
109980
|
+
const resigned = { ...asked, ...answer, headerSha256: hash7(answer.xPayment), floatPaidAtMs: Date.now(), floatResigned: true };
|
|
109981
|
+
store.writeWal(walName2, resigned);
|
|
109982
|
+
mark("float-resigned");
|
|
109983
|
+
return { record: resigned, resigned: true };
|
|
109984
|
+
}
|
|
109985
|
+
let code2;
|
|
109986
|
+
try {
|
|
109987
|
+
const body = await readJson2(response, 8 * 1024);
|
|
109988
|
+
code2 = body?.error ?? body?.code;
|
|
109989
|
+
} catch {
|
|
109990
|
+
code2 = void 0;
|
|
109991
|
+
}
|
|
109992
|
+
if (response.status === 202 && Date.now() + RESIGN_FINISHING_WAIT_MS < until) {
|
|
109993
|
+
mark("float-resign-retry", typeof code2 === "string" && /^[a-z0-9_]{1,60}$/.test(code2) ? code2 : "http_202");
|
|
109994
|
+
await sleep5(RESIGN_FINISHING_WAIT_MS);
|
|
109995
|
+
continue;
|
|
109996
|
+
}
|
|
109997
|
+
mark("float-resign-refused", typeof code2 === "string" && /^[a-z0-9_]{1,60}$/.test(code2) ? code2 : `http_${response.status}`);
|
|
109998
|
+
return { record: asked, resigned: false };
|
|
109999
|
+
}
|
|
110000
|
+
}
|
|
109894
110001
|
function floatRecordOf(store, requestId) {
|
|
109895
110002
|
try {
|
|
109896
110003
|
return store.readWal(floatPaymentWalName(hash7(requestId)));
|
|
@@ -111147,19 +111254,46 @@ async function payViaFloat({
|
|
|
111147
111254
|
...read?.state === "landed" ? { transferLanded: true } : {}
|
|
111148
111255
|
});
|
|
111149
111256
|
}
|
|
111257
|
+
let resignedOnRerun = false;
|
|
111150
111258
|
if (!answeredThisRun && !wasKept) {
|
|
111151
111259
|
const window2 = await transferWindow(record, connection, deps);
|
|
111152
111260
|
if (!window2.open) {
|
|
111153
111261
|
const neverSent = record.state === "float_paid";
|
|
111154
111262
|
const read = await readFloatTransferState(record, fetchImpl);
|
|
111155
|
-
if (read?.state === "dead"
|
|
111156
|
-
|
|
111263
|
+
if (read?.state === "dead" && read.floatState === "dead" && record.sellerStallDead === true && record.floatResignAskedAtMs === void 0) {
|
|
111264
|
+
const proxy = inTorRun() ? freshTorCircuitProxy() : void 0;
|
|
111265
|
+
const fresh = inTorRun() ? proxy === void 0 ? void 0 : newConnectionDispatcher(proxy) : newConnectionDispatcher();
|
|
111266
|
+
if (fresh === void 0) {
|
|
111267
|
+
mark("float-resign-skipped", "no_new_connection");
|
|
111268
|
+
} else {
|
|
111269
|
+
const asked = await askFloatResign({ record, store, walName: walName2, fetchImpl, sleep: sleep5, mark });
|
|
111270
|
+
record = asked.record;
|
|
111271
|
+
if (asked.resigned) {
|
|
111272
|
+
record = { ...record, sellerStallResent: true };
|
|
111273
|
+
store.writeWal(walName2, record);
|
|
111274
|
+
resignedOnRerun = { dispatcher: fresh, proxy };
|
|
111275
|
+
} else {
|
|
111276
|
+
fresh.close?.().catch?.(() => {
|
|
111277
|
+
});
|
|
111278
|
+
}
|
|
111279
|
+
}
|
|
111280
|
+
}
|
|
111281
|
+
if (!resignedOnRerun && (read?.state === "dead" || read?.state === "cancelled")) {
|
|
111282
|
+
byVerdict(read, neverSent ? { broadcastRefusal: "transfer_expired" } : {}, {});
|
|
111283
|
+
}
|
|
111284
|
+
if (!resignedOnRerun && read?.state !== "landed" && read?.state !== "final") {
|
|
111157
111285
|
if (neverSent) {
|
|
111158
111286
|
record = { ...record, broadcastRefusal: "transfer_expired", state: "refund_pending", refundPendingAtMs: record.refundPendingAtMs ?? Date.now() };
|
|
111159
111287
|
store.writeWal(walName2, record);
|
|
111160
111288
|
refundPendingAnswer(record);
|
|
111161
111289
|
}
|
|
111162
|
-
transferExpiredAnswer(
|
|
111290
|
+
transferExpiredAnswer(
|
|
111291
|
+
store,
|
|
111292
|
+
walName2,
|
|
111293
|
+
record,
|
|
111294
|
+
window2,
|
|
111295
|
+
record.sellerStallDead === true && record.floatResignAskedAtMs === void 0 ? { stallResignWait: true } : {}
|
|
111296
|
+
);
|
|
111163
111297
|
}
|
|
111164
111298
|
}
|
|
111165
111299
|
}
|
|
@@ -111173,8 +111307,8 @@ async function payViaFloat({
|
|
|
111173
111307
|
store.writeWal(walName2, record);
|
|
111174
111308
|
mark("seller-sent");
|
|
111175
111309
|
const sentAtMs2 = Date.now();
|
|
111176
|
-
|
|
111177
|
-
|
|
111310
|
+
let stopWaiting = new AbortController();
|
|
111311
|
+
let watch = watchFloatTransfer({ record, fetchImpl, sleep: deps.floatStatusSleep, abort: () => stopWaiting.abort() });
|
|
111178
111312
|
const resendDispatchers = [];
|
|
111179
111313
|
try {
|
|
111180
111314
|
return await sellerLeg();
|
|
@@ -111187,6 +111321,59 @@ async function payViaFloat({
|
|
|
111187
111321
|
record = { ...record, sellerStallResent: true };
|
|
111188
111322
|
store.writeWal(walName2, record);
|
|
111189
111323
|
}
|
|
111324
|
+
async function stalledVerdict(sellerTimeout) {
|
|
111325
|
+
if (record.sellerStallDead !== true || record.floatResignAskedAtMs !== void 0) return;
|
|
111326
|
+
while (!sellerTimeout.aborted && !["dead", "landed", "final", "cancelled"].includes(watch.verdict()?.state)) await sleep5(1e3);
|
|
111327
|
+
}
|
|
111328
|
+
function stallDead() {
|
|
111329
|
+
record = { ...record, sellerStallDead: true, sellerStallDeadAtMs: record.sellerStallDeadAtMs ?? Date.now() };
|
|
111330
|
+
store.writeWal(walName2, record);
|
|
111331
|
+
}
|
|
111332
|
+
async function resignAfterStall(sellerTimeout) {
|
|
111333
|
+
if (record.sellerStallDead !== true || wasKept || record.floatResignAskedAtMs !== void 0 || sellerTimeout.aborted) return void 0;
|
|
111334
|
+
const verdict2 = watch.verdict();
|
|
111335
|
+
if (verdict2?.state !== "dead" || verdict2.floatState !== "dead") return void 0;
|
|
111336
|
+
const leftMs = sentAtMs2 + sellerWaitMs(record) - Date.now();
|
|
111337
|
+
if (leftMs < RESIGN_MIN_SELLER_LEFT_MS) return void 0;
|
|
111338
|
+
const proxy = freshTorCircuitProxy();
|
|
111339
|
+
let dispatcher;
|
|
111340
|
+
try {
|
|
111341
|
+
dispatcher = proxy === void 0 ? void 0 : proxyDispatcher(globalThis[GLOBAL_DISPATCHER5].constructor, proxy);
|
|
111342
|
+
} catch {
|
|
111343
|
+
dispatcher = void 0;
|
|
111344
|
+
}
|
|
111345
|
+
if (dispatcher === void 0) {
|
|
111346
|
+
mark("float-resign-skipped", "no_new_circuit");
|
|
111347
|
+
return void 0;
|
|
111348
|
+
}
|
|
111349
|
+
resendDispatchers.push(dispatcher);
|
|
111350
|
+
const asked = await askFloatResign({ record, store, walName: walName2, fetchImpl, sleep: sleep5, mark });
|
|
111351
|
+
record = asked.record;
|
|
111352
|
+
if (!asked.resigned) return void 0;
|
|
111353
|
+
watch.stop();
|
|
111354
|
+
stopWaiting = new AbortController();
|
|
111355
|
+
watch = watchFloatTransfer({ record, fetchImpl, sleep: deps.floatStatusSleep, abort: () => stopWaiting.abort() });
|
|
111356
|
+
mark("seller-resign-new-circuit", `${hash7(String(process.env.HTTPS_PROXY ?? "")).slice(0, 8)}->${hash7(proxy).slice(0, 8)}`);
|
|
111357
|
+
record = { ...record, state: "submitted", sellerStallResent: true, resignSentAtMs: Date.now() };
|
|
111358
|
+
store.writeWal(walName2, record);
|
|
111359
|
+
const init = {
|
|
111360
|
+
method: sendRequest.method,
|
|
111361
|
+
headers: {
|
|
111362
|
+
...Object.fromEntries(sendRequest.headers),
|
|
111363
|
+
[record.sellerX402?.version === 1 ? "X-PAYMENT" : "PAYMENT-SIGNATURE"]: record.xPayment
|
|
111364
|
+
},
|
|
111365
|
+
...sendRequest.method === "POST" ? { body: Buffer.from(sendRequest.bodyBase64, "base64") } : {},
|
|
111366
|
+
redirect: "error",
|
|
111367
|
+
signal: AbortSignal.any([sellerTimeout, stopWaiting.signal]),
|
|
111368
|
+
dispatcher
|
|
111369
|
+
};
|
|
111370
|
+
mark("seller-sent-resigned");
|
|
111371
|
+
try {
|
|
111372
|
+
return await fetchImpl(record.url, sellerAnswerInit(record.url, init, Math.max(1e3, leftMs)));
|
|
111373
|
+
} catch (error) {
|
|
111374
|
+
return unanswered2(error);
|
|
111375
|
+
}
|
|
111376
|
+
}
|
|
111190
111377
|
async function unanswered2(error) {
|
|
111191
111378
|
if (wasKept) keptAgain();
|
|
111192
111379
|
let verdict2 = watch.verdict();
|
|
@@ -111244,10 +111431,16 @@ async function payViaFloat({
|
|
|
111244
111431
|
let resendUntilMs;
|
|
111245
111432
|
let answeredAtMs;
|
|
111246
111433
|
let dispatcher;
|
|
111434
|
+
if (resignedOnRerun) {
|
|
111435
|
+
dispatcher = resignedOnRerun.dispatcher;
|
|
111436
|
+
resendDispatchers.push(dispatcher);
|
|
111437
|
+
mark("seller-resign-new-circuit", resignedOnRerun.proxy === void 0 ? "new_connection" : `${hash7(String(process.env.HTTPS_PROXY ?? "")).slice(0, 8)}->${hash7(resignedOnRerun.proxy).slice(0, 8)}`);
|
|
111438
|
+
}
|
|
111247
111439
|
let stallProxy;
|
|
111248
111440
|
const waitMs = sellerWaitMs(record);
|
|
111249
111441
|
const sellerTimeout = AbortSignal.timeout(waitMs);
|
|
111250
111442
|
const stopResends = () => Date.now() > resendUntilMs || ["landed", "dead", "final", "cancelled"].includes(watch.verdict()?.state);
|
|
111443
|
+
let resignedNow = false;
|
|
111251
111444
|
for (let resend = 0; ; resend += 1) {
|
|
111252
111445
|
const init = {
|
|
111253
111446
|
// A version 1 seller reads X-PAYMENT (record.sellerX402; PLAN AB249), a version 2 one PAYMENT-SIGNATURE.
|
|
@@ -111267,21 +111460,45 @@ async function payViaFloat({
|
|
|
111267
111460
|
record.url,
|
|
111268
111461
|
dispatcher === void 0 ? keepAliveInit(init) : { ...init, dispatcher },
|
|
111269
111462
|
waitMs,
|
|
111270
|
-
{
|
|
111271
|
-
|
|
111272
|
-
|
|
111273
|
-
|
|
111463
|
+
{
|
|
111464
|
+
mark,
|
|
111465
|
+
resentBefore: record.sellerStallResent === true,
|
|
111466
|
+
onResend: (proxy) => {
|
|
111467
|
+
stallProxy ??= proxy;
|
|
111468
|
+
stallResent();
|
|
111469
|
+
},
|
|
111470
|
+
sameBytesAlive: async () => (await transferWindow(record, connection, deps)).open,
|
|
111471
|
+
onDeadStall: stallDead
|
|
111472
|
+
}
|
|
111274
111473
|
));
|
|
111275
111474
|
} catch (error) {
|
|
111276
|
-
|
|
111475
|
+
if (record.sellerStallDead !== true && inTorRun() && stopWaiting.signal.aborted && watch.verdict()?.state === "dead") {
|
|
111476
|
+
mark("seller-stall-dead-bytes", "float_dead_first");
|
|
111477
|
+
stallDead();
|
|
111478
|
+
}
|
|
111479
|
+
await stalledVerdict(sellerTimeout);
|
|
111480
|
+
const fresh = await resignAfterStall(sellerTimeout);
|
|
111481
|
+
if (fresh === void 0) await unanswered2(error);
|
|
111482
|
+
response = fresh;
|
|
111483
|
+
resignedNow = true;
|
|
111277
111484
|
} finally {
|
|
111278
111485
|
if (socketWatch !== void 0) {
|
|
111279
111486
|
const { outcome, sentAtMs: sentAtMs3 } = socketWatch.stop();
|
|
111280
111487
|
mark("seller-send-socket", outcome, sentAtMs3);
|
|
111281
111488
|
}
|
|
111282
111489
|
}
|
|
111490
|
+
if (!resignedNow && !response.ok && record.sellerStallDead === true && record.floatResignAskedAtMs === void 0) {
|
|
111491
|
+
await stalledVerdict(sellerTimeout);
|
|
111492
|
+
const fresh = await resignAfterStall(sellerTimeout);
|
|
111493
|
+
if (fresh !== void 0) {
|
|
111494
|
+
await drainBody(response);
|
|
111495
|
+
response = fresh;
|
|
111496
|
+
resignedNow = true;
|
|
111497
|
+
}
|
|
111498
|
+
}
|
|
111283
111499
|
answeredAtMs = Date.now();
|
|
111284
|
-
mark(resend === 0 ? "seller-answered" : `seller-answered-resend-${resend}`);
|
|
111500
|
+
mark(resignedNow ? "seller-answered-resigned" : resend === 0 ? "seller-answered" : `seller-answered-resend-${resend}`);
|
|
111501
|
+
if (resignedNow) break;
|
|
111285
111502
|
resendUntilMs ??= Date.now() + FEE_PAYER_RESEND_MS;
|
|
111286
111503
|
if (wasKept || record.sellerX402?.version === 1 || resend >= FEE_PAYER_RESENDS || stopResends() || !(feePayerRotated(response, accepted) || feePayerNotManaged(response))) break;
|
|
111287
111504
|
dispatcher = newConnectionDispatcher(stallProxy);
|
|
@@ -111781,7 +111998,7 @@ function paidResult(record, replayed) {
|
|
|
111781
111998
|
float: { floatId: record.floatId }
|
|
111782
111999
|
};
|
|
111783
112000
|
}
|
|
111784
|
-
var import_web3117, FLOAT_PAYMENT_SCHEMA2, REGENERATE_CODES, FLOAT_PAYMENT_WAL_PREFIX2, FLOAT_CONFIG_SCHEMA, FLOAT_PAY_PATH, FLOAT_MEMO_PATH, FLOAT_STATUS_PATH, MAX_BODY_BYTES, FLOAT_REFUND_ETA_SECONDS, REFUND_READ_EARLY_MS, REFUND_ETA_MAX_SECONDS, refundDueOf, REFUND_SETTLED_AFTER_MS, REFUND_OUTCOME_NEWS_MS, FINISHING_POLL_MS, FINISHING_LIMIT_MS, SELLER_TIMEOUT_MS, SELLER_TIMEOUT_ABSURD_SECONDS, SELLER_STALL_CHECK_AFTER_MS, SELLER_STALL_CHECK_EVERY_MS, SELLER_STALL_CHECK_TIMEOUT_MS, SELLER_STALL_MISSES, RESULT_LIMIT_BYTES, FLOAT_STATUS_START_MS, FLOAT_STATUS_POLL_MS, FLOAT_STATUS_TIMEOUT_MS, CONFIRM_READ_MS, FLOAT_TRANSFER_DEAD, FLOAT_PAYMENT_REVERTED, VERDICT_POLL_MS, SELLER_ANSWER_VERDICT_MS, TRANSFER_MIN_BLOCKS_LEFT, TRANSFER_FRESH_MS, BLOCK_HEIGHT_TIMEOUT_MS, CONFIG_TIMEOUT_MS, MEMO_UPLOAD_TIMEOUT_MS, CONFIG_CACHE_MS, FLOAT_POOL_WARM_MS, DECIMAL3, POSITIVE, PENDING_CODES, FLOAT_FRONT_HEADER, hash7, fail25, GENERIC_REASON, SELLER_REASON_MAX, SELLER_REASON_READ_BYTES, FEE_PAYER_RESENDS, FEE_PAYER_RESEND_MS, GLOBAL_DISPATCHER5, sortedJson, MODEL_ID, floatPaymentWalName, floatRecordName, FLOAT_KEEP_BYTES_MS, memoryOnlyNeedsScrub, FLOAT_KEEP_OPEN_REQUEST_MS, configCache, configGeneration, configReadSequence, configReads, configRefreshes, SPECULATED_MAX_AGE_MS, speculatedQuotes, poolDomains, FLOAT_FACTS_SCHEMA, floatFacts, floatFactsKey, floatFactsMac, poolDomainReads, poolDomainWarmFailedAt, WARM_RETRY_MS, payerGenerator, etaEntry, loadPayerGenerator, plainText, quoteLimits, originOf, BROADCAST_REFUSED, BROADCAST_REFUSED_STANDARD, BROADCAST_DEAD, TRANSFER_LANDING_WINDOW_MS, PROOF_DELIVERY_MS, SELF_BROADCAST_LEG1_LEFT_MS, BROADCAST_UNSIGNED, BROADCAST_NO_LOOKUP, BROADCAST_LANDED, BROADCAST_LIMIT_MS, BROADCAST_QUOTE_MARGIN_MS, SELF_BROADCAST_RESEND_MS, SELF_BROADCAST_UNANSWERED_RESEND_MS, SELLER_HEADERS_MAX_COUNT, SELLER_HEADERS_MAX_BYTES, FINAL_AFTER_202_MS, SELLER_HEADERS_KEPT;
|
|
112001
|
+
var import_web3117, FLOAT_PAYMENT_SCHEMA2, REGENERATE_CODES, FLOAT_PAYMENT_WAL_PREFIX2, FLOAT_CONFIG_SCHEMA, FLOAT_PAY_PATH, FLOAT_MEMO_PATH, FLOAT_STATUS_PATH, MAX_BODY_BYTES, FLOAT_REFUND_ETA_SECONDS, REFUND_READ_EARLY_MS, REFUND_ETA_MAX_SECONDS, refundDueOf, REFUND_SETTLED_AFTER_MS, REFUND_OUTCOME_NEWS_MS, FINISHING_POLL_MS, FINISHING_LIMIT_MS, SELLER_TIMEOUT_MS, SELLER_TIMEOUT_ABSURD_SECONDS, SELLER_STALL_CHECK_AFTER_MS, SELLER_STALL_CHECK_EVERY_MS, SELLER_STALL_CHECK_TIMEOUT_MS, SELLER_STALL_MISSES, RESULT_LIMIT_BYTES, FLOAT_STATUS_START_MS, FLOAT_STATUS_POLL_MS, FLOAT_STATUS_TIMEOUT_MS, CONFIRM_READ_MS, FLOAT_TRANSFER_DEAD, FLOAT_PAYMENT_REVERTED, VERDICT_POLL_MS, SELLER_ANSWER_VERDICT_MS, TRANSFER_MIN_BLOCKS_LEFT, TRANSFER_FRESH_MS, BLOCK_HEIGHT_TIMEOUT_MS, CONFIG_TIMEOUT_MS, MEMO_UPLOAD_TIMEOUT_MS, CONFIG_CACHE_MS, FLOAT_POOL_WARM_MS, DECIMAL3, POSITIVE, PENDING_CODES, FLOAT_FRONT_HEADER, hash7, fail25, GENERIC_REASON, SELLER_REASON_MAX, SELLER_REASON_READ_BYTES, FEE_PAYER_RESENDS, FEE_PAYER_RESEND_MS, GLOBAL_DISPATCHER5, sortedJson, MODEL_ID, RESIGN_ASK_WINDOW_MS, RESIGN_ASK_TIMEOUT_MS, RESIGN_FINISHING_WAIT_MS, RESIGN_MIN_SELLER_LEFT_MS, RESIGN_ANSWER_MAX_BYTES, floatPaymentWalName, floatRecordName, FLOAT_KEEP_BYTES_MS, memoryOnlyNeedsScrub, FLOAT_KEEP_OPEN_REQUEST_MS, configCache, configGeneration, configReadSequence, configReads, configRefreshes, SPECULATED_MAX_AGE_MS, speculatedQuotes, poolDomains, FLOAT_FACTS_SCHEMA, floatFacts, floatFactsKey, floatFactsMac, poolDomainReads, poolDomainWarmFailedAt, WARM_RETRY_MS, payerGenerator, etaEntry, loadPayerGenerator, plainText, quoteLimits, originOf, BROADCAST_REFUSED, BROADCAST_REFUSED_STANDARD, BROADCAST_DEAD, TRANSFER_LANDING_WINDOW_MS, PROOF_DELIVERY_MS, SELF_BROADCAST_LEG1_LEFT_MS, BROADCAST_UNSIGNED, BROADCAST_NO_LOOKUP, BROADCAST_LANDED, BROADCAST_LIMIT_MS, BROADCAST_QUOTE_MARGIN_MS, SELF_BROADCAST_RESEND_MS, SELF_BROADCAST_UNANSWERED_RESEND_MS, SELLER_HEADERS_MAX_COUNT, SELLER_HEADERS_MAX_BYTES, FINAL_AFTER_202_MS, SELLER_HEADERS_KEPT;
|
|
111785
112002
|
var init_floatPay = __esm({
|
|
111786
112003
|
"wallet/src/pay/floatPay.mjs"() {
|
|
111787
112004
|
"use strict";
|
|
@@ -111867,6 +112084,11 @@ var init_floatPay = __esm({
|
|
|
111867
112084
|
GLOBAL_DISPATCHER5 = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.1");
|
|
111868
112085
|
sortedJson = (value2) => JSON.stringify(value2, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.keys(item).sort().map((key) => [key, item[key]])) : item);
|
|
111869
112086
|
MODEL_ID = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,79}$/;
|
|
112087
|
+
RESIGN_ASK_WINDOW_MS = 25e3;
|
|
112088
|
+
RESIGN_ASK_TIMEOUT_MS = 15e3;
|
|
112089
|
+
RESIGN_FINISHING_WAIT_MS = 2e3;
|
|
112090
|
+
RESIGN_MIN_SELLER_LEFT_MS = 15e3;
|
|
112091
|
+
RESIGN_ANSWER_MAX_BYTES = 128 * 1024;
|
|
111870
112092
|
floatPaymentWalName = (requestKey) => `${FLOAT_PAYMENT_WAL_PREFIX2}${requestKey}`;
|
|
111871
112093
|
floatRecordName = (requestId) => floatPaymentWalName(hash7(requestId));
|
|
111872
112094
|
FLOAT_KEEP_BYTES_MS = 6e5;
|
|
@@ -116144,6 +116366,12 @@ function refusalSay(a, tool, again, npmVersion) {
|
|
|
116144
116366
|
`${head} Shinjuku refunds nothing. Do not pay again.`
|
|
116145
116367
|
);
|
|
116146
116368
|
}
|
|
116369
|
+
if (code2 === "p03_float_transfer_expired" && a.stallResignWait === true) {
|
|
116370
|
+
return firstFit(
|
|
116371
|
+
`Connection to ${seller} stalled. If the wallet stays open, it sends a fresh transfer; else the money comes back.`,
|
|
116372
|
+
`Connection to ${seller} stalled. Nothing more is paid; ask again in about 2 minutes.`
|
|
116373
|
+
);
|
|
116374
|
+
}
|
|
116147
116375
|
if (code2 === "p03_float_transfer_expired") {
|
|
116148
116376
|
const amount = total ? `${total} USDC` : "the payment";
|
|
116149
116377
|
return firstFit(
|
|
@@ -122156,7 +122384,7 @@ var init_cli = __esm({
|
|
|
122156
122384
|
EXIT_LEASE_WAIT_MS = 6e4;
|
|
122157
122385
|
if (process.argv[1] && resolve21(process.argv[1]) === fileURLToPath13(new URL("__bundled_source__/wallet/src/unshield/cli.mjs", import.meta.url).href)) {
|
|
122158
122386
|
main2().catch((error) => {
|
|
122159
|
-
console.error(describeCliErrorWithHint(error));
|
|
122387
|
+
console.error(describeCliErrorWithHint(error, { ownHistory: ownHistoryFlags(process.argv.slice(2)) }));
|
|
122160
122388
|
process.exitCode = 1;
|
|
122161
122389
|
});
|
|
122162
122390
|
}
|
|
@@ -123317,7 +123545,7 @@ var init_cli2 = __esm({
|
|
|
123317
123545
|
};
|
|
123318
123546
|
if (process.argv[1] && resolve22(process.argv[1]) === fileURLToPath14(new URL("__bundled_source__/wallet/src/pocket/cli.mjs", import.meta.url).href)) {
|
|
123319
123547
|
main3().catch((error) => {
|
|
123320
|
-
console.error(describeCliErrorWithHint(error, { fallback: "p03_pocket_cli_failed" }));
|
|
123548
|
+
console.error(describeCliErrorWithHint(error, { fallback: "p03_pocket_cli_failed", ownHistory: ownHistoryFlags(process.argv.slice(2)) }));
|
|
123321
123549
|
process.exitCode = 1;
|
|
123322
123550
|
});
|
|
123323
123551
|
}
|
|
@@ -133617,6 +133845,7 @@ function argsKey(args) {
|
|
|
133617
133845
|
}
|
|
133618
133846
|
function withEarlyAnswer(tool, {
|
|
133619
133847
|
sellerSentAt,
|
|
133848
|
+
sellerStalledAt = /* @__PURE__ */ new Map(),
|
|
133620
133849
|
payStartedAt = /* @__PURE__ */ new Map(),
|
|
133621
133850
|
earlyAnswerMs = EARLY_ANSWER_MS,
|
|
133622
133851
|
keepResultMs = KEEP_RESULT_MS,
|
|
@@ -133631,6 +133860,7 @@ function withEarlyAnswer(tool, {
|
|
|
133631
133860
|
const forget = (requestId) => {
|
|
133632
133861
|
payments.delete(requestId);
|
|
133633
133862
|
sellerSentAt.delete(requestId);
|
|
133863
|
+
sellerStalledAt.delete(requestId);
|
|
133634
133864
|
payStartedAt.delete(requestId);
|
|
133635
133865
|
};
|
|
133636
133866
|
const take = (requestId, entry) => {
|
|
@@ -133715,6 +133945,25 @@ function withEarlyAnswer(tool, {
|
|
|
133715
133945
|
log(`MCP_PAY_EARLY_ANSWER requestId=${requestId} waited=${secondsWaited}s`);
|
|
133716
133946
|
entry.toldWaiting = true;
|
|
133717
133947
|
const next = `The payment was sent to ${words2.who} (price + fee left the balance), and ${words2.who} ${words2.busyNext}. Do not pay again: call ${tool.name} again with request_id "${requestId}" and ${words2.same} for the result (that call waits up to ${Math.round(earlyAnswerMs / 1e3)} s for it); it never pays twice. A new request_id for the same request is refused while this one is open. The later call's answer says how it ended: ${words2.who}'s answer, or what happened to the payment.`;
|
|
133948
|
+
if (sellerStalledAt.has(requestId)) {
|
|
133949
|
+
const wait2 = stallResignWaitWords(words2.who);
|
|
133950
|
+
return { text: JSON.stringify(
|
|
133951
|
+
{
|
|
133952
|
+
say: wait2.say,
|
|
133953
|
+
ok: true,
|
|
133954
|
+
paid: false,
|
|
133955
|
+
pending: true,
|
|
133956
|
+
stage: "seller_working",
|
|
133957
|
+
sellerStalled: true,
|
|
133958
|
+
requestId,
|
|
133959
|
+
secondsWaited,
|
|
133960
|
+
sellerWorkingSeconds,
|
|
133961
|
+
next: `The payment was sent to ${words2.who} (price + fee left the balance), but the connection to ${words2.who} stalled after Shinjuku's transfer ran out. ${wait2.next}. Do not pay again: call ${tool.name} again with request_id "${requestId}" and ${words2.same} for the result in about 2 minutes (the fresh transfer's answer, or the refund); it never pays twice. A new request_id for the same request is refused while this one is open.`
|
|
133962
|
+
},
|
|
133963
|
+
null,
|
|
133964
|
+
2
|
|
133965
|
+
) };
|
|
133966
|
+
}
|
|
133718
133967
|
const say2 = sellerWorkingSeconds < JUST_REACHED_SECONDS ? `Sent to ${words2.who}; the request just reached it. Do not pay again; asking for the result pays nothing more.` : `Sent to ${words2.who}; it has not answered yet. Do not pay again; asking for the result pays nothing more.`;
|
|
133719
133968
|
return { text: JSON.stringify({ say: say2, ok: true, paid: false, pending: true, stage: "seller_working", requestId, secondsWaited, sellerWorkingSeconds, next }, null, 2) };
|
|
133720
133969
|
} };
|
|
@@ -133723,6 +133972,7 @@ var EARLY_ANSWER_MS, KEEP_RESULT_MS, SELLER_SENT_POLL_MS, JUST_REACHED_SECONDS,
|
|
|
133723
133972
|
var init_earlyAnswer = __esm({
|
|
133724
133973
|
"wallet/src/mcp/earlyAnswer.mjs"() {
|
|
133725
133974
|
"use strict";
|
|
133975
|
+
init_floatWords();
|
|
133726
133976
|
EARLY_ANSWER_MS = 25e3;
|
|
133727
133977
|
KEEP_RESULT_MS = 6e5;
|
|
133728
133978
|
SELLER_SENT_POLL_MS = 250;
|
|
@@ -135315,7 +135565,8 @@ function floatRefusal(error, overLimit, tool = "pay_for_service") {
|
|
|
135315
135565
|
askNew: "call with a NEW request_id",
|
|
135316
135566
|
noRepeat: `call ${tool} again with this request_id`,
|
|
135317
135567
|
thisId: "this request_id",
|
|
135318
|
-
|
|
135568
|
+
// Lotus to-do 47 live check (2026-11-09): an agent may repeat the detail, so no field name ("balanceAtomic").
|
|
135569
|
+
balance: "your private balance",
|
|
135319
135570
|
refundState: "wallet_receipts shows its state and, once sent, its refundTransaction",
|
|
135320
135571
|
result: `wallet_receipts shows the result (the refund and its transaction, or that the ${inference ? "AI provider" : "seller"} kept it)`,
|
|
135321
135572
|
privateLeg: FLOAT_PRIVATE_LEG,
|
|
@@ -137061,6 +137312,7 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
137061
137312
|
joinNudgeTimer.unref?.();
|
|
137062
137313
|
}
|
|
137063
137314
|
const sellerSentAt = /* @__PURE__ */ new Map();
|
|
137315
|
+
const sellerStalledAt = /* @__PURE__ */ new Map();
|
|
137064
137316
|
const payStartedAt = /* @__PURE__ */ new Map();
|
|
137065
137317
|
const inferenceSentAt = /* @__PURE__ */ new Map();
|
|
137066
137318
|
let moneyCallsInFlight = 0;
|
|
@@ -138460,6 +138712,8 @@ ${canonical5}`;
|
|
|
138460
138712
|
sellerSentAt.set(requestId, Date.now());
|
|
138461
138713
|
earlyCorrection ??= startFloatCorrection();
|
|
138462
138714
|
}
|
|
138715
|
+
if (phase === "seller-stall-dead-bytes") sellerStalledAt.set(requestId, Date.now());
|
|
138716
|
+
if (["seller-sent-resigned", "float-resign-refused", "float-resign-skipped"].includes(phase)) sellerStalledAt.delete(requestId);
|
|
138463
138717
|
if (timing === void 0) return;
|
|
138464
138718
|
timing(phase, outcome, at);
|
|
138465
138719
|
if (phase === "seller-sent" && earlyBalance === void 0) earlyBalance = earlyResultBalance(requestId);
|
|
@@ -139046,6 +139300,8 @@ ${canonical5}`;
|
|
|
139046
139300
|
...error?.resent === true ? { resent: true } : {},
|
|
139047
139301
|
// AB32: this payment went once more on a new Tor circuit after a stall (floatPay.mjs sendWatchingStall).
|
|
139048
139302
|
...error?.stallResent === true ? { stallResent: true } : {},
|
|
139303
|
+
// AB32 option b: a stall after the transfer ran out, Shinjuku's re-sign not asked yet (floatPay.mjs; say.mjs).
|
|
139304
|
+
...error?.stallResignWait === true ? { stallResignWait: true } : {},
|
|
139049
139305
|
...error?.pruned === true ? { pruned: true } : {},
|
|
139050
139306
|
...typeof error?.floatCode === "string" ? { floatCode: error.floatCode } : {},
|
|
139051
139307
|
// AB164: the seller's own code beside its error after it took the payment (floatWords.mjs PAID_SELLER_FAILED_CODE).
|
|
@@ -146438,7 +146694,7 @@ ${JSON.stringify(args ?? {})}`;
|
|
|
146438
146694
|
log(`MCP_READ_BUDGET_PASSED tool=${tool.name}`);
|
|
146439
146695
|
return stillReading(tool);
|
|
146440
146696
|
} };
|
|
146441
|
-
const earlyAnswerFor = (tool) => tool.name === "pay_for_service" ? withEarlyAnswer(tool, { sellerSentAt, payStartedAt, log, autoKey: payJoinText }) : tool.name === "inference_chat" ? withEarlyAnswer(tool, {
|
|
146697
|
+
const earlyAnswerFor = (tool) => tool.name === "pay_for_service" ? withEarlyAnswer(tool, { sellerSentAt, sellerStalledAt, payStartedAt, log, autoKey: payJoinText }) : tool.name === "inference_chat" ? withEarlyAnswer(tool, {
|
|
146442
146698
|
sellerSentAt: inferenceSentAt,
|
|
146443
146699
|
log,
|
|
146444
146700
|
words: INFERENCE_WORDS,
|
|
@@ -147154,7 +147410,7 @@ function createSetupTools({
|
|
|
147154
147410
|
doneTool: sayOnRefusal(doneTool)
|
|
147155
147411
|
};
|
|
147156
147412
|
}
|
|
147157
|
-
var import_web3133, X402_V1_NEXT, shownCaps, RELEASE_RETRY_MS, STAGE_WORDS, slowReadWords, stageWords, INTERNAL_BALANCE_DETAIL, shownBreakdown, sessionLeftShown, RESOURCE_PAYMENT_WAL_PREFIX2, POOL_LAYOUT_CODE, POOL_LAYOUT_UPDATE, USEPOD_VIA_INFERENCE_CHAT, SEND_RUNS_ON, DEPOSIT_RUNS_ON, CLI_FUNDS_PLAN_PREFIX, CLI_FUNDS_SCHEMA, SELF_PAY_ORIGIN3, REQUEST_ID4, POSITIVE_ATOMIC6, PRIVATE_HOST3, FORBIDDEN_HEADERS3, MAX_BODY_BYTES2, PREVIEW_TIMEOUT_MS, PREVIEW_SELLER_READ_MS, CALL_BUDGET_MS, budgetLeft, PAY_ANSWER_MARGIN_MS, MONEY_FIRST_ANSWER_MS, BALANCE_AFTER_LANDING_MS, JOIN_CALL_MAX_MS, JOIN_CALL_ANSWER_MARGIN_S, PAY_AFTER_JOIN_MS, joinAnswerSeconds, JOIN_TIME_MS, JOIN_NUDGE_QUIET_MS, JOIN_STEP_MS, sleep2, PROGRESS_EVERY_MS2, READ_BUDGET_MS, UNPAID_TOR_TRY_MS, UNPAID_CLEAR_MS, READ_BUDGET_TOOLS, FLOAT_BUSY_CODES, RETRY_MARGIN_MS, ASK_PAY_CODES, runningNpmVersion, terminalCommand2, capPlaceWords, noLimitSetLine, CAP_NAMES, capName, entryPlaces, capRaiseText, runningLimits, payCapFlag, noPriceFits, cheaperText, limitNext, overLimitStep, logCause, SAFE_TEXT, causesLog, MCP_TOOL_ALIASES, POOL_SWITCH_WHY, POOL_SWITCH_NEXT, SWITCH_STATES, quietSwitch, switchKey, ATOMIC_TEXT, MAX_PAYMENT_ATOMIC_LEAST, movedTo, FLOAT_ID2, ANSWERED_EXIT_RETRY_MS, ANSWERED_EXIT_UNCONFIRMED_MS, ANSWERED_EXIT_RETRY_WINDOW_MS, ANSWERED_EXIT_CLOSED, switchAmount, switchEta, switchRows, OWNER_CAP_CODES, JOIN_END_MCP, JOIN_END_TERMINAL_LIBRARY, JOIN_RETRY_BACKOFF_MS, WALLET_CAP_FIX, ENTRY_CAP_CODES, MCP_CAP_FIX, capFix, ownerOnlyNext, mcpNext, CONFIDENTIAL_RETIRED, json4, answerResult, discoverTool, LAUNCH_CAP_CODES, dayCapKind, refuse11, newRequestIdFor, payCapName, limitQuestion, stableJson, requestPrint, JSON_SNIFF_MAX_CHARS, publicOffer, FLOAT_PAID_CODES, FLOAT_NOT_CERTAIN_CODES, FLOAT_PRIVATE_LEG, SELLER_ONLY_HERE, outsideWalletRule, TOR_START_STEP, MONEY_ID2, toRecordId, linkKindOf, moneyId, REFUSED_CODES, SEND_STOPPED, SEND_STOP_NOT_SAVED, sendStoppedError, refusedCodeOf, PLAIN_REASONS, insufficientCause, INSUFFICIENT_REASONS, reasonOf, plainReason, KEPT_SEND_TRIES, shownId, isSplitSend, PROMISED_NEXT, partFailReason, sendAnswerOf, PUBLIC_READ_TIMEOUT_MS, RECIPIENT_CHECK_TIMEOUT_MS, withTimeout, ownKey, readFailure, OWN_KEY_TOKENS_MAX, tokenAmountText, elsewhereId, AGENT_ID_SCHEMA, agentIdName, minutesText2, ageWords2, DEPOSIT_SENT_STATES, depositLanded, usdcText3, walkWalletHistory, REFRESH_LEASE_WALK_MS, HOME_MARKS_SETTLED_MS2, AUTO_BACKUPS_KEPT, AUTO_BACKUP_NAME, AUTO_BACKUP_VERIFIED, FRONTED_SETTLE_MARGIN_SLOTS, RECIPIENT_READ_TOTAL_MS, RECIPIENT_READ_SLOW_MS, slowReadSaid, 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, REFUND_CHECK_MIN_MS, SALE_VIEW_AGE_SECONDS, saleViewRead, balanceTextFields, changeFields, balanceAnswer, CAP_BALANCE_WAIT_MS, CAP_BALANCE_RETRY_MS, REFRESH_RETRY_MS, FINALITY_POLL_MS, FINALITY_WAIT_MS, FINALITY_REFRESH_LIMIT_MS, FINALITY_CLOSE_WAIT_MS, POOL_WATCH_MS, POOL_WATCH_POLL_MS, EARLY_BALANCE_DELAY_MS, FINALITY_SETTLE_WINDOW_SLOTS, PUBLIC_READ_ANSWER_MS, LINK_READ_ANSWER_MS, OWN_READS_AHEAD_MS, OWN_PUBLIC_KNOWN_MS, FLOAT_CORRECT_WAIT_MS, SWITCH_WAIT_MS, UNSHIELD_TO_NO_USDC_DETAIL, UNSHIELD_TO_INVALID_NEXT, INFERENCE_MIN_MAX_TOKENS, ELICIT_TIMEOUT_MS, ALLOW_BOX_HOSTS, ALLOW_BOX_PROGRESS_MS, ELICIT_UNSHOWN_MS, elicitUnshown, POLL_SECONDS2, TEMP_CLEAN_DELAY_MS, KEPT_ON_DISK, MAX_SHIELDED_BALANCE_ATOMIC, receiveGenerator, MCP_TOOL_NAMES, MCP_HIDDEN_TOOL_NAMES, setupTerminalNext, SETUP_RUNNING_SAY, SETUP_WAITING_SAY, ACCEPTED_NEXT, SETUP_RUNNING_NEXT, SETUP_ANSWER_WAIT_MS, SETUP_CONFIRMING_SAY, SETUP_CONFIRMING_NEXT, OWN_ADDRESS_QUESTION, OWN_ADDRESS_WHERE, OWN_ADDRESS_INVALID, HOST_CHAT_NOT_PRIVATE, PRIVATE_INFERENCE_WHY, RESTART_STEPS, HOST_BLOCKED_LINE, TOR_BROWSER_PORT, SETUP_TOR_TITLE, SETUP_TOR_WHY;
|
|
147413
|
+
var import_web3133, X402_V1_NEXT, shownCaps, RELEASE_RETRY_MS, STAGE_WORDS, slowReadWords, stageWords, INTERNAL_BALANCE_DETAIL, shownBreakdown, sessionLeftShown, RESOURCE_PAYMENT_WAL_PREFIX2, POOL_LAYOUT_CODE, POOL_LAYOUT_UPDATE, USEPOD_VIA_INFERENCE_CHAT, SEND_RUNS_ON, DEPOSIT_RUNS_ON, CLI_FUNDS_PLAN_PREFIX, CLI_FUNDS_SCHEMA, SELF_PAY_ORIGIN3, REQUEST_ID4, POSITIVE_ATOMIC6, PRIVATE_HOST3, FORBIDDEN_HEADERS3, MAX_BODY_BYTES2, PREVIEW_TIMEOUT_MS, PREVIEW_SELLER_READ_MS, CALL_BUDGET_MS, budgetLeft, PAY_ANSWER_MARGIN_MS, MONEY_FIRST_ANSWER_MS, BALANCE_AFTER_LANDING_MS, JOIN_CALL_MAX_MS, JOIN_CALL_ANSWER_MARGIN_S, PAY_AFTER_JOIN_MS, joinAnswerSeconds, JOIN_TIME_MS, JOIN_NUDGE_QUIET_MS, JOIN_STEP_MS, sleep2, PROGRESS_EVERY_MS2, READ_BUDGET_MS, UNPAID_TOR_TRY_MS, UNPAID_CLEAR_MS, READ_BUDGET_TOOLS, FLOAT_BUSY_CODES, RETRY_MARGIN_MS, ASK_PAY_CODES, runningNpmVersion, terminalCommand2, capPlaceWords, noLimitSetLine, CAP_NAMES, capName, entryPlaces, capRaiseText, runningLimits, payCapFlag, noPriceFits, cheaperText, limitNext, overLimitStep, logCause, SAFE_TEXT, causesLog, MCP_TOOL_ALIASES, POOL_SWITCH_WHY, POOL_SWITCH_NEXT, SWITCH_STATES, quietSwitch, switchKey, ATOMIC_TEXT, MAX_PAYMENT_ATOMIC_LEAST, movedTo, FLOAT_ID2, ANSWERED_EXIT_RETRY_MS, ANSWERED_EXIT_UNCONFIRMED_MS, ANSWERED_EXIT_RETRY_WINDOW_MS, ANSWERED_EXIT_CLOSED, switchAmount, switchEta, switchRows, OWNER_CAP_CODES, JOIN_END_MCP, JOIN_END_TERMINAL_LIBRARY, JOIN_RETRY_BACKOFF_MS, WALLET_CAP_FIX, ENTRY_CAP_CODES, MCP_CAP_FIX, capFix, ownerOnlyNext, mcpNext, CONFIDENTIAL_RETIRED, json4, answerResult, discoverTool, LAUNCH_CAP_CODES, dayCapKind, refuse11, newRequestIdFor, payCapName, limitQuestion, stableJson, requestPrint, JSON_SNIFF_MAX_CHARS, publicOffer, FLOAT_PAID_CODES, FLOAT_NOT_CERTAIN_CODES, FLOAT_PRIVATE_LEG, SELLER_ONLY_HERE, outsideWalletRule, TOR_START_STEP, MONEY_ID2, toRecordId, linkKindOf, moneyId, REFUSED_CODES, SEND_STOPPED, SEND_STOP_NOT_SAVED, sendStoppedError, refusedCodeOf, PLAIN_REASONS, insufficientCause, INSUFFICIENT_REASONS, historyRefusalCode, 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, RECIPIENT_READ_TOTAL_MS, RECIPIENT_READ_SLOW_MS, slowReadSaid, 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, REFUND_CHECK_MIN_MS, SALE_VIEW_AGE_SECONDS, saleViewRead, balanceTextFields, changeFields, balanceAnswer, CAP_BALANCE_WAIT_MS, CAP_BALANCE_RETRY_MS, REFRESH_RETRY_MS, FINALITY_POLL_MS, FINALITY_WAIT_MS, FINALITY_REFRESH_LIMIT_MS, FINALITY_CLOSE_WAIT_MS, POOL_WATCH_MS, POOL_WATCH_POLL_MS, EARLY_BALANCE_DELAY_MS, FINALITY_SETTLE_WINDOW_SLOTS, PUBLIC_READ_ANSWER_MS, LINK_READ_ANSWER_MS, OWN_READS_AHEAD_MS, OWN_PUBLIC_KNOWN_MS, FLOAT_CORRECT_WAIT_MS, SWITCH_WAIT_MS, UNSHIELD_TO_NO_USDC_DETAIL, UNSHIELD_TO_INVALID_NEXT, INFERENCE_MIN_MAX_TOKENS, ELICIT_TIMEOUT_MS, ALLOW_BOX_HOSTS, ALLOW_BOX_PROGRESS_MS, ELICIT_UNSHOWN_MS, elicitUnshown, POLL_SECONDS2, TEMP_CLEAN_DELAY_MS, KEPT_ON_DISK, MAX_SHIELDED_BALANCE_ATOMIC, receiveGenerator, MCP_TOOL_NAMES, MCP_HIDDEN_TOOL_NAMES, setupTerminalNext, SETUP_RUNNING_SAY, SETUP_WAITING_SAY, ACCEPTED_NEXT, SETUP_RUNNING_NEXT, SETUP_ANSWER_WAIT_MS, SETUP_CONFIRMING_SAY, SETUP_CONFIRMING_NEXT, OWN_ADDRESS_QUESTION, OWN_ADDRESS_WHERE, OWN_ADDRESS_INVALID, HOST_CHAT_NOT_PRIVATE, PRIVATE_INFERENCE_WHY, RESTART_STEPS, HOST_BLOCKED_LINE, TOR_BROWSER_PORT, SETUP_TOR_TITLE, SETUP_TOR_WHY;
|
|
147158
147414
|
var init_tools = __esm({
|
|
147159
147415
|
"wallet/src/mcp/tools.mjs"() {
|
|
147160
147416
|
"use strict";
|
|
@@ -147355,7 +147611,7 @@ var init_tools = __esm({
|
|
|
147355
147611
|
if (refusal3) return `rpc answered ${rpcAnswerWords(refusal3)}${refusal3.lasting ? ` kind=${refusal3.kind}` : ""}`;
|
|
147356
147612
|
return redact(String(error?.message ?? error ?? "").split("\n", 1)[0]).slice(0, 240);
|
|
147357
147613
|
};
|
|
147358
|
-
SAFE_TEXT = /^(fetch_|spend_|mcp_|wallet_locked|p03_deposit_(?:rpc_refused|token_balance_unreadable)|p03_pocket_payment_(?:rpc_refused|pocket_balance_unreadable))/;
|
|
147614
|
+
SAFE_TEXT = /^(fetch_|spend_|mcp_|wallet_locked|history_rpc_failed|p03_deposit_(?:rpc_refused|token_balance_unreadable)|p03_pocket_payment_(?:rpc_refused|pocket_balance_unreadable))/;
|
|
147359
147615
|
causesLog = (causes) => causes.length ? ` causes=${causes.join(",")}` : "";
|
|
147360
147616
|
MCP_TOOL_ALIASES = Object.freeze({
|
|
147361
147617
|
fetch_paid: "pay_for_service",
|
|
@@ -147623,7 +147879,8 @@ var init_tools = __esm({
|
|
|
147623
147879
|
held: "an open payment or send held some of the balance until it is final",
|
|
147624
147880
|
short: "the private balance was less than the amount"
|
|
147625
147881
|
};
|
|
147626
|
-
|
|
147882
|
+
historyRefusalCode = (line) => /\bhistory_rpc_failed: (rpc_refused(?:_ip_allowlist|_key)?)\b/.exec(String(line ?? ""))?.[1];
|
|
147883
|
+
reasonOf = (code2, line = code2) => INSUFFICIENT_REASONS[insufficientCause(line)] ?? PLAIN_REASONS.find(([match]) => match.test(String(historyRefusalCode(line) ?? code2 ?? "")))?.[1];
|
|
147627
147884
|
plainReason = (code2) => reasonOf(code2) ?? `the send did not finish (${code2})`;
|
|
147628
147885
|
KEPT_SEND_TRIES = () => JOIN_RETRY_BACKOFF_MS.length + 1;
|
|
147629
147886
|
shownId = (agentId, rid) => typeof agentId === "string" && REQUEST_ID4.test(agentId) && toRecordId(agentId) === rid ? agentId : rid;
|
|
@@ -151257,10 +151514,14 @@ function writePaidAnswer(path, resultBase64) {
|
|
|
151257
151514
|
function describeCliError(error, options = {}) {
|
|
151258
151515
|
return describeError(error, { fallback: "p03_resource_cli_failed", nameUnknown: true, safeText: SELF_TEACHING_CODES, ...options });
|
|
151259
151516
|
}
|
|
151260
|
-
function
|
|
151517
|
+
function ownHistoryFlags(args) {
|
|
151518
|
+
const at = args.indexOf("--history-rpc");
|
|
151519
|
+
return args.includes("--rpc-file") && (args.includes("--history-rpc=own") || at >= 0 && args[at + 1] === "own");
|
|
151520
|
+
}
|
|
151521
|
+
function describeCliErrorWithHint(error, { ownHistory = false, ...options } = {}) {
|
|
151261
151522
|
const line = describeCliError(error, options);
|
|
151262
151523
|
const codes = localErrorCodes(error).join(" ");
|
|
151263
|
-
const hint = historyRpcHint(codes) || rpcRefusalHint(codes);
|
|
151524
|
+
const hint = (/^history_rpc_failed\b/.test(line) ? rpcRefusalHint(line) : void 0) || historyRpcHint(codes, { ownHistory }) || rpcRefusalHint(codes);
|
|
151264
151525
|
return hint ? `${line}
|
|
151265
151526
|
hint: ${hint}` : line;
|
|
151266
151527
|
}
|
|
@@ -151290,7 +151551,7 @@ var init_cli3 = __esm({
|
|
|
151290
151551
|
REQUIRED2 = ["wallet", "passphrase-file", "proof-tools", "program", "url", "request-id", "maximum-atomic", "memo-service"];
|
|
151291
151552
|
if (process.argv[1] && resolve31(process.argv[1]) === fileURLToPath19(new URL("__bundled_source__/wallet/src/pay/cli.mjs", import.meta.url).href)) {
|
|
151292
151553
|
main4().catch((error) => {
|
|
151293
|
-
console.error(describeCliErrorWithHint(error));
|
|
151554
|
+
console.error(describeCliErrorWithHint(error, { ownHistory: ownHistoryFlags(process.argv.slice(2)) }));
|
|
151294
151555
|
process.exitCode = 1;
|
|
151295
151556
|
});
|
|
151296
151557
|
}
|
|
@@ -154065,7 +154326,8 @@ The next question uses it${state2.mode === "talk" ? ", with the conversation so
|
|
|
154065
154326
|
(typeof session.timing === "function" ? session.timing() : void 0)?.("chat-answer-failed", code2 ?? "history_rpc_failed");
|
|
154066
154327
|
} catch {
|
|
154067
154328
|
}
|
|
154068
|
-
|
|
154329
|
+
const answered2 = rpcRefusalOf(error);
|
|
154330
|
+
say2(answered2 ? `The pool's public history could not be read: ${rpcRefusalWords(answered2)}${nothing ? ", so the payment could not start" : ""}. ${paidWords} ${answered2.unlikely ? `${RPC_REFUSAL_HINT}.` : `Wait a moment, then ${again}.`}${closeOtherwise}` : `The pool's public history did not answer in time over Tor (a slow Tor route)${nothing ? ", so the payment could not start" : ""}. ${paidWords} Wait a moment, then ${again}.${closeOtherwise}`);
|
|
154069
154331
|
} else {
|
|
154070
154332
|
try {
|
|
154071
154333
|
const logged = ownCodeWords(error).split(":")[0];
|
|
@@ -154261,6 +154523,7 @@ var init_chat = __esm({
|
|
|
154261
154523
|
init_usdcWords();
|
|
154262
154524
|
init_models();
|
|
154263
154525
|
init_serveRunner();
|
|
154526
|
+
init_rpcRefusal();
|
|
154264
154527
|
init_brand();
|
|
154265
154528
|
init_liveModels();
|
|
154266
154529
|
SPLIT_CODE = "p03_merchant_respend_accounts_split_merge_first";
|
|
@@ -157705,7 +157968,7 @@ async function main5(args = process.argv.slice(2), { output: output2 = (result)
|
|
|
157705
157968
|
}
|
|
157706
157969
|
if (process.argv[1] && resolve35(process.argv[1]) === fileURLToPath20(new URL("__bundled_source__/wallet/src/merge/cli.mjs", import.meta.url).href)) {
|
|
157707
157970
|
main5().catch((error) => {
|
|
157708
|
-
console.error(describeCliErrorWithHint(error));
|
|
157971
|
+
console.error(describeCliErrorWithHint(error, { ownHistory: ownHistoryFlags(process.argv.slice(2)) }));
|
|
157709
157972
|
process.exitCode = 1;
|
|
157710
157973
|
});
|
|
157711
157974
|
}
|
|
@@ -168977,7 +169240,9 @@ function rpcAnswerReason(refusal3, line) {
|
|
|
168977
169240
|
function failureCodes(error, reason) {
|
|
168978
169241
|
const codes = localErrorCodes(error);
|
|
168979
169242
|
const own = /^(rpc_relay_limit|rpc_rate_limited|rpc_refused(?:_ip_allowlist|_key)?|rpc_unreachable|server_tls_failed|proof_tools_folder_not_writable)\b/.exec(reason)?.[1];
|
|
168980
|
-
|
|
169243
|
+
const list = own ? [own, ...codes.filter((code2) => code2 !== own)] : codes;
|
|
169244
|
+
const refused = /^history_rpc_failed: (rpc_refused(?:_ip_allowlist|_key)?)\b/.exec(reason)?.[1];
|
|
169245
|
+
return refused && !list.includes(refused) ? [list[0], refused, ...list.slice(1)] : list;
|
|
168981
169246
|
}
|
|
168982
169247
|
var WRITE_REFUSED_CODES = /* @__PURE__ */ new Set(["EROFS", "EACCES", "EPERM"]);
|
|
168983
169248
|
var PROOF_TOOLS_FLAGS = ["--proof-tools", "--exit-proof-tools", "--payer-proof-tools"];
|
|
@@ -169193,11 +169458,19 @@ function cancelUnsafeHint(command, values, deps) {
|
|
|
169193
169458
|
}
|
|
169194
169459
|
function failureHint(command, reason, deps, values, floatError) {
|
|
169195
169460
|
const pool2 = values?.get("--pool");
|
|
169196
|
-
const
|
|
169461
|
+
const ownRpcGiven = values?.has("--rpc-file") === true;
|
|
169462
|
+
const ownHistory = ownRpcGiven && values?.get("--history-rpc") === "own";
|
|
169463
|
+
const historyRefusalHint = /^history_rpc_failed\b/.test(reason) ? rpcRefusalHint(reason) : void 0;
|
|
169464
|
+
if (historyRefusalHint) {
|
|
169465
|
+
const historyUrl = values?.get("--history-rpc");
|
|
169466
|
+
const which = historyUrl !== void 0 && historyUrl !== "own" ? "(the RPC that refused is the --history-rpc source: name another one there, or leave --history-rpc out)" : `(the RPC that refused is the history proxy this wallet pins for this pool: ${ownRpcGiven ? "add --history-rpc own to read the history from your --rpc-file RPC" : "with your own Solana RPC in --rpc-file <file>, add --history-rpc own"})`;
|
|
169467
|
+
return `${historyRefusalHint} ${which}` + (signsNothing(command, values) ? ". This run signs nothing, so nothing changed on chain" : "");
|
|
169468
|
+
}
|
|
169469
|
+
const historyHint = historyRpcHint(reason, { signsNothing: signsNothing(command, values), ownHistory });
|
|
169197
169470
|
if (historyHint) return historyHint;
|
|
169198
169471
|
const refusalHint = rpcRefusalHint(reason.split(/[:;]/, 1)[0]);
|
|
169199
169472
|
if (refusalHint) {
|
|
169200
|
-
return `${refusalHint} (--rpc-file names your own)` + (signsNothing(command, values) ? ". This run signs nothing, so nothing changed on chain" : "");
|
|
169473
|
+
return `${refusalHint} ${ownRpcGiven ? "(your --rpc-file file names this RPC: name another one there)" : "(--rpc-file names your own)"}` + (signsNothing(command, values) ? ". This run signs nothing, so nothing changed on chain" : "");
|
|
169201
169474
|
}
|
|
169202
169475
|
if (/^rpc_unreachable/.test(reason)) {
|
|
169203
169476
|
const servers = serversOf(command, values, deps?.env);
|