@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/connector.js CHANGED
@@ -40812,6 +40812,226 @@ source of truth.
40812
40812
  `;
40813
40813
  }
40814
40814
 
40815
+ // src/connector/landing-page.ts
40816
+ 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>`;
40817
+ var FAVICON_DATA_URI = `data:image/svg+xml,${encodeURIComponent(FAVICON_SVG).replace(/'/g, "%27")}`;
40818
+ var BACKGROUND_IMAGE_ORIGIN = "https://images.gvnr.xyz";
40819
+ var BACKGROUND_IMAGE_URL = `${BACKGROUND_IMAGE_ORIGIN}/images/layout/backgroundCorleoneb.jpg`;
40820
+ var escapeHtml = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
40821
+ function moneyReality(networks2) {
40822
+ const mainnet = networks2.includes("mainnet");
40823
+ const sepolia = networks2.includes("sepolia");
40824
+ if (mainnet && sepolia) {
40825
+ return {
40826
+ label: "REAL MONEY on mainnet \xB7 practice funds on sepolia",
40827
+ 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."
40828
+ };
40829
+ }
40830
+ if (mainnet) {
40831
+ return {
40832
+ label: "REAL MONEY \u2014 Ethereum mainnet",
40833
+ 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."
40834
+ };
40835
+ }
40836
+ return {
40837
+ label: "PRACTICE FUNDS \u2014 sepolia test network",
40838
+ detail: "This deployment serves sepolia only. The contracts and ceremonies are real, the money is not. Nothing here can move mainnet funds."
40839
+ };
40840
+ }
40841
+ function renderLandingPage(input) {
40842
+ const { publicOrigin, networks: networks2, version: version2, nonce } = input;
40843
+ const origin2 = escapeHtml(publicOrigin);
40844
+ const money = moneyReality(networks2);
40845
+ const config = JSON.stringify({ mcpServers: { "diamond-hands": { type: "http", url: `${publicOrigin}/mcp` } } }, null, 2);
40846
+ return `<!doctype html>
40847
+ <html lang="en">
40848
+ <head>
40849
+ <meta charset="utf-8">
40850
+ <meta name="viewport" content="width=device-width,initial-scale=1">
40851
+ <title>Diamond Hands \u2014 MCP endpoint</title>
40852
+ <link rel="icon" type="image/svg+xml" href="${FAVICON_DATA_URI}">
40853
+ <link rel="apple-touch-icon" href="${FAVICON_DATA_URI}">
40854
+ <style>
40855
+ * { margin:0; padding:0; box-sizing:border-box; }
40856
+ /* House treatment (ops.gvnr.xyz, brando.gvnr.xyz): the image fills the viewport,
40857
+ centred and cropped, and the PAGE never scrolls. */
40858
+ html, body { width:100%; height:100%; overflow:hidden; }
40859
+ body {
40860
+ background: url('${BACKGROUND_IMAGE_URL}') center center / cover no-repeat fixed;
40861
+ color:#f3f4f6;
40862
+ font:15px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
40863
+ }
40864
+ /* NO full-page scrim: the photograph is the point, so darkness lives only behind the
40865
+ text that needs to stay legible. The content scrolls INSIDE the viewport rather than
40866
+ the page scrolling, so a short window never clips anything and the image never moves. */
40867
+ .scroll { height:100%; overflow-y:auto; overscroll-behavior:contain; }
40868
+ main { max-width:41rem; margin:0 auto; padding:1.9rem 1.25rem 2rem;
40869
+ text-shadow:0 1px 3px rgba(0,0,0,.85); }
40870
+ /* Wide viewports: the lower half goes side-by-side so the whole page fits without the
40871
+ viewport scrolling \u2014 the house treatment is a full-bleed image, not a long page. */
40872
+ @media (min-width: 62rem) and (min-height: 34rem) {
40873
+ main { max-width:62rem; }
40874
+ .cols { display:grid; grid-template-columns:1fr 1fr; gap:0 1.6rem; align-items:start; }
40875
+ .cols h2:first-child { margin-top:0; }
40876
+ }
40877
+ h1 { font-size:1.35rem; margin:0 0 .25rem; letter-spacing:-.01em; }
40878
+ .sub { color:#dfe3ea; margin:0 0 1.1rem; font-size:14px; }
40879
+ .card { background:rgba(6,8,12,.62); border:1px solid rgba(255,255,255,.16);
40880
+ border-radius:10px; padding:.75rem .95rem; margin:0 0 .8rem;
40881
+ backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); }
40882
+ .money { border-left:3px solid #f59e0b; }
40883
+ .money strong { display:block; margin-bottom:.15rem; }
40884
+ h2 { font-size:.72rem; text-transform:uppercase; letter-spacing:.08em; color:#cbd2dc;
40885
+ margin:1.1rem 0 .45rem; font-weight:600; }
40886
+ pre { margin:0; padding:.7rem .9rem; background:rgba(0,0,0,.66);
40887
+ border:1px solid rgba(255,255,255,.16); border-radius:8px; overflow-x:auto;
40888
+ font-size:12.5px; line-height:1.45; text-shadow:none;
40889
+ font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; }
40890
+ code { font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:.92em; }
40891
+ table { border-collapse:collapse; width:100%; font-size:13.5px; }
40892
+ td { padding:.3rem .6rem .3rem 0; border-bottom:1px solid rgba(255,255,255,.12); vertical-align:top; }
40893
+ td:first-child { color:#cbd2dc; white-space:nowrap; width:10.5rem; }
40894
+ tr:last-child td { border-bottom:0; }
40895
+ a { color:inherit; text-decoration:underline; text-underline-offset:2px; }
40896
+ .row { display:flex; align-items:center; gap:.6rem; margin-bottom:.4rem; font-size:13px; }
40897
+ button { font:inherit; font-size:12.5px; padding:.25rem .65rem;
40898
+ border:1px solid rgba(255,255,255,.24); border-radius:6px;
40899
+ background:rgba(0,0,0,.55); color:#f3f4f6; cursor:pointer; text-shadow:none; }
40900
+ button:hover { background:rgba(0,0,0,.75); }
40901
+ footer { color:#cbd2dc; font-size:12.5px; margin-top:1.1rem; padding-top:.7rem;
40902
+ border-top:1px solid rgba(255,255,255,.14); }
40903
+ [hidden] { display:none !important; }
40904
+ #reveal-wrap { margin:0 0 .4rem; }
40905
+ #reveal { display:inline-block; padding:.4rem .85rem; border-radius:6px;
40906
+ border:1px solid rgba(255,255,255,.26); background:rgba(6,8,12,.62);
40907
+ backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
40908
+ text-decoration:none; font-size:13.5px; text-shadow:none; cursor:pointer; }
40909
+ #reveal:hover { background:rgba(6,8,12,.85); border-color:rgba(255,255,255,.4); }
40910
+ #reveal::after { content:" \u2193"; opacity:.7; }
40911
+ </style>
40912
+ </head>
40913
+ <body>
40914
+ <div class="scroll">
40915
+ <main>
40916
+ <h1>Diamond Hands \u2014 MCP endpoint</h1>
40917
+ <p class="sub">This host is a <strong>Model Context Protocol</strong> server, not a website.
40918
+ There is no app to use here. If you are a person, the app is at
40919
+ <a href="https://app.diamondhands.credit/">app.diamondhands.credit</a>.</p>
40920
+
40921
+ <!-- Revealed BY SCRIPT, hidden in the served markup \u2014 the inverse of #details below.
40922
+ With no JS this stays hidden and the details stay open, so the page degrades to
40923
+ everything-visible rather than to a trigger that does nothing. -->
40924
+ <p id="reveal-wrap" hidden><a href="#details" id="reveal" role="button">View MCP installation details</a></p>
40925
+
40926
+ <div id="details">
40927
+ <div class="card money">
40928
+ <strong>${escapeHtml(money.label)}</strong>
40929
+ ${escapeHtml(money.detail)}
40930
+ </div>
40931
+
40932
+ <div class="cols">
40933
+ <section>
40934
+ <h2>Connect an agent</h2>
40935
+ <div class="row">
40936
+ <span style="color:var(--muted);font-size:13px">Add this to your MCP client configuration:</span>
40937
+ <button id="copy" type="button">Copy</button>
40938
+ </div>
40939
+ <pre id="cfg">${escapeHtml(config)}</pre>
40940
+
40941
+ <h2>How authorization works</h2>
40942
+ <div class="card">
40943
+ Identity is a <strong>wallet</strong>, not an account: OAuth 2.1 with dynamic client
40944
+ registration (RFC 7591) and PKCE, where the login is an Ethereum signature (EIP-4361).
40945
+ No passwords, no user database. The bearer token proves <em>session identity only</em> \u2014
40946
+ it signs nothing and can never move funds; every fund-moving step raises its own approval
40947
+ in your own wallet. Session state is in memory, so a restart means signing in again.
40948
+ </div>
40949
+ </section>
40950
+
40951
+ <section>
40952
+ <h2>Endpoints</h2>
40953
+ <div class="card">
40954
+ <table>
40955
+ <tr><td>MCP</td><td><code>${origin2}/mcp</code> \u2014 streamable HTTP</td></tr>
40956
+ <tr><td>Networks served</td><td><code>${escapeHtml(networks2.join(", "))}</code></td></tr>
40957
+ <tr><td>Registration</td><td><a href="/auth.md">/auth.md</a> \u2014 how an agent registers and signs in</td></tr>
40958
+ <tr><td>Resource metadata</td><td><a href="/.well-known/oauth-protected-resource">/.well-known/oauth-protected-resource</a></td></tr>
40959
+ <tr><td>Auth server metadata</td><td><a href="/.well-known/oauth-authorization-server">/.well-known/oauth-authorization-server</a></td></tr>
40960
+ </table>
40961
+ </div>
40962
+
40963
+ </section>
40964
+ </div>
40965
+
40966
+ <footer>
40967
+ <code>@gvnrdao/dh-mcp</code> v${escapeHtml(version2)} \xB7 origin <code>${origin2}</code>
40968
+ </footer>
40969
+ </div>
40970
+ </main>
40971
+ </div>
40972
+ <script nonce="${escapeHtml(nonce)}">
40973
+ // Progressive disclosure, applied by SCRIPT rather than baked into the markup: the
40974
+ // details ship visible, and only a browser that can re-open them is allowed to close
40975
+ // them. A page whose whole content sits behind a trigger that needs JS is a page that
40976
+ // shows two sentences and nothing else when the script does not run.
40977
+ (function () {
40978
+ var details = document.getElementById('details');
40979
+ var wrap = document.getElementById('reveal-wrap');
40980
+ var link = document.getElementById('reveal');
40981
+ if (!details || !wrap || !link) return;
40982
+ details.hidden = true;
40983
+ wrap.hidden = false;
40984
+ link.addEventListener('click', function (e) {
40985
+ e.preventDefault();
40986
+ wrap.hidden = true;
40987
+ details.hidden = false;
40988
+ });
40989
+ })();
40990
+
40991
+ document.getElementById('copy').addEventListener('click', function () {
40992
+ var t = document.getElementById('cfg').textContent;
40993
+ navigator.clipboard.writeText(t).then(function () {
40994
+ var b = document.getElementById('copy');
40995
+ b.textContent = 'Copied'; setTimeout(function () { b.textContent = 'Copy'; }, 1400);
40996
+ });
40997
+ });
40998
+ </script>
40999
+ </body>
41000
+ </html>
41001
+ `;
41002
+ }
41003
+
41004
+ // src/util/page-headers.ts
41005
+ var import_node_crypto = require("crypto");
41006
+ function htmlPageSecurityHeaders(extra) {
41007
+ const nonce = (0, import_node_crypto.randomBytes)(16).toString("base64");
41008
+ const base = [
41009
+ `default-src 'none'`,
41010
+ `script-src 'nonce-${nonce}'`,
41011
+ `style-src 'unsafe-inline'`,
41012
+ `connect-src 'self'`,
41013
+ `base-uri 'none'`,
41014
+ `form-action 'none'`,
41015
+ `frame-ancestors 'none'`
41016
+ ];
41017
+ for (const [directive, sources] of Object.entries(extra ?? {})) {
41018
+ if (sources.length === 0) continue;
41019
+ base.push(`${directive} ${sources.join(" ")}`);
41020
+ }
41021
+ return {
41022
+ nonce,
41023
+ headers: {
41024
+ "Content-Security-Policy": base.join("; "),
41025
+ "X-Frame-Options": "DENY",
41026
+ "Referrer-Policy": "no-referrer",
41027
+ "X-Content-Type-Options": "nosniff"
41028
+ }
41029
+ };
41030
+ }
41031
+
41032
+ // src/version.ts
41033
+ var SERVER_VERSION = "0.5.13";
41034
+
40815
41035
  // src/connector/siwe-oauth.ts
