bsv-mcp 0.2.15 → 0.3.1
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/CHANGELOG.md +94 -10
- package/README.md +95 -13
- package/dist/app.html +483 -106
- package/dist/index.js +227724 -117380
- package/index.ts +523 -63
- package/package.json +24 -15
- package/prompts/bsvSdk/auth.ts +1 -1
- package/prompts/bsvSdk/cryptography.ts +1 -1
- package/prompts/bsvSdk/overview.ts +1 -1
- package/prompts/bsvSdk/primitives.ts +1 -1
- package/prompts/bsvSdk/script.ts +1 -1
- package/prompts/bsvSdk/transaction.ts +1 -1
- package/prompts/bsvSdk/wallet.ts +1 -1
- package/prompts/ordinals.ts +1 -1
- package/tools/a2b/discover.ts +2 -2
- package/tools/bap/friend.ts +17 -24
- package/tools/bap/generate.test.ts +34 -32
- package/tools/bap/generate.ts +48 -43
- package/tools/bap/getCurrentAddress.ts +1 -3
- package/tools/bap/getId.test.ts +18 -10
- package/tools/bap/getId.ts +8 -6
- package/tools/bap/utils.ts +1 -1
- package/tools/bsocial/bmapReadPosts.ts +16 -2
- package/tools/bsocial/createPost.ts +21 -10
- package/tools/bsocial/readPosts.ts +10 -4
- package/tools/bsv/decodeTransaction.ts +1 -1
- package/tools/bsv/explore.ts +0 -4
- package/tools/bsv/getPrice.ts +1 -1
- package/tools/bsv/token.ts +14 -6
- package/tools/constants.ts +6 -2
- package/tools/index.ts +22 -13
- package/tools/mnee/getBalance.ts +1 -1
- package/tools/mnee/parseTx.ts +1 -1
- package/tools/mnee/sendMnee.ts +30 -8
- package/tools/ordinals/getInscription.ts +1 -3
- package/tools/ordinals/getTokenByIdOrTicker.ts +1 -3
- package/tools/ordinals/index.ts +4 -1
- package/tools/ordinals/marketListings.ts +1 -1
- package/tools/ordinals/marketSales.ts +1 -1
- package/tools/ordinals/searchInscriptions.ts +1 -1
- package/tools/utils/aip.ts +31 -22
- package/tools/utils/installAgentMaster.ts +8 -9
- package/tools/utils/toolRegistration.ts +21 -22
- package/tools/utils/transactionBuilder.ts +21 -14
- package/tools/wallet/a2bPublishMcp.ts +15 -5
- package/tools/wallet/brc100.ts +567 -312
- package/tools/wallet/cancelListing.ts +29 -37
- package/tools/wallet/createOrdinals.ts +43 -27
- package/tools/wallet/droplit.ts +124 -0
- package/tools/wallet/fetchPaymentUtxos.ts +7 -5
- package/tools/wallet/gatherCollectionInfo.ts +3 -5
- package/tools/wallet/getAddress.ts +1 -4
- package/tools/wallet/getBalance.ts +15 -15
- package/tools/wallet/{getBalanceDroplet.ts → getBalanceDroplit.ts} +6 -6
- package/tools/wallet/getBsv21Balances.ts +20 -14
- package/tools/wallet/getLockData.ts +11 -11
- package/tools/wallet/getOrdinals.ts +26 -20
- package/tools/wallet/integratedWallet.ts +53 -53
- package/tools/wallet/listOrdinal.ts +40 -39
- package/tools/wallet/listTokens.ts +18 -17
- package/tools/wallet/lockBsv.ts +36 -22
- package/tools/wallet/mintCollection.ts +15 -10
- package/tools/wallet/opnsDeregister.ts +29 -39
- package/tools/wallet/opnsRegister.ts +29 -39
- package/tools/wallet/purchaseListing.test.ts +27 -0
- package/tools/wallet/purchaseListing.ts +59 -40
- package/tools/wallet/refreshUtxos.ts +1 -1
- package/tools/wallet/schemas.ts +0 -13
- package/tools/wallet/sendAllBsv.ts +26 -20
- package/tools/wallet/sendBsv.ts +107 -0
- package/tools/wallet/setupDroplit.ts +151 -0
- package/tools/wallet/signBsm.ts +18 -18
- package/tools/wallet/sweepBsv.ts +48 -27
- package/tools/wallet/sweepBsv21.ts +42 -28
- package/tools/wallet/sweepOrdinals.ts +38 -26
- package/tools/wallet/tools.ts +17 -17
- package/tools/wallet/transactionHelper.ts +13 -5
- package/tools/wallet/transferOrdToken.ts +72 -84
- package/tools/wallet/unlockBsv.ts +23 -17
- package/tools/wallet/utxo.ts +1 -0
- package/tools/wallet/wallet.ts +1 -13
- package/test-mcp-server.ts +0 -157
- package/tools/wallet/sendToAddress.ts +0 -74
- package/tools/wallet/setupDroplet.ts +0 -161
package/tools/wallet/brc100.ts
CHANGED
|
@@ -1,27 +1,61 @@
|
|
|
1
|
-
import type { OneSatContext } from
|
|
2
|
-
import type { McpServer } from
|
|
3
|
-
import type { CallToolResult } from
|
|
4
|
-
import { z } from
|
|
1
|
+
import type { OneSatContext } from "@1sat/actions";
|
|
2
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
const noCtx: CallToolResult = {
|
|
7
|
-
content: [{ type:
|
|
7
|
+
content: [{ type: "text", text: "Wallet not initialized." }],
|
|
8
8
|
isError: true,
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
10
|
|
|
11
11
|
function result(data: unknown): CallToolResult {
|
|
12
|
-
return { content: [{ type:
|
|
12
|
+
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function error(err: unknown): CallToolResult {
|
|
16
16
|
return {
|
|
17
|
-
content: [
|
|
17
|
+
content: [
|
|
18
|
+
{ type: "text", text: err instanceof Error ? err.message : String(err) },
|
|
19
|
+
],
|
|
18
20
|
isError: true,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Parse a JSON-encoded tool argument. Malformed JSON is reported rather than
|
|
26
|
+
* passed through as a raw string, which would surface later as an opaque
|
|
27
|
+
* wallet error about the wrong argument.
|
|
28
|
+
*/
|
|
29
|
+
function parseJSON<T>(name: string, s: string | undefined): T | undefined {
|
|
30
|
+
if (!s) return undefined;
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(s) as T;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
`${name} is not valid JSON: ${e instanceof Error ? e.message : String(e)}`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Parse a JSON-encoded tool argument that the BRC-100 call requires. The MCP
|
|
42
|
+
* schema already marks these mandatory, so a missing value means the caller
|
|
43
|
+
* bypassed validation and is reported rather than forwarded as undefined.
|
|
44
|
+
*/
|
|
45
|
+
function parseRequiredJSON<T>(name: string, s: string | undefined): T {
|
|
46
|
+
const parsed = parseJSON<T>(name, s);
|
|
47
|
+
if (parsed === undefined) {
|
|
48
|
+
throw new Error(`${name} is required`);
|
|
19
49
|
}
|
|
50
|
+
return parsed;
|
|
20
51
|
}
|
|
21
52
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
53
|
+
/**
|
|
54
|
+
* BRC-100 models `identityKey` as the literal `true` — present or absent, never
|
|
55
|
+
* `false`. MCP arguments are plain booleans, so `false` is dropped here.
|
|
56
|
+
*/
|
|
57
|
+
function identityKeyArg(v: boolean | undefined): true | undefined {
|
|
58
|
+
return v === true ? true : undefined;
|
|
25
59
|
}
|
|
26
60
|
|
|
27
61
|
export function registerBrc100Tools(
|
|
@@ -31,97 +65,162 @@ export function registerBrc100Tools(
|
|
|
31
65
|
// ── Transaction lifecycle ──────────────────────────────────────────
|
|
32
66
|
|
|
33
67
|
server.tool(
|
|
34
|
-
|
|
35
|
-
|
|
68
|
+
"wallet_createAction",
|
|
69
|
+
"Creates a new Bitcoin transaction. Handles funding, signing, and broadcasting based on options.",
|
|
36
70
|
{
|
|
37
|
-
description: z.string().describe(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
71
|
+
description: z.string().describe("5-50 char description of the action"),
|
|
72
|
+
inputBEEFJSON: z
|
|
73
|
+
.string()
|
|
74
|
+
.optional()
|
|
75
|
+
.describe(
|
|
76
|
+
"JSON array of BEEF bytes proving the inputs. Required whenever inputs are supplied — createAction rejects inputs without their proof chain.",
|
|
77
|
+
),
|
|
78
|
+
inputsJSON: z
|
|
79
|
+
.string()
|
|
80
|
+
.optional()
|
|
81
|
+
.describe("JSON array of transaction inputs"),
|
|
82
|
+
outputsJSON: z
|
|
83
|
+
.string()
|
|
84
|
+
.optional()
|
|
85
|
+
.describe(
|
|
86
|
+
"JSON array of transaction outputs [{lockingScript, satoshis, outputDescription, basket, tags, customInstructions}]",
|
|
87
|
+
),
|
|
88
|
+
labelsJSON: z.string().optional().describe("JSON array of label strings"),
|
|
41
89
|
lockTime: z.number().optional(),
|
|
42
90
|
version: z.number().optional(),
|
|
43
|
-
optionsJSON: z
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
91
|
+
optionsJSON: z
|
|
92
|
+
.string()
|
|
93
|
+
.optional()
|
|
94
|
+
.describe(
|
|
95
|
+
"JSON CreateActionOptions: {noSend, sendWith, acceptDelayedBroadcast, signAndProcess, randomizeOutputs, noSendChange, knownTxids, trustSelf}",
|
|
96
|
+
),
|
|
97
|
+
},
|
|
98
|
+
async ({
|
|
99
|
+
description,
|
|
100
|
+
inputBEEFJSON,
|
|
101
|
+
inputsJSON,
|
|
102
|
+
outputsJSON,
|
|
103
|
+
labelsJSON,
|
|
104
|
+
lockTime,
|
|
105
|
+
version,
|
|
106
|
+
optionsJSON,
|
|
107
|
+
}) => {
|
|
108
|
+
if (!ctx) return noCtx;
|
|
47
109
|
try {
|
|
48
|
-
return result(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
110
|
+
return result(
|
|
111
|
+
await ctx.wallet.createAction({
|
|
112
|
+
description,
|
|
113
|
+
inputBEEF: parseJSON("inputBEEFJSON", inputBEEFJSON),
|
|
114
|
+
inputs: parseJSON("inputsJSON", inputsJSON),
|
|
115
|
+
outputs: parseJSON("outputsJSON", outputsJSON),
|
|
116
|
+
labels: parseJSON("labelsJSON", labelsJSON),
|
|
117
|
+
lockTime,
|
|
118
|
+
version,
|
|
119
|
+
options: parseJSON("optionsJSON", optionsJSON),
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
return error(e);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
);
|
|
60
127
|
|
|
61
128
|
server.tool(
|
|
62
|
-
|
|
63
|
-
|
|
129
|
+
"wallet_signAction",
|
|
130
|
+
"Signs a transaction previously created with createAction (when signAndProcess was false).",
|
|
64
131
|
{
|
|
65
|
-
spendsJSON: z
|
|
66
|
-
|
|
67
|
-
|
|
132
|
+
spendsJSON: z
|
|
133
|
+
.string()
|
|
134
|
+
.describe(
|
|
135
|
+
"JSON map of input index to {unlockingScript, sequenceNumber}",
|
|
136
|
+
),
|
|
137
|
+
reference: z
|
|
138
|
+
.string()
|
|
139
|
+
.describe("Base64 reference from createAction result"),
|
|
140
|
+
optionsJSON: z
|
|
141
|
+
.string()
|
|
142
|
+
.optional()
|
|
143
|
+
.describe("JSON SignActionOptions: {acceptDelayedBroadcast, sendWith}"),
|
|
68
144
|
},
|
|
69
145
|
async ({ spendsJSON, reference, optionsJSON }) => {
|
|
70
|
-
if (!ctx) return noCtx
|
|
146
|
+
if (!ctx) return noCtx;
|
|
71
147
|
try {
|
|
72
|
-
return result(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
148
|
+
return result(
|
|
149
|
+
await ctx.wallet.signAction({
|
|
150
|
+
spends: parseRequiredJSON("spendsJSON", spendsJSON),
|
|
151
|
+
reference,
|
|
152
|
+
options: parseJSON("optionsJSON", optionsJSON),
|
|
153
|
+
}),
|
|
154
|
+
);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
return error(e);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
);
|
|
80
160
|
|
|
81
161
|
server.tool(
|
|
82
|
-
|
|
83
|
-
|
|
162
|
+
"wallet_abortAction",
|
|
163
|
+
"Aborts a pending (nosend or unsigned) transaction, releasing consumed inputs back to spendable state.",
|
|
84
164
|
{
|
|
85
|
-
reference: z
|
|
165
|
+
reference: z
|
|
166
|
+
.string()
|
|
167
|
+
.describe("Base64 reference of the transaction to abort"),
|
|
86
168
|
},
|
|
87
169
|
async ({ reference }) => {
|
|
88
|
-
if (!ctx) return noCtx
|
|
170
|
+
if (!ctx) return noCtx;
|
|
89
171
|
try {
|
|
90
|
-
return result(await ctx.wallet.abortAction({ reference }))
|
|
91
|
-
} catch (e) {
|
|
172
|
+
return result(await ctx.wallet.abortAction({ reference }));
|
|
173
|
+
} catch (e) {
|
|
174
|
+
return error(e);
|
|
175
|
+
}
|
|
92
176
|
},
|
|
93
|
-
)
|
|
177
|
+
);
|
|
94
178
|
|
|
95
179
|
server.tool(
|
|
96
|
-
|
|
97
|
-
|
|
180
|
+
"wallet_internalizeAction",
|
|
181
|
+
"Internalizes an external transaction, adding its outputs to wallet baskets.",
|
|
98
182
|
{
|
|
99
|
-
txJSON: z.string().describe(
|
|
100
|
-
outputsJSON: z.string().describe(
|
|
101
|
-
description: z.string().describe(
|
|
102
|
-
labelsJSON: z.string().optional().describe(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
183
|
+
txJSON: z.string().describe("JSON array of AtomicBEEF bytes"),
|
|
184
|
+
outputsJSON: z.string().describe("JSON array of outputs to internalize"),
|
|
185
|
+
description: z.string().describe("5-50 char description"),
|
|
186
|
+
labelsJSON: z.string().optional().describe("JSON array of label strings"),
|
|
187
|
+
seekPermission: z.boolean().optional(),
|
|
188
|
+
},
|
|
189
|
+
async ({
|
|
190
|
+
txJSON,
|
|
191
|
+
outputsJSON,
|
|
192
|
+
description,
|
|
193
|
+
labelsJSON,
|
|
194
|
+
seekPermission,
|
|
195
|
+
}) => {
|
|
196
|
+
if (!ctx) return noCtx;
|
|
106
197
|
try {
|
|
107
|
-
return result(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
198
|
+
return result(
|
|
199
|
+
await ctx.wallet.internalizeAction({
|
|
200
|
+
tx: parseRequiredJSON("txJSON", txJSON),
|
|
201
|
+
outputs: parseRequiredJSON("outputsJSON", outputsJSON),
|
|
202
|
+
description,
|
|
203
|
+
seekPermission,
|
|
204
|
+
labels: parseJSON("labelsJSON", labelsJSON),
|
|
205
|
+
}),
|
|
206
|
+
);
|
|
207
|
+
} catch (e) {
|
|
208
|
+
return error(e);
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
);
|
|
116
212
|
|
|
117
213
|
// ── Queries ────────────────────────────────────────────────────────
|
|
118
214
|
|
|
119
215
|
server.tool(
|
|
120
|
-
|
|
121
|
-
|
|
216
|
+
"wallet_listActions",
|
|
217
|
+
"Lists wallet transactions filtered by labels, with optional input/output details.",
|
|
122
218
|
{
|
|
123
|
-
labelsJSON: z
|
|
124
|
-
|
|
219
|
+
labelsJSON: z
|
|
220
|
+
.string()
|
|
221
|
+
.default("[]")
|
|
222
|
+
.describe("JSON array of label strings"),
|
|
223
|
+
labelQueryMode: z.enum(["any", "all"]).default("any"),
|
|
125
224
|
includeLabels: z.boolean().default(true),
|
|
126
225
|
includeInputs: z.boolean().default(false),
|
|
127
226
|
includeInputSourceLockingScripts: z.boolean().default(false),
|
|
@@ -130,443 +229,599 @@ export function registerBrc100Tools(
|
|
|
130
229
|
includeOutputLockingScripts: z.boolean().default(false),
|
|
131
230
|
limit: z.number().default(25),
|
|
132
231
|
offset: z.number().default(0),
|
|
232
|
+
seekPermission: z.boolean().optional(),
|
|
133
233
|
},
|
|
134
234
|
async ({ labelsJSON, ...rest }) => {
|
|
135
|
-
if (!ctx) return noCtx
|
|
235
|
+
if (!ctx) return noCtx;
|
|
136
236
|
try {
|
|
137
|
-
return result(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
237
|
+
return result(
|
|
238
|
+
await ctx.wallet.listActions({
|
|
239
|
+
labels: parseRequiredJSON("labelsJSON", labelsJSON),
|
|
240
|
+
...rest,
|
|
241
|
+
}),
|
|
242
|
+
);
|
|
243
|
+
} catch (e) {
|
|
244
|
+
return error(e);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
);
|
|
144
248
|
|
|
145
249
|
server.tool(
|
|
146
|
-
|
|
147
|
-
|
|
250
|
+
"wallet_listOutputs",
|
|
251
|
+
"Lists spendable outputs in a basket, optionally filtered by tags.",
|
|
148
252
|
{
|
|
149
253
|
basket: z.string().describe('Basket name (e.g. "default")'),
|
|
150
|
-
tagsJSON: z.string().optional().describe(
|
|
151
|
-
tagQueryMode: z.enum([
|
|
152
|
-
include: z.enum([
|
|
254
|
+
tagsJSON: z.string().optional().describe("JSON array of tag strings"),
|
|
255
|
+
tagQueryMode: z.enum(["all", "any"]).optional(),
|
|
256
|
+
include: z.enum(["locking scripts", "entire transactions"]).optional(),
|
|
153
257
|
includeCustomInstructions: z.boolean().default(false),
|
|
154
258
|
includeTags: z.boolean().default(false),
|
|
155
259
|
includeLabels: z.boolean().default(false),
|
|
156
260
|
limit: z.number().default(25),
|
|
157
261
|
offset: z.number().default(0),
|
|
262
|
+
seekPermission: z.boolean().optional(),
|
|
158
263
|
},
|
|
159
264
|
async ({ tagsJSON, ...rest }) => {
|
|
160
|
-
if (!ctx) return noCtx
|
|
265
|
+
if (!ctx) return noCtx;
|
|
161
266
|
try {
|
|
162
|
-
return result(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
267
|
+
return result(
|
|
268
|
+
await ctx.wallet.listOutputs({
|
|
269
|
+
tags: parseJSON("tagsJSON", tagsJSON),
|
|
270
|
+
...rest,
|
|
271
|
+
}),
|
|
272
|
+
);
|
|
273
|
+
} catch (e) {
|
|
274
|
+
return error(e);
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
);
|
|
169
278
|
|
|
170
279
|
server.tool(
|
|
171
|
-
|
|
172
|
-
|
|
280
|
+
"wallet_relinquishOutput",
|
|
281
|
+
"Removes an output from a basket without spending it.",
|
|
173
282
|
{
|
|
174
|
-
basket: z.string().describe(
|
|
175
|
-
output: z.string().describe(
|
|
283
|
+
basket: z.string().describe("Basket name"),
|
|
284
|
+
output: z.string().describe("Outpoint string (txid.vout)"),
|
|
176
285
|
},
|
|
177
286
|
async (args) => {
|
|
178
|
-
if (!ctx) return noCtx
|
|
287
|
+
if (!ctx) return noCtx;
|
|
179
288
|
try {
|
|
180
|
-
return result(await ctx.wallet.relinquishOutput(args
|
|
181
|
-
} catch (e) {
|
|
289
|
+
return result(await ctx.wallet.relinquishOutput(args));
|
|
290
|
+
} catch (e) {
|
|
291
|
+
return error(e);
|
|
292
|
+
}
|
|
182
293
|
},
|
|
183
|
-
)
|
|
294
|
+
);
|
|
184
295
|
|
|
185
296
|
// ── Keys & Crypto ──────────────────────────────────────────────────
|
|
186
297
|
|
|
187
298
|
server.tool(
|
|
188
|
-
|
|
299
|
+
"wallet_getPublicKey",
|
|
189
300
|
'Retrieves a public key by protocol/key derivation. Use identityKey:true for the root identity key. protocolID is a JSON array like [2,"1sat"].',
|
|
190
301
|
{
|
|
191
|
-
identityKey: z
|
|
192
|
-
|
|
302
|
+
identityKey: z
|
|
303
|
+
.boolean()
|
|
304
|
+
.optional()
|
|
305
|
+
.describe("If true, return the identity key (ignores other args)"),
|
|
306
|
+
protocolIDJSON: z
|
|
307
|
+
.string()
|
|
308
|
+
.optional()
|
|
309
|
+
.describe('JSON array [securityLevel, protocolString] e.g. [2,"1sat"]'),
|
|
193
310
|
keyID: z.string().optional(),
|
|
194
311
|
counterparty: z.string().optional(),
|
|
195
312
|
forSelf: z.boolean().optional(),
|
|
196
313
|
privileged: z.boolean().optional(),
|
|
197
314
|
privilegedReason: z.string().optional(),
|
|
315
|
+
seekPermission: z.boolean().optional(),
|
|
198
316
|
},
|
|
199
|
-
async ({ protocolIDJSON, ...rest }) => {
|
|
200
|
-
if (!ctx) return noCtx
|
|
317
|
+
async ({ protocolIDJSON, identityKey, ...rest }) => {
|
|
318
|
+
if (!ctx) return noCtx;
|
|
201
319
|
try {
|
|
202
|
-
return result(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
320
|
+
return result(
|
|
321
|
+
await ctx.wallet.getPublicKey({
|
|
322
|
+
protocolID: parseJSON("protocolIDJSON", protocolIDJSON),
|
|
323
|
+
identityKey: identityKeyArg(identityKey),
|
|
324
|
+
...rest,
|
|
325
|
+
}),
|
|
326
|
+
);
|
|
327
|
+
} catch (e) {
|
|
328
|
+
return error(e);
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
);
|
|
209
332
|
|
|
210
333
|
server.tool(
|
|
211
|
-
|
|
334
|
+
"wallet_encrypt",
|
|
212
335
|
'Encrypts data using wallet keys. protocolID is a JSON array like [2,"protocolName"].',
|
|
213
336
|
{
|
|
214
|
-
plaintext: z.array(z.number()).describe(
|
|
215
|
-
protocolIDJSON: z
|
|
337
|
+
plaintext: z.array(z.number()).describe("Data bytes to encrypt"),
|
|
338
|
+
protocolIDJSON: z
|
|
339
|
+
.string()
|
|
340
|
+
.describe("JSON array [securityLevel, protocolString]"),
|
|
216
341
|
keyID: z.string(),
|
|
217
342
|
counterparty: z.string().optional(),
|
|
218
343
|
privileged: z.boolean().optional(),
|
|
344
|
+
privilegedReason: z.string().optional(),
|
|
345
|
+
seekPermission: z.boolean().optional(),
|
|
219
346
|
},
|
|
220
347
|
async ({ protocolIDJSON, ...rest }) => {
|
|
221
|
-
if (!ctx) return noCtx
|
|
348
|
+
if (!ctx) return noCtx;
|
|
222
349
|
try {
|
|
223
|
-
return result(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
350
|
+
return result(
|
|
351
|
+
await ctx.wallet.encrypt({
|
|
352
|
+
protocolID: parseRequiredJSON("protocolIDJSON", protocolIDJSON),
|
|
353
|
+
...rest,
|
|
354
|
+
}),
|
|
355
|
+
);
|
|
356
|
+
} catch (e) {
|
|
357
|
+
return error(e);
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
);
|
|
230
361
|
|
|
231
362
|
server.tool(
|
|
232
|
-
|
|
233
|
-
|
|
363
|
+
"wallet_decrypt",
|
|
364
|
+
"Decrypts data using wallet keys.",
|
|
234
365
|
{
|
|
235
|
-
ciphertext: z.array(z.number()).describe(
|
|
236
|
-
protocolIDJSON: z
|
|
366
|
+
ciphertext: z.array(z.number()).describe("Encrypted data bytes"),
|
|
367
|
+
protocolIDJSON: z
|
|
368
|
+
.string()
|
|
369
|
+
.describe("JSON array [securityLevel, protocolString]"),
|
|
237
370
|
keyID: z.string(),
|
|
238
371
|
counterparty: z.string().optional(),
|
|
239
372
|
privileged: z.boolean().optional(),
|
|
373
|
+
privilegedReason: z.string().optional(),
|
|
374
|
+
seekPermission: z.boolean().optional(),
|
|
240
375
|
},
|
|
241
376
|
async ({ protocolIDJSON, ...rest }) => {
|
|
242
|
-
if (!ctx) return noCtx
|
|
377
|
+
if (!ctx) return noCtx;
|
|
243
378
|
try {
|
|
244
|
-
return result(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
379
|
+
return result(
|
|
380
|
+
await ctx.wallet.decrypt({
|
|
381
|
+
protocolID: parseRequiredJSON("protocolIDJSON", protocolIDJSON),
|
|
382
|
+
...rest,
|
|
383
|
+
}),
|
|
384
|
+
);
|
|
385
|
+
} catch (e) {
|
|
386
|
+
return error(e);
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
);
|
|
251
390
|
|
|
252
391
|
server.tool(
|
|
253
|
-
|
|
254
|
-
|
|
392
|
+
"wallet_createHmac",
|
|
393
|
+
"Creates an HMAC using wallet keys.",
|
|
255
394
|
{
|
|
256
|
-
data: z.array(z.number()).describe(
|
|
257
|
-
protocolIDJSON: z
|
|
395
|
+
data: z.array(z.number()).describe("Data bytes"),
|
|
396
|
+
protocolIDJSON: z
|
|
397
|
+
.string()
|
|
398
|
+
.describe("JSON array [securityLevel, protocolString]"),
|
|
258
399
|
keyID: z.string(),
|
|
259
400
|
counterparty: z.string().optional(),
|
|
260
401
|
privileged: z.boolean().optional(),
|
|
402
|
+
privilegedReason: z.string().optional(),
|
|
403
|
+
seekPermission: z.boolean().optional(),
|
|
261
404
|
},
|
|
262
405
|
async ({ protocolIDJSON, ...rest }) => {
|
|
263
|
-
if (!ctx) return noCtx
|
|
406
|
+
if (!ctx) return noCtx;
|
|
264
407
|
try {
|
|
265
|
-
return result(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
408
|
+
return result(
|
|
409
|
+
await ctx.wallet.createHmac({
|
|
410
|
+
protocolID: parseRequiredJSON("protocolIDJSON", protocolIDJSON),
|
|
411
|
+
...rest,
|
|
412
|
+
}),
|
|
413
|
+
);
|
|
414
|
+
} catch (e) {
|
|
415
|
+
return error(e);
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
);
|
|
272
419
|
|
|
273
420
|
server.tool(
|
|
274
|
-
|
|
275
|
-
|
|
421
|
+
"wallet_verifyHmac",
|
|
422
|
+
"Verifies an HMAC using wallet keys.",
|
|
276
423
|
{
|
|
277
|
-
data: z.array(z.number()).describe(
|
|
278
|
-
hmac: z.array(z.number()).describe(
|
|
279
|
-
protocolIDJSON: z
|
|
424
|
+
data: z.array(z.number()).describe("Data bytes"),
|
|
425
|
+
hmac: z.array(z.number()).describe("HMAC bytes to verify"),
|
|
426
|
+
protocolIDJSON: z
|
|
427
|
+
.string()
|
|
428
|
+
.describe("JSON array [securityLevel, protocolString]"),
|
|
280
429
|
keyID: z.string(),
|
|
281
430
|
counterparty: z.string().optional(),
|
|
282
431
|
privileged: z.boolean().optional(),
|
|
432
|
+
privilegedReason: z.string().optional(),
|
|
433
|
+
seekPermission: z.boolean().optional(),
|
|
283
434
|
},
|
|
284
435
|
async ({ protocolIDJSON, ...rest }) => {
|
|
285
|
-
if (!ctx) return noCtx
|
|
436
|
+
if (!ctx) return noCtx;
|
|
286
437
|
try {
|
|
287
|
-
return result(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
438
|
+
return result(
|
|
439
|
+
await ctx.wallet.verifyHmac({
|
|
440
|
+
protocolID: parseRequiredJSON("protocolIDJSON", protocolIDJSON),
|
|
441
|
+
...rest,
|
|
442
|
+
}),
|
|
443
|
+
);
|
|
444
|
+
} catch (e) {
|
|
445
|
+
return error(e);
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
);
|
|
294
449
|
|
|
295
450
|
server.tool(
|
|
296
|
-
|
|
297
|
-
|
|
451
|
+
"wallet_createSignature",
|
|
452
|
+
"Creates a digital signature using wallet keys. Supply exactly one of data or hashToDirectlySign.",
|
|
298
453
|
{
|
|
299
|
-
data: z.array(z.number()).describe(
|
|
300
|
-
|
|
454
|
+
data: z.array(z.number()).optional().describe("Data bytes to sign"),
|
|
455
|
+
hashToDirectlySign: z
|
|
456
|
+
.array(z.number())
|
|
457
|
+
.optional()
|
|
458
|
+
.describe("Pre-computed 32-byte hash to sign directly"),
|
|
459
|
+
protocolIDJSON: z
|
|
460
|
+
.string()
|
|
461
|
+
.describe("JSON array [securityLevel, protocolString]"),
|
|
301
462
|
keyID: z.string(),
|
|
302
463
|
counterparty: z.string().optional(),
|
|
303
464
|
privileged: z.boolean().optional(),
|
|
465
|
+
privilegedReason: z.string().optional(),
|
|
466
|
+
seekPermission: z.boolean().optional(),
|
|
304
467
|
},
|
|
305
468
|
async ({ protocolIDJSON, ...rest }) => {
|
|
306
|
-
if (!ctx) return noCtx
|
|
469
|
+
if (!ctx) return noCtx;
|
|
307
470
|
try {
|
|
308
|
-
return result(
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
471
|
+
return result(
|
|
472
|
+
await ctx.wallet.createSignature({
|
|
473
|
+
protocolID: parseRequiredJSON("protocolIDJSON", protocolIDJSON),
|
|
474
|
+
...rest,
|
|
475
|
+
}),
|
|
476
|
+
);
|
|
477
|
+
} catch (e) {
|
|
478
|
+
return error(e);
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
);
|
|
315
482
|
|
|
316
483
|
server.tool(
|
|
317
|
-
|
|
318
|
-
|
|
484
|
+
"wallet_verifySignature",
|
|
485
|
+
"Verifies a digital signature using wallet keys. Supply exactly one of data or hashToDirectlyVerify.",
|
|
319
486
|
{
|
|
320
|
-
data: z
|
|
321
|
-
|
|
322
|
-
|
|
487
|
+
data: z
|
|
488
|
+
.array(z.number())
|
|
489
|
+
.optional()
|
|
490
|
+
.describe("Data bytes that were signed"),
|
|
491
|
+
hashToDirectlyVerify: z
|
|
492
|
+
.array(z.number())
|
|
493
|
+
.optional()
|
|
494
|
+
.describe("Pre-computed 32-byte hash that was signed"),
|
|
495
|
+
signature: z.array(z.number()).describe("Signature bytes"),
|
|
496
|
+
protocolIDJSON: z
|
|
497
|
+
.string()
|
|
498
|
+
.describe("JSON array [securityLevel, protocolString]"),
|
|
323
499
|
keyID: z.string(),
|
|
324
500
|
counterparty: z.string().optional(),
|
|
325
501
|
forSelf: z.boolean().optional(),
|
|
326
502
|
privileged: z.boolean().optional(),
|
|
503
|
+
privilegedReason: z.string().optional(),
|
|
504
|
+
seekPermission: z.boolean().optional(),
|
|
327
505
|
},
|
|
328
506
|
async ({ protocolIDJSON, ...rest }) => {
|
|
329
|
-
if (!ctx) return noCtx
|
|
507
|
+
if (!ctx) return noCtx;
|
|
330
508
|
try {
|
|
331
|
-
return result(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
509
|
+
return result(
|
|
510
|
+
await ctx.wallet.verifySignature({
|
|
511
|
+
protocolID: parseRequiredJSON("protocolIDJSON", protocolIDJSON),
|
|
512
|
+
...rest,
|
|
513
|
+
}),
|
|
514
|
+
);
|
|
515
|
+
} catch (e) {
|
|
516
|
+
return error(e);
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
);
|
|
338
520
|
|
|
339
521
|
// ── Key Linkage ────────────────────────────────────────────────────
|
|
340
522
|
|
|
341
523
|
server.tool(
|
|
342
|
-
|
|
343
|
-
|
|
524
|
+
"wallet_revealCounterpartyKeyLinkage",
|
|
525
|
+
"Reveals the linkage between the wallet identity and a counterparty to a verifier.",
|
|
344
526
|
{
|
|
345
|
-
counterparty: z.string().describe(
|
|
346
|
-
verifier: z.string().describe(
|
|
527
|
+
counterparty: z.string().describe("Counterparty public key hex"),
|
|
528
|
+
verifier: z.string().describe("Verifier public key hex"),
|
|
347
529
|
privileged: z.boolean().optional(),
|
|
348
530
|
privilegedReason: z.string().optional(),
|
|
349
531
|
},
|
|
350
532
|
async (args) => {
|
|
351
|
-
if (!ctx) return noCtx
|
|
533
|
+
if (!ctx) return noCtx;
|
|
352
534
|
try {
|
|
353
|
-
return result(await ctx.wallet.revealCounterpartyKeyLinkage(args
|
|
354
|
-
} catch (e) {
|
|
535
|
+
return result(await ctx.wallet.revealCounterpartyKeyLinkage(args));
|
|
536
|
+
} catch (e) {
|
|
537
|
+
return error(e);
|
|
538
|
+
}
|
|
355
539
|
},
|
|
356
|
-
)
|
|
540
|
+
);
|
|
357
541
|
|
|
358
542
|
server.tool(
|
|
359
|
-
|
|
360
|
-
|
|
543
|
+
"wallet_revealSpecificKeyLinkage",
|
|
544
|
+
"Reveals linkage for a specific protocol/key combination to a verifier.",
|
|
361
545
|
{
|
|
362
|
-
counterparty: z.string().describe(
|
|
363
|
-
verifier: z.string().describe(
|
|
364
|
-
protocolIDJSON: z
|
|
546
|
+
counterparty: z.string().describe("Counterparty public key hex"),
|
|
547
|
+
verifier: z.string().describe("Verifier public key hex"),
|
|
548
|
+
protocolIDJSON: z
|
|
549
|
+
.string()
|
|
550
|
+
.describe("JSON array [securityLevel, protocolString]"),
|
|
365
551
|
keyID: z.string(),
|
|
366
552
|
privileged: z.boolean().optional(),
|
|
367
553
|
privilegedReason: z.string().optional(),
|
|
368
554
|
},
|
|
369
555
|
async ({ protocolIDJSON, ...rest }) => {
|
|
370
|
-
if (!ctx) return noCtx
|
|
556
|
+
if (!ctx) return noCtx;
|
|
371
557
|
try {
|
|
372
|
-
return result(
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
558
|
+
return result(
|
|
559
|
+
await ctx.wallet.revealSpecificKeyLinkage({
|
|
560
|
+
protocolID: parseRequiredJSON("protocolIDJSON", protocolIDJSON),
|
|
561
|
+
...rest,
|
|
562
|
+
}),
|
|
563
|
+
);
|
|
564
|
+
} catch (e) {
|
|
565
|
+
return error(e);
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
);
|
|
379
569
|
|
|
380
570
|
// ── Certificates ───────────────────────────────────────────────────
|
|
381
571
|
|
|
382
572
|
server.tool(
|
|
383
|
-
|
|
384
|
-
|
|
573
|
+
"wallet_acquireCertificate",
|
|
574
|
+
"Acquires an identity certificate from a certifier.",
|
|
385
575
|
{
|
|
386
|
-
type: z.string().describe(
|
|
387
|
-
certifier: z.string().describe(
|
|
388
|
-
acquisitionProtocol: z.enum([
|
|
389
|
-
fieldsJSON: z.string().describe(
|
|
576
|
+
type: z.string().describe("Certificate type (base64)"),
|
|
577
|
+
certifier: z.string().describe("Certifier public key hex"),
|
|
578
|
+
acquisitionProtocol: z.enum(["direct", "issuance"]),
|
|
579
|
+
fieldsJSON: z.string().describe("JSON object of certificate fields"),
|
|
390
580
|
serialNumber: z.string().optional(),
|
|
391
581
|
revocationOutpoint: z.string().optional(),
|
|
392
582
|
signature: z.string().optional(),
|
|
393
583
|
certifierUrl: z.string().optional(),
|
|
394
584
|
keyringRevealer: z.string().optional(),
|
|
395
|
-
keyringForSubjectJSON: z
|
|
585
|
+
keyringForSubjectJSON: z
|
|
586
|
+
.string()
|
|
587
|
+
.optional()
|
|
588
|
+
.describe("JSON object of keyring for subject"),
|
|
396
589
|
privileged: z.boolean().optional(),
|
|
397
590
|
privilegedReason: z.string().optional(),
|
|
398
591
|
},
|
|
399
592
|
async ({ fieldsJSON, keyringForSubjectJSON, ...rest }) => {
|
|
400
|
-
if (!ctx) return noCtx
|
|
593
|
+
if (!ctx) return noCtx;
|
|
401
594
|
try {
|
|
402
|
-
return result(
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
595
|
+
return result(
|
|
596
|
+
await ctx.wallet.acquireCertificate({
|
|
597
|
+
fields: parseRequiredJSON("fieldsJSON", fieldsJSON),
|
|
598
|
+
keyringForSubject: parseJSON(
|
|
599
|
+
"keyringForSubjectJSON",
|
|
600
|
+
keyringForSubjectJSON,
|
|
601
|
+
),
|
|
602
|
+
...rest,
|
|
603
|
+
}),
|
|
604
|
+
);
|
|
605
|
+
} catch (e) {
|
|
606
|
+
return error(e);
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
);
|
|
410
610
|
|
|
411
611
|
server.tool(
|
|
412
|
-
|
|
413
|
-
|
|
612
|
+
"wallet_listCertificates",
|
|
613
|
+
"Lists identity certificates filtered by certifiers and types.",
|
|
414
614
|
{
|
|
415
|
-
certifiersJSON: z
|
|
416
|
-
|
|
615
|
+
certifiersJSON: z
|
|
616
|
+
.string()
|
|
617
|
+
.describe("JSON array of certifier public key hexes"),
|
|
618
|
+
typesJSON: z
|
|
619
|
+
.string()
|
|
620
|
+
.describe("JSON array of certificate types (base64)"),
|
|
417
621
|
limit: z.number().default(25),
|
|
418
622
|
offset: z.number().default(0),
|
|
419
623
|
privileged: z.boolean().optional(),
|
|
420
624
|
privilegedReason: z.string().optional(),
|
|
421
625
|
},
|
|
422
626
|
async ({ certifiersJSON, typesJSON, ...rest }) => {
|
|
423
|
-
if (!ctx) return noCtx
|
|
627
|
+
if (!ctx) return noCtx;
|
|
424
628
|
try {
|
|
425
|
-
return result(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
629
|
+
return result(
|
|
630
|
+
await ctx.wallet.listCertificates({
|
|
631
|
+
certifiers: parseRequiredJSON("certifiersJSON", certifiersJSON),
|
|
632
|
+
types: parseRequiredJSON("typesJSON", typesJSON),
|
|
633
|
+
...rest,
|
|
634
|
+
}),
|
|
635
|
+
);
|
|
636
|
+
} catch (e) {
|
|
637
|
+
return error(e);
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
);
|
|
433
641
|
|
|
434
642
|
server.tool(
|
|
435
|
-
|
|
436
|
-
|
|
643
|
+
"wallet_proveCertificate",
|
|
644
|
+
"Proves select fields of a certificate to a verifier.",
|
|
437
645
|
{
|
|
438
|
-
certificateJSON: z
|
|
439
|
-
|
|
440
|
-
|
|
646
|
+
certificateJSON: z
|
|
647
|
+
.string()
|
|
648
|
+
.describe("JSON object of the certificate to prove"),
|
|
649
|
+
fieldsToRevealJSON: z
|
|
650
|
+
.string()
|
|
651
|
+
.describe("JSON array of field names to reveal"),
|
|
652
|
+
verifier: z.string().describe("Verifier public key hex"),
|
|
441
653
|
privileged: z.boolean().optional(),
|
|
442
654
|
privilegedReason: z.string().optional(),
|
|
443
655
|
},
|
|
444
656
|
async ({ certificateJSON, fieldsToRevealJSON, ...rest }) => {
|
|
445
|
-
if (!ctx) return noCtx
|
|
657
|
+
if (!ctx) return noCtx;
|
|
446
658
|
try {
|
|
447
|
-
return result(
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
659
|
+
return result(
|
|
660
|
+
await ctx.wallet.proveCertificate({
|
|
661
|
+
certificate: parseRequiredJSON("certificateJSON", certificateJSON),
|
|
662
|
+
fieldsToReveal: parseRequiredJSON(
|
|
663
|
+
"fieldsToRevealJSON",
|
|
664
|
+
fieldsToRevealJSON,
|
|
665
|
+
),
|
|
666
|
+
...rest,
|
|
667
|
+
}),
|
|
668
|
+
);
|
|
669
|
+
} catch (e) {
|
|
670
|
+
return error(e);
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
);
|
|
455
674
|
|
|
456
675
|
server.tool(
|
|
457
|
-
|
|
458
|
-
|
|
676
|
+
"wallet_relinquishCertificate",
|
|
677
|
+
"Removes a certificate from the wallet.",
|
|
459
678
|
{
|
|
460
|
-
type: z.string().describe(
|
|
461
|
-
serialNumber: z.string().describe(
|
|
462
|
-
certifier: z.string().describe(
|
|
679
|
+
type: z.string().describe("Certificate type"),
|
|
680
|
+
serialNumber: z.string().describe("Certificate serial number"),
|
|
681
|
+
certifier: z.string().describe("Certifier public key hex"),
|
|
463
682
|
},
|
|
464
683
|
async (args) => {
|
|
465
|
-
if (!ctx) return noCtx
|
|
684
|
+
if (!ctx) return noCtx;
|
|
466
685
|
try {
|
|
467
|
-
return result(await ctx.wallet.relinquishCertificate(args
|
|
468
|
-
} catch (e) {
|
|
686
|
+
return result(await ctx.wallet.relinquishCertificate(args));
|
|
687
|
+
} catch (e) {
|
|
688
|
+
return error(e);
|
|
689
|
+
}
|
|
469
690
|
},
|
|
470
|
-
)
|
|
691
|
+
);
|
|
471
692
|
|
|
472
693
|
// ── Discovery ──────────────────────────────────────────────────────
|
|
473
694
|
|
|
474
695
|
server.tool(
|
|
475
|
-
|
|
476
|
-
|
|
696
|
+
"wallet_discoverByIdentityKey",
|
|
697
|
+
"Discovers certificates issued to a given identity key.",
|
|
477
698
|
{
|
|
478
|
-
identityKey: z.string().describe(
|
|
699
|
+
identityKey: z.string().describe("Identity public key hex"),
|
|
479
700
|
limit: z.number().default(25),
|
|
480
701
|
offset: z.number().default(0),
|
|
702
|
+
seekPermission: z.boolean().optional(),
|
|
481
703
|
},
|
|
482
704
|
async (args) => {
|
|
483
|
-
if (!ctx) return noCtx
|
|
705
|
+
if (!ctx) return noCtx;
|
|
484
706
|
try {
|
|
485
|
-
return result(await ctx.wallet.discoverByIdentityKey(args
|
|
486
|
-
} catch (e) {
|
|
707
|
+
return result(await ctx.wallet.discoverByIdentityKey(args));
|
|
708
|
+
} catch (e) {
|
|
709
|
+
return error(e);
|
|
710
|
+
}
|
|
487
711
|
},
|
|
488
|
-
)
|
|
712
|
+
);
|
|
489
713
|
|
|
490
714
|
server.tool(
|
|
491
|
-
|
|
492
|
-
|
|
715
|
+
"wallet_discoverByAttributes",
|
|
716
|
+
"Discovers certificates matching specific attributes.",
|
|
493
717
|
{
|
|
494
|
-
attributesJSON: z
|
|
718
|
+
attributesJSON: z
|
|
719
|
+
.string()
|
|
720
|
+
.describe("JSON object of attribute key/value pairs to match"),
|
|
495
721
|
limit: z.number().default(25),
|
|
496
722
|
offset: z.number().default(0),
|
|
723
|
+
seekPermission: z.boolean().optional(),
|
|
497
724
|
},
|
|
498
725
|
async ({ attributesJSON, ...rest }) => {
|
|
499
|
-
if (!ctx) return noCtx
|
|
726
|
+
if (!ctx) return noCtx;
|
|
500
727
|
try {
|
|
501
|
-
return result(
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
728
|
+
return result(
|
|
729
|
+
await ctx.wallet.discoverByAttributes({
|
|
730
|
+
attributes: parseRequiredJSON("attributesJSON", attributesJSON),
|
|
731
|
+
...rest,
|
|
732
|
+
}),
|
|
733
|
+
);
|
|
734
|
+
} catch (e) {
|
|
735
|
+
return error(e);
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
);
|
|
508
739
|
|
|
509
740
|
// ── Info ────────────────────────────────────────────────────────────
|
|
510
741
|
|
|
511
742
|
server.tool(
|
|
512
|
-
|
|
513
|
-
|
|
743
|
+
"wallet_isAuthenticated",
|
|
744
|
+
"Checks if the wallet user is authenticated.",
|
|
745
|
+
{},
|
|
746
|
+
async () => {
|
|
747
|
+
if (!ctx) return noCtx;
|
|
748
|
+
try {
|
|
749
|
+
return result(await ctx.wallet.isAuthenticated({}));
|
|
750
|
+
} catch (e) {
|
|
751
|
+
return error(e);
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
);
|
|
755
|
+
|
|
756
|
+
server.tool(
|
|
757
|
+
"wallet_waitForAuthentication",
|
|
758
|
+
"Blocks until the wallet user is authenticated.",
|
|
514
759
|
{},
|
|
515
760
|
async () => {
|
|
516
|
-
if (!ctx) return noCtx
|
|
761
|
+
if (!ctx) return noCtx;
|
|
517
762
|
try {
|
|
518
|
-
return result(await ctx.wallet.
|
|
519
|
-
} catch (e) {
|
|
763
|
+
return result(await ctx.wallet.waitForAuthentication({}));
|
|
764
|
+
} catch (e) {
|
|
765
|
+
return error(e);
|
|
766
|
+
}
|
|
520
767
|
},
|
|
521
|
-
)
|
|
768
|
+
);
|
|
522
769
|
|
|
523
770
|
server.tool(
|
|
524
|
-
|
|
525
|
-
|
|
771
|
+
"wallet_getHeight",
|
|
772
|
+
"Gets the current blockchain height.",
|
|
526
773
|
{},
|
|
527
774
|
async () => {
|
|
528
|
-
if (!ctx) return noCtx
|
|
775
|
+
if (!ctx) return noCtx;
|
|
529
776
|
try {
|
|
530
|
-
return result(await ctx.wallet.getHeight({}))
|
|
531
|
-
} catch (e) {
|
|
777
|
+
return result(await ctx.wallet.getHeight({}));
|
|
778
|
+
} catch (e) {
|
|
779
|
+
return error(e);
|
|
780
|
+
}
|
|
532
781
|
},
|
|
533
|
-
)
|
|
782
|
+
);
|
|
534
783
|
|
|
535
784
|
server.tool(
|
|
536
|
-
|
|
537
|
-
|
|
785
|
+
"wallet_getHeaderForHeight",
|
|
786
|
+
"Gets the 80-byte block header at a given height.",
|
|
538
787
|
{
|
|
539
|
-
height: z.number().describe(
|
|
788
|
+
height: z.number().describe("Block height"),
|
|
540
789
|
},
|
|
541
790
|
async ({ height }) => {
|
|
542
|
-
if (!ctx) return noCtx
|
|
791
|
+
if (!ctx) return noCtx;
|
|
543
792
|
try {
|
|
544
|
-
return result(await ctx.wallet.getHeaderForHeight({ height }))
|
|
545
|
-
} catch (e) {
|
|
793
|
+
return result(await ctx.wallet.getHeaderForHeight({ height }));
|
|
794
|
+
} catch (e) {
|
|
795
|
+
return error(e);
|
|
796
|
+
}
|
|
546
797
|
},
|
|
547
|
-
)
|
|
798
|
+
);
|
|
548
799
|
|
|
549
800
|
server.tool(
|
|
550
|
-
|
|
551
|
-
|
|
801
|
+
"wallet_getNetwork",
|
|
802
|
+
"Gets the network the wallet is connected to (mainnet or testnet).",
|
|
552
803
|
{},
|
|
553
804
|
async () => {
|
|
554
|
-
if (!ctx) return noCtx
|
|
805
|
+
if (!ctx) return noCtx;
|
|
555
806
|
try {
|
|
556
|
-
return result(await ctx.wallet.getNetwork({}))
|
|
557
|
-
} catch (e) {
|
|
807
|
+
return result(await ctx.wallet.getNetwork({}));
|
|
808
|
+
} catch (e) {
|
|
809
|
+
return error(e);
|
|
810
|
+
}
|
|
558
811
|
},
|
|
559
|
-
)
|
|
812
|
+
);
|
|
560
813
|
|
|
561
814
|
server.tool(
|
|
562
|
-
|
|
563
|
-
|
|
815
|
+
"wallet_getVersion",
|
|
816
|
+
"Gets the wallet implementation version.",
|
|
564
817
|
{},
|
|
565
818
|
async () => {
|
|
566
|
-
if (!ctx) return noCtx
|
|
819
|
+
if (!ctx) return noCtx;
|
|
567
820
|
try {
|
|
568
|
-
return result(await ctx.wallet.getVersion({}))
|
|
569
|
-
} catch (e) {
|
|
821
|
+
return result(await ctx.wallet.getVersion({}));
|
|
822
|
+
} catch (e) {
|
|
823
|
+
return error(e);
|
|
824
|
+
}
|
|
570
825
|
},
|
|
571
|
-
)
|
|
826
|
+
);
|
|
572
827
|
}
|