@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/index.js
CHANGED
|
@@ -41574,6 +41574,19 @@ var BoundaryCore = class {
|
|
|
41574
41574
|
if (!r.ok) return errEnvelope(failureToError(r.failure));
|
|
41575
41575
|
return okEnvelope({ releasedSats: r.value.releasedSats }, r.source);
|
|
41576
41576
|
}
|
|
41577
|
+
/** C-46. Unlike `recoverStaleSpend` this is NOT permissionless: re-running phase 2 signs
|
|
41578
|
+
* for the vault, so it takes the same borrower gate every fund-moving op takes. */
|
|
41579
|
+
async retryWithdrawExecute(p) {
|
|
41580
|
+
const auth = await this.requireBorrower();
|
|
41581
|
+
if (!auth.ok) return errEnvelope(auth.error);
|
|
41582
|
+
const r = await this.deps.plugin.ops.retryWithdrawExecute({
|
|
41583
|
+
positionId: p.positionId,
|
|
41584
|
+
networkFeeSats: p.networkFeeSats,
|
|
41585
|
+
borrower: auth.borrower
|
|
41586
|
+
});
|
|
41587
|
+
if (!r.ok) return errEnvelope(failureToError(r.failure));
|
|
41588
|
+
return okEnvelope({ attempted: r.value.attempted, transfers: r.value.transfers }, r.source);
|
|
41589
|
+
}
|
|
41577
41590
|
// ---- meta ----
|
|
41578
41591
|
world() {
|
|
41579
41592
|
return {
|
|
@@ -42397,6 +42410,42 @@ var World = class {
|
|
|
42397
42410
|
c.authorizedSpends.splice(idx, 1);
|
|
42398
42411
|
return { ok: true, value: { releasedSats: spend.satoshis } };
|
|
42399
42412
|
}
|
|
42413
|
+
/**
|
|
42414
|
+
* C-46: re-run the withdrawal EXECUTE leg for reservations whose coins have not been
|
|
42415
|
+
* observed moving (`consumed === null`). This is the stranded shape: phase 1 committed
|
|
42416
|
+
* the reservation, phase 2's quantum-stamped signature expired, and the outpoint was
|
|
42417
|
+
* never spent.
|
|
42418
|
+
*
|
|
42419
|
+
* The retry BROADCASTS; it does not observe. `consumed` therefore stays null — that flag
|
|
42420
|
+
* means "seen consumed on Bitcoin", and only MockControl.confirmSpendConsumed (standing
|
|
42421
|
+
* in for the chain) may set it. Conflating the two would let a retry release collateral
|
|
42422
|
+
* against a transaction no one has confirmed, which is the mistake the whole
|
|
42423
|
+
* proof-of-consumption design exists to prevent. So a retry leaves the reservation
|
|
42424
|
+
* holding its balance exactly as before; what it produces is the txid that can LATER
|
|
42425
|
+
* become the invalidator — the proof the stranded state could never generate for itself.
|
|
42426
|
+
*/
|
|
42427
|
+
retryWithdrawExecute(p) {
|
|
42428
|
+
const paused = this.pausedReason();
|
|
42429
|
+
if (paused) return { ok: false, reason: paused };
|
|
42430
|
+
const pos = this.state.positions[p.positionId];
|
|
42431
|
+
if (!pos) return { ok: false, reason: `position ${p.positionId} does not exist` };
|
|
42432
|
+
if (pos.borrower.toLowerCase() !== p.borrower.toLowerCase()) {
|
|
42433
|
+
return { ok: false, reason: `caller ${p.borrower} is not the borrower of this position` };
|
|
42434
|
+
}
|
|
42435
|
+
const c = this.state.collateral[p.positionId];
|
|
42436
|
+
const pending = (c?.authorizedSpends ?? []).filter((s) => s.consumed === null);
|
|
42437
|
+
const transfers = pending.map((spend) => {
|
|
42438
|
+
const { hash: txid } = this.nextId("btc-withdraw-retry");
|
|
42439
|
+
return {
|
|
42440
|
+
utxoIdentifier: `${spend.txid}:${spend.vout}`,
|
|
42441
|
+
ok: true,
|
|
42442
|
+
txid,
|
|
42443
|
+
amountSentSats: spend.satoshis,
|
|
42444
|
+
destination: spend.targetAddress
|
|
42445
|
+
};
|
|
42446
|
+
});
|
|
42447
|
+
return { ok: true, value: { attempted: transfers.length, transfers } };
|
|
42448
|
+
}
|
|
42400
42449
|
// ---- Mock Safes (plan 06): REAL verification semantics, no fakes (M6-21/27) ----
|
|
42401
42450
|
safesMap() {
|
|
42402
42451
|
return this.state.safes;
|
|
@@ -43582,6 +43631,11 @@ var MockUpstreamPlugin = class {
|
|
|
43582
43631
|
const r = this.world.recoverStaleSpend(p);
|
|
43583
43632
|
if (!r.ok) return this.rejected("recoverStaleSpend", r.reason);
|
|
43584
43633
|
return upOk({ txRef: this.world.nextTxRef(), releasedSats: r.value.releasedSats }, this.src("mock-ops"));
|
|
43634
|
+
}),
|
|
43635
|
+
retryWithdrawExecute: (p) => this.write("retryWithdrawExecute", () => {
|
|
43636
|
+
const r = this.world.retryWithdrawExecute({ positionId: p.positionId, borrower: p.borrower });
|
|
43637
|
+
if (!r.ok) return this.rejected("retryWithdrawExecute", r.reason);
|
|
43638
|
+
return upOk({ attempted: r.value.attempted, transfers: r.value.transfers }, this.src("mock-ops"));
|
|
43585
43639
|
})
|
|
43586
43640
|
};
|
|
43587
43641
|
}
|
|
@@ -51821,13 +51875,13 @@ var init_deployment_addresses = __esm2({
|
|
|
51821
51875
|
block: 25472956
|
|
51822
51876
|
},
|
|
51823
51877
|
BTCSpendAuthorizer: {
|
|
51824
|
-
previousImplementation: "
|
|
51825
|
-
newImplementation: "
|
|
51826
|
-
upgradedAt: "2026-
|
|
51827
|
-
upgradedBy: "AdminModule
|
|
51828
|
-
reason: "
|
|
51829
|
-
executeTx: "
|
|
51830
|
-
block:
|
|
51878
|
+
previousImplementation: "0x40c9e8C46C65E0A57BB63da5368868A9E8Df81A5",
|
|
51879
|
+
newImplementation: "0x00D7a47798E8ff169104b748131703B78f23390C",
|
|
51880
|
+
upgradedAt: "2026-09-09T12:05:35.000Z",
|
|
51881
|
+
upgradedBy: "AdminModule generic op 0xc0214ff38bb454864a34f6482dcd03570b3fd04171c84be2c20184afb1a2e161 (bsa-1-7-0 ceremony: proposed by seat 0x3030C0414B6d95aA9d5A57269E51a347fCBaB472 2026-09-08T11:35:23Z, 3/3 seat signatures, 24h timelock); executeGenericAdminOperation sent by 0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6 in tx 0x77cd231966c546177bd8f1a07bd4e705afd5c2dfbd110b096836401679c0c69c (block 25939703)",
|
|
51882
|
+
reason: "BTCSpendAuthorizer 1.6.0 -> 1.7.0: allow a full-vault sweep (targetAmount == satoshis); TargetMustLeaveFeeRoom -> TargetExceedsInputValue (PR #849; mainnet incidents 2026-09-04 and 2026-09-07). Impl deployed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f at nonce 430 from source 0a7c535a1 (contracts/src identical to main 99b335f77). Cross-ref onchain-auth/.safe-batches/mainnet-bsa-1-7-0-{propose,sign,execute}.json and docs/mainnet-bsa-1-7-0-ceremony-2026-09-08.md",
|
|
51883
|
+
executeTx: "0x77cd231966c546177bd8f1a07bd4e705afd5c2dfbd110b096836401679c0c69c",
|
|
51884
|
+
block: 25939703
|
|
51831
51885
|
},
|
|
51832
51886
|
PositionManager: {
|
|
51833
51887
|
previousImplementation: "0x600Dc0D1C2c0F94882B6Bc09172f8650047Ad5B1",
|
|
@@ -51930,7 +51984,7 @@ var init_deployment_addresses = __esm2({
|
|
|
51930
51984
|
ADMIN_MODULE: "0x0023B71B586795eE5fa4E83E384345C1EC8Bb946",
|
|
51931
51985
|
ADMIN_MODULE_IMPL: "0xb4C5C7E051A1e672F014B25CB5D55B225Aa0D512",
|
|
51932
51986
|
BTC_SPEND_AUTHORIZER: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
51933
|
-
BTC_SPEND_AUTHORIZER_IMPL: "
|
|
51987
|
+
BTC_SPEND_AUTHORIZER_IMPL: "0x00D7a47798E8ff169104b748131703B78f23390C",
|
|
51934
51988
|
POSITION_MANAGER_VIEWS: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
|
|
51935
51989
|
POSITION_MANAGER_VIEWS_IMPL: "0xE68DC096A65Ecddbc6A9b5c6e5f878e2CE143Bfe",
|
|
51936
51990
|
POSITION_MANAGER: "0x12A1836e56139ccaD8722B89519d84233efc224B",
|
|
@@ -58000,9 +58054,27 @@ var LOGIN_TYPES_WITH_AUDIENCE2 = {
|
|
|
58000
58054
|
{ name: "audience", type: "string" }
|
|
58001
58055
|
]
|
|
58002
58056
|
};
|
|
58003
|
-
|
|
58057
|
+
var LOGIN_TYPES_WITH_STATEMENT = {
|
|
58058
|
+
DiamondHands: [
|
|
58059
|
+
{ name: "statement", type: "string" },
|
|
58060
|
+
{ name: "address", type: "address" },
|
|
58061
|
+
{ name: "issuedAt", type: "uint256" },
|
|
58062
|
+
{ name: "nonce", type: "bytes32" },
|
|
58063
|
+
{ name: "audience", type: "string" }
|
|
58064
|
+
]
|
|
58065
|
+
};
|
|
58066
|
+
var LOGIN_STATEMENT_TEMPLATE = "{host} is verifying you own this wallet. Signing proves control of the address so we can show your loans and positions. It authorizes no transaction, moves no funds, and costs no gas.";
|
|
58067
|
+
function canonicalLoginStatement(audience) {
|
|
58068
|
+
const host = /^https?:\/\/([^/?#]+)/i.exec(audience)?.[1];
|
|
58069
|
+
if (!host)
|
|
58070
|
+
return null;
|
|
58071
|
+
return LOGIN_STATEMENT_TEMPLATE.replace("{host}", host);
|
|
58072
|
+
}
|
|
58073
|
+
async function buildSignedLoginPayload(signer, chainId, audience, reuse, withStatement = false) {
|
|
58004
58074
|
const address = await signer.getAddress();
|
|
58075
|
+
const statement = withStatement && audience ? canonicalLoginStatement(audience) : null;
|
|
58005
58076
|
const message = {
|
|
58077
|
+
...statement ? { statement } : {},
|
|
58006
58078
|
address,
|
|
58007
58079
|
issuedAt: reuse?.issuedAt ?? Math.floor(Date.now() / 1e3),
|
|
58008
58080
|
nonce: reuse?.nonce ?? (0, import_ethers17.hexlify)((0, import_ethers17.randomBytes)(32)),
|
|
@@ -58010,7 +58082,7 @@ async function buildSignedLoginPayload(signer, chainId, audience, reuse) {
|
|
|
58010
58082
|
};
|
|
58011
58083
|
const signature = await signer.signTypedData(
|
|
58012
58084
|
buildLoginDomain(chainId),
|
|
58013
|
-
audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
|
|
58085
|
+
statement ? LOGIN_TYPES_WITH_STATEMENT : audience ? LOGIN_TYPES_WITH_AUDIENCE2 : LOGIN_TYPES2,
|
|
58014
58086
|
message
|
|
58015
58087
|
);
|
|
58016
58088
|
return { chainId, message, signature };
|
|
@@ -58179,6 +58251,8 @@ var ServerSession = class {
|
|
|
58179
58251
|
signer;
|
|
58180
58252
|
serviceEndpoint;
|
|
58181
58253
|
loginAudience;
|
|
58254
|
+
/** Whether this session's login carries the human-readable statement. */
|
|
58255
|
+
withStatement;
|
|
58182
58256
|
chainId;
|
|
58183
58257
|
store;
|
|
58184
58258
|
onSignaturePrompt;
|
|
@@ -58220,6 +58294,13 @@ var ServerSession = class {
|
|
|
58220
58294
|
/\/+$/,
|
|
58221
58295
|
""
|
|
58222
58296
|
);
|
|
58297
|
+
const explicitAudience = typeof opts.loginAudience === "string" && opts.loginAudience.length > 0;
|
|
58298
|
+
this.withStatement = opts.withStatement === true && explicitAudience;
|
|
58299
|
+
if (opts.withStatement === true && !explicitAudience) {
|
|
58300
|
+
console.warn(
|
|
58301
|
+
"[dh-sdk] withStatement ignored: it requires an explicit loginAudience, since the servers rebuild the expected sentence from the audience host"
|
|
58302
|
+
);
|
|
58303
|
+
}
|
|
58223
58304
|
this.chainId = opts.chainId;
|
|
58224
58305
|
this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
|
|
58225
58306
|
this.onSignaturePrompt = opts.onSignaturePrompt;
|
|
@@ -58473,12 +58554,16 @@ var ServerSession = class {
|
|
|
58473
58554
|
this.signer,
|
|
58474
58555
|
this.chainId,
|
|
58475
58556
|
this.loginAudience,
|
|
58476
|
-
reuse
|
|
58557
|
+
reuse,
|
|
58558
|
+
reuse ? reuse.withStatement === true : this.withStatement
|
|
58477
58559
|
);
|
|
58478
58560
|
if (storeKey && !reuse) {
|
|
58479
58561
|
store.savePending?.(storeKey, {
|
|
58480
58562
|
issuedAt: payload.message.issuedAt,
|
|
58481
|
-
nonce: payload.message.nonce
|
|
58563
|
+
nonce: payload.message.nonce,
|
|
58564
|
+
// Recorded so a resume reproduces this digest even if the
|
|
58565
|
+
// capability flag changes before the owners finish signing.
|
|
58566
|
+
withStatement: this.withStatement
|
|
58482
58567
|
});
|
|
58483
58568
|
}
|
|
58484
58569
|
session = await this.login(payload);
|
|
@@ -70689,6 +70774,9 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
70689
70774
|
signer: config.authSigner ?? config.contractSigner,
|
|
70690
70775
|
serviceEndpoint: config.serviceEndpoint,
|
|
70691
70776
|
loginAudience: config.loginAudience,
|
|
70777
|
+
// Only meaningful alongside an audience; the servers derive the expected
|
|
70778
|
+
// sentence from its host. Defaults off so Node callers are untouched.
|
|
70779
|
+
withStatement: config.loginStatement === true,
|
|
70692
70780
|
chainId: config.chainId,
|
|
70693
70781
|
persistSession: config.sessionPersistence?.enabled,
|
|
70694
70782
|
sessionStore: config.sessionPersistence?.store,
|
|
@@ -79534,7 +79622,33 @@ function buildWriteOps(deps) {
|
|
|
79534
79622
|
kind: "unavailable",
|
|
79535
79623
|
source: SOURCE5,
|
|
79536
79624
|
message: "recoverStaleSpend is not wired in this delivery (permissionless recovery \u2014 planned follow-up)."
|
|
79537
|
-
})
|
|
79625
|
+
}),
|
|
79626
|
+
retryWithdrawExecute: async (p) => {
|
|
79627
|
+
const sdk = deps.getWriteSdk();
|
|
79628
|
+
if (!sdk) return upFail({ kind: "unavailable", source: SOURCE5, message: "write SDK is not initialized (its boot-time construction failed)" });
|
|
79629
|
+
let rows;
|
|
79630
|
+
try {
|
|
79631
|
+
rows = await sdk.executePendingBtcTransfers(p.positionId, p.networkFeeSats);
|
|
79632
|
+
} catch (e) {
|
|
79633
|
+
return failed("retryWithdrawExecute", e);
|
|
79634
|
+
}
|
|
79635
|
+
const gate = rows.find((r) => !r.success && !r.utxoIdentifier);
|
|
79636
|
+
if (gate) return declined("retryWithdrawExecute", gate.error ?? "pending-transfer execution refused before any reservation was attempted");
|
|
79637
|
+
return upOk(
|
|
79638
|
+
{
|
|
79639
|
+
attempted: rows.length,
|
|
79640
|
+
transfers: rows.map((r) => ({
|
|
79641
|
+
utxoIdentifier: r.utxoIdentifier ?? "",
|
|
79642
|
+
ok: r.success,
|
|
79643
|
+
...r.txid ? { txid: r.txid } : {},
|
|
79644
|
+
...r.amountSent !== void 0 ? { amountSentSats: String(r.amountSent) } : {},
|
|
79645
|
+
...r.destination ? { destination: r.destination } : {},
|
|
79646
|
+
...r.error ? { error: r.error } : {}
|
|
79647
|
+
}))
|
|
79648
|
+
},
|
|
79649
|
+
{ id: SOURCE5, kind: "lit-ops", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }
|
|
79650
|
+
);
|
|
79651
|
+
}
|
|
79538
79652
|
};
|
|
79539
79653
|
}
|
|
79540
79654
|
|
|
@@ -80059,7 +80173,8 @@ var RealUpstreamPlugin = class {
|
|
|
80059
80173
|
message: "no signer configured \u2014 psmSwap signs two on-chain transactions (exact-amount approve, then swap/redeem) with the keystore signer. Set DH_KEYSTORE_PATH and DH_KEYSTORE_PASSWORD to enable it."
|
|
80060
80174
|
})
|
|
80061
80175
|
),
|
|
80062
|
-
recoverStaleSpend: () => readOnly("recoverStaleSpend")
|
|
80176
|
+
recoverStaleSpend: () => readOnly("recoverStaleSpend"),
|
|
80177
|
+
retryWithdrawExecute: () => readOnly("retryWithdrawExecute")
|
|
80063
80178
|
};
|
|
80064
80179
|
}
|
|
80065
80180
|
}
|
|
@@ -80227,7 +80342,8 @@ var RealUpstreamPlugin = class {
|
|
|
80227
80342
|
psmSwap: call("psmSwap"),
|
|
80228
80343
|
delegationSetup: call("delegationSetup"),
|
|
80229
80344
|
delegationGrant: call("delegationGrant"),
|
|
80230
|
-
recoverStaleSpend: call("recoverStaleSpend")
|
|
80345
|
+
recoverStaleSpend: call("recoverStaleSpend"),
|
|
80346
|
+
retryWithdrawExecute: call("retryWithdrawExecute")
|
|
80231
80347
|
};
|
|
80232
80348
|
}
|
|
80233
80349
|
async resolveOpsGateway() {
|
|
@@ -81066,6 +81182,9 @@ function wcDeclineOrFault(e) {
|
|
|
81066
81182
|
}
|
|
81067
81183
|
var SignatureBridge = class {
|
|
81068
81184
|
clock;
|
|
81185
|
+
/** Lowercased at construction so every comparison is case-flat — EIP-55 checksum casing
|
|
81186
|
+
* differs between what SIWE signs and what a wallet reports for the SAME address. */
|
|
81187
|
+
boundAccount;
|
|
81069
81188
|
expiryMs;
|
|
81070
81189
|
/** Plan 17 E2: single-decision concurrency cap (null = unbounded, the loopback tier). */
|
|
81071
81190
|
maxPending;
|
|
@@ -81101,6 +81220,7 @@ var SignatureBridge = class {
|
|
|
81101
81220
|
unlockSession = null;
|
|
81102
81221
|
constructor(opts) {
|
|
81103
81222
|
this.clock = opts?.clock ?? Date.now;
|
|
81223
|
+
this.boundAccount = opts?.boundAccount?.toLowerCase();
|
|
81104
81224
|
this.expiryMs = opts?.expiryMs ?? DEFAULT_EXPIRY_MS;
|
|
81105
81225
|
this.maxPending = opts?.maxPending ?? null;
|
|
81106
81226
|
this.attachGraceMs = opts?.attachGraceMs ?? (opts?.mount ? DEFAULT_HOSTED_ATTACH_GRACE_MS : DEFAULT_ATTACH_GRACE_MS);
|
|
@@ -81470,6 +81590,14 @@ var SignatureBridge = class {
|
|
|
81470
81590
|
});
|
|
81471
81591
|
this.wcTransport = await factory2(this.wcConfig);
|
|
81472
81592
|
this.wcTransport.onSession((info) => {
|
|
81593
|
+
const refusal = info ? this.accountRefusal(info.account) : null;
|
|
81594
|
+
if (info && refusal) {
|
|
81595
|
+
this.wcActive = false;
|
|
81596
|
+
this.wallet = null;
|
|
81597
|
+
process.stderr.write(`[bridge] WalletConnect session refused \u2014 ${refusal}
|
|
81598
|
+
`);
|
|
81599
|
+
return;
|
|
81600
|
+
}
|
|
81473
81601
|
this.wcActive = info !== null;
|
|
81474
81602
|
this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
|
|
81475
81603
|
if (info === null) {
|
|
@@ -81567,10 +81695,36 @@ var SignatureBridge = class {
|
|
|
81567
81695
|
this.deny(res, 400, "hello requires account (0x address) and integer chainId");
|
|
81568
81696
|
return;
|
|
81569
81697
|
}
|
|
81698
|
+
const refusal = this.accountRefusal(account);
|
|
81699
|
+
if (refusal) {
|
|
81700
|
+
this.deny(res, 403, refusal);
|
|
81701
|
+
return;
|
|
81702
|
+
}
|
|
81570
81703
|
session.wallet = { account, chainId };
|
|
81571
81704
|
this.wallet = { account, chainId };
|
|
81572
81705
|
this.ok(res);
|
|
81573
81706
|
}
|
|
81707
|
+
/** C-47: the single predicate every wallet account is admitted through. There are THREE
|
|
81708
|
+
* doors into the account this bridge will sign with — `hello`, `accountsChanged`, and the
|
|
81709
|
+
* WalletConnect `onSession` callback — and all three call this. The first version of this
|
|
81710
|
+
* fix guarded only the first two while this docstring already claimed to be "the single
|
|
81711
|
+
* place", which is how the WC door survived a green suite: the claim was in prose, not in a
|
|
81712
|
+
* test. T-EXT-BIND-01/02/04 now pin one door each, so adding a fourth writer of
|
|
81713
|
+
* `this.wallet` without coming through here fails a test rather than a review.
|
|
81714
|
+
*
|
|
81715
|
+
* Returns the refusal reason, or
|
|
81716
|
+
* null when the account may be adopted.
|
|
81717
|
+
*
|
|
81718
|
+
* Both addresses are named because the pre-fix failure surfaced much later as an opaque
|
|
81719
|
+
* signature-recovery error (`external-eoa.ts:230-233`) that named neither and read as a
|
|
81720
|
+
* wallet fault. A user with several accounts in one wallet extension hits this by
|
|
81721
|
+
* accident far more often than any attacker does, and "wrong account" is only actionable
|
|
81722
|
+
* if it says WHICH. */
|
|
81723
|
+
accountRefusal(account) {
|
|
81724
|
+
if (!this.boundAccount) return null;
|
|
81725
|
+
if (account.toLowerCase() === this.boundAccount) return null;
|
|
81726
|
+
return `this session is signed in as ${this.boundAccount} but the wallet offered ${account.toLowerCase()} \u2014 the account that signs must be the account that signed in. Switch your wallet to the signed-in account, or start a new session with this one.`;
|
|
81727
|
+
}
|
|
81574
81728
|
/** accountsChanged / chainChanged: a wallet-state CHANGE mid-request invalidates every
|
|
81575
81729
|
* pending request — what the human saw approved is no longer what would sign. Wallets
|
|
81576
81730
|
* also deliver late no-op echoes of these events; an unchanged state invalidates nothing. */
|
|
@@ -81580,7 +81734,9 @@ var SignatureBridge = class {
|
|
|
81580
81734
|
const account = String(body["account"] ?? "");
|
|
81581
81735
|
const chainId = Number(body["chainId"]);
|
|
81582
81736
|
const prev = session.wallet;
|
|
81583
|
-
|
|
81737
|
+
const offered = /^0x[0-9a-fA-F]{40}$/.test(account) && Number.isInteger(chainId) ? { account, chainId } : null;
|
|
81738
|
+
const refusedSwitch = offered !== null && this.accountRefusal(offered.account) !== null;
|
|
81739
|
+
session.wallet = refusedSwitch ? null : offered;
|
|
81584
81740
|
if (this.wallet !== null && prev !== null && this.wallet.account.toLowerCase() === prev.account.toLowerCase()) {
|
|
81585
81741
|
this.wallet = session.wallet;
|
|
81586
81742
|
}
|
|
@@ -81589,7 +81745,7 @@ var SignatureBridge = class {
|
|
|
81589
81745
|
this.ok(res);
|
|
81590
81746
|
return;
|
|
81591
81747
|
}
|
|
81592
|
-
const reason = prev && session.wallet && prev.account.toLowerCase() !== session.wallet.account.toLowerCase() ? "the wallet account changed while approval was pending" : prev && session.wallet && prev.chainId !== session.wallet.chainId ? "the wallet network changed while approval was pending" : "the wallet disconnected while approval was pending";
|
|
81748
|
+
const reason = refusedSwitch ? "the wallet switched to an account this session is not signed in as" : prev && session.wallet && prev.account.toLowerCase() !== session.wallet.account.toLowerCase() ? "the wallet account changed while approval was pending" : prev && session.wallet && prev.chainId !== session.wallet.chainId ? "the wallet network changed while approval was pending" : "the wallet disconnected while approval was pending";
|
|
81593
81749
|
for (const entry of this.pending.values()) {
|
|
81594
81750
|
if (!entry.settled && !entry.collect) this.settle(entry, { status: "invalidated", reason });
|
|
81595
81751
|
}
|
|
@@ -81899,6 +82055,11 @@ async function createRealBoundary(config, wallet, overrides) {
|
|
|
81899
82055
|
// tenant — one bridge per tenant world, so the bridge cap IS the tenant cap. The
|
|
81900
82056
|
// loopback tier keeps its unbounded pending (multi-owner Safe pages need it).
|
|
81901
82057
|
...overrides?.bridgeMount ? { mount: overrides.bridgeMount(config.network), maxPending: 1 } : {},
|
|
82058
|
+
// C-47: the authenticated identity governs the write path. Passed separately from
|
|
82059
|
+
// `bridgeMount` although the hosted tier sets both — they answer different questions
|
|
82060
|
+
// ("where does the page live" vs "whose wallet may sign"), and fusing them would make
|
|
82061
|
+
// an unbound hosted bridge impossible to express in a test.
|
|
82062
|
+
...overrides?.boundBorrower ? { boundAccount: overrides.boundBorrower } : {},
|
|
81902
82063
|
// M12-12: no unlock closures without a provider — the unlock endpoints answer with
|
|
81903
82064
|
// their loud not-wired refusal instead of ever touching key material.
|
|
81904
82065
|
...keystore ? {
|
|
@@ -82175,6 +82336,32 @@ function offers(d, mode) {
|
|
|
82175
82336
|
function signerModeSourceClause(d) {
|
|
82176
82337
|
return offers(d, "keystore") ? "the set `signer_setup` offers. `boundary://info` reports the NARROWER set the active adapter actually constructs under `capabilities.writes.signerModes` (the real adapter builds `external` + `keystore`; the practice ceremonies are mock-adapter only) \u2014 when the two differ, `boundary://info` is authoritative" : "the same set `signer_setup` offers and `boundary://info` reports under `capabilities.writes.signerModes`";
|
|
82177
82338
|
}
|
|
82339
|
+
function phoneWalletOffer(d) {
|
|
82340
|
+
return d.walletConnect ? "or scan the WalletConnect QR (or paste the pairing code) to approve on a phone wallet" : "This deployment does NOT offer the WalletConnect phone-wallet leg \u2014 there is no QR to scan and `/wc-pairing` answers 404; a browser-extension wallet is the only path here";
|
|
82341
|
+
}
|
|
82342
|
+
function moneyTruth(d) {
|
|
82343
|
+
const practice = offers(d, "mock-simulated");
|
|
82344
|
+
const sepolia = d.networks.includes("sepolia");
|
|
82345
|
+
const mainnet = d.networks.includes("mainnet");
|
|
82346
|
+
const cases = [];
|
|
82347
|
+
if (practice) cases.push("- Adapter `mock` \u2014 a PRACTICE sandbox. No real money anywhere.");
|
|
82348
|
+
if (sepolia) {
|
|
82349
|
+
cases.push(
|
|
82350
|
+
"- Adapter `real` on SEPOLIA (the zero-config default) \u2014 the REAL protocol contracts on\n the test network: real ceremonies and signatures, PRACTICE money (test funds)."
|
|
82351
|
+
);
|
|
82352
|
+
}
|
|
82353
|
+
if (mainnet) cases.push("- Adapter `real` on MAINNET \u2014 REAL MONEY.");
|
|
82354
|
+
const gate = "Writes are enabled on every build; what stops one is having no signing identity connected\nyet \u2014 `signer_setup` is how that is fixed, and every fund movement still needs the user's\nown wallet signature AND `confirmed: true`.";
|
|
82355
|
+
if (cases.length === 1) {
|
|
82356
|
+
const only = mainnet && !sepolia && !practice ? "This deployment serves MAINNET ONLY \u2014 every fund-moving operation here spends REAL MONEY,\nand there is no practice network on it to fall back to." : `This deployment serves exactly one world:
|
|
82357
|
+
${cases[0]}`;
|
|
82358
|
+
return `${only}
|
|
82359
|
+
${gate}`;
|
|
82360
|
+
}
|
|
82361
|
+
return `The money truth on this deployment has ${cases.length === 2 ? "TWO" : "THREE"} cases:
|
|
82362
|
+
${cases.join("\n")}
|
|
82363
|
+
${gate}`;
|
|
82364
|
+
}
|
|
82178
82365
|
var LOCAL_GUIDE_DEPLOYMENT = {
|
|
82179
82366
|
tier: "local",
|
|
82180
82367
|
networks: ["sepolia", "mainnet"],
|
|
@@ -82182,7 +82369,13 @@ var LOCAL_GUIDE_DEPLOYMENT = {
|
|
|
82182
82369
|
// external+keystore and the mock sandbox adds the practice ceremonies, so the guide may
|
|
82183
82370
|
// speak the full vocabulary and let the existing adapter prose ("PRACTICE-ONLY today —
|
|
82184
82371
|
// on the real adapter these modes refuse") carry the narrower adapter axis.
|
|
82185
|
-
signerModes: GUIDE_SIGNER_MODES
|
|
82372
|
+
signerModes: GUIDE_SIGNER_MODES,
|
|
82373
|
+
// FALSE, because `DH_WC_PROJECT_ID` is unset in a default install and the WalletConnect
|
|
82374
|
+
// leg genuinely is not there until an operator configures it. The first draft of this line
|
|
82375
|
+
// said `true` "to keep the walkthrough complete", which is exactly the overclaim C-44 is
|
|
82376
|
+
// about — the default rendering would have promised a QR that most installs cannot show.
|
|
82377
|
+
// A live boot derives this from env either way (network-switch.ts).
|
|
82378
|
+
walletConnect: false
|
|
82186
82379
|
};
|
|
82187
82380
|
function servedNetworks(d) {
|
|
82188
82381
|
if (d.networks.length === 0) throw new Error("guide: a deployment must serve at least one network");
|
|
@@ -82354,7 +82547,7 @@ function keystoreAbsenceBullet() {
|
|
|
82354
82547
|
never ask for a password.`;
|
|
82355
82548
|
}
|
|
82356
82549
|
var GUIDE_TOPIC_SOURCES = {
|
|
82357
|
-
"getting-started": `# Diamond Hands \u2014 what this is
|
|
82550
|
+
"getting-started": (d) => `# Diamond Hands \u2014 what this is
|
|
82358
82551
|
|
|
82359
82552
|
Diamond Hands lets you BORROW a dollar-pegged token (UCD) against your own BITCOIN,
|
|
82360
82553
|
without selling it. Your BTC sits in a custody vault tied to your position; you mint UCD
|
|
@@ -82362,14 +82555,9 @@ against it, pay it back whenever you like, and take your BTC out again.
|
|
|
82362
82555
|
|
|
82363
82556
|
**Agent instructions:** answer in the USER'S language, map their words via the \`glossary\`
|
|
82364
82557
|
topic, and always say plainly whether this session is PRACTICE or REAL MONEY. Read the
|
|
82365
|
-
\`capabilities\` block in \`boundary://info\` FIRST \u2014 it states the network,
|
|
82366
|
-
|
|
82367
|
-
|
|
82368
|
-
- Adapter \`mock\` \u2014 a PRACTICE sandbox. No real money anywhere.
|
|
82369
|
-
- Adapter \`real\` on SEPOLIA (the zero-config default) \u2014 the REAL protocol contracts on
|
|
82370
|
-
the test network: real ceremonies and signatures, PRACTICE money (test funds).
|
|
82371
|
-
- Adapter \`real\` on MAINNET \u2014 REAL MONEY. Writes are disabled unless the operator
|
|
82372
|
-
explicitly arms them; the capabilities block states which applies.
|
|
82558
|
+
\`capabilities\` block in \`boundary://info\` FIRST \u2014 it states the network, which signer
|
|
82559
|
+
modes this build offers, and which mode is active; never promise a capability it does not
|
|
82560
|
+
list. ${moneyTruth(d)}
|
|
82373
82561
|
SAY THIS EARLY AND UNPROMPTED \u2014 users must never wonder whether money is real.
|
|
82374
82562
|
|
|
82375
82563
|
A first conversation usually goes: explain this page \u2192 \`guide first-setup\` (choose how to
|
|
@@ -82394,8 +82582,8 @@ signer modes exist; current terms (\`protocol_terms\`).
|
|
|
82394
82582
|
**2. Choose HOW to authorize operations** (the user's choice, made by talking):
|
|
82395
82583
|
- **"Use my own wallet"** \u2192 call \`signer_setup\` action \`use\`, mode \`external\` \u2014 works
|
|
82396
82584
|
on the real adapter and the mock. The approval page auto-opens in the browser (its URL
|
|
82397
|
-
is ALSO in the tool result); the user connects MetaMask \u2014
|
|
82398
|
-
|
|
82585
|
+
is ALSO in the tool result); the user connects MetaMask \u2014 ${phoneWalletOffer(d)} \u2014 and
|
|
82586
|
+
then APPROVES EACH OPERATION in
|
|
82399
82587
|
their own wallet. The first verified signature binds their wallet address as the
|
|
82400
82588
|
borrower. Full walkthrough: \`guide connect-wallet\`.
|
|
82401
82589
|
${offers(d, "keystore") ? `- **"Sign automatically / no popups"** \u2192 mode \`keystore\`. A local encrypted keystore
|
|
@@ -82426,14 +82614,13 @@ The user can switch authorization modes at ANY time by saying so \u2014 repeat s
|
|
|
82426
82614
|
"connect-wallet": (d) => `# Connect your wallet \u2014 the external-signer walkthrough
|
|
82427
82615
|
|
|
82428
82616
|
External mode means the user approves every operation in their OWN wallet \u2014 a browser
|
|
82429
|
-
extension (MetaMask) or a WalletConnect mobile wallet. It works
|
|
82430
|
-
the mock.
|
|
82617
|
+
extension (MetaMask)${d.walletConnect ? " or a WalletConnect mobile wallet" : ""}. It works
|
|
82618
|
+
on the real adapter and the mock.
|
|
82431
82619
|
|
|
82432
82620
|
**The walkthrough:**
|
|
82433
82621
|
1. \`signer_setup\` action \`use\`, mode \`external\`. The approval page auto-opens in the
|
|
82434
82622
|
desktop browser; ${approvalPageLocation(d)}
|
|
82435
|
-
2. On the page: connect the browser extension, or \u2014 for a mobile wallet \u2014 scan the
|
|
82436
|
-
WalletConnect QR code or paste the pairing code.
|
|
82623
|
+
2. On the page: connect the browser extension${d.walletConnect ? ", or \u2014 for a mobile wallet \u2014 scan the\n WalletConnect QR code or paste the pairing code." : ". " + phoneWalletOffer(d) + "."}
|
|
82437
82624
|
3. For authenticated reads before any write: \`signer_setup\` action \`connect\` runs the
|
|
82438
82625
|
login ceremony explicitly (one typed-data signature in the wallet).
|
|
82439
82626
|
4. The FIRST verified signature binds that wallet address as the borrower \u2014 it persists
|
|
@@ -82514,6 +82701,13 @@ Connections / Connected sites).`,
|
|
|
82514
82701
|
6. **Withdraw BTC** \u2014 \`loan_withdraw {positionId, btcAddress, amountSats, confirmed:true}\`.
|
|
82515
82702
|
BTC sends are IRREVERSIBLE \u2014 read the address back to the user before confirming.
|
|
82516
82703
|
amountSats is gross (fee comes out of it) and may be the whole available balance.
|
|
82704
|
+
The SECOND wallet popup is on a clock of well under a minute; if the user misses it the
|
|
82705
|
+
withdrawal fails with the reservation already committed and their coins still in the
|
|
82706
|
+
vault. That does NOT clear itself and it is not a stale spend \u2014 \`loan_recover_stale_spend\`
|
|
82707
|
+
needs the coins to have MOVED, which is exactly what did not happen. The way out is
|
|
82708
|
+
\`loan_withdraw_retry {positionId, confirmed:true}\`, which re-runs that second step with a
|
|
82709
|
+
fresh stamp using the destination and amount the CHAIN already holds. Check
|
|
82710
|
+
\`position_pending_withdrawals\` first, and tell the user it re-sends real BTC.
|
|
82517
82711
|
7. **Watch it** \u2014 \`position_status\` (one), \`position_list\` (all),
|
|
82518
82712
|
\`position_events\` (history), \`btc_price\`, \`protocol_status\`.
|
|
82519
82713
|
|
|
@@ -82776,8 +82970,7 @@ ${connectorStatusTruth(d)}
|
|
|
82776
82970
|
**What it is:** instead of installing anything, the user adds Diamond Hands to
|
|
82777
82971
|
claude.ai as a connector (paste a URL \u2014 zero install, zero Node, zero config files).
|
|
82778
82972
|
Sign-in IS the wallet: one Sign-In-with-Ethereum signature proves address ownership \u2014
|
|
82779
|
-
no password, no email, no account beyond the wallet address. The sign-in
|
|
82780
|
-
WalletConnect QR too, so a phone wallet works without any browser extension.
|
|
82973
|
+
no password, no email, no account beyond the wallet address.${d.walletConnect ? " The sign-in\npage offers a WalletConnect QR too, so a phone wallet works without any browser extension." : "\n" + phoneWalletOffer(d) + "."}
|
|
82781
82974
|
|
|
82782
82975
|
**Signature cadence, plainly:** the FIRST connect costs one SIWE signature (sign-in)
|
|
82783
82976
|
plus one lit-ops login signature (read access). After that, every operation that moves
|
|
@@ -82798,17 +82991,19 @@ honestly when asked "is this safe"):
|
|
|
82798
82991
|
is never written to disk. A breach here is privacy-class, never money-class.
|
|
82799
82992
|
3. **What the assistant narrates.** Tool results shape what the assistant tells you \u2014
|
|
82800
82993
|
a security concern is filed and audited for exactly this channel.
|
|
82801
|
-
4. **Tenant separation
|
|
82802
|
-
gets its own world: its own boundary, its own signer state, its own
|
|
82803
|
-
mount, keyed by that address.
|
|
82804
|
-
|
|
82805
|
-
|
|
82806
|
-
|
|
82807
|
-
|
|
82808
|
-
|
|
82809
|
-
|
|
82810
|
-
|
|
82811
|
-
|
|
82994
|
+
4. **Tenant separation, and what the mount binding does and does not cover.** Each
|
|
82995
|
+
signed-in wallet gets its own world: its own boundary, its own signer state, its own
|
|
82996
|
+
approval-page mount, keyed by that address. The wallet that connects at the mount
|
|
82997
|
+
must BE that address \u2014 a wallet offering any other account is refused at connect
|
|
82998
|
+
time, and switching accounts afterwards is refused the same way rather than silently
|
|
82999
|
+
becoming the new signer. So the account that signs is the account that signed in.
|
|
83000
|
+
None of that makes the mount link safe to pass around: whoever holds it can still
|
|
83001
|
+
load the page and observe or disrupt a pending ceremony, so treat the link as a
|
|
83002
|
+
secret \u2014 it is freshly random per world and travels only in the user's own tool
|
|
83003
|
+
result. What the binding does mean is that a holder cannot become this session's
|
|
83004
|
+
signer. Alongside that,
|
|
83005
|
+
EVERY fund movement still verifies the signature against the bound borrower, and no
|
|
83006
|
+
key material exists server-side.
|
|
82812
83007
|
5. **Availability and deploy honesty.** Hosted code changes under you: deploys are
|
|
82813
83008
|
version-pinned, the page bundle is open-source, and \`boundary://info\` capabilities
|
|
82814
83009
|
reports the exact server version.
|
|
@@ -82995,11 +83190,17 @@ function createNetworkSwitchRuntime(opts) {
|
|
|
82995
83190
|
}
|
|
82996
83191
|
};
|
|
82997
83192
|
}
|
|
82998
|
-
function guideDeployment(overrides) {
|
|
83193
|
+
function guideDeployment(overrides, env) {
|
|
82999
83194
|
return {
|
|
83000
83195
|
tier: overrides?.bridgeMount ? "hosted" : "local",
|
|
83001
83196
|
networks: overrides?.allowedNetworks ?? LOCAL_GUIDE_DEPLOYMENT.networks,
|
|
83002
|
-
signerModes: overrides?.externalOnly ? EXTERNAL_ONLY_SIGNER_MODES : LOCAL_GUIDE_DEPLOYMENT.signerModes
|
|
83197
|
+
signerModes: overrides?.externalOnly ? EXTERNAL_ONLY_SIGNER_MODES : LOCAL_GUIDE_DEPLOYMENT.signerModes,
|
|
83198
|
+
// C-44 F8, the fourth derivation. Read from the SAME env var the bridge reads
|
|
83199
|
+
// (boundary/config.ts `DH_WC_PROJECT_ID` → BridgeOptions.wc), so the guide cannot promise
|
|
83200
|
+
// a phone-wallet QR that `/wc-pairing` would answer 404 for. Deriving it rather than
|
|
83201
|
+
// hard-coding a tier default is what keeps the guide and `/auth.md` from disagreeing
|
|
83202
|
+
// about the same server, which is exactly what they did before this line existed.
|
|
83203
|
+
walletConnect: Boolean(env?.["DH_WC_PROJECT_ID"])
|
|
83003
83204
|
};
|
|
83004
83205
|
}
|
|
83005
83206
|
function assembleWorld(opts) {
|
|
@@ -83009,7 +83210,7 @@ function assembleWorld(opts) {
|
|
|
83009
83210
|
...boot.mockControl ? { mockControl: boot.mockControl } : {},
|
|
83010
83211
|
...boot.signer ? { signer: boot.signer } : {},
|
|
83011
83212
|
...opts.overrides?.externalOnly ? { externalOnly: true } : {},
|
|
83012
|
-
deployment: guideDeployment(opts.overrides),
|
|
83213
|
+
deployment: guideDeployment(opts.overrides, opts.env),
|
|
83013
83214
|
...opts.configResult.ok && opts.configResult.config.adapter === "mock" && opts.configResult.config.chainId ? { chainId: opts.configResult.config.chainId } : {}
|
|
83014
83215
|
};
|
|
83015
83216
|
if ((opts.env["DH_ADAPTER"] ?? "real") !== "mock") {
|
|
@@ -83321,6 +83522,32 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
83321
83522
|
return renderEnvelope(await b.boundary.withdrawBtc({ positionId, btcAddress: btcAddress2, amountSats, networkFeeSats }));
|
|
83322
83523
|
})
|
|
83323
83524
|
);
|
|
83525
|
+
registerBoundaryTool(
|
|
83526
|
+
server,
|
|
83527
|
+
"loan_withdraw_retry",
|
|
83528
|
+
{
|
|
83529
|
+
title: "Re-run a stalled BTC withdrawal's execute step",
|
|
83530
|
+
description: `Finish a withdrawal that authorized but never broadcast. loan_withdraw has two steps: the first commits the reservation on-chain, the second signs a time-stamped hash whose window is under a minute \u2014 often nearer twenty seconds. If that second signature is not given in time the withdrawal fails with the reservation ALREADY committed and the coins still in the vault, and it does not clear itself: loan_recover_stale_spend needs the coins to have MOVED, which is exactly what did not happen. This re-runs the second step alone with a fresh stamp. Destination and amount come from the on-chain record, not from you \u2014 the only figure you supply is the network fee, which is taken OUT of the already-authorized amount and cannot increase what leaves the vault. Use position_pending_withdrawals to see what is outstanding first. Sends real BTC. ${LATENCY_NOTE} Requires human confirmation (confirmed: true).`,
|
|
83531
|
+
inputSchema: {
|
|
83532
|
+
positionId: positionIdSchema,
|
|
83533
|
+
networkFeeSats: import_zod.z.number().int().positive().default(1e3).describe("BTC network fee in sats (declared default 1000); taken FROM the authorized amount, not added on top"),
|
|
83534
|
+
confirmed: confirmedSchema
|
|
83535
|
+
},
|
|
83536
|
+
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
|
|
83537
|
+
},
|
|
83538
|
+
async ({ positionId, networkFeeSats, confirmed }) => guardedWrite(getB, async () => {
|
|
83539
|
+
const gate = requireConfirmation(
|
|
83540
|
+
confirmed,
|
|
83541
|
+
`re-run the execute step for every outstanding BTC withdrawal reservation on position ${positionId} (this BROADCASTS real BTC to the destination each reservation already authorizes)`
|
|
83542
|
+
);
|
|
83543
|
+
if (gate) return gate;
|
|
83544
|
+
const problem = checkPositionIdHex(positionId) ?? checkSatsAmount(networkFeeSats, "Network fee");
|
|
83545
|
+
if (problem) return validationFailed(problem);
|
|
83546
|
+
const b = getB();
|
|
83547
|
+
if (!b.ok) return renderError(b.error);
|
|
83548
|
+
return renderEnvelope(await b.boundary.retryWithdrawExecute({ positionId, networkFeeSats }));
|
|
83549
|
+
})
|
|
83550
|
+
);
|
|
83324
83551
|
registerBoundaryTool(
|
|
83325
83552
|
server,
|
|
83326
83553
|
"loan_allowlist_destination",
|
|
@@ -83346,7 +83573,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
83346
83573
|
"loan_delegation_setup",
|
|
83347
83574
|
{
|
|
83348
83575
|
title: "Install delegation on the Safe (one owner ceremony)",
|
|
83349
|
-
description: `The ONE-TIME Safe delegation batch (signer mode 'safe-module'): your owners sign a single durable Safe transaction \u2014 at their leisure, no time window \u2014 that enables the Safe's AgentModule, binds the agent key, registers it in the delegation registry, and pre-approves the given BTC withdrawal destinations. After it, day-to-day operations (create/mint/pay/extend) run agent-solo; withdrawals always still need the owners' short signing burst, and only to destinations approved here (or later via loan_allowlist_destination \u2014 also owners-only). A revoked agent address burns FOREVER (AR-1) \u2014 rotation means a fresh key. Requires human confirmation (confirmed: true).`,
|
|
83576
|
+
description: `NOT AVAILABLE on the real protocol in this build \u2014 the real adapter answers UPSTREAM_UNAVAILABLE ('not wired in this delivery'). It runs on the practice (mock) adapter only. Say so before a user plans around it. The ONE-TIME Safe delegation batch (signer mode 'safe-module'): your owners sign a single durable Safe transaction \u2014 at their leisure, no time window \u2014 that enables the Safe's AgentModule, binds the agent key, registers it in the delegation registry, and pre-approves the given BTC withdrawal destinations. After it, day-to-day operations (create/mint/pay/extend) run agent-solo; withdrawals always still need the owners' short signing burst, and only to destinations approved here (or later via loan_allowlist_destination \u2014 also owners-only). A revoked agent address burns FOREVER (AR-1) \u2014 rotation means a fresh key. Requires human confirmation (confirmed: true).`,
|
|
83350
83577
|
inputSchema: {
|
|
83351
83578
|
btcAddresses: import_zod.z.array(import_zod.z.string().min(1)).describe("BTC withdrawal destinations to pre-approve in the same ceremony (avoids a second owner gathering before the first withdrawal)"),
|
|
83352
83579
|
confirmed: confirmedSchema
|
|
@@ -83366,7 +83593,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
83366
83593
|
"loan_delegation_grant",
|
|
83367
83594
|
{
|
|
83368
83595
|
title: "Grant the agent per-position scopes (owners sign)",
|
|
83369
|
-
description: `Set what the delegated agent may do on ONE position \u2014 RENEW (extend), REPAY (pay down), MINT (borrow, only while the post-mint collateral ratio stays at or above mintFloorBps \u2014 required for MINT, it is the owners' risk bound). Grants are user-only expansion: for a Safe this is a QUORUM signature (durable Safe transaction, owners sign at leisure) \u2014 the agent can never widen its own powers. Omitting a scope leaves it un-granted; a grant with no scopes clears the position's grant. Requires human confirmation (confirmed: true).`,
|
|
83596
|
+
description: `NOT AVAILABLE on the real protocol in this build \u2014 the real adapter answers UPSTREAM_UNAVAILABLE ('not wired in this delivery'). It runs on the practice (mock) adapter only. Say so before a user plans around it. Set what the delegated agent may do on ONE position \u2014 RENEW (extend), REPAY (pay down), MINT (borrow, only while the post-mint collateral ratio stays at or above mintFloorBps \u2014 required for MINT, it is the owners' risk bound). Grants are user-only expansion: for a Safe this is a QUORUM signature (durable Safe transaction, owners sign at leisure) \u2014 the agent can never widen its own powers. Omitting a scope leaves it un-granted; a grant with no scopes clears the position's grant. Requires human confirmation (confirmed: true).`,
|
|
83370
83597
|
inputSchema: {
|
|
83371
83598
|
positionId: positionIdSchema,
|
|
83372
83599
|
renew: import_zod.z.boolean().optional().describe("Allow the agent to extend/renew this position"),
|
|
@@ -83396,7 +83623,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
83396
83623
|
"loan_recover_stale_spend",
|
|
83397
83624
|
{
|
|
83398
83625
|
title: "Recover a stale BTC reservation via LIT-attested proof",
|
|
83399
|
-
description: "Clear a stale authorized BTC spend on BTCSpendAuthorizer using a LIT-attested StaleSpendRecovery attestation. The original UTXO must already be consumed on Bitcoin with \u22656 confirmations. `invalidatorTxid` is either the borrower's authorized broadcast (after confirmations) or a PKP self-spend that invalidated the reservation. Permissionless on-chain.",
|
|
83626
|
+
description: "NOT AVAILABLE on the real protocol in this build \u2014 the real adapter answers UPSTREAM_UNAVAILABLE ('not wired in this delivery'); it runs on the practice (mock) adapter only. For a withdrawal that authorized but never broadcast, loan_withdraw_retry is the working path. Clear a stale authorized BTC spend on BTCSpendAuthorizer using a LIT-attested StaleSpendRecovery attestation. The original UTXO must already be consumed on Bitcoin with \u22656 confirmations. `invalidatorTxid` is either the borrower's authorized broadcast (after confirmations) or a PKP self-spend that invalidated the reservation. Permissionless on-chain.",
|
|
83400
83627
|
inputSchema: {
|
|
83401
83628
|
positionId: positionIdSchema,
|
|
83402
83629
|
utxoTxid: import_zod.z.string().describe("The original authorized UTXO's txid"),
|
|
@@ -84274,7 +84501,7 @@ function registerBoundaryInfoResource(server, getB) {
|
|
|
84274
84501
|
}
|
|
84275
84502
|
|
|
84276
84503
|
// src/version.ts
|
|
84277
|
-
var SERVER_VERSION = "0.5.
|
|
84504
|
+
var SERVER_VERSION = "0.5.13";
|
|
84278
84505
|
|
|
84279
84506
|
// src/server.ts
|
|
84280
84507
|
var SERVER_INSTRUCTIONS = "Diamond Hands MCP \u2014 Bitcoin-collateralized borrowing. Before promising ANY flow, read the boundary://info resource and honor its `capabilities` block: it states which network this server is on, whether money is real (practiceWorld), whether writes are enabled (and the true reason when they are not), and which signer modes this build actually offers \u2014 never describe a flow outside it. State the network and whether funds are real when the user first acts. Authorization is chosen by conversation via the signer_setup tool (when listed); writes always require confirmed:true after showing the human-readable card. For walkthroughs consult the guide tool / guide:// resources instead of inventing steps; when a tool refuses, relay its stated reason and remedy \u2014 do not improvise alternatives. When a network_switch tool is listed, the network can change mid-session \u2014 after ANY switch, re-read boundary://info and state the new network and money reality to the user before doing anything else. When the user asks to disconnect / log out / sign out / forget or remove their wallet, call signer_setup action 'disconnect' (the full flush) \u2014 never treat 'reset-borrower' as a disconnect; it only swaps identity. READING DATA: a payload's fields and notes are authoritative \u2014 state what they say, never speculate past them, and when the data does not carry something, say 'the data does not carry X'. Field meanings live in guide topic 'reading-data'; `reading` notes inside a result are interpretation instructions for that exact payload \u2014 follow them over any prior assumption.";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gvnrdao/dh-mcp",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.13",
|
|
4
4
|
"description": "MCP server for the Diamond Hands protocol",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@anthropic-ai/mcpb": "2.1.2",
|
|
57
|
-
"@gvnrdao/dh-sdk": "^0.0.
|
|
57
|
+
"@gvnrdao/dh-sdk": "^0.0.338",
|
|
58
58
|
"@types/express": "5.0.3",
|
|
59
59
|
"@types/jest": "29.5.12",
|
|
60
60
|
"@types/node": "20.14.10",
|