@gvnrdao/dh-mcp 0.5.12 → 0.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boundary.js +178 -17
- package/dist/connector-embed.js +286 -53
- package/dist/connector.js +286 -53
- package/dist/index.js +280 -53
- package/package.json +2 -2
package/dist/connector.js
CHANGED
|
@@ -41030,7 +41030,7 @@ function htmlPageSecurityHeaders(extra) {
|
|
|
41030
41030
|
}
|
|
41031
41031
|
|
|
41032
41032
|
// src/version.ts
|
|
41033
|
-
var SERVER_VERSION = "0.5.
|
|
41033
|
+
var SERVER_VERSION = "0.5.13";
|
|
41034
41034
|
|
|
41035
41035
|
// src/connector/siwe-oauth.ts
|
|
41036
41036
|
var import_node_crypto2 = require("crypto");
|
|
@@ -42483,6 +42483,19 @@ var BoundaryCore = class {
|
|
|
42483
42483
|
if (!r.ok) return errEnvelope(failureToError(r.failure));
|
|
42484
42484
|
return okEnvelope({ releasedSats: r.value.releasedSats }, r.source);
|
|
42485
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
|
+
}
|
|
42486
42499
|
// ---- meta ----
|
|
42487
42500
|
world() {
|
|
42488
42501
|
return {
|
|
@@ -43306,6 +43319,42 @@ var World = class {
|
|
|
43306
43319
|
c.authorizedSpends.splice(idx, 1);
|
|
43307
43320
|
return { ok: true, value: { releasedSats: spend.satoshis } };
|
|
43308
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
|
+
}
|
|
43309
43358
|
// ---- Mock Safes (plan 06): REAL verification semantics, no fakes (M6-21/27) ----
|
|
43310
43359
|
safesMap() {
|
|
43311
43360
|
return this.state.safes;
|
|
@@ -44500,6 +44549,11 @@ var MockUpstreamPlugin = class {
|
|
|
44500
44549
|
const r = this.world.recoverStaleSpend(p);
|
|
44501
44550
|
if (!r.ok) return this.rejected("recoverStaleSpend", r.reason);
|
|
44502
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"));
|
|
44503
44557
|
})
|
|
44504
44558
|
};
|
|
44505
44559
|
}
|
|
@@ -52739,13 +52793,13 @@ var init_deployment_addresses = __esm2({
|
|
|
52739
52793
|
block: 25472956
|
|
52740
52794
|
},
|
|
52741
52795
|
BTCSpendAuthorizer: {
|
|
52742
|
-
previousImplementation: "
|
|
52743
|
-
newImplementation: "
|
|
52744
|
-
upgradedAt: "2026-
|
|
52745
|
-
upgradedBy: "AdminModule
|
|
52746
|
-
reason: "
|
|
52747
|
-
executeTx: "
|
|
52748
|
-
block:
|
|
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
|
|
52749
52803
|
},
|
|
52750
52804
|
PositionManager: {
|
|
52751
52805
|
previousImplementation: "0x600Dc0D1C2c0F94882B6Bc09172f8650047Ad5B1",
|
|
@@ -52848,7 +52902,7 @@ var init_deployment_addresses = __esm2({
|
|
|
52848
52902
|
ADMIN_MODULE: "0x0023B71B586795eE5fa4E83E384345C1EC8Bb946",
|
|
52849
52903
|
ADMIN_MODULE_IMPL: "0xb4C5C7E051A1e672F014B25CB5D55B225Aa0D512",
|
|
52850
52904
|
BTC_SPEND_AUTHORIZER: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
52851
|
-
BTC_SPEND_AUTHORIZER_IMPL: "
|
|
52905
|
+
BTC_SPEND_AUTHORIZER_IMPL: "0x00D7a47798E8ff169104b748131703B78f23390C",
|
|
52852
52906
|
POSITION_MANAGER_VIEWS: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
|
|
52853
52907
|
POSITION_MANAGER_VIEWS_IMPL: "0xE68DC096A65Ecddbc6A9b5c6e5f878e2CE143Bfe",
|
|
52854
52908
|
POSITION_MANAGER: "0x12A1836e56139ccaD8722B89519d84233efc224B",
|
|
@@ -58918,9 +58972,27 @@ var LOGIN_TYPES_WITH_AUDIENCE2 = {
|
|
|
58918
58972
|
{ name: "audience", type: "string" }
|
|
58919
58973
|
]
|
|
58920
58974
|
};
|
|
58921
|
-
|
|
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) {
|
|
58922
58992
|
const address = await signer.getAddress();
|
|
58993
|
+
const statement = withStatement && audience ? canonicalLoginStatement(audience) : null;
|
|
58923
58994
|
const message = {
|
|
58995
|
+
...statement ? { statement } : {},
|
|
58924
58996
|
address,
|
|
58925
58997
|
issuedAt: reuse?.issuedAt ?? Math.floor(Date.now() / 1e3),
|
|
58926
58998
|
nonce: reuse?.nonce ?? (0, import_ethers18.hexlify)((0, import_ethers18.randomBytes)(32)),
|
|
@@ -58928,7 +59000,7 @@ async function buildSignedLoginPayload(signer, chainId, audience, reuse) {
|
|
|
58928
59000
|
};
|
|
58929
59001
|
const signature = await signer.signTypedData(
|
|
58930
59002
|
buildLoginDomain(chainId),
|
|
58931
|
-
audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
|
|
59003
|
+
statement ? LOGIN_TYPES_WITH_STATEMENT : audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
|
|
58932
59004
|
message
|
|
58933
59005
|
);
|
|
58934
59006
|
return { chainId, message, signature };
|
|
@@ -59097,6 +59169,8 @@ var ServerSession = class {
|
|
|
59097
59169
|
signer;
|
|
59098
59170
|
serviceEndpoint;
|
|
59099
59171
|
loginAudience;
|
|
59172
|
+
/** Whether this session's login carries the human-readable statement. */
|
|
59173
|
+
withStatement;
|
|
59100
59174
|
chainId;
|
|
59101
59175
|
store;
|
|
59102
59176
|
onSignaturePrompt;
|
|
@@ -59138,6 +59212,13 @@ var ServerSession = class {
|
|
|
59138
59212
|
/\/+$/,
|
|
59139
59213
|
""
|
|
59140
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
|
+
}
|
|
59141
59222
|
this.chainId = opts.chainId;
|
|
59142
59223
|
this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
|
|
59143
59224
|
this.onSignaturePrompt = opts.onSignaturePrompt;
|
|
@@ -59391,12 +59472,16 @@ var ServerSession = class {
|
|
|
59391
59472
|
this.signer,
|
|
59392
59473
|
this.chainId,
|
|
59393
59474
|
this.loginAudience,
|
|
59394
|
-
reuse
|
|
59475
|
+
reuse,
|
|
59476
|
+
reuse ? reuse.withStatement === true : this.withStatement
|
|
59395
59477
|
);
|
|
59396
59478
|
if (storeKey && !reuse) {
|
|
59397
59479
|
store.savePending?.(storeKey, {
|
|
59398
59480
|
issuedAt: payload.message.issuedAt,
|
|
59399
|
-
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
|
|
59400
59485
|
});
|
|
59401
59486
|
}
|
|
59402
59487
|
session = await this.login(payload);
|
|
@@ -71607,6 +71692,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
71607
71692
|
signer: config.authSigner ?? config.contractSigner,
|
|
71608
71693
|
serviceEndpoint: config.serviceEndpoint,
|
|
71609
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,
|
|
71610
71698
|
chainId: config.chainId,
|
|
71611
71699
|
persistSession: config.sessionPersistence?.enabled,
|
|
71612
71700
|
sessionStore: config.sessionPersistence?.store,
|
|
@@ -80452,7 +80540,33 @@ function buildWriteOps(deps) {
|
|
|
80452
80540
|
kind: "unavailable",
|
|
80453
80541
|
source: SOURCE5,
|
|
80454
80542
|
message: "recoverStaleSpend is not wired in this delivery (permissionless recovery \u2014 planned follow-up)."
|
|
80455
|
-
})
|
|
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
|
+
}
|
|
80456
80570
|
};
|
|
80457
80571
|
}
|
|
80458
80572
|
|
|
@@ -80977,7 +81091,8 @@ var RealUpstreamPlugin = class {
|
|
|
80977
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."
|
|
80978
81092
|
})
|
|
80979
81093
|
),
|
|
80980
|
-
recoverStaleSpend: () => readOnly("recoverStaleSpend")
|
|
81094
|
+
recoverStaleSpend: () => readOnly("recoverStaleSpend"),
|
|
81095
|
+
retryWithdrawExecute: () => readOnly("retryWithdrawExecute")
|
|
80981
81096
|
};
|
|
80982
81097
|
}
|
|
80983
81098
|
}
|
|
@@ -81145,7 +81260,8 @@ var RealUpstreamPlugin = class {
|
|
|
81145
81260
|
psmSwap: call("psmSwap"),
|
|
81146
81261
|
delegationSetup: call("delegationSetup"),
|
|
81147
81262
|
delegationGrant: call("delegationGrant"),
|
|
81148
|
-
recoverStaleSpend: call("recoverStaleSpend")
|
|
81263
|
+
recoverStaleSpend: call("recoverStaleSpend"),
|
|
81264
|
+
retryWithdrawExecute: call("retryWithdrawExecute")
|
|
81149
81265
|
};
|
|
81150
81266
|
}
|
|
81151
81267
|
async resolveOpsGateway() {
|
|
@@ -81956,6 +82072,9 @@ function wcDeclineOrFault(e) {
|
|
|
81956
82072
|
}
|
|
81957
82073
|
var SignatureBridge = class {
|
|
81958
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;
|
|
81959
82078
|
expiryMs;
|
|
81960
82079
|
/** Plan 17 E2: single-decision concurrency cap (null = unbounded, the loopback tier). */
|
|
81961
82080
|
maxPending;
|
|
@@ -81991,6 +82110,7 @@ var SignatureBridge = class {
|
|
|
81991
82110
|
unlockSession = null;
|
|
81992
82111
|
constructor(opts) {
|
|
81993
82112
|
this.clock = opts?.clock ?? Date.now;
|
|
82113
|
+
this.boundAccount = opts?.boundAccount?.toLowerCase();
|
|
81994
82114
|
this.expiryMs = opts?.expiryMs ?? DEFAULT_EXPIRY_MS;
|
|
81995
82115
|
this.maxPending = opts?.maxPending ?? null;
|
|
81996
82116
|
this.attachGraceMs = opts?.attachGraceMs ?? (opts?.mount ? DEFAULT_HOSTED_ATTACH_GRACE_MS : DEFAULT_ATTACH_GRACE_MS);
|
|
@@ -82360,6 +82480,14 @@ var SignatureBridge = class {
|
|
|
82360
82480
|
});
|
|
82361
82481
|
this.wcTransport = await factory2(this.wcConfig);
|
|
82362
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
|
+
}
|
|
82363
82491
|
this.wcActive = info !== null;
|
|
82364
82492
|
this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
|
|
82365
82493
|
if (info === null) {
|
|
@@ -82457,10 +82585,36 @@ var SignatureBridge = class {
|
|
|
82457
82585
|
this.deny(res, 400, "hello requires account (0x address) and integer chainId");
|
|
82458
82586
|
return;
|
|
82459
82587
|
}
|
|
82588
|
+
const refusal = this.accountRefusal(account);
|
|
82589
|
+
if (refusal) {
|
|
82590
|
+
this.deny(res, 403, refusal);
|
|
82591
|
+
return;
|
|
82592
|
+
}
|
|
82460
82593
|
session.wallet = { account, chainId };
|
|
82461
82594
|
this.wallet = { account, chainId };
|
|
82462
82595
|
this.ok(res);
|
|
82463
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
|
+
}
|
|
82464
82618
|
/** accountsChanged / chainChanged: a wallet-state CHANGE mid-request invalidates every
|
|
82465
82619
|
* pending request — what the human saw approved is no longer what would sign. Wallets
|
|
82466
82620
|
* also deliver late no-op echoes of these events; an unchanged state invalidates nothing. */
|
|
@@ -82470,7 +82624,9 @@ var SignatureBridge = class {
|
|
|
82470
82624
|
const account = String(body["account"] ?? "");
|
|
82471
82625
|
const chainId = Number(body["chainId"]);
|
|
82472
82626
|
const prev = session.wallet;
|
|
82473
|
-
|
|
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;
|
|
82474
82630
|
if (this.wallet !== null && prev !== null && this.wallet.account.toLowerCase() === prev.account.toLowerCase()) {
|
|
82475
82631
|
this.wallet = session.wallet;
|
|
82476
82632
|
}
|
|
@@ -82479,7 +82635,7 @@ var SignatureBridge = class {
|
|
|
82479
82635
|
this.ok(res);
|
|
82480
82636
|
return;
|
|
82481
82637
|
}
|
|
82482
|
-
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";
|
|
82483
82639
|
for (const entry of this.pending.values()) {
|
|
82484
82640
|
if (!entry.settled && !entry.collect) this.settle(entry, { status: "invalidated", reason });
|
|
82485
82641
|
}
|
|
@@ -82789,6 +82945,11 @@ async function createRealBoundary(config, wallet, overrides) {
|
|
|
82789
82945
|
// tenant — one bridge per tenant world, so the bridge cap IS the tenant cap. The
|
|
82790
82946
|
// loopback tier keeps its unbounded pending (multi-owner Safe pages need it).
|
|
82791
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 } : {},
|
|
82792
82953
|
// M12-12: no unlock closures without a provider — the unlock endpoints answer with
|
|
82793
82954
|
// their loud not-wired refusal instead of ever touching key material.
|
|
82794
82955
|
...keystore ? {
|
|
@@ -83065,6 +83226,32 @@ function offers(d, mode) {
|
|
|
83065
83226
|
function signerModeSourceClause(d) {
|
|
83066
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`";
|
|
83067
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
|
+
}
|
|
83068
83255
|
var LOCAL_GUIDE_DEPLOYMENT = {
|
|
83069
83256
|
tier: "local",
|
|
83070
83257
|
networks: ["sepolia", "mainnet"],
|
|
@@ -83072,7 +83259,13 @@ var LOCAL_GUIDE_DEPLOYMENT = {
|
|
|
83072
83259
|
// external+keystore and the mock sandbox adds the practice ceremonies, so the guide may
|
|
83073
83260
|
// speak the full vocabulary and let the existing adapter prose ("PRACTICE-ONLY today —
|
|
83074
83261
|
// on the real adapter these modes refuse") carry the narrower adapter axis.
|
|
83075
|
-
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
|
|
83076
83269
|
};
|
|
83077
83270
|
function servedNetworks(d) {
|
|
83078
83271
|
if (d.networks.length === 0) throw new Error("guide: a deployment must serve at least one network");
|
|
@@ -83244,7 +83437,7 @@ function keystoreAbsenceBullet() {
|
|
|
83244
83437
|
never ask for a password.`;
|
|
83245
83438
|
}
|
|
83246
83439
|
var GUIDE_TOPIC_SOURCES = {
|
|
83247
|
-
"getting-started": `# Diamond Hands \u2014 what this is
|
|
83440
|
+
"getting-started": (d) => `# Diamond Hands \u2014 what this is
|
|
83248
83441
|
|
|
83249
83442
|
Diamond Hands lets you BORROW a dollar-pegged token (UCD) against your own BITCOIN,
|
|
83250
83443
|
without selling it. Your BTC sits in a custody vault tied to your position; you mint UCD
|
|
@@ -83252,14 +83445,9 @@ against it, pay it back whenever you like, and take your BTC out again.
|
|
|
83252
83445
|
|
|
83253
83446
|
**Agent instructions:** answer in the USER'S language, map their words via the \`glossary\`
|
|
83254
83447
|
topic, and always say plainly whether this session is PRACTICE or REAL MONEY. Read the
|
|
83255
|
-
\`capabilities\` block in \`boundary://info\` FIRST \u2014 it states the network,
|
|
83256
|
-
|
|
83257
|
-
|
|
83258
|
-
- Adapter \`mock\` \u2014 a PRACTICE sandbox. No real money anywhere.
|
|
83259
|
-
- Adapter \`real\` on SEPOLIA (the zero-config default) \u2014 the REAL protocol contracts on
|
|
83260
|
-
the test network: real ceremonies and signatures, PRACTICE money (test funds).
|
|
83261
|
-
- Adapter \`real\` on MAINNET \u2014 REAL MONEY. Writes are disabled unless the operator
|
|
83262
|
-
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)}
|
|
83263
83451
|
SAY THIS EARLY AND UNPROMPTED \u2014 users must never wonder whether money is real.
|
|
83264
83452
|
|
|
83265
83453
|
A first conversation usually goes: explain this page \u2192 \`guide first-setup\` (choose how to
|
|
@@ -83284,8 +83472,8 @@ signer modes exist; current terms (\`protocol_terms\`).
|
|
|
83284
83472
|
**2. Choose HOW to authorize operations** (the user's choice, made by talking):
|
|
83285
83473
|
- **"Use my own wallet"** \u2192 call \`signer_setup\` action \`use\`, mode \`external\` \u2014 works
|
|
83286
83474
|
on the real adapter and the mock. The approval page auto-opens in the browser (its URL
|
|
83287
|
-
is ALSO in the tool result); the user connects MetaMask \u2014
|
|
83288
|
-
|
|
83475
|
+
is ALSO in the tool result); the user connects MetaMask \u2014 ${phoneWalletOffer(d)} \u2014 and
|
|
83476
|
+
then APPROVES EACH OPERATION in
|
|
83289
83477
|
their own wallet. The first verified signature binds their wallet address as the
|
|
83290
83478
|
borrower. Full walkthrough: \`guide connect-wallet\`.
|
|
83291
83479
|
${offers(d, "keystore") ? `- **"Sign automatically / no popups"** \u2192 mode \`keystore\`. A local encrypted keystore
|
|
@@ -83316,14 +83504,13 @@ The user can switch authorization modes at ANY time by saying so \u2014 repeat s
|
|
|
83316
83504
|
"connect-wallet": (d) => `# Connect your wallet \u2014 the external-signer walkthrough
|
|
83317
83505
|
|
|
83318
83506
|
External mode means the user approves every operation in their OWN wallet \u2014 a browser
|
|
83319
|
-
extension (MetaMask) or a WalletConnect mobile wallet. It works
|
|
83320
|
-
the mock.
|
|
83507
|
+
extension (MetaMask)${d.walletConnect ? " or a WalletConnect mobile wallet" : ""}. It works
|
|
83508
|
+
on the real adapter and the mock.
|
|
83321
83509
|
|
|
83322
83510
|
**The walkthrough:**
|
|
83323
83511
|
1. \`signer_setup\` action \`use\`, mode \`external\`. The approval page auto-opens in the
|
|
83324
83512
|
desktop browser; ${approvalPageLocation(d)}
|
|
83325
|
-
2. On the page: connect the browser extension, or \u2014 for a mobile wallet \u2014 scan the
|
|
83326
|
-
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) + "."}
|
|
83327
83514
|
3. For authenticated reads before any write: \`signer_setup\` action \`connect\` runs the
|
|
83328
83515
|
login ceremony explicitly (one typed-data signature in the wallet).
|
|
83329
83516
|
4. The FIRST verified signature binds that wallet address as the borrower \u2014 it persists
|
|
@@ -83404,6 +83591,13 @@ Connections / Connected sites).`,
|
|
|
83404
83591
|
6. **Withdraw BTC** \u2014 \`loan_withdraw {positionId, btcAddress, amountSats, confirmed:true}\`.
|
|
83405
83592
|
BTC sends are IRREVERSIBLE \u2014 read the address back to the user before confirming.
|
|
83406
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.
|
|
83407
83601
|
7. **Watch it** \u2014 \`position_status\` (one), \`position_list\` (all),
|
|
83408
83602
|
\`position_events\` (history), \`btc_price\`, \`protocol_status\`.
|
|
83409
83603
|
|
|
@@ -83666,8 +83860,7 @@ ${connectorStatusTruth(d)}
|
|
|
83666
83860
|
**What it is:** instead of installing anything, the user adds Diamond Hands to
|
|
83667
83861
|
claude.ai as a connector (paste a URL \u2014 zero install, zero Node, zero config files).
|
|
83668
83862
|
Sign-in IS the wallet: one Sign-In-with-Ethereum signature proves address ownership \u2014
|
|
83669
|
-
no password, no email, no account beyond the wallet address. The sign-in
|
|
83670
|
-
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) + "."}
|
|
83671
83864
|
|
|
83672
83865
|
**Signature cadence, plainly:** the FIRST connect costs one SIWE signature (sign-in)
|
|
83673
83866
|
plus one lit-ops login signature (read access). After that, every operation that moves
|
|
@@ -83688,17 +83881,19 @@ honestly when asked "is this safe"):
|
|
|
83688
83881
|
is never written to disk. A breach here is privacy-class, never money-class.
|
|
83689
83882
|
3. **What the assistant narrates.** Tool results shape what the assistant tells you \u2014
|
|
83690
83883
|
a security concern is filed and audited for exactly this channel.
|
|
83691
|
-
4. **Tenant separation
|
|
83692
|
-
gets its own world: its own boundary, its own signer state, its own
|
|
83693
|
-
mount, keyed by that address.
|
|
83694
|
-
|
|
83695
|
-
|
|
83696
|
-
|
|
83697
|
-
|
|
83698
|
-
|
|
83699
|
-
|
|
83700
|
-
|
|
83701
|
-
|
|
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.
|
|
83702
83897
|
5. **Availability and deploy honesty.** Hosted code changes under you: deploys are
|
|
83703
83898
|
version-pinned, the page bundle is open-source, and \`boundary://info\` capabilities
|
|
83704
83899
|
reports the exact server version.
|
|
@@ -83885,11 +84080,17 @@ function createNetworkSwitchRuntime(opts) {
|
|
|
83885
84080
|
}
|
|
83886
84081
|
};
|
|
83887
84082
|
}
|
|
83888
|
-
function guideDeployment(overrides) {
|
|
84083
|
+
function guideDeployment(overrides, env) {
|
|
83889
84084
|
return {
|
|
83890
84085
|
tier: overrides?.bridgeMount ? "hosted" : "local",
|
|
83891
84086
|
networks: overrides?.allowedNetworks ?? LOCAL_GUIDE_DEPLOYMENT.networks,
|
|
83892
|
-
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"])
|
|
83893
84094
|
};
|
|
83894
84095
|
}
|
|
83895
84096
|
function assembleWorld(opts) {
|
|
@@ -83899,7 +84100,7 @@ function assembleWorld(opts) {
|
|
|
83899
84100
|
...boot.mockControl ? { mockControl: boot.mockControl } : {},
|
|
83900
84101
|
...boot.signer ? { signer: boot.signer } : {},
|
|
83901
84102
|
...opts.overrides?.externalOnly ? { externalOnly: true } : {},
|
|
83902
|
-
deployment: guideDeployment(opts.overrides),
|
|
84103
|
+
deployment: guideDeployment(opts.overrides, opts.env),
|
|
83903
84104
|
...opts.configResult.ok && opts.configResult.config.adapter === "mock" && opts.configResult.config.chainId ? { chainId: opts.configResult.config.chainId } : {}
|
|
83904
84105
|
};
|
|
83905
84106
|
if ((opts.env["DH_ADAPTER"] ?? "real") !== "mock") {
|
|
@@ -84211,6 +84412,32 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
84211
84412
|
return renderEnvelope(await b.boundary.withdrawBtc({ positionId, btcAddress: btcAddress2, amountSats, networkFeeSats }));
|
|
84212
84413
|
})
|
|
84213
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
|
+
);
|
|
84214
84441
|
registerBoundaryTool(
|
|
84215
84442
|
server,
|
|
84216
84443
|
"loan_allowlist_destination",
|
|
@@ -84236,7 +84463,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
84236
84463
|
"loan_delegation_setup",
|
|
84237
84464
|
{
|
|
84238
84465
|
title: "Install delegation on the Safe (one owner ceremony)",
|
|
84239
|
-
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).`,
|
|
84240
84467
|
inputSchema: {
|
|
84241
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)"),
|
|
84242
84469
|
confirmed: confirmedSchema
|
|
@@ -84256,7 +84483,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
84256
84483
|
"loan_delegation_grant",
|
|
84257
84484
|
{
|
|
84258
84485
|
title: "Grant the agent per-position scopes (owners sign)",
|
|
84259
|
-
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).`,
|
|
84260
84487
|
inputSchema: {
|
|
84261
84488
|
positionId: positionIdSchema,
|
|
84262
84489
|
renew: import_zod.z.boolean().optional().describe("Allow the agent to extend/renew this position"),
|
|
@@ -84286,7 +84513,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
84286
84513
|
"loan_recover_stale_spend",
|
|
84287
84514
|
{
|
|
84288
84515
|
title: "Recover a stale BTC reservation via LIT-attested proof",
|
|
84289
|
-
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.",
|
|
84290
84517
|
inputSchema: {
|
|
84291
84518
|
positionId: positionIdSchema,
|
|
84292
84519
|
utxoTxid: import_zod.z.string().describe("The original authorized UTXO's txid"),
|
|
@@ -85285,6 +85512,12 @@ function composeConnector(opts, rawPublicOrigin) {
|
|
|
85285
85512
|
const overrides = {
|
|
85286
85513
|
externalOnly: true,
|
|
85287
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,
|
|
85288
85521
|
bridgeMount: () => ({ baseUrl: `${publicOrigin}/approval/${mountId}`, origin: publicOrigin }),
|
|
85289
85522
|
signerPersistence: (network) => {
|
|
85290
85523
|
let s = stores.get(network);
|