@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-embed.js
CHANGED
|
@@ -41036,7 +41036,7 @@ function htmlPageSecurityHeaders(extra) {
|
|
|
41036
41036
|
}
|
|
41037
41037
|
|
|
41038
41038
|
// src/version.ts
|
|
41039
|
-
var SERVER_VERSION = "0.5.
|
|
41039
|
+
var SERVER_VERSION = "0.5.13";
|
|
41040
41040
|
|
|
41041
41041
|
// src/connector/siwe-oauth.ts
|
|
41042
41042
|
var import_node_crypto2 = require("crypto");
|
|
@@ -42489,6 +42489,19 @@ var BoundaryCore = class {
|
|
|
42489
42489
|
if (!r.ok) return errEnvelope(failureToError(r.failure));
|
|
42490
42490
|
return okEnvelope({ releasedSats: r.value.releasedSats }, r.source);
|
|
42491
42491
|
}
|
|
42492
|
+
/** C-46. Unlike `recoverStaleSpend` this is NOT permissionless: re-running phase 2 signs
|
|
42493
|
+
* for the vault, so it takes the same borrower gate every fund-moving op takes. */
|
|
42494
|
+
async retryWithdrawExecute(p) {
|
|
42495
|
+
const auth = await this.requireBorrower();
|
|
42496
|
+
if (!auth.ok) return errEnvelope(auth.error);
|
|
42497
|
+
const r = await this.deps.plugin.ops.retryWithdrawExecute({
|
|
42498
|
+
positionId: p.positionId,
|
|
42499
|
+
networkFeeSats: p.networkFeeSats,
|
|
42500
|
+
borrower: auth.borrower
|
|
42501
|
+
});
|
|
42502
|
+
if (!r.ok) return errEnvelope(failureToError(r.failure));
|
|
42503
|
+
return okEnvelope({ attempted: r.value.attempted, transfers: r.value.transfers }, r.source);
|
|
42504
|
+
}
|
|
42492
42505
|
// ---- meta ----
|
|
42493
42506
|
world() {
|
|
42494
42507
|
return {
|
|
@@ -43312,6 +43325,42 @@ var World = class {
|
|
|
43312
43325
|
c.authorizedSpends.splice(idx, 1);
|
|
43313
43326
|
return { ok: true, value: { releasedSats: spend.satoshis } };
|
|
43314
43327
|
}
|
|
43328
|
+
/**
|
|
43329
|
+
* C-46: re-run the withdrawal EXECUTE leg for reservations whose coins have not been
|
|
43330
|
+
* observed moving (`consumed === null`). This is the stranded shape: phase 1 committed
|
|
43331
|
+
* the reservation, phase 2's quantum-stamped signature expired, and the outpoint was
|
|
43332
|
+
* never spent.
|
|
43333
|
+
*
|
|
43334
|
+
* The retry BROADCASTS; it does not observe. `consumed` therefore stays null — that flag
|
|
43335
|
+
* means "seen consumed on Bitcoin", and only MockControl.confirmSpendConsumed (standing
|
|
43336
|
+
* in for the chain) may set it. Conflating the two would let a retry release collateral
|
|
43337
|
+
* against a transaction no one has confirmed, which is the mistake the whole
|
|
43338
|
+
* proof-of-consumption design exists to prevent. So a retry leaves the reservation
|
|
43339
|
+
* holding its balance exactly as before; what it produces is the txid that can LATER
|
|
43340
|
+
* become the invalidator — the proof the stranded state could never generate for itself.
|
|
43341
|
+
*/
|
|
43342
|
+
retryWithdrawExecute(p) {
|
|
43343
|
+
const paused = this.pausedReason();
|
|
43344
|
+
if (paused) return { ok: false, reason: paused };
|
|
43345
|
+
const pos = this.state.positions[p.positionId];
|
|
43346
|
+
if (!pos) return { ok: false, reason: `position ${p.positionId} does not exist` };
|
|
43347
|
+
if (pos.borrower.toLowerCase() !== p.borrower.toLowerCase()) {
|
|
43348
|
+
return { ok: false, reason: `caller ${p.borrower} is not the borrower of this position` };
|
|
43349
|
+
}
|
|
43350
|
+
const c = this.state.collateral[p.positionId];
|
|
43351
|
+
const pending = (c?.authorizedSpends ?? []).filter((s) => s.consumed === null);
|
|
43352
|
+
const transfers = pending.map((spend) => {
|
|
43353
|
+
const { hash: txid } = this.nextId("btc-withdraw-retry");
|
|
43354
|
+
return {
|
|
43355
|
+
utxoIdentifier: `${spend.txid}:${spend.vout}`,
|
|
43356
|
+
ok: true,
|
|
43357
|
+
txid,
|
|
43358
|
+
amountSentSats: spend.satoshis,
|
|
43359
|
+
destination: spend.targetAddress
|
|
43360
|
+
};
|
|
43361
|
+
});
|
|
43362
|
+
return { ok: true, value: { attempted: transfers.length, transfers } };
|
|
43363
|
+
}
|
|
43315
43364
|
// ---- Mock Safes (plan 06): REAL verification semantics, no fakes (M6-21/27) ----
|
|
43316
43365
|
safesMap() {
|
|
43317
43366
|
return this.state.safes;
|
|
@@ -44506,6 +44555,11 @@ var MockUpstreamPlugin = class {
|
|
|
44506
44555
|
const r = this.world.recoverStaleSpend(p);
|
|
44507
44556
|
if (!r.ok) return this.rejected("recoverStaleSpend", r.reason);
|
|
44508
44557
|
return upOk({ txRef: this.world.nextTxRef(), releasedSats: r.value.releasedSats }, this.src("mock-ops"));
|
|
44558
|
+
}),
|
|
44559
|
+
retryWithdrawExecute: (p) => this.write("retryWithdrawExecute", () => {
|
|
44560
|
+
const r = this.world.retryWithdrawExecute({ positionId: p.positionId, borrower: p.borrower });
|
|
44561
|
+
if (!r.ok) return this.rejected("retryWithdrawExecute", r.reason);
|
|
44562
|
+
return upOk({ attempted: r.value.attempted, transfers: r.value.transfers }, this.src("mock-ops"));
|
|
44509
44563
|
})
|
|
44510
44564
|
};
|
|
44511
44565
|
}
|
|
@@ -52745,13 +52799,13 @@ var init_deployment_addresses = __esm2({
|
|
|
52745
52799
|
block: 25472956
|
|
52746
52800
|
},
|
|
52747
52801
|
BTCSpendAuthorizer: {
|
|
52748
|
-
previousImplementation: "
|
|
52749
|
-
newImplementation: "
|
|
52750
|
-
upgradedAt: "2026-
|
|
52751
|
-
upgradedBy: "AdminModule
|
|
52752
|
-
reason: "
|
|
52753
|
-
executeTx: "
|
|
52754
|
-
block:
|
|
52802
|
+
previousImplementation: "0x40c9e8C46C65E0A57BB63da5368868A9E8Df81A5",
|
|
52803
|
+
newImplementation: "0x00D7a47798E8ff169104b748131703B78f23390C",
|
|
52804
|
+
upgradedAt: "2026-09-09T12:05:35.000Z",
|
|
52805
|
+
upgradedBy: "AdminModule generic op 0xc0214ff38bb454864a34f6482dcd03570b3fd04171c84be2c20184afb1a2e161 (bsa-1-7-0 ceremony: proposed by seat 0x3030C0414B6d95aA9d5A57269E51a347fCBaB472 2026-09-08T11:35:23Z, 3/3 seat signatures, 24h timelock); executeGenericAdminOperation sent by 0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6 in tx 0x77cd231966c546177bd8f1a07bd4e705afd5c2dfbd110b096836401679c0c69c (block 25939703)",
|
|
52806
|
+
reason: "BTCSpendAuthorizer 1.6.0 -> 1.7.0: allow a full-vault sweep (targetAmount == satoshis); TargetMustLeaveFeeRoom -> TargetExceedsInputValue (PR #849; mainnet incidents 2026-09-04 and 2026-09-07). Impl deployed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f at nonce 430 from source 0a7c535a1 (contracts/src identical to main 99b335f77). Cross-ref onchain-auth/.safe-batches/mainnet-bsa-1-7-0-{propose,sign,execute}.json and docs/mainnet-bsa-1-7-0-ceremony-2026-09-08.md",
|
|
52807
|
+
executeTx: "0x77cd231966c546177bd8f1a07bd4e705afd5c2dfbd110b096836401679c0c69c",
|
|
52808
|
+
block: 25939703
|
|
52755
52809
|
},
|
|
52756
52810
|
PositionManager: {
|
|
52757
52811
|
previousImplementation: "0x600Dc0D1C2c0F94882B6Bc09172f8650047Ad5B1",
|
|
@@ -52854,7 +52908,7 @@ var init_deployment_addresses = __esm2({
|
|
|
52854
52908
|
ADMIN_MODULE: "0x0023B71B586795eE5fa4E83E384345C1EC8Bb946",
|
|
52855
52909
|
ADMIN_MODULE_IMPL: "0xb4C5C7E051A1e672F014B25CB5D55B225Aa0D512",
|
|
52856
52910
|
BTC_SPEND_AUTHORIZER: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
52857
|
-
BTC_SPEND_AUTHORIZER_IMPL: "
|
|
52911
|
+
BTC_SPEND_AUTHORIZER_IMPL: "0x00D7a47798E8ff169104b748131703B78f23390C",
|
|
52858
52912
|
POSITION_MANAGER_VIEWS: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
|
|
52859
52913
|
POSITION_MANAGER_VIEWS_IMPL: "0xE68DC096A65Ecddbc6A9b5c6e5f878e2CE143Bfe",
|
|
52860
52914
|
POSITION_MANAGER: "0x12A1836e56139ccaD8722B89519d84233efc224B",
|
|
@@ -58924,9 +58978,27 @@ var LOGIN_TYPES_WITH_AUDIENCE2 = {
|
|
|
58924
58978
|
{ name: "audience", type: "string" }
|
|
58925
58979
|
]
|
|
58926
58980
|
};
|
|
58927
|
-
|
|
58981
|
+
var LOGIN_TYPES_WITH_STATEMENT = {
|
|
58982
|
+
DiamondHands: [
|
|
58983
|
+
{ name: "statement", type: "string" },
|
|
58984
|
+
{ name: "address", type: "address" },
|
|
58985
|
+
{ name: "issuedAt", type: "uint256" },
|
|
58986
|
+
{ name: "nonce", type: "bytes32" },
|
|
58987
|
+
{ name: "audience", type: "string" }
|
|
58988
|
+
]
|
|
58989
|
+
};
|
|
58990
|
+
var LOGIN_STATEMENT_TEMPLATE = "{host} is verifying you own this wallet. Signing proves control of the address so we can show your loans and positions. It authorizes no transaction, moves no funds, and costs no gas.";
|
|
58991
|
+
function canonicalLoginStatement(audience) {
|
|
58992
|
+
const host = /^https?:\/\/([^/?#]+)/i.exec(audience)?.[1];
|
|
58993
|
+
if (!host)
|
|
58994
|
+
return null;
|
|
58995
|
+
return LOGIN_STATEMENT_TEMPLATE.replace("{host}", host);
|
|
58996
|
+
}
|
|
58997
|
+
async function buildSignedLoginPayload(signer, chainId, audience, reuse, withStatement = false) {
|
|
58928
58998
|
const address = await signer.getAddress();
|
|
58999
|
+
const statement = withStatement && audience ? canonicalLoginStatement(audience) : null;
|
|
58929
59000
|
const message = {
|
|
59001
|
+
...statement ? { statement } : {},
|
|
58930
59002
|
address,
|
|
58931
59003
|
issuedAt: reuse?.issuedAt ?? Math.floor(Date.now() / 1e3),
|
|
58932
59004
|
nonce: reuse?.nonce ?? (0, import_ethers18.hexlify)((0, import_ethers18.randomBytes)(32)),
|
|
@@ -58934,7 +59006,7 @@ async function buildSignedLoginPayload(signer, chainId, audience, reuse) {
|
|
|
58934
59006
|
};
|
|
58935
59007
|
const signature = await signer.signTypedData(
|
|
58936
59008
|
buildLoginDomain(chainId),
|
|
58937
|
-
audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
|
|
59009
|
+
statement ? LOGIN_TYPES_WITH_STATEMENT : audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
|
|
58938
59010
|
message
|
|
58939
59011
|
);
|
|
58940
59012
|
return { chainId, message, signature };
|
|
@@ -59103,6 +59175,8 @@ var ServerSession = class {
|
|
|
59103
59175
|
signer;
|
|
59104
59176
|
serviceEndpoint;
|
|
59105
59177
|
loginAudience;
|
|
59178
|
+
/** Whether this session's login carries the human-readable statement. */
|
|
59179
|
+
withStatement;
|
|
59106
59180
|
chainId;
|
|
59107
59181
|
store;
|
|
59108
59182
|
onSignaturePrompt;
|
|
@@ -59144,6 +59218,13 @@ var ServerSession = class {
|
|
|
59144
59218
|
/\/+$/,
|
|
59145
59219
|
""
|
|
59146
59220
|
);
|
|
59221
|
+
const explicitAudience = typeof opts.loginAudience === "string" && opts.loginAudience.length > 0;
|
|
59222
|
+
this.withStatement = opts.withStatement === true && explicitAudience;
|
|
59223
|
+
if (opts.withStatement === true && !explicitAudience) {
|
|
59224
|
+
console.warn(
|
|
59225
|
+
"[dh-sdk] withStatement ignored: it requires an explicit loginAudience, since the servers rebuild the expected sentence from the audience host"
|
|
59226
|
+
);
|
|
59227
|
+
}
|
|
59147
59228
|
this.chainId = opts.chainId;
|
|
59148
59229
|
this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
|
|
59149
59230
|
this.onSignaturePrompt = opts.onSignaturePrompt;
|
|
@@ -59397,12 +59478,16 @@ var ServerSession = class {
|
|
|
59397
59478
|
this.signer,
|
|
59398
59479
|
this.chainId,
|
|
59399
59480
|
this.loginAudience,
|
|
59400
|
-
reuse
|
|
59481
|
+
reuse,
|
|
59482
|
+
reuse ? reuse.withStatement === true : this.withStatement
|
|
59401
59483
|
);
|
|
59402
59484
|
if (storeKey && !reuse) {
|
|
59403
59485
|
store.savePending?.(storeKey, {
|
|
59404
59486
|
issuedAt: payload.message.issuedAt,
|
|
59405
|
-
nonce: payload.message.nonce
|
|
59487
|
+
nonce: payload.message.nonce,
|
|
59488
|
+
// Recorded so a resume reproduces this digest even if the
|
|
59489
|
+
// capability flag changes before the owners finish signing.
|
|
59490
|
+
withStatement: this.withStatement
|
|
59406
59491
|
});
|
|
59407
59492
|
}
|
|
59408
59493
|
session = await this.login(payload);
|
|
@@ -71613,6 +71698,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
71613
71698
|
signer: config.authSigner ?? config.contractSigner,
|
|
71614
71699
|
serviceEndpoint: config.serviceEndpoint,
|
|
71615
71700
|
loginAudience: config.loginAudience,
|
|
71701
|
+
// Only meaningful alongside an audience; the servers derive the expected
|
|
71702
|
+
// sentence from its host. Defaults off so Node callers are untouched.
|
|
71703
|
+
withStatement: config.loginStatement === true,
|
|
71616
71704
|
chainId: config.chainId,
|
|
71617
71705
|
persistSession: config.sessionPersistence?.enabled,
|
|
71618
71706
|
sessionStore: config.sessionPersistence?.store,
|
|
@@ -80458,7 +80546,33 @@ function buildWriteOps(deps) {
|
|
|
80458
80546
|
kind: "unavailable",
|
|
80459
80547
|
source: SOURCE5,
|
|
80460
80548
|
message: "recoverStaleSpend is not wired in this delivery (permissionless recovery \u2014 planned follow-up)."
|
|
80461
|
-
})
|
|
80549
|
+
}),
|
|
80550
|
+
retryWithdrawExecute: async (p) => {
|
|
80551
|
+
const sdk = deps.getWriteSdk();
|
|
80552
|
+
if (!sdk) return upFail({ kind: "unavailable", source: SOURCE5, message: "write SDK is not initialized (its boot-time construction failed)" });
|
|
80553
|
+
let rows;
|
|
80554
|
+
try {
|
|
80555
|
+
rows = await sdk.executePendingBtcTransfers(p.positionId, p.networkFeeSats);
|
|
80556
|
+
} catch (e) {
|
|
80557
|
+
return failed("retryWithdrawExecute", e);
|
|
80558
|
+
}
|
|
80559
|
+
const gate = rows.find((r) => !r.success && !r.utxoIdentifier);
|
|
80560
|
+
if (gate) return declined("retryWithdrawExecute", gate.error ?? "pending-transfer execution refused before any reservation was attempted");
|
|
80561
|
+
return upOk(
|
|
80562
|
+
{
|
|
80563
|
+
attempted: rows.length,
|
|
80564
|
+
transfers: rows.map((r) => ({
|
|
80565
|
+
utxoIdentifier: r.utxoIdentifier ?? "",
|
|
80566
|
+
ok: r.success,
|
|
80567
|
+
...r.txid ? { txid: r.txid } : {},
|
|
80568
|
+
...r.amountSent !== void 0 ? { amountSentSats: String(r.amountSent) } : {},
|
|
80569
|
+
...r.destination ? { destination: r.destination } : {},
|
|
80570
|
+
...r.error ? { error: r.error } : {}
|
|
80571
|
+
}))
|
|
80572
|
+
},
|
|
80573
|
+
{ id: SOURCE5, kind: "lit-ops", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }
|
|
80574
|
+
);
|
|
80575
|
+
}
|
|
80462
80576
|
};
|
|
80463
80577
|
}
|
|
80464
80578
|
|
|
@@ -80983,7 +81097,8 @@ var RealUpstreamPlugin = class {
|
|
|
80983
81097
|
message: "no signer configured \u2014 psmSwap signs two on-chain transactions (exact-amount approve, then swap/redeem) with the keystore signer. Set DH_KEYSTORE_PATH and DH_KEYSTORE_PASSWORD to enable it."
|
|
80984
81098
|
})
|
|
80985
81099
|
),
|
|
80986
|
-
recoverStaleSpend: () => readOnly("recoverStaleSpend")
|
|
81100
|
+
recoverStaleSpend: () => readOnly("recoverStaleSpend"),
|
|
81101
|
+
retryWithdrawExecute: () => readOnly("retryWithdrawExecute")
|
|
80987
81102
|
};
|
|
80988
81103
|
}
|
|
80989
81104
|
}
|
|
@@ -81151,7 +81266,8 @@ var RealUpstreamPlugin = class {
|
|
|
81151
81266
|
psmSwap: call("psmSwap"),
|
|
81152
81267
|
delegationSetup: call("delegationSetup"),
|
|
81153
81268
|
delegationGrant: call("delegationGrant"),
|
|
81154
|
-
recoverStaleSpend: call("recoverStaleSpend")
|
|
81269
|
+
recoverStaleSpend: call("recoverStaleSpend"),
|
|
81270
|
+
retryWithdrawExecute: call("retryWithdrawExecute")
|
|
81155
81271
|
};
|
|
81156
81272
|
}
|
|
81157
81273
|
async resolveOpsGateway() {
|
|
@@ -81962,6 +82078,9 @@ function wcDeclineOrFault(e) {
|
|
|
81962
82078
|
}
|
|
81963
82079
|
var SignatureBridge = class {
|
|
81964
82080
|
clock;
|
|
82081
|
+
/** Lowercased at construction so every comparison is case-flat — EIP-55 checksum casing
|
|
82082
|
+
* differs between what SIWE signs and what a wallet reports for the SAME address. */
|
|
82083
|
+
boundAccount;
|
|
81965
82084
|
expiryMs;
|
|
81966
82085
|
/** Plan 17 E2: single-decision concurrency cap (null = unbounded, the loopback tier). */
|
|
81967
82086
|
maxPending;
|
|
@@ -81997,6 +82116,7 @@ var SignatureBridge = class {
|
|
|
81997
82116
|
unlockSession = null;
|
|
81998
82117
|
constructor(opts) {
|
|
81999
82118
|
this.clock = opts?.clock ?? Date.now;
|
|
82119
|
+
this.boundAccount = opts?.boundAccount?.toLowerCase();
|
|
82000
82120
|
this.expiryMs = opts?.expiryMs ?? DEFAULT_EXPIRY_MS;
|
|
82001
82121
|
this.maxPending = opts?.maxPending ?? null;
|
|
82002
82122
|
this.attachGraceMs = opts?.attachGraceMs ?? (opts?.mount ? DEFAULT_HOSTED_ATTACH_GRACE_MS : DEFAULT_ATTACH_GRACE_MS);
|
|
@@ -82366,6 +82486,14 @@ var SignatureBridge = class {
|
|
|
82366
82486
|
});
|
|
82367
82487
|
this.wcTransport = await factory2(this.wcConfig);
|
|
82368
82488
|
this.wcTransport.onSession((info) => {
|
|
82489
|
+
const refusal = info ? this.accountRefusal(info.account) : null;
|
|
82490
|
+
if (info && refusal) {
|
|
82491
|
+
this.wcActive = false;
|
|
82492
|
+
this.wallet = null;
|
|
82493
|
+
process.stderr.write(`[bridge] WalletConnect session refused \u2014 ${refusal}
|
|
82494
|
+
`);
|
|
82495
|
+
return;
|
|
82496
|
+
}
|
|
82369
82497
|
this.wcActive = info !== null;
|
|
82370
82498
|
this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
|
|
82371
82499
|
if (info === null) {
|
|
@@ -82463,10 +82591,36 @@ var SignatureBridge = class {
|
|
|
82463
82591
|
this.deny(res, 400, "hello requires account (0x address) and integer chainId");
|
|
82464
82592
|
return;
|
|
82465
82593
|
}
|
|
82594
|
+
const refusal = this.accountRefusal(account);
|
|
82595
|
+
if (refusal) {
|
|
82596
|
+
this.deny(res, 403, refusal);
|
|
82597
|
+
return;
|
|
82598
|
+
}
|
|
82466
82599
|
session.wallet = { account, chainId };
|
|
82467
82600
|
this.wallet = { account, chainId };
|
|
82468
82601
|
this.ok(res);
|
|
82469
82602
|
}
|
|
82603
|
+
/** C-47: the single predicate every wallet account is admitted through. There are THREE
|
|
82604
|
+
* doors into the account this bridge will sign with — `hello`, `accountsChanged`, and the
|
|
82605
|
+
* WalletConnect `onSession` callback — and all three call this. The first version of this
|
|
82606
|
+
* fix guarded only the first two while this docstring already claimed to be "the single
|
|
82607
|
+
* place", which is how the WC door survived a green suite: the claim was in prose, not in a
|
|
82608
|
+
* test. T-EXT-BIND-01/02/04 now pin one door each, so adding a fourth writer of
|
|
82609
|
+
* `this.wallet` without coming through here fails a test rather than a review.
|
|
82610
|
+
*
|
|
82611
|
+
* Returns the refusal reason, or
|
|
82612
|
+
* null when the account may be adopted.
|
|
82613
|
+
*
|
|
82614
|
+
* Both addresses are named because the pre-fix failure surfaced much later as an opaque
|
|
82615
|
+
* signature-recovery error (`external-eoa.ts:230-233`) that named neither and read as a
|
|
82616
|
+
* wallet fault. A user with several accounts in one wallet extension hits this by
|
|
82617
|
+
* accident far more often than any attacker does, and "wrong account" is only actionable
|
|
82618
|
+
* if it says WHICH. */
|
|
82619
|
+
accountRefusal(account) {
|
|
82620
|
+
if (!this.boundAccount) return null;
|
|
82621
|
+
if (account.toLowerCase() === this.boundAccount) return null;
|
|
82622
|
+
return `this session is signed in as ${this.boundAccount} but the wallet offered ${account.toLowerCase()} \u2014 the account that signs must be the account that signed in. Switch your wallet to the signed-in account, or start a new session with this one.`;
|
|
82623
|
+
}
|
|
82470
82624
|
/** accountsChanged / chainChanged: a wallet-state CHANGE mid-request invalidates every
|
|
82471
82625
|
* pending request — what the human saw approved is no longer what would sign. Wallets
|
|
82472
82626
|
* also deliver late no-op echoes of these events; an unchanged state invalidates nothing. */
|
|
@@ -82476,7 +82630,9 @@ var SignatureBridge = class {
|
|
|
82476
82630
|
const account = String(body["account"] ?? "");
|
|
82477
82631
|
const chainId = Number(body["chainId"]);
|
|
82478
82632
|
const prev = session.wallet;
|
|
82479
|
-
|
|
82633
|
+
const offered = /^0x[0-9a-fA-F]{40}$/.test(account) && Number.isInteger(chainId) ? { account, chainId } : null;
|
|
82634
|
+
const refusedSwitch = offered !== null && this.accountRefusal(offered.account) !== null;
|
|
82635
|
+
session.wallet = refusedSwitch ? null : offered;
|
|
82480
82636
|
if (this.wallet !== null && prev !== null && this.wallet.account.toLowerCase() === prev.account.toLowerCase()) {
|
|
82481
82637
|
this.wallet = session.wallet;
|
|
82482
82638
|
}
|
|
@@ -82485,7 +82641,7 @@ var SignatureBridge = class {
|
|
|
82485
82641
|
this.ok(res);
|
|
82486
82642
|
return;
|
|
82487
82643
|
}
|
|
82488
|
-
const reason = prev && session.wallet && prev.account.toLowerCase() !== session.wallet.account.toLowerCase() ? "the wallet account changed while approval was pending" : prev && session.wallet && prev.chainId !== session.wallet.chainId ? "the wallet network changed while approval was pending" : "the wallet disconnected while approval was pending";
|
|
82644
|
+
const reason = refusedSwitch ? "the wallet switched to an account this session is not signed in as" : prev && session.wallet && prev.account.toLowerCase() !== session.wallet.account.toLowerCase() ? "the wallet account changed while approval was pending" : prev && session.wallet && prev.chainId !== session.wallet.chainId ? "the wallet network changed while approval was pending" : "the wallet disconnected while approval was pending";
|
|
82489
82645
|
for (const entry of this.pending.values()) {
|
|
82490
82646
|
if (!entry.settled && !entry.collect) this.settle(entry, { status: "invalidated", reason });
|
|
82491
82647
|
}
|
|
@@ -82795,6 +82951,11 @@ async function createRealBoundary(config, wallet, overrides) {
|
|
|
82795
82951
|
// tenant — one bridge per tenant world, so the bridge cap IS the tenant cap. The
|
|
82796
82952
|
// loopback tier keeps its unbounded pending (multi-owner Safe pages need it).
|
|
82797
82953
|
...overrides?.bridgeMount ? { mount: overrides.bridgeMount(config.network), maxPending: 1 } : {},
|
|
82954
|
+
// C-47: the authenticated identity governs the write path. Passed separately from
|
|
82955
|
+
// `bridgeMount` although the hosted tier sets both — they answer different questions
|
|
82956
|
+
// ("where does the page live" vs "whose wallet may sign"), and fusing them would make
|
|
82957
|
+
// an unbound hosted bridge impossible to express in a test.
|
|
82958
|
+
...overrides?.boundBorrower ? { boundAccount: overrides.boundBorrower } : {},
|
|
82798
82959
|
// M12-12: no unlock closures without a provider — the unlock endpoints answer with
|
|
82799
82960
|
// their loud not-wired refusal instead of ever touching key material.
|
|
82800
82961
|
...keystore ? {
|
|
@@ -83071,6 +83232,32 @@ function offers(d, mode) {
|
|
|
83071
83232
|
function signerModeSourceClause(d) {
|
|
83072
83233
|
return offers(d, "keystore") ? "the set `signer_setup` offers. `boundary://info` reports the NARROWER set the active adapter actually constructs under `capabilities.writes.signerModes` (the real adapter builds `external` + `keystore`; the practice ceremonies are mock-adapter only) \u2014 when the two differ, `boundary://info` is authoritative" : "the same set `signer_setup` offers and `boundary://info` reports under `capabilities.writes.signerModes`";
|
|
83073
83234
|
}
|
|
83235
|
+
function phoneWalletOffer(d) {
|
|
83236
|
+
return d.walletConnect ? "or scan the WalletConnect QR (or paste the pairing code) to approve on a phone wallet" : "This deployment does NOT offer the WalletConnect phone-wallet leg \u2014 there is no QR to scan and `/wc-pairing` answers 404; a browser-extension wallet is the only path here";
|
|
83237
|
+
}
|
|
83238
|
+
function moneyTruth(d) {
|
|
83239
|
+
const practice = offers(d, "mock-simulated");
|
|
83240
|
+
const sepolia = d.networks.includes("sepolia");
|
|
83241
|
+
const mainnet = d.networks.includes("mainnet");
|
|
83242
|
+
const cases = [];
|
|
83243
|
+
if (practice) cases.push("- Adapter `mock` \u2014 a PRACTICE sandbox. No real money anywhere.");
|
|
83244
|
+
if (sepolia) {
|
|
83245
|
+
cases.push(
|
|
83246
|
+
"- Adapter `real` on SEPOLIA (the zero-config default) \u2014 the REAL protocol contracts on\n the test network: real ceremonies and signatures, PRACTICE money (test funds)."
|
|
83247
|
+
);
|
|
83248
|
+
}
|
|
83249
|
+
if (mainnet) cases.push("- Adapter `real` on MAINNET \u2014 REAL MONEY.");
|
|
83250
|
+
const gate = "Writes are enabled on every build; what stops one is having no signing identity connected\nyet \u2014 `signer_setup` is how that is fixed, and every fund movement still needs the user's\nown wallet signature AND `confirmed: true`.";
|
|
83251
|
+
if (cases.length === 1) {
|
|
83252
|
+
const only = mainnet && !sepolia && !practice ? "This deployment serves MAINNET ONLY \u2014 every fund-moving operation here spends REAL MONEY,\nand there is no practice network on it to fall back to." : `This deployment serves exactly one world:
|
|
83253
|
+
${cases[0]}`;
|
|
83254
|
+
return `${only}
|
|
83255
|
+
${gate}`;
|
|
83256
|
+
}
|
|
83257
|
+
return `The money truth on this deployment has ${cases.length === 2 ? "TWO" : "THREE"} cases:
|
|
83258
|
+
${cases.join("\n")}
|
|
83259
|
+
${gate}`;
|
|
83260
|
+
}
|
|
83074
83261
|
var LOCAL_GUIDE_DEPLOYMENT = {
|
|
83075
83262
|
tier: "local",
|
|
83076
83263
|
networks: ["sepolia", "mainnet"],
|
|
@@ -83078,7 +83265,13 @@ var LOCAL_GUIDE_DEPLOYMENT = {
|
|
|
83078
83265
|
// external+keystore and the mock sandbox adds the practice ceremonies, so the guide may
|
|
83079
83266
|
// speak the full vocabulary and let the existing adapter prose ("PRACTICE-ONLY today —
|
|
83080
83267
|
// on the real adapter these modes refuse") carry the narrower adapter axis.
|
|
83081
|
-
signerModes: GUIDE_SIGNER_MODES
|
|
83268
|
+
signerModes: GUIDE_SIGNER_MODES,
|
|
83269
|
+
// FALSE, because `DH_WC_PROJECT_ID` is unset in a default install and the WalletConnect
|
|
83270
|
+
// leg genuinely is not there until an operator configures it. The first draft of this line
|
|
83271
|
+
// said `true` "to keep the walkthrough complete", which is exactly the overclaim C-44 is
|
|
83272
|
+
// about — the default rendering would have promised a QR that most installs cannot show.
|
|
83273
|
+
// A live boot derives this from env either way (network-switch.ts).
|
|
83274
|
+
walletConnect: false
|
|
83082
83275
|
};
|
|
83083
83276
|
function servedNetworks(d) {
|
|
83084
83277
|
if (d.networks.length === 0) throw new Error("guide: a deployment must serve at least one network");
|
|
@@ -83250,7 +83443,7 @@ function keystoreAbsenceBullet() {
|
|
|
83250
83443
|
never ask for a password.`;
|
|
83251
83444
|
}
|
|
83252
83445
|
var GUIDE_TOPIC_SOURCES = {
|
|
83253
|
-
"getting-started": `# Diamond Hands \u2014 what this is
|
|
83446
|
+
"getting-started": (d) => `# Diamond Hands \u2014 what this is
|
|
83254
83447
|
|
|
83255
83448
|
Diamond Hands lets you BORROW a dollar-pegged token (UCD) against your own BITCOIN,
|
|
83256
83449
|
without selling it. Your BTC sits in a custody vault tied to your position; you mint UCD
|
|
@@ -83258,14 +83451,9 @@ against it, pay it back whenever you like, and take your BTC out again.
|
|
|
83258
83451
|
|
|
83259
83452
|
**Agent instructions:** answer in the USER'S language, map their words via the \`glossary\`
|
|
83260
83453
|
topic, and always say plainly whether this session is PRACTICE or REAL MONEY. Read the
|
|
83261
|
-
\`capabilities\` block in \`boundary://info\` FIRST \u2014 it states the network,
|
|
83262
|
-
|
|
83263
|
-
|
|
83264
|
-
- Adapter \`mock\` \u2014 a PRACTICE sandbox. No real money anywhere.
|
|
83265
|
-
- Adapter \`real\` on SEPOLIA (the zero-config default) \u2014 the REAL protocol contracts on
|
|
83266
|
-
the test network: real ceremonies and signatures, PRACTICE money (test funds).
|
|
83267
|
-
- Adapter \`real\` on MAINNET \u2014 REAL MONEY. Writes are disabled unless the operator
|
|
83268
|
-
explicitly arms them; the capabilities block states which applies.
|
|
83454
|
+
\`capabilities\` block in \`boundary://info\` FIRST \u2014 it states the network, which signer
|
|
83455
|
+
modes this build offers, and which mode is active; never promise a capability it does not
|
|
83456
|
+
list. ${moneyTruth(d)}
|
|
83269
83457
|
SAY THIS EARLY AND UNPROMPTED \u2014 users must never wonder whether money is real.
|
|
83270
83458
|
|
|
83271
83459
|
A first conversation usually goes: explain this page \u2192 \`guide first-setup\` (choose how to
|
|
@@ -83290,8 +83478,8 @@ signer modes exist; current terms (\`protocol_terms\`).
|
|
|
83290
83478
|
**2. Choose HOW to authorize operations** (the user's choice, made by talking):
|
|
83291
83479
|
- **"Use my own wallet"** \u2192 call \`signer_setup\` action \`use\`, mode \`external\` \u2014 works
|
|
83292
83480
|
on the real adapter and the mock. The approval page auto-opens in the browser (its URL
|
|
83293
|
-
is ALSO in the tool result); the user connects MetaMask \u2014
|
|
83294
|
-
|
|
83481
|
+
is ALSO in the tool result); the user connects MetaMask \u2014 ${phoneWalletOffer(d)} \u2014 and
|
|
83482
|
+
then APPROVES EACH OPERATION in
|
|
83295
83483
|
their own wallet. The first verified signature binds their wallet address as the
|
|
83296
83484
|
borrower. Full walkthrough: \`guide connect-wallet\`.
|
|
83297
83485
|
${offers(d, "keystore") ? `- **"Sign automatically / no popups"** \u2192 mode \`keystore\`. A local encrypted keystore
|
|
@@ -83322,14 +83510,13 @@ The user can switch authorization modes at ANY time by saying so \u2014 repeat s
|
|
|
83322
83510
|
"connect-wallet": (d) => `# Connect your wallet \u2014 the external-signer walkthrough
|
|
83323
83511
|
|
|
83324
83512
|
External mode means the user approves every operation in their OWN wallet \u2014 a browser
|
|
83325
|
-
extension (MetaMask) or a WalletConnect mobile wallet. It works
|
|
83326
|
-
the mock.
|
|
83513
|
+
extension (MetaMask)${d.walletConnect ? " or a WalletConnect mobile wallet" : ""}. It works
|
|
83514
|
+
on the real adapter and the mock.
|
|
83327
83515
|
|
|
83328
83516
|
**The walkthrough:**
|
|
83329
83517
|
1. \`signer_setup\` action \`use\`, mode \`external\`. The approval page auto-opens in the
|
|
83330
83518
|
desktop browser; ${approvalPageLocation(d)}
|
|
83331
|
-
2. On the page: connect the browser extension, or \u2014 for a mobile wallet \u2014 scan the
|
|
83332
|
-
WalletConnect QR code or paste the pairing code.
|
|
83519
|
+
2. On the page: connect the browser extension${d.walletConnect ? ", or \u2014 for a mobile wallet \u2014 scan the\n WalletConnect QR code or paste the pairing code." : ". " + phoneWalletOffer(d) + "."}
|
|
83333
83520
|
3. For authenticated reads before any write: \`signer_setup\` action \`connect\` runs the
|
|
83334
83521
|
login ceremony explicitly (one typed-data signature in the wallet).
|
|
83335
83522
|
4. The FIRST verified signature binds that wallet address as the borrower \u2014 it persists
|
|
@@ -83410,6 +83597,13 @@ Connections / Connected sites).`,
|
|
|
83410
83597
|
6. **Withdraw BTC** \u2014 \`loan_withdraw {positionId, btcAddress, amountSats, confirmed:true}\`.
|
|
83411
83598
|
BTC sends are IRREVERSIBLE \u2014 read the address back to the user before confirming.
|
|
83412
83599
|
amountSats is gross (fee comes out of it) and may be the whole available balance.
|
|
83600
|
+
The SECOND wallet popup is on a clock of well under a minute; if the user misses it the
|
|
83601
|
+
withdrawal fails with the reservation already committed and their coins still in the
|
|
83602
|
+
vault. That does NOT clear itself and it is not a stale spend \u2014 \`loan_recover_stale_spend\`
|
|
83603
|
+
needs the coins to have MOVED, which is exactly what did not happen. The way out is
|
|
83604
|
+
\`loan_withdraw_retry {positionId, confirmed:true}\`, which re-runs that second step with a
|
|
83605
|
+
fresh stamp using the destination and amount the CHAIN already holds. Check
|
|
83606
|
+
\`position_pending_withdrawals\` first, and tell the user it re-sends real BTC.
|
|
83413
83607
|
7. **Watch it** \u2014 \`position_status\` (one), \`position_list\` (all),
|
|
83414
83608
|
\`position_events\` (history), \`btc_price\`, \`protocol_status\`.
|
|
83415
83609
|
|
|
@@ -83672,8 +83866,7 @@ ${connectorStatusTruth(d)}
|
|
|
83672
83866
|
**What it is:** instead of installing anything, the user adds Diamond Hands to
|
|
83673
83867
|
claude.ai as a connector (paste a URL \u2014 zero install, zero Node, zero config files).
|
|
83674
83868
|
Sign-in IS the wallet: one Sign-In-with-Ethereum signature proves address ownership \u2014
|
|
83675
|
-
no password, no email, no account beyond the wallet address. The sign-in
|
|
83676
|
-
WalletConnect QR too, so a phone wallet works without any browser extension.
|
|
83869
|
+
no password, no email, no account beyond the wallet address.${d.walletConnect ? " The sign-in\npage offers a WalletConnect QR too, so a phone wallet works without any browser extension." : "\n" + phoneWalletOffer(d) + "."}
|
|
83677
83870
|
|
|
83678
83871
|
**Signature cadence, plainly:** the FIRST connect costs one SIWE signature (sign-in)
|
|
83679
83872
|
plus one lit-ops login signature (read access). After that, every operation that moves
|
|
@@ -83694,17 +83887,19 @@ honestly when asked "is this safe"):
|
|
|
83694
83887
|
is never written to disk. A breach here is privacy-class, never money-class.
|
|
83695
83888
|
3. **What the assistant narrates.** Tool results shape what the assistant tells you \u2014
|
|
83696
83889
|
a security concern is filed and audited for exactly this channel.
|
|
83697
|
-
4. **Tenant separation
|
|
83698
|
-
gets its own world: its own boundary, its own signer state, its own
|
|
83699
|
-
mount, keyed by that address.
|
|
83700
|
-
|
|
83701
|
-
|
|
83702
|
-
|
|
83703
|
-
|
|
83704
|
-
|
|
83705
|
-
|
|
83706
|
-
|
|
83707
|
-
|
|
83890
|
+
4. **Tenant separation, and what the mount binding does and does not cover.** Each
|
|
83891
|
+
signed-in wallet gets its own world: its own boundary, its own signer state, its own
|
|
83892
|
+
approval-page mount, keyed by that address. The wallet that connects at the mount
|
|
83893
|
+
must BE that address \u2014 a wallet offering any other account is refused at connect
|
|
83894
|
+
time, and switching accounts afterwards is refused the same way rather than silently
|
|
83895
|
+
becoming the new signer. So the account that signs is the account that signed in.
|
|
83896
|
+
None of that makes the mount link safe to pass around: whoever holds it can still
|
|
83897
|
+
load the page and observe or disrupt a pending ceremony, so treat the link as a
|
|
83898
|
+
secret \u2014 it is freshly random per world and travels only in the user's own tool
|
|
83899
|
+
result. What the binding does mean is that a holder cannot become this session's
|
|
83900
|
+
signer. Alongside that,
|
|
83901
|
+
EVERY fund movement still verifies the signature against the bound borrower, and no
|
|
83902
|
+
key material exists server-side.
|
|
83708
83903
|
5. **Availability and deploy honesty.** Hosted code changes under you: deploys are
|
|
83709
83904
|
version-pinned, the page bundle is open-source, and \`boundary://info\` capabilities
|
|
83710
83905
|
reports the exact server version.
|
|
@@ -83891,11 +84086,17 @@ function createNetworkSwitchRuntime(opts) {
|
|
|
83891
84086
|
}
|
|
83892
84087
|
};
|
|
83893
84088
|
}
|
|
83894
|
-
function guideDeployment(overrides) {
|
|
84089
|
+
function guideDeployment(overrides, env) {
|
|
83895
84090
|
return {
|
|
83896
84091
|
tier: overrides?.bridgeMount ? "hosted" : "local",
|
|
83897
84092
|
networks: overrides?.allowedNetworks ?? LOCAL_GUIDE_DEPLOYMENT.networks,
|
|
83898
|
-
signerModes: overrides?.externalOnly ? EXTERNAL_ONLY_SIGNER_MODES : LOCAL_GUIDE_DEPLOYMENT.signerModes
|
|
84093
|
+
signerModes: overrides?.externalOnly ? EXTERNAL_ONLY_SIGNER_MODES : LOCAL_GUIDE_DEPLOYMENT.signerModes,
|
|
84094
|
+
// C-44 F8, the fourth derivation. Read from the SAME env var the bridge reads
|
|
84095
|
+
// (boundary/config.ts `DH_WC_PROJECT_ID` → BridgeOptions.wc), so the guide cannot promise
|
|
84096
|
+
// a phone-wallet QR that `/wc-pairing` would answer 404 for. Deriving it rather than
|
|
84097
|
+
// hard-coding a tier default is what keeps the guide and `/auth.md` from disagreeing
|
|
84098
|
+
// about the same server, which is exactly what they did before this line existed.
|
|
84099
|
+
walletConnect: Boolean(env?.["DH_WC_PROJECT_ID"])
|
|
83899
84100
|
};
|
|
83900
84101
|
}
|
|
83901
84102
|
function assembleWorld(opts) {
|
|
@@ -83905,7 +84106,7 @@ function assembleWorld(opts) {
|
|
|
83905
84106
|
...boot.mockControl ? { mockControl: boot.mockControl } : {},
|
|
83906
84107
|
...boot.signer ? { signer: boot.signer } : {},
|
|
83907
84108
|
...opts.overrides?.externalOnly ? { externalOnly: true } : {},
|
|
83908
|
-
deployment: guideDeployment(opts.overrides),
|
|
84109
|
+
deployment: guideDeployment(opts.overrides, opts.env),
|
|
83909
84110
|
...opts.configResult.ok && opts.configResult.config.adapter === "mock" && opts.configResult.config.chainId ? { chainId: opts.configResult.config.chainId } : {}
|
|
83910
84111
|
};
|
|
83911
84112
|
if ((opts.env["DH_ADAPTER"] ?? "real") !== "mock") {
|
|
@@ -84217,6 +84418,32 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
84217
84418
|
return renderEnvelope(await b.boundary.withdrawBtc({ positionId, btcAddress: btcAddress2, amountSats, networkFeeSats }));
|
|
84218
84419
|
})
|
|
84219
84420
|
);
|
|
84421
|
+
registerBoundaryTool(
|
|
84422
|
+
server,
|
|
84423
|
+
"loan_withdraw_retry",
|
|
84424
|
+
{
|
|
84425
|
+
title: "Re-run a stalled BTC withdrawal's execute step",
|
|
84426
|
+
description: `Finish a withdrawal that authorized but never broadcast. loan_withdraw has two steps: the first commits the reservation on-chain, the second signs a time-stamped hash whose window is under a minute \u2014 often nearer twenty seconds. If that second signature is not given in time the withdrawal fails with the reservation ALREADY committed and the coins still in the vault, and it does not clear itself: loan_recover_stale_spend needs the coins to have MOVED, which is exactly what did not happen. This re-runs the second step alone with a fresh stamp. Destination and amount come from the on-chain record, not from you \u2014 the only figure you supply is the network fee, which is taken OUT of the already-authorized amount and cannot increase what leaves the vault. Use position_pending_withdrawals to see what is outstanding first. Sends real BTC. ${LATENCY_NOTE} Requires human confirmation (confirmed: true).`,
|
|
84427
|
+
inputSchema: {
|
|
84428
|
+
positionId: positionIdSchema,
|
|
84429
|
+
networkFeeSats: import_zod.z.number().int().positive().default(1e3).describe("BTC network fee in sats (declared default 1000); taken FROM the authorized amount, not added on top"),
|
|
84430
|
+
confirmed: confirmedSchema
|
|
84431
|
+
},
|
|
84432
|
+
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
|
|
84433
|
+
},
|
|
84434
|
+
async ({ positionId, networkFeeSats, confirmed }) => guardedWrite(getB, async () => {
|
|
84435
|
+
const gate = requireConfirmation(
|
|
84436
|
+
confirmed,
|
|
84437
|
+
`re-run the execute step for every outstanding BTC withdrawal reservation on position ${positionId} (this BROADCASTS real BTC to the destination each reservation already authorizes)`
|
|
84438
|
+
);
|
|
84439
|
+
if (gate) return gate;
|
|
84440
|
+
const problem = checkPositionIdHex(positionId) ?? checkSatsAmount(networkFeeSats, "Network fee");
|
|
84441
|
+
if (problem) return validationFailed(problem);
|
|
84442
|
+
const b = getB();
|
|
84443
|
+
if (!b.ok) return renderError(b.error);
|
|
84444
|
+
return renderEnvelope(await b.boundary.retryWithdrawExecute({ positionId, networkFeeSats }));
|
|
84445
|
+
})
|
|
84446
|
+
);
|
|
84220
84447
|
registerBoundaryTool(
|
|
84221
84448
|
server,
|
|
84222
84449
|
"loan_allowlist_destination",
|
|
@@ -84242,7 +84469,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
84242
84469
|
"loan_delegation_setup",
|
|
84243
84470
|
{
|
|
84244
84471
|
title: "Install delegation on the Safe (one owner ceremony)",
|
|
84245
|
-
description: `The ONE-TIME Safe delegation batch (signer mode 'safe-module'): your owners sign a single durable Safe transaction \u2014 at their leisure, no time window \u2014 that enables the Safe's AgentModule, binds the agent key, registers it in the delegation registry, and pre-approves the given BTC withdrawal destinations. After it, day-to-day operations (create/mint/pay/extend) run agent-solo; withdrawals always still need the owners' short signing burst, and only to destinations approved here (or later via loan_allowlist_destination \u2014 also owners-only). A revoked agent address burns FOREVER (AR-1) \u2014 rotation means a fresh key. Requires human confirmation (confirmed: true).`,
|
|
84472
|
+
description: `NOT AVAILABLE on the real protocol in this build \u2014 the real adapter answers UPSTREAM_UNAVAILABLE ('not wired in this delivery'). It runs on the practice (mock) adapter only. Say so before a user plans around it. The ONE-TIME Safe delegation batch (signer mode 'safe-module'): your owners sign a single durable Safe transaction \u2014 at their leisure, no time window \u2014 that enables the Safe's AgentModule, binds the agent key, registers it in the delegation registry, and pre-approves the given BTC withdrawal destinations. After it, day-to-day operations (create/mint/pay/extend) run agent-solo; withdrawals always still need the owners' short signing burst, and only to destinations approved here (or later via loan_allowlist_destination \u2014 also owners-only). A revoked agent address burns FOREVER (AR-1) \u2014 rotation means a fresh key. Requires human confirmation (confirmed: true).`,
|
|
84246
84473
|
inputSchema: {
|
|
84247
84474
|
btcAddresses: import_zod.z.array(import_zod.z.string().min(1)).describe("BTC withdrawal destinations to pre-approve in the same ceremony (avoids a second owner gathering before the first withdrawal)"),
|
|
84248
84475
|
confirmed: confirmedSchema
|
|
@@ -84262,7 +84489,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
84262
84489
|
"loan_delegation_grant",
|
|
84263
84490
|
{
|
|
84264
84491
|
title: "Grant the agent per-position scopes (owners sign)",
|
|
84265
|
-
description: `Set what the delegated agent may do on ONE position \u2014 RENEW (extend), REPAY (pay down), MINT (borrow, only while the post-mint collateral ratio stays at or above mintFloorBps \u2014 required for MINT, it is the owners' risk bound). Grants are user-only expansion: for a Safe this is a QUORUM signature (durable Safe transaction, owners sign at leisure) \u2014 the agent can never widen its own powers. Omitting a scope leaves it un-granted; a grant with no scopes clears the position's grant. Requires human confirmation (confirmed: true).`,
|
|
84492
|
+
description: `NOT AVAILABLE on the real protocol in this build \u2014 the real adapter answers UPSTREAM_UNAVAILABLE ('not wired in this delivery'). It runs on the practice (mock) adapter only. Say so before a user plans around it. Set what the delegated agent may do on ONE position \u2014 RENEW (extend), REPAY (pay down), MINT (borrow, only while the post-mint collateral ratio stays at or above mintFloorBps \u2014 required for MINT, it is the owners' risk bound). Grants are user-only expansion: for a Safe this is a QUORUM signature (durable Safe transaction, owners sign at leisure) \u2014 the agent can never widen its own powers. Omitting a scope leaves it un-granted; a grant with no scopes clears the position's grant. Requires human confirmation (confirmed: true).`,
|
|
84266
84493
|
inputSchema: {
|
|
84267
84494
|
positionId: positionIdSchema,
|
|
84268
84495
|
renew: import_zod.z.boolean().optional().describe("Allow the agent to extend/renew this position"),
|
|
@@ -84292,7 +84519,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
84292
84519
|
"loan_recover_stale_spend",
|
|
84293
84520
|
{
|
|
84294
84521
|
title: "Recover a stale BTC reservation via LIT-attested proof",
|
|
84295
|
-
description: "Clear a stale authorized BTC spend on BTCSpendAuthorizer using a LIT-attested StaleSpendRecovery attestation. The original UTXO must already be consumed on Bitcoin with \u22656 confirmations. `invalidatorTxid` is either the borrower's authorized broadcast (after confirmations) or a PKP self-spend that invalidated the reservation. Permissionless on-chain.",
|
|
84522
|
+
description: "NOT AVAILABLE on the real protocol in this build \u2014 the real adapter answers UPSTREAM_UNAVAILABLE ('not wired in this delivery'); it runs on the practice (mock) adapter only. For a withdrawal that authorized but never broadcast, loan_withdraw_retry is the working path. Clear a stale authorized BTC spend on BTCSpendAuthorizer using a LIT-attested StaleSpendRecovery attestation. The original UTXO must already be consumed on Bitcoin with \u22656 confirmations. `invalidatorTxid` is either the borrower's authorized broadcast (after confirmations) or a PKP self-spend that invalidated the reservation. Permissionless on-chain.",
|
|
84296
84523
|
inputSchema: {
|
|
84297
84524
|
positionId: positionIdSchema,
|
|
84298
84525
|
utxoTxid: import_zod.z.string().describe("The original authorized UTXO's txid"),
|
|
@@ -85291,6 +85518,12 @@ function composeConnector(opts, rawPublicOrigin) {
|
|
|
85291
85518
|
const overrides = {
|
|
85292
85519
|
externalOnly: true,
|
|
85293
85520
|
allowedNetworks,
|
|
85521
|
+
// C-47: `tenantKey` IS the lowercased SIWE address (see the `authImpl.tenant` call
|
|
85522
|
+
// site). Until this line it was a map key and an error string and nothing else, so a
|
|
85523
|
+
// session authenticated as A could write as B by connecting B to the approval page.
|
|
85524
|
+
// The mount is a bearer capability that transits the LLM transcript by design
|
|
85525
|
+
// (C-45), which is what made that reachable rather than merely untidy.
|
|
85526
|
+
boundBorrower: tenantKey,
|
|
85294
85527
|
bridgeMount: () => ({ baseUrl: `${publicOrigin}/approval/${mountId}`, origin: publicOrigin }),
|
|
85295
85528
|
signerPersistence: (network) => {
|
|
85296
85529
|
let s = stores.get(network);
|