@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/index.js CHANGED
@@ -40638,7 +40638,11 @@ var NETWORK_DEFAULTS = {
40638
40638
  },
40639
40639
  mainnet: {
40640
40640
  rpcUrl: "https://ethereum-rpc.publicnode.com",
40641
- serviceEndpoint: "https://ops.gvnr.xyz",
40641
+ // Cutover 2026-09-08 — see sdk/src/constants/chunks/network-configs.ts for the full
40642
+ // reasoning. Widening, not a rename: ops.gvnr.xyz serves the same broker and cannot be
40643
+ // retired while installed copies call it. The sepolia entry above deliberately stays on
40644
+ // ops-test.gvnr.xyz — there is no ops-test.diamondhands.credit twin (open decision 2).
40645
+ serviceEndpoint: "https://ops.diamondhands.credit",
40642
40646
  litNetwork: "chipotle",
40643
40647
  // On-chain PKPValidation generation, mainnet (validatorForVersion(3) is the ONLY
40644
40648
  // registered validator — verified live 2026-08-05). Without this the SDK defaults
@@ -41570,6 +41574,19 @@ var BoundaryCore = class {
41570
41574
  if (!r.ok) return errEnvelope(failureToError(r.failure));
41571
41575
  return okEnvelope({ releasedSats: r.value.releasedSats }, r.source);
41572
41576
  }
41577
+ /** C-46. Unlike `recoverStaleSpend` this is NOT permissionless: re-running phase 2 signs
41578
+ * for the vault, so it takes the same borrower gate every fund-moving op takes. */
41579
+ async retryWithdrawExecute(p) {
41580
+ const auth = await this.requireBorrower();
41581
+ if (!auth.ok) return errEnvelope(auth.error);
41582
+ const r = await this.deps.plugin.ops.retryWithdrawExecute({
41583
+ positionId: p.positionId,
41584
+ networkFeeSats: p.networkFeeSats,
41585
+ borrower: auth.borrower
41586
+ });
41587
+ if (!r.ok) return errEnvelope(failureToError(r.failure));
41588
+ return okEnvelope({ attempted: r.value.attempted, transfers: r.value.transfers }, r.source);
41589
+ }
41573
41590
  // ---- meta ----
41574
41591
  world() {
41575
41592
  return {
@@ -42393,6 +42410,42 @@ var World = class {
42393
42410
  c.authorizedSpends.splice(idx, 1);
42394
42411
  return { ok: true, value: { releasedSats: spend.satoshis } };
42395
42412
  }
42413
+ /**
42414
+ * C-46: re-run the withdrawal EXECUTE leg for reservations whose coins have not been
42415
+ * observed moving (`consumed === null`). This is the stranded shape: phase 1 committed
42416
+ * the reservation, phase 2's quantum-stamped signature expired, and the outpoint was
42417
+ * never spent.
42418
+ *
42419
+ * The retry BROADCASTS; it does not observe. `consumed` therefore stays null — that flag
42420
+ * means "seen consumed on Bitcoin", and only MockControl.confirmSpendConsumed (standing
42421
+ * in for the chain) may set it. Conflating the two would let a retry release collateral
42422
+ * against a transaction no one has confirmed, which is the mistake the whole
42423
+ * proof-of-consumption design exists to prevent. So a retry leaves the reservation
42424
+ * holding its balance exactly as before; what it produces is the txid that can LATER
42425
+ * become the invalidator — the proof the stranded state could never generate for itself.
42426
+ */
42427
+ retryWithdrawExecute(p) {
42428
+ const paused = this.pausedReason();
42429
+ if (paused) return { ok: false, reason: paused };
42430
+ const pos = this.state.positions[p.positionId];
42431
+ if (!pos) return { ok: false, reason: `position ${p.positionId} does not exist` };
42432
+ if (pos.borrower.toLowerCase() !== p.borrower.toLowerCase()) {
42433
+ return { ok: false, reason: `caller ${p.borrower} is not the borrower of this position` };
42434
+ }
42435
+ const c = this.state.collateral[p.positionId];
42436
+ const pending = (c?.authorizedSpends ?? []).filter((s) => s.consumed === null);
42437
+ const transfers = pending.map((spend) => {
42438
+ const { hash: txid } = this.nextId("btc-withdraw-retry");
42439
+ return {
42440
+ utxoIdentifier: `${spend.txid}:${spend.vout}`,
42441
+ ok: true,
42442
+ txid,
42443
+ amountSentSats: spend.satoshis,
42444
+ destination: spend.targetAddress
42445
+ };
42446
+ });
42447
+ return { ok: true, value: { attempted: transfers.length, transfers } };
42448
+ }
42396
42449
  // ---- Mock Safes (plan 06): REAL verification semantics, no fakes (M6-21/27) ----
42397
42450
  safesMap() {
42398
42451
  return this.state.safes;
@@ -43578,6 +43631,11 @@ var MockUpstreamPlugin = class {
43578
43631
  const r = this.world.recoverStaleSpend(p);
43579
43632
  if (!r.ok) return this.rejected("recoverStaleSpend", r.reason);
43580
43633
  return upOk({ txRef: this.world.nextTxRef(), releasedSats: r.value.releasedSats }, this.src("mock-ops"));
43634
+ }),
43635
+ retryWithdrawExecute: (p) => this.write("retryWithdrawExecute", () => {
43636
+ const r = this.world.retryWithdrawExecute({ positionId: p.positionId, borrower: p.borrower });
43637
+ if (!r.ok) return this.rejected("retryWithdrawExecute", r.reason);
43638
+ return upOk({ attempted: r.value.attempted, transfers: r.value.transfers }, this.src("mock-ops"));
43581
43639
  })
43582
43640
  };
43583
43641
  }
@@ -51817,13 +51875,13 @@ var init_deployment_addresses = __esm2({
51817
51875
  block: 25472956
51818
51876
  },
51819
51877
  BTCSpendAuthorizer: {
51820
- previousImplementation: "0xb003ed89F695E8819a85513fE17260b805B3c478",
51821
- newImplementation: "0x40c9e8C46C65E0A57BB63da5368868A9E8Df81A5",
51822
- upgradedAt: "2026-07-06T10:40:59.000Z",
51823
- upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f in tx 0xe1b1884a7e76c7fd569522545a04e49d5128d83d27b3892cda59f143b53b5281 (block 25472957)",
51824
- reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
51825
- executeTx: "0xe1b1884a7e76c7fd569522545a04e49d5128d83d27b3892cda59f143b53b5281",
51826
- block: 25472957
51878
+ previousImplementation: "0x40c9e8C46C65E0A57BB63da5368868A9E8Df81A5",
51879
+ newImplementation: "0x00D7a47798E8ff169104b748131703B78f23390C",
51880
+ upgradedAt: "2026-09-09T12:05:35.000Z",
51881
+ 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)",
51882
+ 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",
51883
+ executeTx: "0x77cd231966c546177bd8f1a07bd4e705afd5c2dfbd110b096836401679c0c69c",
51884
+ block: 25939703
51827
51885
  },
51828
51886
  PositionManager: {
51829
51887
  previousImplementation: "0x600Dc0D1C2c0F94882B6Bc09172f8650047Ad5B1",
@@ -51926,7 +51984,7 @@ var init_deployment_addresses = __esm2({
51926
51984
  ADMIN_MODULE: "0x0023B71B586795eE5fa4E83E384345C1EC8Bb946",
51927
51985
  ADMIN_MODULE_IMPL: "0xb4C5C7E051A1e672F014B25CB5D55B225Aa0D512",
51928
51986
  BTC_SPEND_AUTHORIZER: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
51929
- BTC_SPEND_AUTHORIZER_IMPL: "0x40c9e8C46C65E0A57BB63da5368868A9E8Df81A5",
51987
+ BTC_SPEND_AUTHORIZER_IMPL: "0x00D7a47798E8ff169104b748131703B78f23390C",
51930
51988
  POSITION_MANAGER_VIEWS: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
51931
51989
  POSITION_MANAGER_VIEWS_IMPL: "0xE68DC096A65Ecddbc6A9b5c6e5f878e2CE143Bfe",
51932
51990
  POSITION_MANAGER: "0x12A1836e56139ccaD8722B89519d84233efc224B",
@@ -56902,7 +56960,17 @@ function getSepoliaConfig() {
56902
56960
  function getMainnetConfig() {
56903
56961
  return {
56904
56962
  mode: "service",
56905
- serviceEndpoint: "https://ops.gvnr.xyz",
56963
+ // Cutover 2026-09-08: the product's own domain. `ops.gvnr.xyz` still serves the same
56964
+ // broker and always will — every already-installed copy of this package calls it, so
56965
+ // it can never be retired. This changes what NEW installs default to, nothing else.
56966
+ //
56967
+ // Safe only because the server accepts the new audience ALREADY: the SDK derives the
56968
+ // login audience from this endpoint (`server-session.ts` — `loginAudience ??
56969
+ // serviceEndpoint`) and lit-ops-server FAILS CLOSED on an unknown one. Verified live
56970
+ // before this edit: DH_ACCEPTED_LOGIN_AUDIENCES on the deployed revision lists
56971
+ // https://ops.diamondhands.credit. Publishing this ahead of that would lock out every
56972
+ // client that installed it.
56973
+ serviceEndpoint: "https://ops.diamondhands.credit",
56906
56974
  chainId: 1,
56907
56975
  name: "mainnet",
56908
56976
  // No default RPC: mainnet runs in service mode (serviceEndpoint above), so
@@ -57986,9 +58054,27 @@ var LOGIN_TYPES_WITH_AUDIENCE2 = {
57986
58054
  { name: "audience", type: "string" }
57987
58055
  ]
57988
58056
  };
57989
- async function buildSignedLoginPayload(signer, chainId, audience, reuse) {
58057
+ var LOGIN_TYPES_WITH_STATEMENT = {
58058
+ DiamondHands: [
58059
+ { name: "statement", type: "string" },
58060
+ { name: "address", type: "address" },
58061
+ { name: "issuedAt", type: "uint256" },
58062
+ { name: "nonce", type: "bytes32" },
58063
+ { name: "audience", type: "string" }
58064
+ ]
58065
+ };
58066
+ 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.";
58067
+ function canonicalLoginStatement(audience) {
58068
+ const host = /^https?:\/\/([^/?#]+)/i.exec(audience)?.[1];
58069
+ if (!host)
58070
+ return null;
58071
+ return LOGIN_STATEMENT_TEMPLATE.replace("{host}", host);
58072
+ }
58073
+ async function buildSignedLoginPayload(signer, chainId, audience, reuse, withStatement = false) {
57990
58074
  const address = await signer.getAddress();
58075
+ const statement = withStatement && audience ? canonicalLoginStatement(audience) : null;
57991
58076
  const message = {
58077
+ ...statement ? { statement } : {},
57992
58078
  address,
57993
58079
  issuedAt: reuse?.issuedAt ?? Math.floor(Date.now() / 1e3),
57994
58080
  nonce: reuse?.nonce ?? (0, import_ethers17.hexlify)((0, import_ethers17.randomBytes)(32)),
@@ -57996,7 +58082,7 @@ async function buildSignedLoginPayload(signer, chainId, audience, reuse) {
57996
58082
  };
57997
58083
  const signature = await signer.signTypedData(
57998
58084
  buildLoginDomain(chainId),
57999
- audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
58085
+ statement ? LOGIN_TYPES_WITH_STATEMENT : audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
58000
58086
  message
58001
58087
  );
58002
58088
  return { chainId, message, signature };
@@ -58165,6 +58251,8 @@ var ServerSession = class {
58165
58251
  signer;
58166
58252
  serviceEndpoint;
58167
58253
  loginAudience;
58254
+ /** Whether this session's login carries the human-readable statement. */
58255
+ withStatement;
58168
58256
  chainId;
58169
58257
  store;
58170
58258
  onSignaturePrompt;
@@ -58206,6 +58294,13 @@ var ServerSession = class {
58206
58294
  /\/+$/,
58207
58295
  ""
58208
58296
  );
58297
+ const explicitAudience = typeof opts.loginAudience === "string" && opts.loginAudience.length > 0;
58298
+ this.withStatement = opts.withStatement === true && explicitAudience;
58299
+ if (opts.withStatement === true && !explicitAudience) {
58300
+ console.warn(
58301
+ "[dh-sdk] withStatement ignored: it requires an explicit loginAudience, since the servers rebuild the expected sentence from the audience host"
58302
+ );
58303
+ }
58209
58304
  this.chainId = opts.chainId;
58210
58305
  this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
58211
58306
  this.onSignaturePrompt = opts.onSignaturePrompt;
@@ -58459,12 +58554,16 @@ var ServerSession = class {
58459
58554
  this.signer,
58460
58555
  this.chainId,
58461
58556
  this.loginAudience,
58462
- reuse
58557
+ reuse,
58558
+ reuse ? reuse.withStatement === true : this.withStatement
58463
58559
  );
58464
58560
  if (storeKey && !reuse) {
58465
58561
  store.savePending?.(storeKey, {
58466
58562
  issuedAt: payload.message.issuedAt,
58467
- nonce: payload.message.nonce
58563
+ nonce: payload.message.nonce,
58564
+ // Recorded so a resume reproduces this digest even if the
58565
+ // capability flag changes before the owners finish signing.
58566
+ withStatement: this.withStatement
58468
58567
  });
58469
58568
  }
58470
58569
  session = await this.login(payload);
@@ -70675,6 +70774,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
70675
70774
  signer: config.authSigner ?? config.contractSigner,
70676
70775
  serviceEndpoint: config.serviceEndpoint,
70677
70776
  loginAudience: config.loginAudience,
70777
+ // Only meaningful alongside an audience; the servers derive the expected
70778
+ // sentence from its host. Defaults off so Node callers are untouched.
70779
+ withStatement: config.loginStatement === true,
70678
70780
  chainId: config.chainId,
70679
70781
  persistSession: config.sessionPersistence?.enabled,
70680
70782
  sessionStore: config.sessionPersistence?.store,
@@ -79520,7 +79622,33 @@ function buildWriteOps(deps) {
79520
79622
  kind: "unavailable",
79521
79623
  source: SOURCE5,
79522
79624
  message: "recoverStaleSpend is not wired in this delivery (permissionless recovery \u2014 planned follow-up)."
79523
- })
79625
+ }),
79626
+ retryWithdrawExecute: async (p) => {
79627
+ const sdk = deps.getWriteSdk();
79628
+ if (!sdk) return upFail({ kind: "unavailable", source: SOURCE5, message: "write SDK is not initialized (its boot-time construction failed)" });
79629
+ let rows;
79630
+ try {
79631
+ rows = await sdk.executePendingBtcTransfers(p.positionId, p.networkFeeSats);
79632
+ } catch (e) {
79633
+ return failed("retryWithdrawExecute", e);
79634
+ }
79635
+ const gate = rows.find((r) => !r.success && !r.utxoIdentifier);
79636
+ if (gate) return declined("retryWithdrawExecute", gate.error ?? "pending-transfer execution refused before any reservation was attempted");
79637
+ return upOk(
79638
+ {
79639
+ attempted: rows.length,
79640
+ transfers: rows.map((r) => ({
79641
+ utxoIdentifier: r.utxoIdentifier ?? "",
79642
+ ok: r.success,
79643
+ ...r.txid ? { txid: r.txid } : {},
79644
+ ...r.amountSent !== void 0 ? { amountSentSats: String(r.amountSent) } : {},
79645
+ ...r.destination ? { destination: r.destination } : {},
79646
+ ...r.error ? { error: r.error } : {}
79647
+ }))
79648
+ },
79649
+ { id: SOURCE5, kind: "lit-ops", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }
79650
+ );
79651
+ }
79524
79652
  };
79525
79653
  }
79526
79654
 
@@ -80045,7 +80173,8 @@ var RealUpstreamPlugin = class {
80045
80173
  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."
80046
80174
  })
80047
80175
  ),
80048
- recoverStaleSpend: () => readOnly("recoverStaleSpend")
80176
+ recoverStaleSpend: () => readOnly("recoverStaleSpend"),
80177
+ retryWithdrawExecute: () => readOnly("retryWithdrawExecute")
80049
80178
  };
80050
80179
  }
80051
80180
  }
@@ -80213,7 +80342,8 @@ var RealUpstreamPlugin = class {
80213
80342
  psmSwap: call("psmSwap"),
80214
80343
  delegationSetup: call("delegationSetup"),
80215
80344
  delegationGrant: call("delegationGrant"),
80216
- recoverStaleSpend: call("recoverStaleSpend")
80345
+ recoverStaleSpend: call("recoverStaleSpend"),
80346
+ retryWithdrawExecute: call("retryWithdrawExecute")
80217
80347
  };
80218
80348
  }
80219
80349
  async resolveOpsGateway() {
@@ -81011,12 +81141,25 @@ document.getElementById("generate").onclick = () => submit(true);
81011
81141
 
81012
81142
  // src/util/page-headers.ts
81013
81143
  var import_node_crypto6 = require("crypto");
81014
- function htmlPageSecurityHeaders() {
81144
+ function htmlPageSecurityHeaders(extra) {
81015
81145
  const nonce = (0, import_node_crypto6.randomBytes)(16).toString("base64");
81146
+ const base = [
81147
+ `default-src 'none'`,
81148
+ `script-src 'nonce-${nonce}'`,
81149
+ `style-src 'unsafe-inline'`,
81150
+ `connect-src 'self'`,
81151
+ `base-uri 'none'`,
81152
+ `form-action 'none'`,
81153
+ `frame-ancestors 'none'`
81154
+ ];
81155
+ for (const [directive, sources] of Object.entries(extra ?? {})) {
81156
+ if (sources.length === 0) continue;
81157
+ base.push(`${directive} ${sources.join(" ")}`);
81158
+ }
81016
81159
  return {
81017
81160
  nonce,
81018
81161
  headers: {
81019
- "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'`,
81162
+ "Content-Security-Policy": base.join("; "),
81020
81163
  "X-Frame-Options": "DENY",
81021
81164
  "Referrer-Policy": "no-referrer",
81022
81165
  "X-Content-Type-Options": "nosniff"
@@ -81039,6 +81182,9 @@ function wcDeclineOrFault(e) {
81039
81182
  }
81040
81183
  var SignatureBridge = class {
81041
81184
  clock;
81185
+ /** Lowercased at construction so every comparison is case-flat — EIP-55 checksum casing
81186
+ * differs between what SIWE signs and what a wallet reports for the SAME address. */
81187
+ boundAccount;
81042
81188
  expiryMs;
81043
81189
  /** Plan 17 E2: single-decision concurrency cap (null = unbounded, the loopback tier). */
81044
81190
  maxPending;
@@ -81074,6 +81220,7 @@ var SignatureBridge = class {
81074
81220
  unlockSession = null;
81075
81221
  constructor(opts) {
81076
81222
  this.clock = opts?.clock ?? Date.now;
81223
+ this.boundAccount = opts?.boundAccount?.toLowerCase();
81077
81224
  this.expiryMs = opts?.expiryMs ?? DEFAULT_EXPIRY_MS;
81078
81225
  this.maxPending = opts?.maxPending ?? null;
81079
81226
  this.attachGraceMs = opts?.attachGraceMs ?? (opts?.mount ? DEFAULT_HOSTED_ATTACH_GRACE_MS : DEFAULT_ATTACH_GRACE_MS);
@@ -81443,6 +81590,14 @@ var SignatureBridge = class {
81443
81590
  });
81444
81591
  this.wcTransport = await factory2(this.wcConfig);
81445
81592
  this.wcTransport.onSession((info) => {
81593
+ const refusal = info ? this.accountRefusal(info.account) : null;
81594
+ if (info && refusal) {
81595
+ this.wcActive = false;
81596
+ this.wallet = null;
81597
+ process.stderr.write(`[bridge] WalletConnect session refused \u2014 ${refusal}
81598
+ `);
81599
+ return;
81600
+ }
81446
81601
  this.wcActive = info !== null;
81447
81602
  this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
81448
81603
  if (info === null) {
@@ -81540,10 +81695,36 @@ var SignatureBridge = class {
81540
81695
  this.deny(res, 400, "hello requires account (0x address) and integer chainId");
81541
81696
  return;
81542
81697
  }
81698
+ const refusal = this.accountRefusal(account);
81699
+ if (refusal) {
81700
+ this.deny(res, 403, refusal);
81701
+ return;
81702
+ }
81543
81703
  session.wallet = { account, chainId };
81544
81704
  this.wallet = { account, chainId };
81545
81705
  this.ok(res);
81546
81706
  }
81707
+ /** C-47: the single predicate every wallet account is admitted through. There are THREE
81708
+ * doors into the account this bridge will sign with — `hello`, `accountsChanged`, and the
81709
+ * WalletConnect `onSession` callback — and all three call this. The first version of this
81710
+ * fix guarded only the first two while this docstring already claimed to be "the single
81711
+ * place", which is how the WC door survived a green suite: the claim was in prose, not in a
81712
+ * test. T-EXT-BIND-01/02/04 now pin one door each, so adding a fourth writer of
81713
+ * `this.wallet` without coming through here fails a test rather than a review.
81714
+ *
81715
+ * Returns the refusal reason, or
81716
+ * null when the account may be adopted.
81717
+ *
81718
+ * Both addresses are named because the pre-fix failure surfaced much later as an opaque
81719
+ * signature-recovery error (`external-eoa.ts:230-233`) that named neither and read as a
81720
+ * wallet fault. A user with several accounts in one wallet extension hits this by
81721
+ * accident far more often than any attacker does, and "wrong account" is only actionable
81722
+ * if it says WHICH. */
81723
+ accountRefusal(account) {
81724
+ if (!this.boundAccount) return null;
81725
+ if (account.toLowerCase() === this.boundAccount) return null;
81726
+ 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.`;
81727
+ }
81547
81728
  /** accountsChanged / chainChanged: a wallet-state CHANGE mid-request invalidates every
81548
81729
  * pending request — what the human saw approved is no longer what would sign. Wallets
81549
81730
  * also deliver late no-op echoes of these events; an unchanged state invalidates nothing. */
@@ -81553,7 +81734,9 @@ var SignatureBridge = class {
81553
81734
  const account = String(body["account"] ?? "");
81554
81735
  const chainId = Number(body["chainId"]);
81555
81736
  const prev = session.wallet;
81556
- session.wallet = /^0x[0-9a-fA-F]{40}$/.test(account) && Number.isInteger(chainId) ? { account, chainId } : null;
81737
+ const offered = /^0x[0-9a-fA-F]{40}$/.test(account) && Number.isInteger(chainId) ? { account, chainId } : null;
81738
+ const refusedSwitch = offered !== null && this.accountRefusal(offered.account) !== null;
81739
+ session.wallet = refusedSwitch ? null : offered;
81557
81740
  if (this.wallet !== null && prev !== null && this.wallet.account.toLowerCase() === prev.account.toLowerCase()) {
81558
81741
  this.wallet = session.wallet;
81559
81742
  }
@@ -81562,7 +81745,7 @@ var SignatureBridge = class {
81562
81745
  this.ok(res);
81563
81746
  return;
81564
81747
  }
81565
- 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";
81748
+ 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";
81566
81749
  for (const entry of this.pending.values()) {
81567
81750
  if (!entry.settled && !entry.collect) this.settle(entry, { status: "invalidated", reason });
81568
81751
  }
@@ -81872,6 +82055,11 @@ async function createRealBoundary(config, wallet, overrides) {
81872
82055
  // tenant — one bridge per tenant world, so the bridge cap IS the tenant cap. The
81873
82056
  // loopback tier keeps its unbounded pending (multi-owner Safe pages need it).
81874
82057
  ...overrides?.bridgeMount ? { mount: overrides.bridgeMount(config.network), maxPending: 1 } : {},
82058
+ // C-47: the authenticated identity governs the write path. Passed separately from
82059
+ // `bridgeMount` although the hosted tier sets both — they answer different questions
82060
+ // ("where does the page live" vs "whose wallet may sign"), and fusing them would make
82061
+ // an unbound hosted bridge impossible to express in a test.
82062
+ ...overrides?.boundBorrower ? { boundAccount: overrides.boundBorrower } : {},
81875
82063
  // M12-12: no unlock closures without a provider — the unlock endpoints answer with
81876
82064
  // their loud not-wired refusal instead of ever touching key material.
81877
82065
  ...keystore ? {
@@ -82148,6 +82336,32 @@ function offers(d, mode) {
82148
82336
  function signerModeSourceClause(d) {
82149
82337
  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`";
82150
82338
  }
82339
+ function phoneWalletOffer(d) {
82340
+ 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";
82341
+ }
82342
+ function moneyTruth(d) {
82343
+ const practice = offers(d, "mock-simulated");
82344
+ const sepolia = d.networks.includes("sepolia");
82345
+ const mainnet = d.networks.includes("mainnet");
82346
+ const cases = [];
82347
+ if (practice) cases.push("- Adapter `mock` \u2014 a PRACTICE sandbox. No real money anywhere.");
82348
+ if (sepolia) {
82349
+ cases.push(
82350
+ "- 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)."
82351
+ );
82352
+ }
82353
+ if (mainnet) cases.push("- Adapter `real` on MAINNET \u2014 REAL MONEY.");
82354
+ 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`.";
82355
+ if (cases.length === 1) {
82356
+ 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:
82357
+ ${cases[0]}`;
82358
+ return `${only}
82359
+ ${gate}`;
82360
+ }
82361
+ return `The money truth on this deployment has ${cases.length === 2 ? "TWO" : "THREE"} cases:
82362
+ ${cases.join("\n")}
82363
+ ${gate}`;
82364
+ }
82151
82365
  var LOCAL_GUIDE_DEPLOYMENT = {
82152
82366
  tier: "local",
82153
82367
  networks: ["sepolia", "mainnet"],
@@ -82155,7 +82369,13 @@ var LOCAL_GUIDE_DEPLOYMENT = {
82155
82369
  // external+keystore and the mock sandbox adds the practice ceremonies, so the guide may
82156
82370
  // speak the full vocabulary and let the existing adapter prose ("PRACTICE-ONLY today —
82157
82371
  // on the real adapter these modes refuse") carry the narrower adapter axis.
82158
- signerModes: GUIDE_SIGNER_MODES
82372
+ signerModes: GUIDE_SIGNER_MODES,
82373
+ // FALSE, because `DH_WC_PROJECT_ID` is unset in a default install and the WalletConnect
82374
+ // leg genuinely is not there until an operator configures it. The first draft of this line
82375
+ // said `true` "to keep the walkthrough complete", which is exactly the overclaim C-44 is
82376
+ // about — the default rendering would have promised a QR that most installs cannot show.
82377
+ // A live boot derives this from env either way (network-switch.ts).
82378
+ walletConnect: false
82159
82379
  };
82160
82380
  function servedNetworks(d) {
82161
82381
  if (d.networks.length === 0) throw new Error("guide: a deployment must serve at least one network");
@@ -82327,7 +82547,7 @@ function keystoreAbsenceBullet() {
82327
82547
  never ask for a password.`;
82328
82548
  }
82329
82549
  var GUIDE_TOPIC_SOURCES = {
82330
- "getting-started": `# Diamond Hands \u2014 what this is
82550
+ "getting-started": (d) => `# Diamond Hands \u2014 what this is
82331
82551
 
82332
82552
  Diamond Hands lets you BORROW a dollar-pegged token (UCD) against your own BITCOIN,
82333
82553
  without selling it. Your BTC sits in a custody vault tied to your position; you mint UCD
@@ -82335,14 +82555,9 @@ against it, pay it back whenever you like, and take your BTC out again.
82335
82555
 
82336
82556
  **Agent instructions:** answer in the USER'S language, map their words via the \`glossary\`
82337
82557
  topic, and always say plainly whether this session is PRACTICE or REAL MONEY. Read the
82338
- \`capabilities\` block in \`boundary://info\` FIRST \u2014 it states the network, whether writes
82339
- are enabled (and the true reason when not), and which signer modes this build offers;
82340
- never promise a capability it does not list. The money truth has THREE cases:
82341
- - Adapter \`mock\` \u2014 a PRACTICE sandbox. No real money anywhere.
82342
- - Adapter \`real\` on SEPOLIA (the zero-config default) \u2014 the REAL protocol contracts on
82343
- the test network: real ceremonies and signatures, PRACTICE money (test funds).
82344
- - Adapter \`real\` on MAINNET \u2014 REAL MONEY. Writes are disabled unless the operator
82345
- explicitly arms them; the capabilities block states which applies.
82558
+ \`capabilities\` block in \`boundary://info\` FIRST \u2014 it states the network, which signer
82559
+ modes this build offers, and which mode is active; never promise a capability it does not
82560
+ list. ${moneyTruth(d)}
82346
82561
  SAY THIS EARLY AND UNPROMPTED \u2014 users must never wonder whether money is real.
82347
82562
 
82348
82563
  A first conversation usually goes: explain this page \u2192 \`guide first-setup\` (choose how to
@@ -82367,8 +82582,8 @@ signer modes exist; current terms (\`protocol_terms\`).
82367
82582
  **2. Choose HOW to authorize operations** (the user's choice, made by talking):
82368
82583
  - **"Use my own wallet"** \u2192 call \`signer_setup\` action \`use\`, mode \`external\` \u2014 works
82369
82584
  on the real adapter and the mock. The approval page auto-opens in the browser (its URL
82370
- is ALSO in the tool result); the user connects MetaMask \u2014 or scans the WalletConnect QR
82371
- / pastes the pairing code for a mobile wallet \u2014 and then APPROVES EACH OPERATION in
82585
+ is ALSO in the tool result); the user connects MetaMask \u2014 ${phoneWalletOffer(d)} \u2014 and
82586
+ then APPROVES EACH OPERATION in
82372
82587
  their own wallet. The first verified signature binds their wallet address as the
82373
82588
  borrower. Full walkthrough: \`guide connect-wallet\`.
82374
82589
  ${offers(d, "keystore") ? `- **"Sign automatically / no popups"** \u2192 mode \`keystore\`. A local encrypted keystore
@@ -82399,14 +82614,13 @@ The user can switch authorization modes at ANY time by saying so \u2014 repeat s
82399
82614
  "connect-wallet": (d) => `# Connect your wallet \u2014 the external-signer walkthrough
82400
82615
 
82401
82616
  External mode means the user approves every operation in their OWN wallet \u2014 a browser
82402
- extension (MetaMask) or a WalletConnect mobile wallet. It works on the real adapter and
82403
- the mock.
82617
+ extension (MetaMask)${d.walletConnect ? " or a WalletConnect mobile wallet" : ""}. It works
82618
+ on the real adapter and the mock.
82404
82619
 
82405
82620
  **The walkthrough:**
82406
82621
  1. \`signer_setup\` action \`use\`, mode \`external\`. The approval page auto-opens in the
82407
82622
  desktop browser; ${approvalPageLocation(d)}
82408
- 2. On the page: connect the browser extension, or \u2014 for a mobile wallet \u2014 scan the
82409
- WalletConnect QR code or paste the pairing code.
82623
+ 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) + "."}
82410
82624
  3. For authenticated reads before any write: \`signer_setup\` action \`connect\` runs the
82411
82625
  login ceremony explicitly (one typed-data signature in the wallet).
82412
82626
  4. The FIRST verified signature binds that wallet address as the borrower \u2014 it persists
@@ -82487,6 +82701,13 @@ Connections / Connected sites).`,
82487
82701
  6. **Withdraw BTC** \u2014 \`loan_withdraw {positionId, btcAddress, amountSats, confirmed:true}\`.
82488
82702
  BTC sends are IRREVERSIBLE \u2014 read the address back to the user before confirming.
82489
82703
  amountSats is gross (fee comes out of it) and may be the whole available balance.
82704
+ The SECOND wallet popup is on a clock of well under a minute; if the user misses it the
82705
+ withdrawal fails with the reservation already committed and their coins still in the
82706
+ vault. That does NOT clear itself and it is not a stale spend \u2014 \`loan_recover_stale_spend\`
82707
+ needs the coins to have MOVED, which is exactly what did not happen. The way out is
82708
+ \`loan_withdraw_retry {positionId, confirmed:true}\`, which re-runs that second step with a
82709
+ fresh stamp using the destination and amount the CHAIN already holds. Check
82710
+ \`position_pending_withdrawals\` first, and tell the user it re-sends real BTC.
82490
82711
  7. **Watch it** \u2014 \`position_status\` (one), \`position_list\` (all),
82491
82712
  \`position_events\` (history), \`btc_price\`, \`protocol_status\`.
82492
82713
 
@@ -82749,8 +82970,7 @@ ${connectorStatusTruth(d)}
82749
82970
  **What it is:** instead of installing anything, the user adds Diamond Hands to
82750
82971
  claude.ai as a connector (paste a URL \u2014 zero install, zero Node, zero config files).
82751
82972
  Sign-in IS the wallet: one Sign-In-with-Ethereum signature proves address ownership \u2014
82752
- no password, no email, no account beyond the wallet address. The sign-in page offers a
82753
- WalletConnect QR too, so a phone wallet works without any browser extension.
82973
+ 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) + "."}
82754
82974
 
82755
82975
  **Signature cadence, plainly:** the FIRST connect costs one SIWE signature (sign-in)
82756
82976
  plus one lit-ops login signature (read access). After that, every operation that moves
@@ -82771,17 +82991,19 @@ honestly when asked "is this safe"):
82771
82991
  is never written to disk. A breach here is privacy-class, never money-class.
82772
82992
  3. **What the assistant narrates.** Tool results shape what the assistant tells you \u2014
82773
82993
  a security concern is filed and audited for exactly this channel.
82774
- 4. **Tenant separation \u2014 and the one binding it does NOT make.** Each signed-in wallet
82775
- gets its own world: its own boundary, its own signer state, its own approval-page
82776
- mount, keyed by that address. What is NOT bound is the mount to that address \u2014 the
82777
- world's borrower is whichever wallet CONNECTS at the mount, so a leaked mount link
82778
- plus an earlier connection would make a different wallet this session's signer. That
82779
- is signing-class, not merely privacy-class; do not tell a user it cannot be. What
82780
- contains it: the mount id is freshly random per world and travels only in the user's
82781
- own tool result (treat the link as a secret), and EVERY fund movement verifies the
82782
- signature against that bound borrower \u2014 no key material exists server-side, so
82783
- whoever reaches the page still cannot sign for anyone else. The gap is filed and
82784
- audited; state it this way rather than claiming a binding that isn't there.
82994
+ 4. **Tenant separation, and what the mount binding does and does not cover.** Each
82995
+ signed-in wallet gets its own world: its own boundary, its own signer state, its own
82996
+ approval-page mount, keyed by that address. The wallet that connects at the mount
82997
+ must BE that address \u2014 a wallet offering any other account is refused at connect
82998
+ time, and switching accounts afterwards is refused the same way rather than silently
82999
+ becoming the new signer. So the account that signs is the account that signed in.
83000
+ None of that makes the mount link safe to pass around: whoever holds it can still
83001
+ load the page and observe or disrupt a pending ceremony, so treat the link as a
83002
+ secret \u2014 it is freshly random per world and travels only in the user's own tool
83003
+ result. What the binding does mean is that a holder cannot become this session's
83004
+ signer. Alongside that,
83005
+ EVERY fund movement still verifies the signature against the bound borrower, and no
83006
+ key material exists server-side.
82785
83007
  5. **Availability and deploy honesty.** Hosted code changes under you: deploys are
82786
83008
  version-pinned, the page bundle is open-source, and \`boundary://info\` capabilities
82787
83009
  reports the exact server version.
@@ -82968,11 +83190,17 @@ function createNetworkSwitchRuntime(opts) {
82968
83190
  }
82969
83191
  };
82970
83192
  }
82971
- function guideDeployment(overrides) {
83193
+ function guideDeployment(overrides, env) {
82972
83194
  return {
82973
83195
  tier: overrides?.bridgeMount ? "hosted" : "local",
82974
83196
  networks: overrides?.allowedNetworks ?? LOCAL_GUIDE_DEPLOYMENT.networks,
82975
- signerModes: overrides?.externalOnly ? EXTERNAL_ONLY_SIGNER_MODES : LOCAL_GUIDE_DEPLOYMENT.signerModes
83197
+ signerModes: overrides?.externalOnly ? EXTERNAL_ONLY_SIGNER_MODES : LOCAL_GUIDE_DEPLOYMENT.signerModes,
83198
+ // C-44 F8, the fourth derivation. Read from the SAME env var the bridge reads
83199
+ // (boundary/config.ts `DH_WC_PROJECT_ID` → BridgeOptions.wc), so the guide cannot promise
83200
+ // a phone-wallet QR that `/wc-pairing` would answer 404 for. Deriving it rather than
83201
+ // hard-coding a tier default is what keeps the guide and `/auth.md` from disagreeing
83202
+ // about the same server, which is exactly what they did before this line existed.
83203
+ walletConnect: Boolean(env?.["DH_WC_PROJECT_ID"])
82976
83204
  };
82977
83205
  }
82978
83206
  function assembleWorld(opts) {
@@ -82982,7 +83210,7 @@ function assembleWorld(opts) {
82982
83210
  ...boot.mockControl ? { mockControl: boot.mockControl } : {},
82983
83211
  ...boot.signer ? { signer: boot.signer } : {},
82984
83212
  ...opts.overrides?.externalOnly ? { externalOnly: true } : {},
82985
- deployment: guideDeployment(opts.overrides),
83213
+ deployment: guideDeployment(opts.overrides, opts.env),
82986
83214
  ...opts.configResult.ok && opts.configResult.config.adapter === "mock" && opts.configResult.config.chainId ? { chainId: opts.configResult.config.chainId } : {}
82987
83215
  };
82988
83216
  if ((opts.env["DH_ADAPTER"] ?? "real") !== "mock") {
@@ -83294,6 +83522,32 @@ function registerLoanTools(server, getB, adapter2 = "real") {
83294
83522
  return renderEnvelope(await b.boundary.withdrawBtc({ positionId, btcAddress: btcAddress2, amountSats, networkFeeSats }));
83295
83523
  })
83296
83524
  );
83525
+ registerBoundaryTool(
83526
+ server,
83527
+ "loan_withdraw_retry",
83528
+ {
83529
+ title: "Re-run a stalled BTC withdrawal's execute step",
83530
+ 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).`,
83531
+ inputSchema: {
83532
+ positionId: positionIdSchema,
83533
+ 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"),
83534
+ confirmed: confirmedSchema
83535
+ },
83536
+ annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
83537
+ },
83538
+ async ({ positionId, networkFeeSats, confirmed }) => guardedWrite(getB, async () => {
83539
+ const gate = requireConfirmation(
83540
+ confirmed,
83541
+ `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)`
83542
+ );
83543
+ if (gate) return gate;
83544
+ const problem = checkPositionIdHex(positionId) ?? checkSatsAmount(networkFeeSats, "Network fee");
83545
+ if (problem) return validationFailed(problem);
83546
+ const b = getB();
83547
+ if (!b.ok) return renderError(b.error);
83548
+ return renderEnvelope(await b.boundary.retryWithdrawExecute({ positionId, networkFeeSats }));
83549
+ })
83550
+ );
83297
83551
  registerBoundaryTool(
83298
83552
  server,
83299
83553
  "loan_allowlist_destination",
@@ -83319,7 +83573,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
83319
83573
  "loan_delegation_setup",
83320
83574
  {
83321
83575
  title: "Install delegation on the Safe (one owner ceremony)",
83322
- 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).`,
83576
+ 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).`,
83323
83577
  inputSchema: {
83324
83578
  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)"),
83325
83579
  confirmed: confirmedSchema
@@ -83339,7 +83593,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
83339
83593
  "loan_delegation_grant",
83340
83594
  {
83341
83595
  title: "Grant the agent per-position scopes (owners sign)",
83342
- 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).`,
83596
+ 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).`,
83343
83597
  inputSchema: {
83344
83598
  positionId: positionIdSchema,
83345
83599
  renew: import_zod.z.boolean().optional().describe("Allow the agent to extend/renew this position"),
@@ -83369,7 +83623,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
83369
83623
  "loan_recover_stale_spend",
83370
83624
  {
83371
83625
  title: "Recover a stale BTC reservation via LIT-attested proof",
83372
- 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.",
83626
+ 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.",
83373
83627
  inputSchema: {
83374
83628
  positionId: positionIdSchema,
83375
83629
  utxoTxid: import_zod.z.string().describe("The original authorized UTXO's txid"),
@@ -84247,7 +84501,7 @@ function registerBoundaryInfoResource(server, getB) {
84247
84501
  }
84248
84502
 
84249
84503
  // src/version.ts
84250
- var SERVER_VERSION = "0.5.11";
84504
+ var SERVER_VERSION = "0.5.13";
84251
84505
 
84252
84506
  // src/server.ts
84253
84507
  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.";