40816
41036
  var import_node_crypto2 = require("crypto");
40817
41037
  var import_ethers = require("ethers");
@@ -40861,7 +41081,7 @@ button { font-size: 1rem; padding: 0.6rem 1.2rem; cursor: pointer; margin-right:
40861
41081
  </head>
40862
41082
  <body>
40863
41083
  <h1>Sign in to Diamond Hands</h1>
40864
- <p><span class="cname" dir="ltr">${escapeHtml(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>
41084
+ <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>
40865
41085
  <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>
40866
41086
  <button id="connect">Browser wallet</button>
40867
41087
  <button id="wc">Mobile wallet (QR)</button>
@@ -40937,7 +41157,7 @@ document.getElementById("wc").addEventListener("click", async () => {
40937
41157
  </body>
40938
41158
  </html>`;
40939
41159
  }
40940
- function escapeHtml(s) {
41160
+ function escapeHtml2(s) {
40941
41161
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
40942
41162
  }
40943
41163
  var MAX_CLIENT_NAME_CHARS = 64;
@@ -40958,7 +41178,7 @@ function splitRedirectHost(host) {
40958
41178
  function renderRedirectHost(host) {
40959
41179
  const { head, elided, tail } = splitRedirectHost(host);
40960
41180
  const cut = elided === 0 ? "" : `<span class="host-cut">\u2026+${elided} chars\u2026</span>`;
40961
- return `<span class="host-head">${escapeHtml(head)}</span>${cut}<span class="host-tail">${escapeHtml(tail)}</span>`;
41181
+ return `<span class="host-head">${escapeHtml2(head)}</span>${cut}<span class="host-tail">${escapeHtml2(tail)}</span>`;
40962
41182
  }
40963
41183
  function clampClientName(name) {
40964
41184
  const points = [...name];
@@ -40966,21 +41186,6 @@ function clampClientName(name) {
40966
41186
  return `${points.slice(0, MAX_CLIENT_NAME_CHARS - 1).join("")}\u2026`;
40967
41187
  }
40968
41188
 
40969
- // src/util/page-headers.ts
40970
- var import_node_crypto = require("crypto");
40971
- function htmlPageSecurityHeaders() {
40972
- const nonce = (0, import_node_crypto.randomBytes)(16).toString("base64");
40973
- return {
40974
- nonce,
40975
- headers: {
40976
- "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'`,
40977
- "X-Frame-Options": "DENY",
40978
- "Referrer-Policy": "no-referrer",
40979
- "X-Content-Type-Options": "nosniff"
40980
- }
40981
- };
40982
- }
40983
-
40984
41189
  // src/connector/siwe-oauth.ts
40985
41190
  var FLOW_TTL_MS = 10 * 60 * 1e3;
40986
41191
  var CODE_TTL_MS = 60 * 1e3;
@@ -41342,7 +41547,11 @@ var NETWORK_DEFAULTS = {
41342
41547
  },
41343
41548
  mainnet: {
41344
41549
  rpcUrl: "https://ethereum-rpc.publicnode.com",
41345
- serviceEndpoint: "https://ops.gvnr.xyz",
41550
+ // Cutover 2026-09-08 — see sdk/src/constants/chunks/network-configs.ts for the full
41551
+ // reasoning. Widening, not a rename: ops.gvnr.xyz serves the same broker and cannot be
41552
+ // retired while installed copies call it. The sepolia entry above deliberately stays on
41553
+ // ops-test.gvnr.xyz — there is no ops-test.diamondhands.credit twin (open decision 2).
41554
+ serviceEndpoint: "https://ops.diamondhands.credit",
41346
41555
  litNetwork: "chipotle",
41347
41556
  // On-chain PKPValidation generation, mainnet (validatorForVersion(3) is the ONLY
41348
41557
  // registered validator — verified live 2026-08-05). Without this the SDK defaults
@@ -42274,6 +42483,19 @@ var BoundaryCore = class {
42274
42483
  if (!r.ok) return errEnvelope(failureToError(r.failure));
42275
42484
  return okEnvelope({ releasedSats: r.value.releasedSats }, r.source);
42276
42485
  }
42486
+ /** C-46. Unlike `recoverStaleSpend` this is NOT permissionless: re-running phase 2 signs
42487
+ * for the vault, so it takes the same borrower gate every fund-moving op takes. */
42488
+ async retryWithdrawExecute(p) {
42489
+ const auth = await this.requireBorrower();
42490
+ if (!auth.ok) return errEnvelope(auth.error);
42491
+ const r = await this.deps.plugin.ops.retryWithdrawExecute({
42492
+ positionId: p.positionId,
42493
+ networkFeeSats: p.networkFeeSats,
42494
+ borrower: auth.borrower
42495
+ });
42496
+ if (!r.ok) return errEnvelope(failureToError(r.failure));
42497
+ return okEnvelope({ attempted: r.value.attempted, transfers: r.value.transfers }, r.source);
42498
+ }
42277
42499
  // ---- meta ----
42278
42500
  world() {
42279
42501
  return {
@@ -43097,6 +43319,42 @@ var World = class {
43097
43319
  c.authorizedSpends.splice(idx, 1);
43098
43320
  return { ok: true, value: { releasedSats: spend.satoshis } };
43099
43321
  }
43322
+ /**
43323
+ * C-46: re-run the withdrawal EXECUTE leg for reservations whose coins have not been
43324
+ * observed moving (`consumed === null`). This is the stranded shape: phase 1 committed
43325
+ * the reservation, phase 2's quantum-stamped signature expired, and the outpoint was
43326
+ * never spent.
43327
+ *
43328
+ * The retry BROADCASTS; it does not observe. `consumed` therefore stays null — that flag
43329
+ * means "seen consumed on Bitcoin", and only MockControl.confirmSpendConsumed (standing
43330
+ * in for the chain) may set it. Conflating the two would let a retry release collateral
43331
+ * against a transaction no one has confirmed, which is the mistake the whole
43332
+ * proof-of-consumption design exists to prevent. So a retry leaves the reservation
43333
+ * holding its balance exactly as before; what it produces is the txid that can LATER
43334
+ * become the invalidator — the proof the stranded state could never generate for itself.
43335
+ */
43336
+ retryWithdrawExecute(p) {
43337
+ const paused = this.pausedReason();
43338
+ if (paused) return { ok: false, reason: paused };
43339
+ const pos = this.state.positions[p.positionId];
43340
+ if (!pos) return { ok: false, reason: `position ${p.positionId} does not exist` };
43341
+ if (pos.borrower.toLowerCase() !== p.borrower.toLowerCase()) {
43342
+ return { ok: false, reason: `caller ${p.borrower} is not the borrower of this position` };
43343
+ }
43344
+ const c = this.state.collateral[p.positionId];
43345
+ const pending = (c?.authorizedSpends ?? []).filter((s) => s.consumed === null);
43346
+ const transfers = pending.map((spend) => {
43347
+ const { hash: txid } = this.nextId("btc-withdraw-retry");
43348
+ return {
43349
+ utxoIdentifier: `${spend.txid}:${spend.vout}`,
43350
+ ok: true,
43351
+ txid,
43352
+ amountSentSats: spend.satoshis,
43353
+ destination: spend.targetAddress
43354
+ };
43355
+ });
43356
+ return { ok: true, value: { attempted: transfers.length, transfers } };
43357
+ }
43100
43358
  // ---- Mock Safes (plan 06): REAL verification semantics, no fakes (M6-21/27) ----
43101
43359
  safesMap() {
43102
43360
  return this.state.safes;
@@ -44291,6 +44549,11 @@ var MockUpstreamPlugin = class {
44291
44549
  const r = this.world.recoverStaleSpend(p);
44292
44550
  if (!r.ok) return this.rejected("recoverStaleSpend", r.reason);
44293
44551
  return upOk({ txRef: this.world.nextTxRef(), releasedSats: r.value.releasedSats }, this.src("mock-ops"));
44552
+ }),
44553
+ retryWithdrawExecute: (p) => this.write("retryWithdrawExecute", () => {
44554
+ const r = this.world.retryWithdrawExecute({ positionId: p.positionId, borrower: p.borrower });
44555
+ if (!r.ok) return this.rejected("retryWithdrawExecute", r.reason);
44556
+ return upOk({ attempted: r.value.attempted, transfers: r.value.transfers }, this.src("mock-ops"));
44294
44557
  })
44295
44558
  };
44296
44559
  }
@@ -52530,13 +52793,13 @@ var init_deployment_addresses = __esm2({
52530
52793
  block: 25472956
52531
52794
  },
52532
52795
  BTCSpendAuthorizer: {
52533
- previousImplementation: "0xb003ed89F695E8819a85513fE17260b805B3c478",
52534
- newImplementation: "0x40c9e8C46C65E0A57BB63da5368868A9E8Df81A5",
52535
- upgradedAt: "2026-07-06T10:40:59.000Z",
52536
- upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f in tx 0xe1b1884a7e76c7fd569522545a04e49d5128d83d27b3892cda59f143b53b5281 (block 25472957)",
52537
- reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
52538
- executeTx: "0xe1b1884a7e76c7fd569522545a04e49d5128d83d27b3892cda59f143b53b5281",
52539
- block: 25472957
52796
+ previousImplementation: "0x40c9e8C46C65E0A57BB63da5368868A9E8Df81A5",
52797
+ newImplementation: "0x00D7a47798E8ff169104b748131703B78f23390C",
52798
+ upgradedAt: "2026-09-09T12:05:35.000Z",
52799
+ 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)",
52800
+ 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",
52801
+ executeTx: "0x77cd231966c546177bd8f1a07bd4e705afd5c2dfbd110b096836401679c0c69c",
52802
+ block: 25939703
52540
52803
  },
52541
52804
  PositionManager: {
52542
52805
  previousImplementation: "0x600Dc0D1C2c0F94882B6Bc09172f8650047Ad5B1",
@@ -52639,7 +52902,7 @@ var init_deployment_addresses = __esm2({
52639
52902
  ADMIN_MODULE: "0x0023B71B586795eE5fa4E83E384345C1EC8Bb946",
52640
52903
  ADMIN_MODULE_IMPL: "0xb4C5C7E051A1e672F014B25CB5D55B225Aa0D512",
52641
52904
  BTC_SPEND_AUTHORIZER: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
52642
- BTC_SPEND_AUTHORIZER_IMPL: "0x40c9e8C46C65E0A57BB63da5368868A9E8Df81A5",
52905
+ BTC_SPEND_AUTHORIZER_IMPL: "0x00D7a47798E8ff169104b748131703B78f23390C",
52643
52906
  POSITION_MANAGER_VIEWS: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
52644
52907
  POSITION_MANAGER_VIEWS_IMPL: "0xE68DC096A65Ecddbc6A9b5c6e5f878e2CE143Bfe",
52645
52908
  POSITION_MANAGER: "0x12A1836e56139ccaD8722B89519d84233efc224B",
@@ -57615,7 +57878,17 @@ function getSepoliaConfig() {
57615
57878
  function getMainnetConfig() {
57616
57879
  return {
57617
57880
  mode: "service",
57618
- serviceEndpoint: "https://ops.gvnr.xyz",
57881
+ // Cutover 2026-09-08: the product's own domain. `ops.gvnr.xyz` still serves the same
57882
+ // broker and always will — every already-installed copy of this package calls it, so
57883
+ // it can never be retired. This changes what NEW installs default to, nothing else.
57884
+ //
57885
+ // Safe only because the server accepts the new audience ALREADY: the SDK derives the
57886
+ // login audience from this endpoint (`server-session.ts` — `loginAudience ??
57887
+ // serviceEndpoint`) and lit-ops-server FAILS CLOSED on an unknown one. Verified live
57888
+ // before this edit: DH_ACCEPTED_LOGIN_AUDIENCES on the deployed revision lists
57889
+ // https://ops.diamondhands.credit. Publishing this ahead of that would lock out every
57890
+ // client that installed it.
57891
+ serviceEndpoint: "https://ops.diamondhands.credit",
57619
57892
  chainId: 1,
57620
57893
  name: "mainnet",
57621
57894
  // No default RPC: mainnet runs in service mode (serviceEndpoint above), so
@@ -58699,9 +58972,27 @@ var LOGIN_TYPES_WITH_AUDIENCE2 = {
58699
58972
  { name: "audience", type: "string" }
58700
58973
  ]
58701
58974
  };
58702
- async function buildSignedLoginPayload(signer, chainId, audience, reuse) {
58975
+ var LOGIN_TYPES_WITH_STATEMENT = {
58976
+ DiamondHands: [
58977
+ { name: "statement", type: "string" },
58978
+ { name: "address", type: "address" },
58979
+ { name: "issuedAt", type: "uint256" },
58980
+ { name: "nonce", type: "bytes32" },
58981
+ { name: "audience", type: "string" }
58982
+ ]
58983
+ };
58984
+ 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.";
58985
+ function canonicalLoginStatement(audience) {
58986
+ const host = /^https?:\/\/([^/?#]+)/i.exec(audience)?.[1];
58987
+ if (!host)
58988
+ return null;
58989
+ return LOGIN_STATEMENT_TEMPLATE.replace("{host}", host);
58990
+ }
58991
+ async function buildSignedLoginPayload(signer, chainId, audience, reuse, withStatement = false) {
58703
58992
  const address = await signer.getAddress();
58993
+ const statement = withStatement && audience ? canonicalLoginStatement(audience) : null;
58704
58994
  const message = {
58995
+ ...statement ? { statement } : {},
58705
58996
  address,
58706
58997
  issuedAt: reuse?.issuedAt ?? Math.floor(Date.now() / 1e3),
58707
58998
  nonce: reuse?.nonce ?? (0, import_ethers18.hexlify)((0, import_ethers18.randomBytes)(32)),
@@ -58709,7 +59000,7 @@ async function buildSignedLoginPayload(signer, chainId, audience, reuse) {
58709
59000
  };
58710
59001
  const signature = await signer.signTypedData(
58711
59002
  buildLoginDomain(chainId),
58712
- audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
59003
+ statement ? LOGIN_TYPES_WITH_STATEMENT : audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
58713
59004
  message
58714
59005
  );
58715
59006
  return { chainId, message, signature };
@@ -58878,6 +59169,8 @@ var ServerSession = class {
58878
59169
  signer;
58879
59170
  serviceEndpoint;
58880
59171
  loginAudience;
59172
+ /** Whether this session's login carries the human-readable statement. */
59173
+ withStatement;
58881
59174
  chainId;
58882
59175
  store;
58883
59176
  onSignaturePrompt;
@@ -58919,6 +59212,13 @@ var ServerSession = class {
58919
59212
  /\/+$/,
58920
59213
  ""
58921
59214
  );
59215
+ const explicitAudience = typeof opts.loginAudience === "string" && opts.loginAudience.length > 0;
59216
+ this.withStatement = opts.withStatement === true && explicitAudience;
59217
+ if (opts.withStatement === true && !explicitAudience) {
59218
+ console.warn(
59219
+ "[dh-sdk] withStatement ignored: it requires an explicit loginAudience, since the servers rebuild the expected sentence from the audience host"
59220
+ );
59221
+ }
58922
59222
  this.chainId = opts.chainId;
58923
59223
  this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
58924
59224
  this.onSignaturePrompt = opts.onSignaturePrompt;
@@ -59172,12 +59472,16 @@ var ServerSession = class {
59172
59472
  this.signer,
59173
59473
  this.chainId,
59174
59474
  this.loginAudience,
59175
- reuse
59475
+ reuse,
59476
+ reuse ? reuse.withStatement === true : this.withStatement
59176
59477
  );
59177
59478
  if (storeKey && !reuse) {
59178
59479
  store.savePending?.(storeKey, {
59179
59480
  issuedAt: payload.message.issuedAt,
59180
- nonce: payload.message.nonce
59481
+ nonce: payload.message.nonce,
59482
+ // Recorded so a resume reproduces this digest even if the
59483
+ // capability flag changes before the owners finish signing.
59484
+ withStatement: this.withStatement
59181
59485
  });
59182
59486
  }
59183
59487
  session = await this.login(payload);
@@ -71388,6 +71692,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
71388
71692
  signer: config.authSigner ?? config.contractSigner,
71389
71693
  serviceEndpoint: config.serviceEndpoint,
71390
71694
  loginAudience: config.loginAudience,
71695
+ // Only meaningful alongside an audience; the servers derive the expected
71696
+ // sentence from its host. Defaults off so Node callers are untouched.
71697
+ withStatement: config.loginStatement === true,
71391
71698
  chainId: config.chainId,
71392
71699
  persistSession: config.sessionPersistence?.enabled,
71393
71700
  sessionStore: config.sessionPersistence?.store,
@@ -80233,7 +80540,33 @@ function buildWriteOps(deps) {
80233
80540
  kind: "unavailable",
80234
80541
  source: SOURCE5,
80235
80542
  message: "recoverStaleSpend is not wired in this delivery (permissionless recovery \u2014 planned follow-up)."
80236
- })
80543
+ }),
80544
+ retryWithdrawExecute: async (p) => {
80545
+ const sdk = deps.getWriteSdk();
80546
+ if (!sdk) return upFail({ kind: "unavailable", source: SOURCE5, message: "write SDK is not initialized (its boot-time construction failed)" });
80547
+ let rows;
80548
+ try {
80549
+ rows = await sdk.executePendingBtcTransfers(p.positionId, p.networkFeeSats);
80550
+ } catch (e) {
80551
+ return failed("retryWithdrawExecute", e);
80552
+ }
80553
+ const gate = rows.find((r) => !r.success && !r.utxoIdentifier);
80554
+ if (gate) return declined("retryWithdrawExecute", gate.error ?? "pending-transfer execution refused before any reservation was attempted");
80555
+ return upOk(
80556
+ {
80557
+ attempted: rows.length,
80558
+ transfers: rows.map((r) => ({
80559
+ utxoIdentifier: r.utxoIdentifier ?? "",
80560
+ ok: r.success,
80561
+ ...r.txid ? { txid: r.txid } : {},
80562
+ ...r.amountSent !== void 0 ? { amountSentSats: String(r.amountSent) } : {},
80563
+ ...r.destination ? { destination: r.destination } : {},
80564
+ ...r.error ? { error: r.error } : {}
80565
+ }))
80566
+ },
80567
+ { id: SOURCE5, kind: "lit-ops", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }
80568
+ );
80569
+ }
80237
80570
  };
80238
80571
  }
80239
80572
 
@@ -80758,7 +81091,8 @@ var RealUpstreamPlugin = class {
80758
81091
  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."
80759
81092
  })
80760
81093
  ),
80761
- recoverStaleSpend: () => readOnly("recoverStaleSpend")
81094
+ recoverStaleSpend: () => readOnly("recoverStaleSpend"),
81095
+ retryWithdrawExecute: () => readOnly("retryWithdrawExecute")
80762
81096
  };
80763
81097
  }
80764
81098
  }
@@ -80926,7 +81260,8 @@ var RealUpstreamPlugin = class {
80926
81260
  psmSwap: call("psmSwap"),
80927
81261
  delegationSetup: call("delegationSetup"),
80928
81262
  delegationGrant: call("delegationGrant"),
80929
- recoverStaleSpend: call("recoverStaleSpend")
81263
+ recoverStaleSpend: call("recoverStaleSpend"),
81264
+ retryWithdrawExecute: call("retryWithdrawExecute")
80930
81265
  };
80931
81266
  }
80932
81267
  async resolveOpsGateway() {
@@ -81737,6 +82072,9 @@ function wcDeclineOrFault(e) {
81737
82072
  }
81738
82073
  var SignatureBridge = class {
81739
82074
  clock;
82075
+ /** Lowercased at construction so every comparison is case-flat — EIP-55 checksum casing
82076
+ * differs between what SIWE signs and what a wallet reports for the SAME address. */
82077
+ boundAccount;
81740
82078
  expiryMs;
81741
82079
  /** Plan 17 E2: single-decision concurrency cap (null = unbounded, the loopback tier). */
81742
82080
  maxPending;
@@ -81772,6 +82110,7 @@ var SignatureBridge = class {
81772
82110
  unlockSession = null;
81773
82111
  constructor(opts) {
81774
82112
  this.clock = opts?.clock ?? Date.now;
82113
+ this.boundAccount = opts?.boundAccount?.toLowerCase();
81775
82114
  this.expiryMs = opts?.expiryMs ?? DEFAULT_EXPIRY_MS;
81776
82115
  this.maxPending = opts?.maxPending ?? null;
81777
82116
  this.attachGraceMs = opts?.attachGraceMs ?? (opts?.mount ? DEFAULT_HOSTED_ATTACH_GRACE_MS : DEFAULT_ATTACH_GRACE_MS);
@@ -82141,6 +82480,14 @@ var SignatureBridge = class {
82141
82480
  });
82142
82481
  this.wcTransport = await factory2(this.wcConfig);
82143
82482
  this.wcTransport.onSession((info) => {
82483
+ const refusal = info ? this.accountRefusal(info.account) : null;
82484
+ if (info && refusal) {
82485
+ this.wcActive = false;
82486
+ this.wallet = null;
82487
+ process.stderr.write(`[bridge] WalletConnect session refused \u2014 ${refusal}
82488
+ `);
82489
+ return;
82490
+ }
82144
82491
  this.wcActive = info !== null;
82145
82492
  this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
82146
82493
  if (info === null) {
@@ -82238,10 +82585,36 @@ var SignatureBridge = class {
82238
82585
  this.deny(res, 400, "hello requires account (0x address) and integer chainId");
82239
82586
  return;
82240
82587
  }
82588
+ const refusal = this.accountRefusal(account);
82589
+ if (refusal) {
82590
+ this.deny(res, 403, refusal);
82591
+ return;
82592
+ }
82241
82593
  session.wallet = { account, chainId };
82242
82594
  this.wallet = { account, chainId };
82243
82595
  this.ok(res);
82244
82596
  }
82597
+ /** C-47: the single predicate every wallet account is admitted through. There are THREE
82598
+ * doors into the account this bridge will sign with — `hello`, `accountsChanged`, and the
82599
+ * WalletConnect `onSession` callback — and all three call this. The first version of this
82600
+ * fix guarded only the first two while this docstring already claimed to be "the single
82601
+ * place", which is how the WC door survived a green suite: the claim was in prose, not in a
82602
+ * test. T-EXT-BIND-01/02/04 now pin one door each, so adding a fourth writer of
82603
+ * `this.wallet` without coming through here fails a test rather than a review.
82604
+ *
82605
+ * Returns the refusal reason, or
82606
+ * null when the account may be adopted.
82607
+ *
82608
+ * Both addresses are named because the pre-fix failure surfaced much later as an opaque
82609
+ * signature-recovery error (`external-eoa.ts:230-233`) that named neither and read as a
82610
+ * wallet fault. A user with several accounts in one wallet extension hits this by
82611
+ * accident far more often than any attacker does, and "wrong account" is only actionable
82612
+ * if it says WHICH. */
82613
+ accountRefusal(account) {
82614
+ if (!this.boundAccount) return null;
82615
+ if (account.toLowerCase() === this.boundAccount) return null;
82616
+ 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.`;
82617
+ }
82245
82618
  /** accountsChanged / chainChanged: a wallet-state CHANGE mid-request invalidates every
82246
82619
  * pending request — what the human saw approved is no longer what would sign. Wallets
82247
82620
  * also deliver late no-op echoes of these events; an unchanged state invalidates nothing. */
@@ -82251,7 +82624,9 @@ var SignatureBridge = class {
82251
82624
  const account = String(body["account"] ?? "");
82252
82625
  const chainId = Number(body["chainId"]);
82253
82626
  const prev = session.wallet;
82254
- session.wallet = /^0x[0-9a-fA-F]{40}$/.test(account) && Number.isInteger(chainId) ? { account, chainId } : null;
82627
+ const offered = /^0x[0-9a-fA-F]{40}$/.test(account) && Number.isInteger(chainId) ? { account, chainId } : null;
82628
+ const refusedSwitch = offered !== null && this.accountRefusal(offered.account) !== null;
82629
+ session.wallet = refusedSwitch ? null : offered;
82255
82630
  if (this.wallet !== null && prev !== null && this.wallet.account.toLowerCase() === prev.account.toLowerCase()) {
82256
82631
  this.wallet = session.wallet;
82257
82632
  }
@@ -82260,7 +82635,7 @@ var SignatureBridge = class {
82260
82635
  this.ok(res);
82261
82636
  return;
82262
82637
  }
82263
- 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";
82638
+ 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";
82264
82639
  for (const entry of this.pending.values()) {
82265
82640
  if (!entry.settled && !entry.collect) this.settle(entry, { status: "invalidated", reason });
82266
82641
  }
@@ -82570,6 +82945,11 @@ async function createRealBoundary(config, wallet, overrides) {
82570
82945
  // tenant — one bridge per tenant world, so the bridge cap IS the tenant cap. The
82571
82946
  // loopback tier keeps its unbounded pending (multi-owner Safe pages need it).
82572
82947
  ...overrides?.bridgeMount ? { mount: overrides.bridgeMount(config.network), maxPending: 1 } : {},
82948
+ // C-47: the authenticated identity governs the write path. Passed separately from
82949
+ // `bridgeMount` although the hosted tier sets both — they answer different questions
82950
+ // ("where does the page live" vs "whose wallet may sign"), and fusing them would make
82951
+ // an unbound hosted bridge impossible to express in a test.
82952
+ ...overrides?.boundBorrower ? { boundAccount: overrides.boundBorrower } : {},
82573
82953
  // M12-12: no unlock closures without a provider — the unlock endpoints answer with
82574
82954
  // their loud not-wired refusal instead of ever touching key material.
82575
82955
  ...keystore ? {
@@ -82846,6 +83226,32 @@ function offers(d, mode) {
82846
83226
  function signerModeSourceClause(d) {
82847
83227
  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`";
82848
83228
  }
83229
+ function phoneWalletOffer(d) {
83230
+ 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";
83231
+ }
83232
+ function moneyTruth(d) {
83233
+ const practice = offers(d, "mock-simulated");
83234
+ const sepolia = d.networks.includes("sepolia");
83235
+ const mainnet = d.networks.includes("mainnet");
83236
+ const cases = [];
83237
+ if (practice) cases.push("- Adapter `mock` \u2014 a PRACTICE sandbox. No real money anywhere.");
83238
+ if (sepolia) {
83239
+ cases.push(
83240
+ "- 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)."
83241
+ );
83242
+ }
83243
+ if (mainnet) cases.push("- Adapter `real` on MAINNET \u2014 REAL MONEY.");
83244
+ 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`.";
83245
+ if (cases.length === 1) {
83246
+ 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:
83247
+ ${cases[0]}`;
83248
+ return `${only}
83249
+ ${gate}`;
83250
+ }
83251
+ return `The money truth on this deployment has ${cases.length === 2 ? "TWO" : "THREE"} cases:
83252
+ ${cases.join("\n")}
83253
+ ${gate}`;
83254
+ }
82849
83255
  var LOCAL_GUIDE_DEPLOYMENT = {
82850
83256
  tier: "local",
82851
83257
  networks: ["sepolia", "mainnet"],
@@ -82853,7 +83259,13 @@ var LOCAL_GUIDE_DEPLOYMENT = {
82853
83259
  // external+keystore and the mock sandbox adds the practice ceremonies, so the guide may
82854
83260
  // speak the full vocabulary and let the existing adapter prose ("PRACTICE-ONLY today —
82855
83261
  // on the real adapter these modes refuse") carry the narrower adapter axis.
82856
- signerModes: GUIDE_SIGNER_MODES
83262
+ signerModes: GUIDE_SIGNER_MODES,
83263
+ // FALSE, because `DH_WC_PROJECT_ID` is unset in a default install and the WalletConnect
83264
+ // leg genuinely is not there until an operator configures it. The first draft of this line
83265
+ // said `true` "to keep the walkthrough complete", which is exactly the overclaim C-44 is
83266
+ // about — the default rendering would have promised a QR that most installs cannot show.
83267
+ // A live boot derives this from env either way (network-switch.ts).
83268
+ walletConnect: false
82857
83269
  };
82858
83270
  function servedNetworks(d) {
82859
83271
  if (d.networks.length === 0) throw new Error("guide: a deployment must serve at least one network");
@@ -83025,7 +83437,7 @@ function keystoreAbsenceBullet() {
83025
83437
  never ask for a password.`;
83026
83438
  }
83027
83439
  var GUIDE_TOPIC_SOURCES = {
83028
- "getting-started": `# Diamond Hands \u2014 what this is
83440
+ "getting-started": (d) => `# Diamond Hands \u2014 what this is
83029
83441
 
83030
83442
  Diamond Hands lets you BORROW a dollar-pegged token (UCD) against your own BITCOIN,
83031
83443
  without selling it. Your BTC sits in a custody vault tied to your position; you mint UCD
@@ -83033,14 +83445,9 @@ against it, pay it back whenever you like, and take your BTC out again.
83033
83445
 
83034
83446
  **Agent instructions:** answer in the USER'S language, map their words via the \`glossary\`
83035
83447
  topic, and always say plainly whether this session is PRACTICE or REAL MONEY. Read the
83036
- \`capabilities\` block in \`boundary://info\` FIRST \u2014 it states the network, whether writes
83037
- are enabled (and the true reason when not), and which signer modes this build offers;
83038
- never promise a capability it does not list. The money truth has THREE cases:
83039
- - Adapter \`mock\` \u2014 a PRACTICE sandbox. No real money anywhere.
83040
- - Adapter \`real\` on SEPOLIA (the zero-config default) \u2014 the REAL protocol contracts on
83041
- the test network: real ceremonies and signatures, PRACTICE money (test funds).
83042
- - Adapter \`real\` on MAINNET \u2014 REAL MONEY. Writes are disabled unless the operator
83043
- explicitly arms them; the capabilities block states which applies.
83448
+ \`capabilities\` block in \`boundary://info\` FIRST \u2014 it states the network, which signer
83449
+ modes this build offers, and which mode is active; never promise a capability it does not
83450
+ list. ${moneyTruth(d)}
83044
83451
  SAY THIS EARLY AND UNPROMPTED \u2014 users must never wonder whether money is real.
83045
83452
 
83046
83453
  A first conversation usually goes: explain this page \u2192 \`guide first-setup\` (choose how to
@@ -83065,8 +83472,8 @@ signer modes exist; current terms (\`protocol_terms\`).
83065
83472
  **2. Choose HOW to authorize operations** (the user's choice, made by talking):
83066
83473
  - **"Use my own wallet"** \u2192 call \`signer_setup\` action \`use\`, mode \`external\` \u2014 works
83067
83474
  on the real adapter and the mock. The approval page auto-opens in the browser (its URL
83068
- is ALSO in the tool result); the user connects MetaMask \u2014 or scans the WalletConnect QR
83069
- / pastes the pairing code for a mobile wallet \u2014 and then APPROVES EACH OPERATION in
83475
+ is ALSO in the tool result); the user connects MetaMask \u2014 ${phoneWalletOffer(d)} \u2014 and
83476
+ then APPROVES EACH OPERATION in
83070
83477
  their own wallet. The first verified signature binds their wallet address as the
83071
83478
  borrower. Full walkthrough: \`guide connect-wallet\`.
83072
83479
  ${offers(d, "keystore") ? `- **"Sign automatically / no popups"** \u2192 mode \`keystore\`. A local encrypted keystore
@@ -83097,14 +83504,13 @@ The user can switch authorization modes at ANY time by saying so \u2014 repeat s
83097
83504
  "connect-wallet": (d) => `# Connect your wallet \u2014 the external-signer walkthrough
83098
83505
 
83099
83506
  External mode means the user approves every operation in their OWN wallet \u2014 a browser
83100
- extension (MetaMask) or a WalletConnect mobile wallet. It works on the real adapter and
83101
- the mock.
83507
+ extension (MetaMask)${d.walletConnect ? " or a WalletConnect mobile wallet" : ""}. It works
83508
+ on the real adapter and the mock.
83102
83509
 
83103
83510
  **The walkthrough:**
83104
83511
  1. \`signer_setup\` action \`use\`, mode \`external\`. The approval page auto-opens in the
83105
83512
  desktop browser; ${approvalPageLocation(d)}
83106
- 2. On the page: connect the browser extension, or \u2014 for a mobile wallet \u2014 scan the
83107
- WalletConnect QR code or paste the pairing code.
83513
+ 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) + "."}
83108
83514
  3. For authenticated reads before any write: \`signer_setup\` action \`connect\` runs the
83109
83515
  login ceremony explicitly (one typed-data signature in the wallet).
83110
83516
  4. The FIRST verified signature binds that wallet address as the borrower \u2014 it persists
@@ -83185,6 +83591,13 @@ Connections / Connected sites).`,
83185
83591
  6. **Withdraw BTC** \u2014 \`loan_withdraw {positionId, btcAddress, amountSats, confirmed:true}\`.
83186
83592
  BTC sends are IRREVERSIBLE \u2014 read the address back to the user before confirming.
83187
83593
  amountSats is gross (fee comes out of it) and may be the whole available balance.
83594
+ The SECOND wallet popup is on a clock of well under a minute; if the user misses it the
83595
+ withdrawal fails with the reservation already committed and their coins still in the
83596
+ vault. That does NOT clear itself and it is not a stale spend \u2014 \`loan_recover_stale_spend\`
83597
+ needs the coins to have MOVED, which is exactly what did not happen. The way out is
83598
+ \`loan_withdraw_retry {positionId, confirmed:true}\`, which re-runs that second step with a
83599
+ fresh stamp using the destination and amount the CHAIN already holds. Check
83600
+ \`position_pending_withdrawals\` first, and tell the user it re-sends real BTC.
83188
83601
  7. **Watch it** \u2014 \`position_status\` (one), \`position_list\` (all),
83189
83602
  \`position_events\` (history), \`btc_price\`, \`protocol_status\`.
83190
83603
 
@@ -83447,8 +83860,7 @@ ${connectorStatusTruth(d)}
83447
83860
  **What it is:** instead of installing anything, the user adds Diamond Hands to
83448
83861
  claude.ai as a connector (paste a URL \u2014 zero install, zero Node, zero config files).
83449
83862
  Sign-in IS the wallet: one Sign-In-with-Ethereum signature proves address ownership \u2014
83450
- no password, no email, no account beyond the wallet address. The sign-in page offers a
83451
- WalletConnect QR too, so a phone wallet works without any browser extension.
83863
+ 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) + "."}
83452
83864
 
83453
83865
  **Signature cadence, plainly:** the FIRST connect costs one SIWE signature (sign-in)
83454
83866
  plus one lit-ops login signature (read access). After that, every operation that moves
@@ -83469,17 +83881,19 @@ honestly when asked "is this safe"):
83469
83881
  is never written to disk. A breach here is privacy-class, never money-class.
83470
83882
  3. **What the assistant narrates.** Tool results shape what the assistant tells you \u2014
83471
83883
  a security concern is filed and audited for exactly this channel.
83472
- 4. **Tenant separation \u2014 and the one binding it does NOT make.** Each signed-in wallet
83473
- gets its own world: its own boundary, its own signer state, its own approval-page
83474
- mount, keyed by that address. What is NOT bound is the mount to that address \u2014 the
83475
- world's borrower is whichever wallet CONNECTS at the mount, so a leaked mount link
83476
- plus an earlier connection would make a different wallet this session's signer. That
83477
- is signing-class, not merely privacy-class; do not tell a user it cannot be. What
83478
- contains it: the mount id is freshly random per world and travels only in the user's
83479
- own tool result (treat the link as a secret), and EVERY fund movement verifies the
83480
- signature against that bound borrower \u2014 no key material exists server-side, so
83481
- whoever reaches the page still cannot sign for anyone else. The gap is filed and
83482
- audited; state it this way rather than claiming a binding that isn't there.
83884
+ 4. **Tenant separation, and what the mount binding does and does not cover.** Each
83885
+ signed-in wallet gets its own world: its own boundary, its own signer state, its own
83886
+ approval-page mount, keyed by that address. The wallet that connects at the mount
83887
+ must BE that address \u2014 a wallet offering any other account is refused at connect
83888
+ time, and switching accounts afterwards is refused the same way rather than silently
83889
+ becoming the new signer. So the account that signs is the account that signed in.
83890
+ None of that makes the mount link safe to pass around: whoever holds it can still
83891
+ load the page and observe or disrupt a pending ceremony, so treat the link as a
83892
+ secret \u2014 it is freshly random per world and travels only in the user's own tool
83893
+ result. What the binding does mean is that a holder cannot become this session's
83894
+ signer. Alongside that,
83895
+ EVERY fund movement still verifies the signature against the bound borrower, and no
83896
+ key material exists server-side.
83483
83897
  5. **Availability and deploy honesty.** Hosted code changes under you: deploys are
83484
83898
  version-pinned, the page bundle is open-source, and \`boundary://info\` capabilities
83485
83899
  reports the exact server version.
@@ -83666,11 +84080,17 @@ function createNetworkSwitchRuntime(opts) {
83666
84080
  }
83667
84081
  };
83668
84082
  }
83669
- function guideDeployment(overrides) {
84083
+ function guideDeployment(overrides, env) {
83670
84084
  return {
83671
84085
  tier: overrides?.bridgeMount ? "hosted" : "local",
83672
84086
  networks: overrides?.allowedNetworks ?? LOCAL_GUIDE_DEPLOYMENT.networks,
83673
- signerModes: overrides?.externalOnly ? EXTERNAL_ONLY_SIGNER_MODES : LOCAL_GUIDE_DEPLOYMENT.signerModes
84087
+ signerModes: overrides?.externalOnly ? EXTERNAL_ONLY_SIGNER_MODES : LOCAL_GUIDE_DEPLOYMENT.signerModes,
84088
+ // C-44 F8, the fourth derivation. Read from the SAME env var the bridge reads
84089
+ // (boundary/config.ts `DH_WC_PROJECT_ID` → BridgeOptions.wc), so the guide cannot promise
84090
+ // a phone-wallet QR that `/wc-pairing` would answer 404 for. Deriving it rather than
84091
+ // hard-coding a tier default is what keeps the guide and `/auth.md` from disagreeing
84092
+ // about the same server, which is exactly what they did before this line existed.
84093
+ walletConnect: Boolean(env?.["DH_WC_PROJECT_ID"])
83674
84094
  };
83675
84095
  }
83676
84096
  function assembleWorld(opts) {
@@ -83680,7 +84100,7 @@ function assembleWorld(opts) {
83680
84100
  ...boot.mockControl ? { mockControl: boot.mockControl } : {},
83681
84101
  ...boot.signer ? { signer: boot.signer } : {},
83682
84102
  ...opts.overrides?.externalOnly ? { externalOnly: true } : {},
83683
- deployment: guideDeployment(opts.overrides),
84103
+ deployment: guideDeployment(opts.overrides, opts.env),
83684
84104
  ...opts.configResult.ok && opts.configResult.config.adapter === "mock" && opts.configResult.config.chainId ? { chainId: opts.configResult.config.chainId } : {}
83685
84105
  };
83686
84106
  if ((opts.env["DH_ADAPTER"] ?? "real") !== "mock") {
@@ -83992,6 +84412,32 @@ function registerLoanTools(server, getB, adapter2 = "real") {
83992
84412
  return renderEnvelope(await b.boundary.withdrawBtc({ positionId, btcAddress: btcAddress2, amountSats, networkFeeSats }));
83993
84413
  })
83994
84414
  );
84415
+ registerBoundaryTool(
84416
+ server,
84417
+ "loan_withdraw_retry",
84418
+ {
84419
+ title: "Re-run a stalled BTC withdrawal's execute step",
84420
+ 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).`,
84421
+ inputSchema: {
84422
+ positionId: positionIdSchema,
84423
+ 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"),
84424
+ confirmed: confirmedSchema
84425
+ },
84426
+ annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
84427
+ },
84428
+ async ({ positionId, networkFeeSats, confirmed }) => guardedWrite(getB, async () => {
84429
+ const gate = requireConfirmation(
84430
+ confirmed,
84431
+ `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)`
84432
+ );
84433
+ if (gate) return gate;
84434
+ const problem = checkPositionIdHex(positionId) ?? checkSatsAmount(networkFeeSats, "Network fee");
84435
+ if (problem) return validationFailed(problem);
84436
+ const b = getB();
84437
+ if (!b.ok) return renderError(b.error);
84438
+ return renderEnvelope(await b.boundary.retryWithdrawExecute({ positionId, networkFeeSats }));
84439
+ })
84440
+ );
83995
84441
  registerBoundaryTool(
83996
84442
  server,
83997
84443
  "loan_allowlist_destination",
@@ -84017,7 +84463,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
84017
84463
  "loan_delegation_setup",
84018
84464
  {
84019
84465
  title: "Install delegation on the Safe (one owner ceremony)",
84020
- 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).`,
84466
+ 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).`,
84021
84467
  inputSchema: {
84022
84468
  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)"),
84023
84469
  confirmed: confirmedSchema
@@ -84037,7 +84483,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
84037
84483
  "loan_delegation_grant",
84038
84484
  {
84039
84485
  title: "Grant the agent per-position scopes (owners sign)",
84040
- 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).`,
84486
+ 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).`,
84041
84487
  inputSchema: {
84042
84488
  positionId: positionIdSchema,
84043
84489
  renew: import_zod.z.boolean().optional().describe("Allow the agent to extend/renew this position"),
@@ -84067,7 +84513,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
84067
84513
  "loan_recover_stale_spend",
84068
84514
  {
84069
84515
  title: "Recover a stale BTC reservation via LIT-attested proof",
84070
- 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.",
84516
+ 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.",
84071
84517
  inputSchema: {
84072
84518
  positionId: positionIdSchema,
84073
84519
  utxoTxid: import_zod.z.string().describe("The original authorized UTXO's txid"),
@@ -84944,9 +85390,6 @@ function registerBoundaryInfoResource(server, getB) {
84944
85390
  );
84945
85391
  }
84946
85392
 
84947
- // src/version.ts
84948
- var SERVER_VERSION = "0.5.11";
84949
-
84950
85393
  // src/server.ts
84951
85394
  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.";
84952
85395
  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'.";
@@ -85069,6 +85512,12 @@ function composeConnector(opts, rawPublicOrigin) {
85069
85512
  const overrides = {
85070
85513
  externalOnly: true,
85071
85514
  allowedNetworks,
85515
+ // C-47: `tenantKey` IS the lowercased SIWE address (see the `authImpl.tenant` call
85516
+ // site). Until this line it was a map key and an error string and nothing else, so a
85517
+ // session authenticated as A could write as B by connecting B to the approval page.
85518
+ // The mount is a bearer capability that transits the LLM transcript by design
85519
+ // (C-45), which is what made that reachable rather than merely untidy.
85520
+ boundBorrower: tenantKey,
85072
85521
  bridgeMount: () => ({ baseUrl: `${publicOrigin}/approval/${mountId}`, origin: publicOrigin }),
85073
85522
  signerPersistence: (network) => {
85074
85523
  let s = stores.get(network);
@@ -85447,6 +85896,13 @@ function composeConnector(opts, rawPublicOrigin) {
85447
85896
  }
85448
85897
  };
85449
85898
  }
85899
+ if (opts.serveLandingPage) {
85900
+ app.get("/", (_req, res) => {
85901
+ const { nonce, headers } = htmlPageSecurityHeaders({ "img-src": [BACKGROUND_IMAGE_ORIGIN, "data:"] });
85902
+ for (const [k, v] of Object.entries(headers)) res.setHeader(k, v);
85903
+ res.type("text/html; charset=utf-8").send(renderLandingPage({ publicOrigin, networks: allowedNetworks, version: SERVER_VERSION, nonce }));
85904
+ });
85905
+ }
85450
85906
  app.use((_req, res) => deny(res, 404, "not found \u2014 the MCP endpoint is /mcp"));
85451
85907
  const sweeper = setInterval(() => sweepService(), 6e4);
85452
85908
  sweeper.unref();
@@ -85491,7 +85947,7 @@ async function startConnectorService(opts) {
85491
85947
  if (addr === null || typeof addr === "string") throw new Error("connector service: no bound address");
85492
85948
  const authority = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
85493
85949
  const publicOrigin = opts.publicOrigin ?? `http://${authority}:${addr.port}`;
85494
- const composed = composeConnector(opts, publicOrigin);
85950
+ const composed = composeConnector({ ...opts, serveLandingPage: true }, publicOrigin);
85495
85951
  httpServer.on("request", composed.app);
85496
85952
  return {
85497
85953
  url: `http://${host}:${addr.port}/mcp`,