@gvnrdao/dh-mcp 0.5.11 → 0.5.13
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/dist/boundary.js +209 -21
- package/dist/connector-embed.js +531 -75
- package/dist/connector.js +532 -76
- package/dist/index.js +311 -57
- package/package.json +2 -2
package/dist/connector-embed.js
CHANGED
|
@@ -40818,6 +40818,226 @@ source of truth.
|
|
|
40818
40818
|
`;
|
|
40819
40819
|
}
|
|
40820
40820
|
|
|
40821
|
+
// src/connector/landing-page.ts
|
|
40822
|
+
var FAVICON_SVG = `<svg width="512" height="512" viewBox="-6 -11 88 88" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Diamond Hands"><path d="M1.08325 20.7041L37.9038 64.4967L74.2886 20.7041L61.8699 0.877686H13.502L1.08325 20.7041Z" fill="#C9F284" stroke="#34440E" stroke-width="1.75559"/><path d="M13.9385 0.877441L37.9045 64.2785" stroke="#34440E" stroke-width="1.75559"/><path d="M61.6553 0.877441L37.9071 64.4964" stroke="#34440E" stroke-width="1.75559"/><path d="M1.08276 20.7029H74.2882" stroke="#34440E" stroke-width="1.75559"/></svg>`;
|
|
40823
|
+
var FAVICON_DATA_URI = `data:image/svg+xml,${encodeURIComponent(FAVICON_SVG).replace(/'/g, "%27")}`;
|
|
40824
|
+
var BACKGROUND_IMAGE_ORIGIN = "https://images.gvnr.xyz";
|
|
40825
|
+
var BACKGROUND_IMAGE_URL = `${BACKGROUND_IMAGE_ORIGIN}/images/layout/backgroundCorleoneb.jpg`;
|
|
40826
|
+
var escapeHtml = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
40827
|
+
function moneyReality(networks2) {
|
|
40828
|
+
const mainnet = networks2.includes("mainnet");
|
|
40829
|
+
const sepolia = networks2.includes("sepolia");
|
|
40830
|
+
if (mainnet && sepolia) {
|
|
40831
|
+
return {
|
|
40832
|
+
label: "REAL MONEY on mainnet \xB7 practice funds on sepolia",
|
|
40833
|
+
detail: "This deployment serves both networks. Mainnet moves real BTC and real UCD; sepolia is the test network and its funds are not real. Ask which network you are on before acting."
|
|
40834
|
+
};
|
|
40835
|
+
}
|
|
40836
|
+
if (mainnet) {
|
|
40837
|
+
return {
|
|
40838
|
+
label: "REAL MONEY \u2014 Ethereum mainnet",
|
|
40839
|
+
detail: "This deployment serves mainnet only. Every fund-moving operation moves real BTC and real UCD, and each one needs a fresh signature from your own wallet."
|
|
40840
|
+
};
|
|
40841
|
+
}
|
|
40842
|
+
return {
|
|
40843
|
+
label: "PRACTICE FUNDS \u2014 sepolia test network",
|
|
40844
|
+
detail: "This deployment serves sepolia only. The contracts and ceremonies are real, the money is not. Nothing here can move mainnet funds."
|
|
40845
|
+
};
|
|
40846
|
+
}
|
|
40847
|
+
function renderLandingPage(input) {
|
|
40848
|
+
const { publicOrigin, networks: networks2, version: version2, nonce } = input;
|
|
40849
|
+
const origin2 = escapeHtml(publicOrigin);
|
|
40850
|
+
const money = moneyReality(networks2);
|
|
40851
|
+
const config = JSON.stringify({ mcpServers: { "diamond-hands": { type: "http", url: `${publicOrigin}/mcp` } } }, null, 2);
|
|
40852
|
+
return `<!doctype html>
|
|
40853
|
+
<html lang="en">
|
|
40854
|
+
<head>
|
|
40855
|
+
<meta charset="utf-8">
|
|
40856
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
40857
|
+
<title>Diamond Hands \u2014 MCP endpoint</title>
|
|
40858
|
+
<link rel="icon" type="image/svg+xml" href="${FAVICON_DATA_URI}">
|
|
40859
|
+
<link rel="apple-touch-icon" href="${FAVICON_DATA_URI}">
|
|
40860
|
+
<style>
|
|
40861
|
+
* { margin:0; padding:0; box-sizing:border-box; }
|
|
40862
|
+
/* House treatment (ops.gvnr.xyz, brando.gvnr.xyz): the image fills the viewport,
|
|
40863
|
+
centred and cropped, and the PAGE never scrolls. */
|
|
40864
|
+
html, body { width:100%; height:100%; overflow:hidden; }
|
|
40865
|
+
body {
|
|
40866
|
+
background: url('${BACKGROUND_IMAGE_URL}') center center / cover no-repeat fixed;
|
|
40867
|
+
color:#f3f4f6;
|
|
40868
|
+
font:15px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
|
|
40869
|
+
}
|
|
40870
|
+
/* NO full-page scrim: the photograph is the point, so darkness lives only behind the
|
|
40871
|
+
text that needs to stay legible. The content scrolls INSIDE the viewport rather than
|
|
40872
|
+
the page scrolling, so a short window never clips anything and the image never moves. */
|
|
40873
|
+
.scroll { height:100%; overflow-y:auto; overscroll-behavior:contain; }
|
|
40874
|
+
main { max-width:41rem; margin:0 auto; padding:1.9rem 1.25rem 2rem;
|
|
40875
|
+
text-shadow:0 1px 3px rgba(0,0,0,.85); }
|
|
40876
|
+
/* Wide viewports: the lower half goes side-by-side so the whole page fits without the
|
|
40877
|
+
viewport scrolling \u2014 the house treatment is a full-bleed image, not a long page. */
|
|
40878
|
+
@media (min-width: 62rem) and (min-height: 34rem) {
|
|
40879
|
+
main { max-width:62rem; }
|
|
40880
|
+
.cols { display:grid; grid-template-columns:1fr 1fr; gap:0 1.6rem; align-items:start; }
|
|
40881
|
+
.cols h2:first-child { margin-top:0; }
|
|
40882
|
+
}
|
|
40883
|
+
h1 { font-size:1.35rem; margin:0 0 .25rem; letter-spacing:-.01em; }
|
|
40884
|
+
.sub { color:#dfe3ea; margin:0 0 1.1rem; font-size:14px; }
|
|
40885
|
+
.card { background:rgba(6,8,12,.62); border:1px solid rgba(255,255,255,.16);
|
|
40886
|
+
border-radius:10px; padding:.75rem .95rem; margin:0 0 .8rem;
|
|
40887
|
+
backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); }
|
|
40888
|
+
.money { border-left:3px solid #f59e0b; }
|
|
40889
|
+
.money strong { display:block; margin-bottom:.15rem; }
|
|
40890
|
+
h2 { font-size:.72rem; text-transform:uppercase; letter-spacing:.08em; color:#cbd2dc;
|
|
40891
|
+
margin:1.1rem 0 .45rem; font-weight:600; }
|
|
40892
|
+
pre { margin:0; padding:.7rem .9rem; background:rgba(0,0,0,.66);
|
|
40893
|
+
border:1px solid rgba(255,255,255,.16); border-radius:8px; overflow-x:auto;
|
|
40894
|
+
font-size:12.5px; line-height:1.45; text-shadow:none;
|
|
40895
|
+
font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; }
|
|
40896
|
+
code { font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:.92em; }
|
|
40897
|
+
table { border-collapse:collapse; width:100%; font-size:13.5px; }
|
|
40898
|
+
td { padding:.3rem .6rem .3rem 0; border-bottom:1px solid rgba(255,255,255,.12); vertical-align:top; }
|
|
40899
|
+
td:first-child { color:#cbd2dc; white-space:nowrap; width:10.5rem; }
|
|
40900
|
+
tr:last-child td { border-bottom:0; }
|
|
40901
|
+
a { color:inherit; text-decoration:underline; text-underline-offset:2px; }
|
|
40902
|
+
.row { display:flex; align-items:center; gap:.6rem; margin-bottom:.4rem; font-size:13px; }
|
|
40903
|
+
button { font:inherit; font-size:12.5px; padding:.25rem .65rem;
|
|
40904
|
+
border:1px solid rgba(255,255,255,.24); border-radius:6px;
|
|
40905
|
+
background:rgba(0,0,0,.55); color:#f3f4f6; cursor:pointer; text-shadow:none; }
|
|
40906
|
+
button:hover { background:rgba(0,0,0,.75); }
|
|
40907
|
+
footer { color:#cbd2dc; font-size:12.5px; margin-top:1.1rem; padding-top:.7rem;
|
|
40908
|
+
border-top:1px solid rgba(255,255,255,.14); }
|
|
40909
|
+
[hidden] { display:none !important; }
|
|
40910
|
+
#reveal-wrap { margin:0 0 .4rem; }
|
|
40911
|
+
#reveal { display:inline-block; padding:.4rem .85rem; border-radius:6px;
|
|
40912
|
+
border:1px solid rgba(255,255,255,.26); background:rgba(6,8,12,.62);
|
|
40913
|
+
backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
|
|
40914
|
+
text-decoration:none; font-size:13.5px; text-shadow:none; cursor:pointer; }
|
|
40915
|
+
#reveal:hover { background:rgba(6,8,12,.85); border-color:rgba(255,255,255,.4); }
|
|
40916
|
+
#reveal::after { content:" \u2193"; opacity:.7; }
|
|
40917
|
+
</style>
|
|
40918
|
+
</head>
|
|
40919
|
+
<body>
|
|
40920
|
+
<div class="scroll">
|
|
40921
|
+
<main>
|
|
40922
|
+
<h1>Diamond Hands \u2014 MCP endpoint</h1>
|
|
40923
|
+
<p class="sub">This host is a <strong>Model Context Protocol</strong> server, not a website.
|
|
40924
|
+
There is no app to use here. If you are a person, the app is at
|
|
40925
|
+
<a href="https://app.diamondhands.credit/">app.diamondhands.credit</a>.</p>
|
|
40926
|
+
|
|
40927
|
+
<!-- Revealed BY SCRIPT, hidden in the served markup \u2014 the inverse of #details below.
|
|
40928
|
+
With no JS this stays hidden and the details stay open, so the page degrades to
|
|
40929
|
+
everything-visible rather than to a trigger that does nothing. -->
|
|
40930
|
+
<p id="reveal-wrap" hidden><a href="#details" id="reveal" role="button">View MCP installation details</a></p>
|
|
40931
|
+
|
|
40932
|
+
<div id="details">
|
|
40933
|
+
<div class="card money">
|
|
40934
|
+
<strong>${escapeHtml(money.label)}</strong>
|
|
40935
|
+
${escapeHtml(money.detail)}
|
|
40936
|
+
</div>
|
|
40937
|
+
|
|
40938
|
+
<div class="cols">
|
|
40939
|
+
<section>
|
|
40940
|
+
<h2>Connect an agent</h2>
|
|
40941
|
+
<div class="row">
|
|
40942
|
+
<span style="color:var(--muted);font-size:13px">Add this to your MCP client configuration:</span>
|
|
40943
|
+
<button id="copy" type="button">Copy</button>
|
|
40944
|
+
</div>
|
|
40945
|
+
<pre id="cfg">${escapeHtml(config)}</pre>
|
|
40946
|
+
|
|
40947
|
+
<h2>How authorization works</h2>
|
|
40948
|
+
<div class="card">
|
|
40949
|
+
Identity is a <strong>wallet</strong>, not an account: OAuth 2.1 with dynamic client
|
|
40950
|
+
registration (RFC 7591) and PKCE, where the login is an Ethereum signature (EIP-4361).
|
|
40951
|
+
No passwords, no user database. The bearer token proves <em>session identity only</em> \u2014
|
|
40952
|
+
it signs nothing and can never move funds; every fund-moving step raises its own approval
|
|
40953
|
+
in your own wallet. Session state is in memory, so a restart means signing in again.
|
|
40954
|
+
</div>
|
|
40955
|
+
</section>
|
|
40956
|
+
|
|
40957
|
+
<section>
|
|
40958
|
+
<h2>Endpoints</h2>
|
|
40959
|
+
<div class="card">
|
|
40960
|
+
<table>
|
|
40961
|
+
<tr><td>MCP</td><td><code>${origin2}/mcp</code> \u2014 streamable HTTP</td></tr>
|
|
40962
|
+
<tr><td>Networks served</td><td><code>${escapeHtml(networks2.join(", "))}</code></td></tr>
|
|
40963
|
+
<tr><td>Registration</td><td><a href="/auth.md">/auth.md</a> \u2014 how an agent registers and signs in</td></tr>
|
|
40964
|
+
<tr><td>Resource metadata</td><td><a href="/.well-known/oauth-protected-resource">/.well-known/oauth-protected-resource</a></td></tr>
|
|
40965
|
+
<tr><td>Auth server metadata</td><td><a href="/.well-known/oauth-authorization-server">/.well-known/oauth-authorization-server</a></td></tr>
|
|
40966
|
+
</table>
|
|
40967
|
+
</div>
|
|
40968
|
+
|
|
40969
|
+
</section>
|
|
40970
|
+
</div>
|
|
40971
|
+
|
|
40972
|
+
<footer>
|
|
40973
|
+
<code>@gvnrdao/dh-mcp</code> v${escapeHtml(version2)} \xB7 origin <code>${origin2}</code>
|
|
40974
|
+
</footer>
|
|
40975
|
+
</div>
|
|
40976
|
+
</main>
|
|
40977
|
+
</div>
|
|
40978
|
+
<script nonce="${escapeHtml(nonce)}">
|
|
40979
|
+
// Progressive disclosure, applied by SCRIPT rather than baked into the markup: the
|
|
40980
|
+
// details ship visible, and only a browser that can re-open them is allowed to close
|
|
40981
|
+
// them. A page whose whole content sits behind a trigger that needs JS is a page that
|
|
40982
|
+
// shows two sentences and nothing else when the script does not run.
|
|
40983
|
+
(function () {
|
|
40984
|
+
var details = document.getElementById('details');
|
|
40985
|
+
var wrap = document.getElementById('reveal-wrap');
|
|
40986
|
+
var link = document.getElementById('reveal');
|
|
40987
|
+
if (!details || !wrap || !link) return;
|
|
40988
|
+
details.hidden = true;
|
|
40989
|
+
wrap.hidden = false;
|
|
40990
|
+
link.addEventListener('click', function (e) {
|
|
40991
|
+
e.preventDefault();
|
|
40992
|
+
wrap.hidden = true;
|
|
40993
|
+
details.hidden = false;
|
|
40994
|
+
});
|
|
40995
|
+
})();
|
|
40996
|
+
|
|
40997
|
+
document.getElementById('copy').addEventListener('click', function () {
|
|
40998
|
+
var t = document.getElementById('cfg').textContent;
|
|
40999
|
+
navigator.clipboard.writeText(t).then(function () {
|
|
41000
|
+
var b = document.getElementById('copy');
|
|
41001
|
+
b.textContent = 'Copied'; setTimeout(function () { b.textContent = 'Copy'; }, 1400);
|
|
41002
|
+
});
|
|
41003
|
+
});
|
|
41004
|
+
</script>
|
|
41005
|
+
</body>
|
|
41006
|
+
</html>
|
|
41007
|
+
`;
|
|
41008
|
+
}
|
|
41009
|
+
|
|
41010
|
+
// src/util/page-headers.ts
|
|
41011
|
+
var import_node_crypto = require("crypto");
|
|
41012
|
+
function htmlPageSecurityHeaders(extra) {
|
|
41013
|
+
const nonce = (0, import_node_crypto.randomBytes)(16).toString("base64");
|
|
41014
|
+
const base = [
|
|
41015
|
+
`default-src 'none'`,
|
|
41016
|
+
`script-src 'nonce-${nonce}'`,
|
|
41017
|
+
`style-src 'unsafe-inline'`,
|
|
41018
|
+
`connect-src 'self'`,
|
|
41019
|
+
`base-uri 'none'`,
|
|
41020
|
+
`form-action 'none'`,
|
|
41021
|
+
`frame-ancestors 'none'`
|
|
41022
|
+
];
|
|
41023
|
+
for (const [directive, sources] of Object.entries(extra ?? {})) {
|
|
41024
|
+
if (sources.length === 0) continue;
|
|
41025
|
+
base.push(`${directive} ${sources.join(" ")}`);
|
|
41026
|
+
}
|
|
41027
|
+
return {
|
|
41028
|
+
nonce,
|
|
41029
|
+
headers: {
|
|
41030
|
+
"Content-Security-Policy": base.join("; "),
|
|
41031
|
+
"X-Frame-Options": "DENY",
|
|
41032
|
+
"Referrer-Policy": "no-referrer",
|
|
41033
|
+
"X-Content-Type-Options": "nosniff"
|
|
41034
|
+
}
|
|
41035
|
+
};
|
|
41036
|
+
}
|
|
41037
|
+
|
|
41038
|
+
// src/version.ts
|
|
41039
|
+
var SERVER_VERSION = "0.5.13";
|
|
41040
|
+
|
|
40821
41041
|
// src/connector/siwe-oauth.ts
|
|
40822
41042
|
var import_node_crypto2 = require("crypto");
|
|
40823
41043
|
var import_ethers = require("ethers");
|
|
@@ -40867,7 +41087,7 @@ button { font-size: 1rem; padding: 0.6rem 1.2rem; cursor: pointer; margin-right:
|
|
|
40867
41087
|
</head>
|
|
40868
41088
|
<body>
|
|
40869
41089
|
<h1>Sign in to Diamond Hands</h1>
|
|
40870
|
-
<p><span class="cname" dir="ltr">${
|
|
41090
|
+
<p><span class="cname" dir="ltr">${escapeHtml2(clientName)}</span> is asking to connect. Signing in proves you own a wallet address \u2014 it authorizes nothing on-chain and can never move funds.</p>
|
|
40871
41091
|
<p class="dest">When you sign, this connection is handed to <code dir="ltr">${renderRedirectHost(redirectHost)}</code>. Anyone can register a client under any name, so read the host, not the name \u2014 and read it from the <b>bold end</b>, which is the part that decides who actually owns it. If you do not recognize it, close this page; nothing has happened yet.</p>
|
|
40872
41092
|
<button id="connect">Browser wallet</button>
|
|
40873
41093
|
<button id="wc">Mobile wallet (QR)</button>
|
|
@@ -40943,7 +41163,7 @@ document.getElementById("wc").addEventListener("click", async () => {
|
|
|
40943
41163
|
</body>
|
|
40944
41164
|
</html>`;
|
|
40945
41165
|
}
|
|
40946
|
-
function
|
|
41166
|
+
function escapeHtml2(s) {
|
|
40947
41167
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
40948
41168
|
}
|
|
40949
41169
|
var MAX_CLIENT_NAME_CHARS = 64;
|
|
@@ -40964,7 +41184,7 @@ function splitRedirectHost(host) {
|
|
|
40964
41184
|
function renderRedirectHost(host) {
|
|
40965
41185
|
const { head, elided, tail } = splitRedirectHost(host);
|
|
40966
41186
|
const cut = elided === 0 ? "" : `<span class="host-cut">\u2026+${elided} chars\u2026</span>`;
|
|
40967
|
-
return `<span class="host-head">${
|
|
41187
|
+
return `<span class="host-head">${escapeHtml2(head)}</span>${cut}<span class="host-tail">${escapeHtml2(tail)}</span>`;
|
|
40968
41188
|
}
|
|
40969
41189
|
function clampClientName(name) {
|
|
40970
41190
|
const points = [...name];
|
|
@@ -40972,21 +41192,6 @@ function clampClientName(name) {
|
|
|
40972
41192
|
return `${points.slice(0, MAX_CLIENT_NAME_CHARS - 1).join("")}\u2026`;
|
|
40973
41193
|
}
|
|
40974
41194
|
|
|
40975
|
-
// src/util/page-headers.ts
|
|
40976
|
-
var import_node_crypto = require("crypto");
|
|
40977
|
-
function htmlPageSecurityHeaders() {
|
|
40978
|
-
const nonce = (0, import_node_crypto.randomBytes)(16).toString("base64");
|
|
40979
|
-
return {
|
|
40980
|
-
nonce,
|
|
40981
|
-
headers: {
|
|
40982
|
-
"Content-Security-Policy": `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'unsafe-inline'; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`,
|
|
40983
|
-
"X-Frame-Options": "DENY",
|
|
40984
|
-
"Referrer-Policy": "no-referrer",
|
|
40985
|
-
"X-Content-Type-Options": "nosniff"
|
|
40986
|
-
}
|
|
40987
|
-
};
|
|
40988
|
-
}
|
|
40989
|
-
|
|
40990
41195
|
// src/connector/siwe-oauth.ts
|
|
40991
41196
|
var FLOW_TTL_MS = 10 * 60 * 1e3;
|
|
40992
41197
|
var CODE_TTL_MS = 60 * 1e3;
|
|
@@ -41348,7 +41553,11 @@ var NETWORK_DEFAULTS = {
|
|
|
41348
41553
|
},
|
|
41349
41554
|
mainnet: {
|
|
41350
41555
|
rpcUrl: "https://ethereum-rpc.publicnode.com",
|
|
41351
|
-
|
|
41556
|
+
// Cutover 2026-09-08 — see sdk/src/constants/chunks/network-configs.ts for the full
|
|
41557
|
+
// reasoning. Widening, not a rename: ops.gvnr.xyz serves the same broker and cannot be
|
|
41558
|
+
// retired while installed copies call it. The sepolia entry above deliberately stays on
|
|
41559
|
+
// ops-test.gvnr.xyz — there is no ops-test.diamondhands.credit twin (open decision 2).
|
|
41560
|
+
serviceEndpoint: "https://ops.diamondhands.credit",
|
|
41352
41561
|
litNetwork: "chipotle",
|
|
41353
41562
|
// On-chain PKPValidation generation, mainnet (validatorForVersion(3) is the ONLY
|
|
41354
41563
|
// registered validator — verified live 2026-08-05). Without this the SDK defaults
|
|
@@ -42280,6 +42489,19 @@ var BoundaryCore = class {
|
|
|
42280
42489
|
if (!r.ok) return errEnvelope(failureToError(r.failure));
|
|
42281
42490
|
return okEnvelope({ releasedSats: r.value.releasedSats }, r.source);
|
|
42282
42491
|
}
|
|
42492
|
+
/** C-46. Unlike `recoverStaleSpend` this is NOT permissionless: re-running phase 2 signs
|
|
42493
|
+
* for the vault, so it takes the same borrower gate every fund-moving op takes. */
|
|
42494
|
+
async retryWithdrawExecute(p) {
|
|
42495
|
+
const auth = await this.requireBorrower();
|
|
42496
|
+
if (!auth.ok) return errEnvelope(auth.error);
|
|
42497
|
+
const r = await this.deps.plugin.ops.retryWithdrawExecute({
|
|
42498
|
+
positionId: p.positionId,
|
|
42499
|
+
networkFeeSats: p.networkFeeSats,
|
|
42500
|
+
borrower: auth.borrower
|
|
42501
|
+
});
|
|
42502
|
+
if (!r.ok) return errEnvelope(failureToError(r.failure));
|
|
42503
|
+
return okEnvelope({ attempted: r.value.attempted, transfers: r.value.transfers }, r.source);
|
|
42504
|
+
}
|
|
42283
42505
|
// ---- meta ----
|
|
42284
42506
|
world() {
|
|
42285
42507
|
return {
|
|
@@ -43103,6 +43325,42 @@ var World = class {
|
|
|
43103
43325
|
c.authorizedSpends.splice(idx, 1);
|
|
43104
43326
|
return { ok: true, value: { releasedSats: spend.satoshis } };
|
|
43105
43327
|
}
|
|
43328
|
+
/**
|
|
43329
|
+
* C-46: re-run the withdrawal EXECUTE leg for reservations whose coins have not been
|
|
43330
|
+
* observed moving (`consumed === null`). This is the stranded shape: phase 1 committed
|
|
43331
|
+
* the reservation, phase 2's quantum-stamped signature expired, and the outpoint was
|
|
43332
|
+
* never spent.
|
|
43333
|
+
*
|
|
43334
|
+
* The retry BROADCASTS; it does not observe. `consumed` therefore stays null — that flag
|
|
43335
|
+
* means "seen consumed on Bitcoin", and only MockControl.confirmSpendConsumed (standing
|
|
43336
|
+
* in for the chain) may set it. Conflating the two would let a retry release collateral
|
|
43337
|
+
* against a transaction no one has confirmed, which is the mistake the whole
|
|
43338
|
+
* proof-of-consumption design exists to prevent. So a retry leaves the reservation
|
|
43339
|
+
* holding its balance exactly as before; what it produces is the txid that can LATER
|
|
43340
|
+
* become the invalidator — the proof the stranded state could never generate for itself.
|
|
43341
|
+
*/
|
|
43342
|
+
retryWithdrawExecute(p) {
|
|
43343
|
+
const paused = this.pausedReason();
|
|
43344
|
+
if (paused) return { ok: false, reason: paused };
|
|
43345
|
+
const pos = this.state.positions[p.positionId];
|
|
43346
|
+
if (!pos) return { ok: false, reason: `position ${p.positionId} does not exist` };
|
|
43347
|
+
if (pos.borrower.toLowerCase() !== p.borrower.toLowerCase()) {
|
|
43348
|
+
return { ok: false, reason: `caller ${p.borrower} is not the borrower of this position` };
|
|
43349
|
+
}
|
|
43350
|
+
const c = this.state.collateral[p.positionId];
|
|
43351
|
+
const pending = (c?.authorizedSpends ?? []).filter((s) => s.consumed === null);
|
|
43352
|
+
const transfers = pending.map((spend) => {
|
|
43353
|
+
const { hash: txid } = this.nextId("btc-withdraw-retry");
|
|
43354
|
+
return {
|
|
43355
|
+
utxoIdentifier: `${spend.txid}:${spend.vout}`,
|
|
43356
|
+
ok: true,
|
|
43357
|
+
txid,
|
|
43358
|
+
amountSentSats: spend.satoshis,
|
|
43359
|
+
destination: spend.targetAddress
|
|
43360
|
+
};
|
|
43361
|
+
});
|
|
43362
|
+
return { ok: true, value: { attempted: transfers.length, transfers } };
|
|
43363
|
+
}
|
|
43106
43364
|
// ---- Mock Safes (plan 06): REAL verification semantics, no fakes (M6-21/27) ----
|
|
43107
43365
|
safesMap() {
|
|
43108
43366
|
return this.state.safes;
|
|
@@ -44297,6 +44555,11 @@ var MockUpstreamPlugin = class {
|
|
|
44297
44555
|
const r = this.world.recoverStaleSpend(p);
|
|
44298
44556
|
if (!r.ok) return this.rejected("recoverStaleSpend", r.reason);
|
|
44299
44557
|
return upOk({ txRef: this.world.nextTxRef(), releasedSats: r.value.releasedSats }, this.src("mock-ops"));
|
|
44558
|
+
}),
|
|
44559
|
+
retryWithdrawExecute: (p) => this.write("retryWithdrawExecute", () => {
|
|
44560
|
+
const r = this.world.retryWithdrawExecute({ positionId: p.positionId, borrower: p.borrower });
|
|
44561
|
+
if (!r.ok) return this.rejected("retryWithdrawExecute", r.reason);
|
|
44562
|
+
return upOk({ attempted: r.value.attempted, transfers: r.value.transfers }, this.src("mock-ops"));
|
|
44300
44563
|
})
|
|
44301
44564
|
};
|
|
44302
44565
|
}
|
|
@@ -52536,13 +52799,13 @@ var init_deployment_addresses = __esm2({
|
|
|
52536
52799
|
block: 25472956
|
|
52537
52800
|
},
|
|
52538
52801
|
BTCSpendAuthorizer: {
|
|
52539
|
-
previousImplementation: "
|
|
52540
|
-
newImplementation: "
|
|
52541
|
-
upgradedAt: "2026-
|
|
52542
|
-
upgradedBy: "AdminModule
|
|
52543
|
-
reason: "
|
|
52544
|
-
executeTx: "
|
|
52545
|
-
block:
|
|
52802
|
+
previousImplementation: "0x40c9e8C46C65E0A57BB63da5368868A9E8Df81A5",
|
|
52803
|
+
newImplementation: "0x00D7a47798E8ff169104b748131703B78f23390C",
|
|
52804
|
+
upgradedAt: "2026-09-09T12:05:35.000Z",
|
|
52805
|
+
upgradedBy: "AdminModule generic op 0xc0214ff38bb454864a34f6482dcd03570b3fd04171c84be2c20184afb1a2e161 (bsa-1-7-0 ceremony: proposed by seat 0x3030C0414B6d95aA9d5A57269E51a347fCBaB472 2026-09-08T11:35:23Z, 3/3 seat signatures, 24h timelock); executeGenericAdminOperation sent by 0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6 in tx 0x77cd231966c546177bd8f1a07bd4e705afd5c2dfbd110b096836401679c0c69c (block 25939703)",
|
|
52806
|
+
reason: "BTCSpendAuthorizer 1.6.0 -> 1.7.0: allow a full-vault sweep (targetAmount == satoshis); TargetMustLeaveFeeRoom -> TargetExceedsInputValue (PR #849; mainnet incidents 2026-09-04 and 2026-09-07). Impl deployed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f at nonce 430 from source 0a7c535a1 (contracts/src identical to main 99b335f77). Cross-ref onchain-auth/.safe-batches/mainnet-bsa-1-7-0-{propose,sign,execute}.json and docs/mainnet-bsa-1-7-0-ceremony-2026-09-08.md",
|
|
52807
|
+
executeTx: "0x77cd231966c546177bd8f1a07bd4e705afd5c2dfbd110b096836401679c0c69c",
|
|
52808
|
+
block: 25939703
|
|
52546
52809
|
},
|
|
52547
52810
|
PositionManager: {
|
|
52548
52811
|
previousImplementation: "0x600Dc0D1C2c0F94882B6Bc09172f8650047Ad5B1",
|
|
@@ -52645,7 +52908,7 @@ var init_deployment_addresses = __esm2({
|
|
|
52645
52908
|
ADMIN_MODULE: "0x0023B71B586795eE5fa4E83E384345C1EC8Bb946",
|
|
52646
52909
|
ADMIN_MODULE_IMPL: "0xb4C5C7E051A1e672F014B25CB5D55B225Aa0D512",
|
|
52647
52910
|
BTC_SPEND_AUTHORIZER: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
52648
|
-
BTC_SPEND_AUTHORIZER_IMPL: "
|
|
52911
|
+
BTC_SPEND_AUTHORIZER_IMPL: "0x00D7a47798E8ff169104b748131703B78f23390C",
|
|
52649
52912
|
POSITION_MANAGER_VIEWS: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
|
|
52650
52913
|
POSITION_MANAGER_VIEWS_IMPL: "0xE68DC096A65Ecddbc6A9b5c6e5f878e2CE143Bfe",
|
|
52651
52914
|
POSITION_MANAGER: "0x12A1836e56139ccaD8722B89519d84233efc224B",
|
|
@@ -57621,7 +57884,17 @@ function getSepoliaConfig() {
|
|
|
57621
57884
|
function getMainnetConfig() {
|
|
57622
57885
|
return {
|
|
57623
57886
|
mode: "service",
|
|
57624
|
-
|
|
57887
|
+
// Cutover 2026-09-08: the product's own domain. `ops.gvnr.xyz` still serves the same
|
|
57888
|
+
// broker and always will — every already-installed copy of this package calls it, so
|
|
57889
|
+
// it can never be retired. This changes what NEW installs default to, nothing else.
|
|
57890
|
+
//
|
|
57891
|
+
// Safe only because the server accepts the new audience ALREADY: the SDK derives the
|
|
57892
|
+
// login audience from this endpoint (`server-session.ts` — `loginAudience ??
|
|
57893
|
+
// serviceEndpoint`) and lit-ops-server FAILS CLOSED on an unknown one. Verified live
|
|
57894
|
+
// before this edit: DH_ACCEPTED_LOGIN_AUDIENCES on the deployed revision lists
|
|
57895
|
+
// https://ops.diamondhands.credit. Publishing this ahead of that would lock out every
|
|
57896
|
+
// client that installed it.
|
|
57897
|
+
serviceEndpoint: "https://ops.diamondhands.credit",
|
|
57625
57898
|
chainId: 1,
|
|
57626
57899
|
name: "mainnet",
|
|
57627
57900
|
// No default RPC: mainnet runs in service mode (serviceEndpoint above), so
|
|
@@ -58705,9 +58978,27 @@ var LOGIN_TYPES_WITH_AUDIENCE2 = {
|
|
|
58705
58978
|
{ name: "audience", type: "string" }
|
|
58706
58979
|
]
|
|
58707
58980
|
};
|
|
58708
|
-
|
|
58981
|
+
var LOGIN_TYPES_WITH_STATEMENT = {
|
|
58982
|
+
DiamondHands: [
|
|
58983
|
+
{ name: "statement", type: "string" },
|
|
58984
|
+
{ name: "address", type: "address" },
|
|
58985
|
+
{ name: "issuedAt", type: "uint256" },
|
|
58986
|
+
{ name: "nonce", type: "bytes32" },
|
|
58987
|
+
{ name: "audience", type: "string" }
|
|
58988
|
+
]
|
|
58989
|
+
};
|
|
58990
|
+
var LOGIN_STATEMENT_TEMPLATE = "{host} is verifying you own this wallet. Signing proves control of the address so we can show your loans and positions. It authorizes no transaction, moves no funds, and costs no gas.";
|
|
58991
|
+
function canonicalLoginStatement(audience) {
|
|
58992
|
+
const host = /^https?:\/\/([^/?#]+)/i.exec(audience)?.[1];
|
|
58993
|
+
if (!host)
|
|
58994
|
+
return null;
|
|
58995
|
+
return LOGIN_STATEMENT_TEMPLATE.replace("{host}", host);
|
|
58996
|
+
}
|
|
58997
|
+
async function buildSignedLoginPayload(signer, chainId, audience, reuse, withStatement = false) {
|
|
58709
58998
|
const address = await signer.getAddress();
|
|
58999
|
+
const statement = withStatement && audience ? canonicalLoginStatement(audience) : null;
|
|
58710
59000
|
const message = {
|
|
59001
|
+
...statement ? { statement } : {},
|
|
58711
59002
|
address,
|
|
58712
59003
|
issuedAt: reuse?.issuedAt ?? Math.floor(Date.now() / 1e3),
|
|
58713
59004
|
nonce: reuse?.nonce ?? (0, import_ethers18.hexlify)((0, import_ethers18.randomBytes)(32)),
|
|
@@ -58715,7 +59006,7 @@ async function buildSignedLoginPayload(signer, chainId, audience, reuse) {
|
|
|
58715
59006
|
};
|
|
58716
59007
|
const signature = await signer.signTypedData(
|
|
58717
59008
|
buildLoginDomain(chainId),
|
|
58718
|
-
audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
|
|
59009
|
+
statement ? LOGIN_TYPES_WITH_STATEMENT : audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
|
|
58719
59010
|
message
|
|
58720
59011
|
);
|
|
58721
59012
|
return { chainId, message, signature };
|
|
@@ -58884,6 +59175,8 @@ var ServerSession = class {
|
|
|
58884
59175
|
signer;
|
|
58885
59176
|
serviceEndpoint;
|
|
58886
59177
|
loginAudience;
|
|
59178
|
+
/** Whether this session's login carries the human-readable statement. */
|
|
59179
|
+
withStatement;
|
|
58887
59180
|
chainId;
|
|
58888
59181
|
store;
|
|
58889
59182
|
onSignaturePrompt;
|
|
@@ -58925,6 +59218,13 @@ var ServerSession = class {
|
|
|
58925
59218
|
/\/+$/,
|
|
58926
59219
|
""
|
|
58927
59220
|
);
|
|
59221
|
+
const explicitAudience = typeof opts.loginAudience === "string" && opts.loginAudience.length > 0;
|
|
59222
|
+
this.withStatement = opts.withStatement === true && explicitAudience;
|
|
59223
|
+
if (opts.withStatement === true && !explicitAudience) {
|
|
59224
|
+
console.warn(
|
|
59225
|
+
"[dh-sdk] withStatement ignored: it requires an explicit loginAudience, since the servers rebuild the expected sentence from the audience host"
|
|
59226
|
+
);
|
|
59227
|
+
}
|
|
58928
59228
|
this.chainId = opts.chainId;
|
|
58929
59229
|
this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
|
|
58930
59230
|
this.onSignaturePrompt = opts.onSignaturePrompt;
|
|
@@ -59178,12 +59478,16 @@ var ServerSession = class {
|
|
|
59178
59478
|
this.signer,
|
|
59179
59479
|
this.chainId,
|
|
59180
59480
|
this.loginAudience,
|
|
59181
|
-
reuse
|
|
59481
|
+
reuse,
|
|
59482
|
+
reuse ? reuse.withStatement === true : this.withStatement
|
|
59182
59483
|
);
|
|
59183
59484
|
if (storeKey && !reuse) {
|
|
59184
59485
|
store.savePending?.(storeKey, {
|
|
59185
59486
|
issuedAt: payload.message.issuedAt,
|
|
59186
|
-
nonce: payload.message.nonce
|
|
59487
|
+
nonce: payload.message.nonce,
|
|
59488
|
+
// Recorded so a resume reproduces this digest even if the
|
|
59489
|
+
// capability flag changes before the owners finish signing.
|
|
59490
|
+
withStatement: this.withStatement
|
|
59187
59491
|
});
|
|
59188
59492
|
}
|
|
59189
59493
|
session = await this.login(payload);
|
|
@@ -71394,6 +71698,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
71394
71698
|
signer: config.authSigner ?? config.contractSigner,
|
|
71395
71699
|
serviceEndpoint: config.serviceEndpoint,
|
|
71396
71700
|
loginAudience: config.loginAudience,
|
|
71701
|
+
// Only meaningful alongside an audience; the servers derive the expected
|
|
71702
|
+
// sentence from its host. Defaults off so Node callers are untouched.
|
|
71703
|
+
withStatement: config.loginStatement === true,
|
|
71397
71704
|
chainId: config.chainId,
|
|
71398
71705
|
persistSession: config.sessionPersistence?.enabled,
|
|
71399
71706
|
sessionStore: config.sessionPersistence?.store,
|
|
@@ -80239,7 +80546,33 @@ function buildWriteOps(deps) {
|
|
|
80239
80546
|
kind: "unavailable",
|
|
80240
80547
|
source: SOURCE5,
|
|
80241
80548
|
message: "recoverStaleSpend is not wired in this delivery (permissionless recovery \u2014 planned follow-up)."
|
|
80242
|
-
})
|
|
80549
|
+
}),
|
|
80550
|
+
retryWithdrawExecute: async (p) => {
|
|
80551
|
+
const sdk = deps.getWriteSdk();
|
|
80552
|
+
if (!sdk) return upFail({ kind: "unavailable", source: SOURCE5, message: "write SDK is not initialized (its boot-time construction failed)" });
|
|
80553
|
+
let rows;
|
|
80554
|
+
try {
|
|
80555
|
+
rows = await sdk.executePendingBtcTransfers(p.positionId, p.networkFeeSats);
|
|
80556
|
+
} catch (e) {
|
|
80557
|
+
return failed("retryWithdrawExecute", e);
|
|
80558
|
+
}
|
|
80559
|
+
const gate = rows.find((r) => !r.success && !r.utxoIdentifier);
|
|
80560
|
+
if (gate) return declined("retryWithdrawExecute", gate.error ?? "pending-transfer execution refused before any reservation was attempted");
|
|
80561
|
+
return upOk(
|
|
80562
|
+
{
|
|
80563
|
+
attempted: rows.length,
|
|
80564
|
+
transfers: rows.map((r) => ({
|
|
80565
|
+
utxoIdentifier: r.utxoIdentifier ?? "",
|
|
80566
|
+
ok: r.success,
|
|
80567
|
+
...r.txid ? { txid: r.txid } : {},
|
|
80568
|
+
...r.amountSent !== void 0 ? { amountSentSats: String(r.amountSent) } : {},
|
|
80569
|
+
...r.destination ? { destination: r.destination } : {},
|
|
80570
|
+
...r.error ? { error: r.error } : {}
|
|
80571
|
+
}))
|
|
80572
|
+
},
|
|
80573
|
+
{ id: SOURCE5, kind: "lit-ops", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }
|
|
80574
|
+
);
|
|
80575
|
+
}
|
|
80243
80576
|
};
|
|
80244
80577
|
}
|
|
80245
80578
|
|
|
@@ -80764,7 +81097,8 @@ var RealUpstreamPlugin = class {
|
|
|
80764
81097
|
message: "no signer configured \u2014 psmSwap signs two on-chain transactions (exact-amount approve, then swap/redeem) with the keystore signer. Set DH_KEYSTORE_PATH and DH_KEYSTORE_PASSWORD to enable it."
|
|
80765
81098
|
})
|
|
80766
81099
|
),
|
|
80767
|
-
recoverStaleSpend: () => readOnly("recoverStaleSpend")
|
|
81100
|
+
recoverStaleSpend: () => readOnly("recoverStaleSpend"),
|
|
81101
|
+
retryWithdrawExecute: () => readOnly("retryWithdrawExecute")
|
|
80768
81102
|
};
|
|
80769
81103
|
}
|
|
80770
81104
|
}
|
|
@@ -80932,7 +81266,8 @@ var RealUpstreamPlugin = class {
|
|
|
80932
81266
|
psmSwap: call("psmSwap"),
|
|
80933
81267
|
delegationSetup: call("delegationSetup"),
|
|
80934
81268
|
delegationGrant: call("delegationGrant"),
|
|
80935
|
-
recoverStaleSpend: call("recoverStaleSpend")
|
|
81269
|
+
recoverStaleSpend: call("recoverStaleSpend"),
|
|
81270
|
+
retryWithdrawExecute: call("retryWithdrawExecute")
|
|
80936
81271
|
};
|
|
80937
81272
|
}
|
|
80938
81273
|
async resolveOpsGateway() {
|
|
@@ -81743,6 +82078,9 @@ function wcDeclineOrFault(e) {
|
|
|
81743
82078
|
}
|
|
81744
82079
|
var SignatureBridge = class {
|
|
81745
82080
|
clock;
|
|
82081
|
+
/** Lowercased at construction so every comparison is case-flat — EIP-55 checksum casing
|
|
82082
|
+
* differs between what SIWE signs and what a wallet reports for the SAME address. */
|
|
82083
|
+
boundAccount;
|
|
81746
82084
|
expiryMs;
|
|
81747
82085
|
/** Plan 17 E2: single-decision concurrency cap (null = unbounded, the loopback tier). */
|
|
81748
82086
|
maxPending;
|
|
@@ -81778,6 +82116,7 @@ var SignatureBridge = class {
|
|
|
81778
82116
|
unlockSession = null;
|
|
81779
82117
|
constructor(opts) {
|
|
81780
82118
|
this.clock = opts?.clock ?? Date.now;
|
|
82119
|
+
this.boundAccount = opts?.boundAccount?.toLowerCase();
|
|
81781
82120
|
this.expiryMs = opts?.expiryMs ?? DEFAULT_EXPIRY_MS;
|
|
81782
82121
|
this.maxPending = opts?.maxPending ?? null;
|
|
81783
82122
|
this.attachGraceMs = opts?.attachGraceMs ?? (opts?.mount ? DEFAULT_HOSTED_ATTACH_GRACE_MS : DEFAULT_ATTACH_GRACE_MS);
|
|
@@ -82147,6 +82486,14 @@ var SignatureBridge = class {
|
|
|
82147
82486
|
});
|
|
82148
82487
|
this.wcTransport = await factory2(this.wcConfig);
|
|
82149
82488
|
this.wcTransport.onSession((info) => {
|
|
82489
|
+
const refusal = info ? this.accountRefusal(info.account) : null;
|
|
82490
|
+
if (info && refusal) {
|
|
82491
|
+
this.wcActive = false;
|
|
82492
|
+
this.wallet = null;
|
|
82493
|
+
process.stderr.write(`[bridge] WalletConnect session refused \u2014 ${refusal}
|
|
82494
|
+
`);
|
|
82495
|
+
return;
|
|
82496
|
+
}
|
|
82150
82497
|
this.wcActive = info !== null;
|
|
82151
82498
|
this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
|
|
82152
82499
|
if (info === null) {
|
|
@@ -82244,10 +82591,36 @@ var SignatureBridge = class {
|
|
|
82244
82591
|
this.deny(res, 400, "hello requires account (0x address) and integer chainId");
|
|
82245
82592
|
return;
|
|
82246
82593
|
}
|
|
82594
|
+
const refusal = this.accountRefusal(account);
|
|
82595
|
+
if (refusal) {
|
|
82596
|
+
this.deny(res, 403, refusal);
|
|
82597
|
+
return;
|
|
82598
|
+
}
|
|
82247
82599
|
session.wallet = { account, chainId };
|
|
82248
82600
|
this.wallet = { account, chainId };
|
|
82249
82601
|
this.ok(res);
|
|
82250
82602
|
}
|
|
82603
|
+
/** C-47: the single predicate every wallet account is admitted through. There are THREE
|
|
82604
|
+
* doors into the account this bridge will sign with — `hello`, `accountsChanged`, and the
|
|
82605
|
+
* WalletConnect `onSession` callback — and all three call this. The first version of this
|
|
82606
|
+
* fix guarded only the first two while this docstring already claimed to be "the single
|
|
82607
|
+
* place", which is how the WC door survived a green suite: the claim was in prose, not in a
|
|
82608
|
+
* test. T-EXT-BIND-01/02/04 now pin one door each, so adding a fourth writer of
|
|
82609
|
+
* `this.wallet` without coming through here fails a test rather than a review.
|
|
82610
|
+
*
|
|
82611
|
+
* Returns the refusal reason, or
|
|
82612
|
+
* null when the account may be adopted.
|
|
82613
|
+
*
|
|
82614
|
+
* Both addresses are named because the pre-fix failure surfaced much later as an opaque
|
|
82615
|
+
* signature-recovery error (`external-eoa.ts:230-233`) that named neither and read as a
|
|
82616
|
+
* wallet fault. A user with several accounts in one wallet extension hits this by
|
|
82617
|
+
* accident far more often than any attacker does, and "wrong account" is only actionable
|
|
82618
|
+
* if it says WHICH. */
|
|
82619
|
+
accountRefusal(account) {
|
|
82620
|
+
if (!this.boundAccount) return null;
|
|
82621
|
+
if (account.toLowerCase() === this.boundAccount) return null;
|
|
82622
|
+
return `this session is signed in as ${this.boundAccount} but the wallet offered ${account.toLowerCase()} \u2014 the account that signs must be the account that signed in. Switch your wallet to the signed-in account, or start a new session with this one.`;
|
|
82623
|
+
}
|
|
82251
82624
|
/** accountsChanged / chainChanged: a wallet-state CHANGE mid-request invalidates every
|
|
82252
82625
|
* pending request — what the human saw approved is no longer what would sign. Wallets
|
|
82253
82626
|
* also deliver late no-op echoes of these events; an unchanged state invalidates nothing. */
|
|
@@ -82257,7 +82630,9 @@ var SignatureBridge = class {
|
|
|
82257
82630
|
const account = String(body["account"] ?? "");
|
|
82258
82631
|
const chainId = Number(body["chainId"]);
|
|
82259
82632
|
const prev = session.wallet;
|
|
82260
|
-
|
|
82633
|
+
const offered = /^0x[0-9a-fA-F]{40}$/.test(account) && Number.isInteger(chainId) ? { account, chainId } : null;
|
|
82634
|
+
const refusedSwitch = offered !== null && this.accountRefusal(offered.account) !== null;
|
|
82635
|
+
session.wallet = refusedSwitch ? null : offered;
|
|
82261
82636
|
if (this.wallet !== null && prev !== null && this.wallet.account.toLowerCase() === prev.account.toLowerCase()) {
|
|
82262
82637
|
this.wallet = session.wallet;
|
|
82263
82638
|
}
|
|
@@ -82266,7 +82641,7 @@ var SignatureBridge = class {
|
|
|
82266
82641
|
this.ok(res);
|
|
82267
82642
|
return;
|
|
82268
82643
|
}
|
|
82269
|
-
const reason = prev && session.wallet && prev.account.toLowerCase() !== session.wallet.account.toLowerCase() ? "the wallet account changed while approval was pending" : prev && session.wallet && prev.chainId !== session.wallet.chainId ? "the wallet network changed while approval was pending" : "the wallet disconnected while approval was pending";
|
|
82644
|
+
const reason = refusedSwitch ? "the wallet switched to an account this session is not signed in as" : prev && session.wallet && prev.account.toLowerCase() !== session.wallet.account.toLowerCase() ? "the wallet account changed while approval was pending" : prev && session.wallet && prev.chainId !== session.wallet.chainId ? "the wallet network changed while approval was pending" : "the wallet disconnected while approval was pending";
|
|
82270
82645
|
for (const entry of this.pending.values()) {
|
|
82271
82646
|
if (!entry.settled && !entry.collect) this.settle(entry, { status: "invalidated", reason });
|
|
82272
82647
|
}
|
|
@@ -82576,6 +82951,11 @@ async function createRealBoundary(config, wallet, overrides) {
|
|
|
82576
82951
|
// tenant — one bridge per tenant world, so the bridge cap IS the tenant cap. The
|
|
82577
82952
|
// loopback tier keeps its unbounded pending (multi-owner Safe pages need it).
|
|
82578
82953
|
...overrides?.bridgeMount ? { mount: overrides.bridgeMount(config.network), maxPending: 1 } : {},
|
|
82954
|
+
// C-47: the authenticated identity governs the write path. Passed separately from
|
|
82955
|
+
// `bridgeMount` although the hosted tier sets both — they answer different questions
|
|
82956
|
+
// ("where does the page live" vs "whose wallet may sign"), and fusing them would make
|
|
82957
|
+
// an unbound hosted bridge impossible to express in a test.
|
|
82958
|
+
...overrides?.boundBorrower ? { boundAccount: overrides.boundBorrower } : {},
|
|
82579
82959
|
// M12-12: no unlock closures without a provider — the unlock endpoints answer with
|
|
82580
82960
|
// their loud not-wired refusal instead of ever touching key material.
|
|
82581
82961
|
...keystore ? {
|
|
@@ -82852,6 +83232,32 @@ function offers(d, mode) {
|
|
|
82852
83232
|
function signerModeSourceClause(d) {
|
|
82853
83233
|
return offers(d, "keystore") ? "the set `signer_setup` offers. `boundary://info` reports the NARROWER set the active adapter actually constructs under `capabilities.writes.signerModes` (the real adapter builds `external` + `keystore`; the practice ceremonies are mock-adapter only) \u2014 when the two differ, `boundary://info` is authoritative" : "the same set `signer_setup` offers and `boundary://info` reports under `capabilities.writes.signerModes`";
|
|
82854
83234
|
}
|
|
83235
|
+
function phoneWalletOffer(d) {
|
|
83236
|
+
return d.walletConnect ? "or scan the WalletConnect QR (or paste the pairing code) to approve on a phone wallet" : "This deployment does NOT offer the WalletConnect phone-wallet leg \u2014 there is no QR to scan and `/wc-pairing` answers 404; a browser-extension wallet is the only path here";
|
|
83237
|
+
}
|
|
83238
|
+
function moneyTruth(d) {
|
|
83239
|
+
const practice = offers(d, "mock-simulated");
|
|
83240
|
+
const sepolia = d.networks.includes("sepolia");
|
|
83241
|
+
const mainnet = d.networks.includes("mainnet");
|
|
83242
|
+
const cases = [];
|
|
83243
|
+
if (practice) cases.push("- Adapter `mock` \u2014 a PRACTICE sandbox. No real money anywhere.");
|
|
83244
|
+
if (sepolia) {
|
|
83245
|
+
cases.push(
|
|
83246
|
+
"- Adapter `real` on SEPOLIA (the zero-config default) \u2014 the REAL protocol contracts on\n the test network: real ceremonies and signatures, PRACTICE money (test funds)."
|
|
83247
|
+
);
|
|
83248
|
+
}
|
|
83249
|
+
if (mainnet) cases.push("- Adapter `real` on MAINNET \u2014 REAL MONEY.");
|
|
83250
|
+
const gate = "Writes are enabled on every build; what stops one is having no signing identity connected\nyet \u2014 `signer_setup` is how that is fixed, and every fund movement still needs the user's\nown wallet signature AND `confirmed: true`.";
|
|
83251
|
+
if (cases.length === 1) {
|
|
83252
|
+
const only = mainnet && !sepolia && !practice ? "This deployment serves MAINNET ONLY \u2014 every fund-moving operation here spends REAL MONEY,\nand there is no practice network on it to fall back to." : `This deployment serves exactly one world:
|
|
83253
|
+
${cases[0]}`;
|
|
83254
|
+
return `${only}
|
|
83255
|
+
${gate}`;
|
|
83256
|
+
}
|
|
83257
|
+
return `The money truth on this deployment has ${cases.length === 2 ? "TWO" : "THREE"} cases:
|
|
83258
|
+
${cases.join("\n")}
|
|
83259
|
+
${gate}`;
|
|
83260
|
+
}
|
|
82855
83261
|
var LOCAL_GUIDE_DEPLOYMENT = {
|
|
82856
83262
|
tier: "local",
|
|
82857
83263
|
networks: ["sepolia", "mainnet"],
|
|
@@ -82859,7 +83265,13 @@ var LOCAL_GUIDE_DEPLOYMENT = {
|
|
|
82859
83265
|
// external+keystore and the mock sandbox adds the practice ceremonies, so the guide may
|
|
82860
83266
|
// speak the full vocabulary and let the existing adapter prose ("PRACTICE-ONLY today —
|
|
82861
83267
|
// on the real adapter these modes refuse") carry the narrower adapter axis.
|
|
82862
|
-
signerModes: GUIDE_SIGNER_MODES
|
|
83268
|
+
signerModes: GUIDE_SIGNER_MODES,
|
|
83269
|
+
// FALSE, because `DH_WC_PROJECT_ID` is unset in a default install and the WalletConnect
|
|
83270
|
+
// leg genuinely is not there until an operator configures it. The first draft of this line
|
|
83271
|
+
// said `true` "to keep the walkthrough complete", which is exactly the overclaim C-44 is
|
|
83272
|
+
// about — the default rendering would have promised a QR that most installs cannot show.
|
|
83273
|
+
// A live boot derives this from env either way (network-switch.ts).
|
|
83274
|
+
walletConnect: false
|
|
82863
83275
|
};
|
|
82864
83276
|
function servedNetworks(d) {
|
|
82865
83277
|
if (d.networks.length === 0) throw new Error("guide: a deployment must serve at least one network");
|
|
@@ -83031,7 +83443,7 @@ function keystoreAbsenceBullet() {
|
|
|
83031
83443
|
never ask for a password.`;
|
|
83032
83444
|
}
|
|
83033
83445
|
var GUIDE_TOPIC_SOURCES = {
|
|
83034
|
-
"getting-started": `# Diamond Hands \u2014 what this is
|
|
83446
|
+
"getting-started": (d) => `# Diamond Hands \u2014 what this is
|
|
83035
83447
|
|
|
83036
83448
|
Diamond Hands lets you BORROW a dollar-pegged token (UCD) against your own BITCOIN,
|
|
83037
83449
|
without selling it. Your BTC sits in a custody vault tied to your position; you mint UCD
|
|
@@ -83039,14 +83451,9 @@ against it, pay it back whenever you like, and take your BTC out again.
|
|
|
83039
83451
|
|
|
83040
83452
|
**Agent instructions:** answer in the USER'S language, map their words via the \`glossary\`
|
|
83041
83453
|
topic, and always say plainly whether this session is PRACTICE or REAL MONEY. Read the
|
|
83042
|
-
\`capabilities\` block in \`boundary://info\` FIRST \u2014 it states the network,
|
|
83043
|
-
|
|
83044
|
-
|
|
83045
|
-
- Adapter \`mock\` \u2014 a PRACTICE sandbox. No real money anywhere.
|
|
83046
|
-
- Adapter \`real\` on SEPOLIA (the zero-config default) \u2014 the REAL protocol contracts on
|
|
83047
|
-
the test network: real ceremonies and signatures, PRACTICE money (test funds).
|
|
83048
|
-
- Adapter \`real\` on MAINNET \u2014 REAL MONEY. Writes are disabled unless the operator
|
|
83049
|
-
explicitly arms them; the capabilities block states which applies.
|
|
83454
|
+
\`capabilities\` block in \`boundary://info\` FIRST \u2014 it states the network, which signer
|
|
83455
|
+
modes this build offers, and which mode is active; never promise a capability it does not
|
|
83456
|
+
list. ${moneyTruth(d)}
|
|
83050
83457
|
SAY THIS EARLY AND UNPROMPTED \u2014 users must never wonder whether money is real.
|
|
83051
83458
|
|
|
83052
83459
|
A first conversation usually goes: explain this page \u2192 \`guide first-setup\` (choose how to
|
|
@@ -83071,8 +83478,8 @@ signer modes exist; current terms (\`protocol_terms\`).
|
|
|
83071
83478
|
**2. Choose HOW to authorize operations** (the user's choice, made by talking):
|
|
83072
83479
|
- **"Use my own wallet"** \u2192 call \`signer_setup\` action \`use\`, mode \`external\` \u2014 works
|
|
83073
83480
|
on the real adapter and the mock. The approval page auto-opens in the browser (its URL
|
|
83074
|
-
is ALSO in the tool result); the user connects MetaMask \u2014
|
|
83075
|
-
|
|
83481
|
+
is ALSO in the tool result); the user connects MetaMask \u2014 ${phoneWalletOffer(d)} \u2014 and
|
|
83482
|
+
then APPROVES EACH OPERATION in
|
|
83076
83483
|
their own wallet. The first verified signature binds their wallet address as the
|
|
83077
83484
|
borrower. Full walkthrough: \`guide connect-wallet\`.
|
|
83078
83485
|
${offers(d, "keystore") ? `- **"Sign automatically / no popups"** \u2192 mode \`keystore\`. A local encrypted keystore
|
|
@@ -83103,14 +83510,13 @@ The user can switch authorization modes at ANY time by saying so \u2014 repeat s
|
|
|
83103
83510
|
"connect-wallet": (d) => `# Connect your wallet \u2014 the external-signer walkthrough
|
|
83104
83511
|
|
|
83105
83512
|
External mode means the user approves every operation in their OWN wallet \u2014 a browser
|
|
83106
|
-
extension (MetaMask) or a WalletConnect mobile wallet. It works
|
|
83107
|
-
the mock.
|
|
83513
|
+
extension (MetaMask)${d.walletConnect ? " or a WalletConnect mobile wallet" : ""}. It works
|
|
83514
|
+
on the real adapter and the mock.
|
|
83108
83515
|
|
|
83109
83516
|
**The walkthrough:**
|
|
83110
83517
|
1. \`signer_setup\` action \`use\`, mode \`external\`. The approval page auto-opens in the
|
|
83111
83518
|
desktop browser; ${approvalPageLocation(d)}
|
|
83112
|
-
2. On the page: connect the browser extension, or \u2014 for a mobile wallet \u2014 scan the
|
|
83113
|
-
WalletConnect QR code or paste the pairing code.
|
|
83519
|
+
2. On the page: connect the browser extension${d.walletConnect ? ", or \u2014 for a mobile wallet \u2014 scan the\n WalletConnect QR code or paste the pairing code." : ". " + phoneWalletOffer(d) + "."}
|
|
83114
83520
|
3. For authenticated reads before any write: \`signer_setup\` action \`connect\` runs the
|
|
83115
83521
|
login ceremony explicitly (one typed-data signature in the wallet).
|
|
83116
83522
|
4. The FIRST verified signature binds that wallet address as the borrower \u2014 it persists
|
|
@@ -83191,6 +83597,13 @@ Connections / Connected sites).`,
|
|
|
83191
83597
|
6. **Withdraw BTC** \u2014 \`loan_withdraw {positionId, btcAddress, amountSats, confirmed:true}\`.
|
|
83192
83598
|
BTC sends are IRREVERSIBLE \u2014 read the address back to the user before confirming.
|
|
83193
83599
|
amountSats is gross (fee comes out of it) and may be the whole available balance.
|
|
83600
|
+
The SECOND wallet popup is on a clock of well under a minute; if the user misses it the
|
|
83601
|
+
withdrawal fails with the reservation already committed and their coins still in the
|
|
83602
|
+
vault. That does NOT clear itself and it is not a stale spend \u2014 \`loan_recover_stale_spend\`
|
|
83603
|
+
needs the coins to have MOVED, which is exactly what did not happen. The way out is
|
|
83604
|
+
\`loan_withdraw_retry {positionId, confirmed:true}\`, which re-runs that second step with a
|
|
83605
|
+
fresh stamp using the destination and amount the CHAIN already holds. Check
|
|
83606
|
+
\`position_pending_withdrawals\` first, and tell the user it re-sends real BTC.
|
|
83194
83607
|
7. **Watch it** \u2014 \`position_status\` (one), \`position_list\` (all),
|
|
83195
83608
|
\`position_events\` (history), \`btc_price\`, \`protocol_status\`.
|
|
83196
83609
|
|
|
@@ -83453,8 +83866,7 @@ ${connectorStatusTruth(d)}
|
|
|
83453
83866
|
**What it is:** instead of installing anything, the user adds Diamond Hands to
|
|
83454
83867
|
claude.ai as a connector (paste a URL \u2014 zero install, zero Node, zero config files).
|
|
83455
83868
|
Sign-in IS the wallet: one Sign-In-with-Ethereum signature proves address ownership \u2014
|
|
83456
|
-
no password, no email, no account beyond the wallet address. The sign-in
|
|
83457
|
-
WalletConnect QR too, so a phone wallet works without any browser extension.
|
|
83869
|
+
no password, no email, no account beyond the wallet address.${d.walletConnect ? " The sign-in\npage offers a WalletConnect QR too, so a phone wallet works without any browser extension." : "\n" + phoneWalletOffer(d) + "."}
|
|
83458
83870
|
|
|
83459
83871
|
**Signature cadence, plainly:** the FIRST connect costs one SIWE signature (sign-in)
|
|
83460
83872
|
plus one lit-ops login signature (read access). After that, every operation that moves
|
|
@@ -83475,17 +83887,19 @@ honestly when asked "is this safe"):
|
|
|
83475
83887
|
is never written to disk. A breach here is privacy-class, never money-class.
|
|
83476
83888
|
3. **What the assistant narrates.** Tool results shape what the assistant tells you \u2014
|
|
83477
83889
|
a security concern is filed and audited for exactly this channel.
|
|
83478
|
-
4. **Tenant separation
|
|
83479
|
-
gets its own world: its own boundary, its own signer state, its own
|
|
83480
|
-
mount, keyed by that address.
|
|
83481
|
-
|
|
83482
|
-
|
|
83483
|
-
|
|
83484
|
-
|
|
83485
|
-
|
|
83486
|
-
|
|
83487
|
-
|
|
83488
|
-
|
|
83890
|
+
4. **Tenant separation, and what the mount binding does and does not cover.** Each
|
|
83891
|
+
signed-in wallet gets its own world: its own boundary, its own signer state, its own
|
|
83892
|
+
approval-page mount, keyed by that address. The wallet that connects at the mount
|
|
83893
|
+
must BE that address \u2014 a wallet offering any other account is refused at connect
|
|
83894
|
+
time, and switching accounts afterwards is refused the same way rather than silently
|
|
83895
|
+
becoming the new signer. So the account that signs is the account that signed in.
|
|
83896
|
+
None of that makes the mount link safe to pass around: whoever holds it can still
|
|
83897
|
+
load the page and observe or disrupt a pending ceremony, so treat the link as a
|
|
83898
|
+
secret \u2014 it is freshly random per world and travels only in the user's own tool
|
|
83899
|
+
result. What the binding does mean is that a holder cannot become this session's
|
|
83900
|
+
signer. Alongside that,
|
|
83901
|
+
EVERY fund movement still verifies the signature against the bound borrower, and no
|
|
83902
|
+
key material exists server-side.
|
|
83489
83903
|
5. **Availability and deploy honesty.** Hosted code changes under you: deploys are
|
|
83490
83904
|
version-pinned, the page bundle is open-source, and \`boundary://info\` capabilities
|
|
83491
83905
|
reports the exact server version.
|
|
@@ -83672,11 +84086,17 @@ function createNetworkSwitchRuntime(opts) {
|
|
|
83672
84086
|
}
|
|
83673
84087
|
};
|
|
83674
84088
|
}
|
|
83675
|
-
function guideDeployment(overrides) {
|
|
84089
|
+
function guideDeployment(overrides, env) {
|
|
83676
84090
|
return {
|
|
83677
84091
|
tier: overrides?.bridgeMount ? "hosted" : "local",
|
|
83678
84092
|
networks: overrides?.allowedNetworks ?? LOCAL_GUIDE_DEPLOYMENT.networks,
|
|
83679
|
-
signerModes: overrides?.externalOnly ? EXTERNAL_ONLY_SIGNER_MODES : LOCAL_GUIDE_DEPLOYMENT.signerModes
|
|
84093
|
+
signerModes: overrides?.externalOnly ? EXTERNAL_ONLY_SIGNER_MODES : LOCAL_GUIDE_DEPLOYMENT.signerModes,
|
|
84094
|
+
// C-44 F8, the fourth derivation. Read from the SAME env var the bridge reads
|
|
84095
|
+
// (boundary/config.ts `DH_WC_PROJECT_ID` → BridgeOptions.wc), so the guide cannot promise
|
|
84096
|
+
// a phone-wallet QR that `/wc-pairing` would answer 404 for. Deriving it rather than
|
|
84097
|
+
// hard-coding a tier default is what keeps the guide and `/auth.md` from disagreeing
|
|
84098
|
+
// about the same server, which is exactly what they did before this line existed.
|
|
84099
|
+
walletConnect: Boolean(env?.["DH_WC_PROJECT_ID"])
|
|
83680
84100
|
};
|
|
83681
84101
|
}
|
|
83682
84102
|
function assembleWorld(opts) {
|
|
@@ -83686,7 +84106,7 @@ function assembleWorld(opts) {
|
|
|
83686
84106
|
...boot.mockControl ? { mockControl: boot.mockControl } : {},
|
|
83687
84107
|
...boot.signer ? { signer: boot.signer } : {},
|
|
83688
84108
|
...opts.overrides?.externalOnly ? { externalOnly: true } : {},
|
|
83689
|
-
deployment: guideDeployment(opts.overrides),
|
|
84109
|
+
deployment: guideDeployment(opts.overrides, opts.env),
|
|
83690
84110
|
...opts.configResult.ok && opts.configResult.config.adapter === "mock" && opts.configResult.config.chainId ? { chainId: opts.configResult.config.chainId } : {}
|
|
83691
84111
|
};
|
|
83692
84112
|
if ((opts.env["DH_ADAPTER"] ?? "real") !== "mock") {
|
|
@@ -83998,6 +84418,32 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
83998
84418
|
return renderEnvelope(await b.boundary.withdrawBtc({ positionId, btcAddress: btcAddress2, amountSats, networkFeeSats }));
|
|
83999
84419
|
})
|
|
84000
84420
|
);
|
|
84421
|
+
registerBoundaryTool(
|
|
84422
|
+
server,
|
|
84423
|
+
"loan_withdraw_retry",
|
|
84424
|
+
{
|
|
84425
|
+
title: "Re-run a stalled BTC withdrawal's execute step",
|
|
84426
|
+
description: `Finish a withdrawal that authorized but never broadcast. loan_withdraw has two steps: the first commits the reservation on-chain, the second signs a time-stamped hash whose window is under a minute \u2014 often nearer twenty seconds. If that second signature is not given in time the withdrawal fails with the reservation ALREADY committed and the coins still in the vault, and it does not clear itself: loan_recover_stale_spend needs the coins to have MOVED, which is exactly what did not happen. This re-runs the second step alone with a fresh stamp. Destination and amount come from the on-chain record, not from you \u2014 the only figure you supply is the network fee, which is taken OUT of the already-authorized amount and cannot increase what leaves the vault. Use position_pending_withdrawals to see what is outstanding first. Sends real BTC. ${LATENCY_NOTE} Requires human confirmation (confirmed: true).`,
|
|
84427
|
+
inputSchema: {
|
|
84428
|
+
positionId: positionIdSchema,
|
|
84429
|
+
networkFeeSats: import_zod.z.number().int().positive().default(1e3).describe("BTC network fee in sats (declared default 1000); taken FROM the authorized amount, not added on top"),
|
|
84430
|
+
confirmed: confirmedSchema
|
|
84431
|
+
},
|
|
84432
|
+
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
|
|
84433
|
+
},
|
|
84434
|
+
async ({ positionId, networkFeeSats, confirmed }) => guardedWrite(getB, async () => {
|
|
84435
|
+
const gate = requireConfirmation(
|
|
84436
|
+
confirmed,
|
|
84437
|
+
`re-run the execute step for every outstanding BTC withdrawal reservation on position ${positionId} (this BROADCASTS real BTC to the destination each reservation already authorizes)`
|
|
84438
|
+
);
|
|
84439
|
+
if (gate) return gate;
|
|
84440
|
+
const problem = checkPositionIdHex(positionId) ?? checkSatsAmount(networkFeeSats, "Network fee");
|
|
84441
|
+
if (problem) return validationFailed(problem);
|
|
84442
|
+
const b = getB();
|
|
84443
|
+
if (!b.ok) return renderError(b.error);
|
|
84444
|
+
return renderEnvelope(await b.boundary.retryWithdrawExecute({ positionId, networkFeeSats }));
|
|
84445
|
+
})
|
|
84446
|
+
);
|
|
84001
84447
|
registerBoundaryTool(
|
|
84002
84448
|
server,
|
|
84003
84449
|
"loan_allowlist_destination",
|
|
@@ -84023,7 +84469,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
84023
84469
|
"loan_delegation_setup",
|
|
84024
84470
|
{
|
|
84025
84471
|
title: "Install delegation on the Safe (one owner ceremony)",
|
|
84026
|
-
description: `The ONE-TIME Safe delegation batch (signer mode 'safe-module'): your owners sign a single durable Safe transaction \u2014 at their leisure, no time window \u2014 that enables the Safe's AgentModule, binds the agent key, registers it in the delegation registry, and pre-approves the given BTC withdrawal destinations. After it, day-to-day operations (create/mint/pay/extend) run agent-solo; withdrawals always still need the owners' short signing burst, and only to destinations approved here (or later via loan_allowlist_destination \u2014 also owners-only). A revoked agent address burns FOREVER (AR-1) \u2014 rotation means a fresh key. Requires human confirmation (confirmed: true).`,
|
|
84472
|
+
description: `NOT AVAILABLE on the real protocol in this build \u2014 the real adapter answers UPSTREAM_UNAVAILABLE ('not wired in this delivery'). It runs on the practice (mock) adapter only. Say so before a user plans around it. The ONE-TIME Safe delegation batch (signer mode 'safe-module'): your owners sign a single durable Safe transaction \u2014 at their leisure, no time window \u2014 that enables the Safe's AgentModule, binds the agent key, registers it in the delegation registry, and pre-approves the given BTC withdrawal destinations. After it, day-to-day operations (create/mint/pay/extend) run agent-solo; withdrawals always still need the owners' short signing burst, and only to destinations approved here (or later via loan_allowlist_destination \u2014 also owners-only). A revoked agent address burns FOREVER (AR-1) \u2014 rotation means a fresh key. Requires human confirmation (confirmed: true).`,
|
|
84027
84473
|
inputSchema: {
|
|
84028
84474
|
btcAddresses: import_zod.z.array(import_zod.z.string().min(1)).describe("BTC withdrawal destinations to pre-approve in the same ceremony (avoids a second owner gathering before the first withdrawal)"),
|
|
84029
84475
|
confirmed: confirmedSchema
|
|
@@ -84043,7 +84489,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
84043
84489
|
"loan_delegation_grant",
|
|
84044
84490
|
{
|
|
84045
84491
|
title: "Grant the agent per-position scopes (owners sign)",
|
|
84046
|
-
description: `Set what the delegated agent may do on ONE position \u2014 RENEW (extend), REPAY (pay down), MINT (borrow, only while the post-mint collateral ratio stays at or above mintFloorBps \u2014 required for MINT, it is the owners' risk bound). Grants are user-only expansion: for a Safe this is a QUORUM signature (durable Safe transaction, owners sign at leisure) \u2014 the agent can never widen its own powers. Omitting a scope leaves it un-granted; a grant with no scopes clears the position's grant. Requires human confirmation (confirmed: true).`,
|
|
84492
|
+
description: `NOT AVAILABLE on the real protocol in this build \u2014 the real adapter answers UPSTREAM_UNAVAILABLE ('not wired in this delivery'). It runs on the practice (mock) adapter only. Say so before a user plans around it. Set what the delegated agent may do on ONE position \u2014 RENEW (extend), REPAY (pay down), MINT (borrow, only while the post-mint collateral ratio stays at or above mintFloorBps \u2014 required for MINT, it is the owners' risk bound). Grants are user-only expansion: for a Safe this is a QUORUM signature (durable Safe transaction, owners sign at leisure) \u2014 the agent can never widen its own powers. Omitting a scope leaves it un-granted; a grant with no scopes clears the position's grant. Requires human confirmation (confirmed: true).`,
|
|
84047
84493
|
inputSchema: {
|
|
84048
84494
|
positionId: positionIdSchema,
|
|
84049
84495
|
renew: import_zod.z.boolean().optional().describe("Allow the agent to extend/renew this position"),
|
|
@@ -84073,7 +84519,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
84073
84519
|
"loan_recover_stale_spend",
|
|
84074
84520
|
{
|
|
84075
84521
|
title: "Recover a stale BTC reservation via LIT-attested proof",
|
|
84076
|
-
description: "Clear a stale authorized BTC spend on BTCSpendAuthorizer using a LIT-attested StaleSpendRecovery attestation. The original UTXO must already be consumed on Bitcoin with \u22656 confirmations. `invalidatorTxid` is either the borrower's authorized broadcast (after confirmations) or a PKP self-spend that invalidated the reservation. Permissionless on-chain.",
|
|
84522
|
+
description: "NOT AVAILABLE on the real protocol in this build \u2014 the real adapter answers UPSTREAM_UNAVAILABLE ('not wired in this delivery'); it runs on the practice (mock) adapter only. For a withdrawal that authorized but never broadcast, loan_withdraw_retry is the working path. Clear a stale authorized BTC spend on BTCSpendAuthorizer using a LIT-attested StaleSpendRecovery attestation. The original UTXO must already be consumed on Bitcoin with \u22656 confirmations. `invalidatorTxid` is either the borrower's authorized broadcast (after confirmations) or a PKP self-spend that invalidated the reservation. Permissionless on-chain.",
|
|
84077
84523
|
inputSchema: {
|
|
84078
84524
|
positionId: positionIdSchema,
|
|
84079
84525
|
utxoTxid: import_zod.z.string().describe("The original authorized UTXO's txid"),
|
|
@@ -84950,9 +85396,6 @@ function registerBoundaryInfoResource(server, getB) {
|
|
|
84950
85396
|
);
|
|
84951
85397
|
}
|
|
84952
85398
|
|
|
84953
|
-
// src/version.ts
|
|
84954
|
-
var SERVER_VERSION = "0.5.11";
|
|
84955
|
-
|
|
84956
85399
|
// src/server.ts
|
|
84957
85400
|
var SERVER_INSTRUCTIONS = "Diamond Hands MCP \u2014 Bitcoin-collateralized borrowing. Before promising ANY flow, read the boundary://info resource and honor its `capabilities` block: it states which network this server is on, whether money is real (practiceWorld), whether writes are enabled (and the true reason when they are not), and which signer modes this build actually offers \u2014 never describe a flow outside it. State the network and whether funds are real when the user first acts. Authorization is chosen by conversation via the signer_setup tool (when listed); writes always require confirmed:true after showing the human-readable card. For walkthroughs consult the guide tool / guide:// resources instead of inventing steps; when a tool refuses, relay its stated reason and remedy \u2014 do not improvise alternatives. When a network_switch tool is listed, the network can change mid-session \u2014 after ANY switch, re-read boundary://info and state the new network and money reality to the user before doing anything else. When the user asks to disconnect / log out / sign out / forget or remove their wallet, call signer_setup action 'disconnect' (the full flush) \u2014 never treat 'reset-borrower' as a disconnect; it only swaps identity. READING DATA: a payload's fields and notes are authoritative \u2014 state what they say, never speculate past them, and when the data does not carry something, say 'the data does not carry X'. Field meanings live in guide topic 'reading-data'; `reading` notes inside a result are interpretation instructions for that exact payload \u2014 follow them over any prior assumption.";
|
|
84958
85401
|
var CONNECTOR_INSTRUCTIONS = SERVER_INSTRUCTIONS + " HOSTED CONNECTOR TIER: this server is the hosted claude.ai connector. Signer modes are external-wallet ONLY \u2014 keystore mode is ABSENT from this build (structurally, not disabled); the server never holds a key, and every fund-moving action needs a fresh signature from the user's own wallet. Each tenant's world is isolated by wallet identity; network_switch moves ONLY this tenant, within the networks this deployment serves (the refusal states the rollout truth). The login session lives in server memory only \u2014 a server restart or idle eviction means signing in again; that is the no-data-at-rest property, not a fault. Trust ledger and cadence: guide topic 'connector'.";
|
|
@@ -85075,6 +85518,12 @@ function composeConnector(opts, rawPublicOrigin) {
|
|
|
85075
85518
|
const overrides = {
|
|
85076
85519
|
externalOnly: true,
|
|
85077
85520
|
allowedNetworks,
|
|
85521
|
+
// C-47: `tenantKey` IS the lowercased SIWE address (see the `authImpl.tenant` call
|
|
85522
|
+
// site). Until this line it was a map key and an error string and nothing else, so a
|
|
85523
|
+
// session authenticated as A could write as B by connecting B to the approval page.
|
|
85524
|
+
// The mount is a bearer capability that transits the LLM transcript by design
|
|
85525
|
+
// (C-45), which is what made that reachable rather than merely untidy.
|
|
85526
|
+
boundBorrower: tenantKey,
|
|
85078
85527
|
bridgeMount: () => ({ baseUrl: `${publicOrigin}/approval/${mountId}`, origin: publicOrigin }),
|
|
85079
85528
|
signerPersistence: (network) => {
|
|
85080
85529
|
let s = stores.get(network);
|
|
@@ -85453,6 +85902,13 @@ function composeConnector(opts, rawPublicOrigin) {
|
|
|
85453
85902
|
}
|
|
85454
85903
|
};
|
|
85455
85904
|
}
|
|
85905
|
+
if (opts.serveLandingPage) {
|
|
85906
|
+
app.get("/", (_req, res) => {
|
|
85907
|
+
const { nonce, headers } = htmlPageSecurityHeaders({ "img-src": [BACKGROUND_IMAGE_ORIGIN, "data:"] });
|
|
85908
|
+
for (const [k, v] of Object.entries(headers)) res.setHeader(k, v);
|
|
85909
|
+
res.type("text/html; charset=utf-8").send(renderLandingPage({ publicOrigin, networks: allowedNetworks, version: SERVER_VERSION, nonce }));
|
|
85910
|
+
});
|
|
85911
|
+
}
|
|
85456
85912
|
app.use((_req, res) => deny(res, 404, "not found \u2014 the MCP endpoint is /mcp"));
|
|
85457
85913
|
const sweeper = setInterval(() => sweepService(), 6e4);
|
|
85458
85914
|
sweeper.unref();
|