@bsv/sdk 1.8.9 → 1.8.10

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.
Files changed (63) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/transaction/Beef.js +1 -0
  3. package/dist/cjs/src/transaction/Beef.js.map +1 -1
  4. package/dist/cjs/src/wallet/WERR_INSUFFICIENT_FUNDS.js +26 -0
  5. package/dist/cjs/src/wallet/WERR_INSUFFICIENT_FUNDS.js.map +1 -0
  6. package/dist/cjs/src/wallet/WERR_INVALID_PARAMETER.js +20 -0
  7. package/dist/cjs/src/wallet/WERR_INVALID_PARAMETER.js.map +1 -0
  8. package/dist/cjs/src/wallet/WalletClient.js +23 -0
  9. package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
  10. package/dist/cjs/src/wallet/WalletError.js +55 -0
  11. package/dist/cjs/src/wallet/WalletError.js.map +1 -1
  12. package/dist/cjs/src/wallet/index.js +18 -1
  13. package/dist/cjs/src/wallet/index.js.map +1 -1
  14. package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js +28 -11
  15. package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
  16. package/dist/cjs/src/wallet/validationHelpers.js +920 -0
  17. package/dist/cjs/src/wallet/validationHelpers.js.map +1 -0
  18. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  19. package/dist/esm/src/transaction/Beef.js +1 -0
  20. package/dist/esm/src/transaction/Beef.js.map +1 -1
  21. package/dist/esm/src/wallet/WERR_INSUFFICIENT_FUNDS.js +25 -0
  22. package/dist/esm/src/wallet/WERR_INSUFFICIENT_FUNDS.js.map +1 -0
  23. package/dist/esm/src/wallet/WERR_INVALID_PARAMETER.js +18 -0
  24. package/dist/esm/src/wallet/WERR_INVALID_PARAMETER.js.map +1 -0
  25. package/dist/esm/src/wallet/WalletClient.js +23 -0
  26. package/dist/esm/src/wallet/WalletClient.js.map +1 -1
  27. package/dist/esm/src/wallet/WalletError.js +55 -0
  28. package/dist/esm/src/wallet/WalletError.js.map +1 -1
  29. package/dist/esm/src/wallet/index.js +3 -0
  30. package/dist/esm/src/wallet/index.js.map +1 -1
  31. package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js +25 -11
  32. package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
  33. package/dist/esm/src/wallet/validationHelpers.js +859 -0
  34. package/dist/esm/src/wallet/validationHelpers.js.map +1 -0
  35. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  36. package/dist/types/src/transaction/Beef.d.ts +1 -0
  37. package/dist/types/src/transaction/Beef.d.ts.map +1 -1
  38. package/dist/types/src/wallet/WERR_INSUFFICIENT_FUNDS.d.ts +19 -0
  39. package/dist/types/src/wallet/WERR_INSUFFICIENT_FUNDS.d.ts.map +1 -0
  40. package/dist/types/src/wallet/WERR_INVALID_PARAMETER.d.ts +13 -0
  41. package/dist/types/src/wallet/WERR_INVALID_PARAMETER.d.ts.map +1 -0
  42. package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
  43. package/dist/types/src/wallet/WalletError.d.ts +14 -1
  44. package/dist/types/src/wallet/WalletError.d.ts.map +1 -1
  45. package/dist/types/src/wallet/index.d.ts +3 -0
  46. package/dist/types/src/wallet/index.d.ts.map +1 -1
  47. package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts.map +1 -1
  48. package/dist/types/src/wallet/validationHelpers.d.ts +512 -0
  49. package/dist/types/src/wallet/validationHelpers.d.ts.map +1 -0
  50. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  51. package/dist/umd/bundle.js +4 -4
  52. package/dist/umd/bundle.js.map +1 -1
  53. package/docs/reference/wallet.md +1431 -53
  54. package/package.json +1 -1
  55. package/src/transaction/Beef.ts +2 -0
  56. package/src/wallet/WERR_INSUFFICIENT_FUNDS.ts +25 -0
  57. package/src/wallet/WERR_INVALID_PARAMETER.ts +20 -0
  58. package/src/wallet/WalletClient.ts +30 -0
  59. package/src/wallet/WalletError.ts +52 -0
  60. package/src/wallet/__tests/WalletClient.test.ts +31 -0
  61. package/src/wallet/index.ts +3 -0
  62. package/src/wallet/substrates/HTTPWalletJSON.ts +19 -9
  63. package/src/wallet/validationHelpers.ts +1211 -0
@@ -0,0 +1,920 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.specOpThrowReviewActions = exports.validateListActionsArgs = exports.validateListOutputsArgs = exports.validateDiscoverByAttributesArgs = exports.validateDiscoverByIdentityKeyArgs = exports.validateProveCertificateArgs = exports.validateAcquireDirectCertificateArgs = exports.validateAcquireIssuanceCertificateArgs = exports.validateListCertificatesArgs = exports.validateRelinquishCertificateArgs = exports.validateRelinquishOutputArgs = exports.validateOutpointString = exports.validateOptionalOutpointString = exports.validateInternalizeActionArgs = exports.validateOriginator = exports.validateInternalizeOutput = exports.validateBasketInsertion = exports.validateWalletPayment = exports.validateAbortActionArgs = exports.validateSignActionArgs = exports.validateSignActionOptions = exports.validateCreateActionArgs = exports.validateCreateActionOptions = exports.validateCreateActionOutput = exports.validateCreateActionInput = exports.isHexString = exports.validateBase64String = exports.validateStringLength = exports.validatePositiveIntegerOrZero = exports.validateInteger = exports.validateOptionalInteger = exports.validateSatoshis = exports.parseWalletOutpoint = void 0;
30
+ const Utils = __importStar(require("../primitives/utils.js"));
31
+ const WERR_INVALID_PARAMETER_js_1 = __importDefault(require("./WERR_INVALID_PARAMETER.js"));
32
+ const Beef_js_1 = __importDefault(require("../transaction/Beef.js"));
33
+ function parseWalletOutpoint(outpoint) {
34
+ const [txid, vout] = outpoint.split('.');
35
+ return { txid, vout: Number(vout) };
36
+ }
37
+ exports.parseWalletOutpoint = parseWalletOutpoint;
38
+ function defaultTrue(v) {
39
+ return v ?? true;
40
+ }
41
+ function defaultFalse(v) {
42
+ return v ?? false;
43
+ }
44
+ function defaultZero(v) {
45
+ return v ?? 0;
46
+ }
47
+ function default0xffffffff(v) {
48
+ return v ?? 0xffffffff;
49
+ }
50
+ function defaultOne(v) {
51
+ return v ?? 1;
52
+ }
53
+ function defaultEmpty(v) {
54
+ return v ?? [];
55
+ }
56
+ function validateOptionalStringLength(s, name, min, max) {
57
+ if (s === undefined)
58
+ return undefined;
59
+ return validateStringLength(s, name, min, max);
60
+ }
61
+ /**
62
+ * Validate a satoshi amount.
63
+ *
64
+ * @param v - value to validate (integer number of satoshis)
65
+ * @param name - parameter name used in error messages
66
+ * @param min - optional minimum allowed satoshi value
67
+ * @returns validated satoshi number
68
+ * @throws WERR_INVALID_PARAMETER when invalid
69
+ */
70
+ function validateSatoshis(v, name, min) {
71
+ if (v === undefined || !Number.isInteger(v) || v < 0 || v > 21e14) {
72
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, 'a valid number of satoshis');
73
+ }
74
+ if (min !== undefined && v < min)
75
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `at least ${min} satoshis.`);
76
+ return v;
77
+ }
78
+ exports.validateSatoshis = validateSatoshis;
79
+ /**
80
+ * Validate an optional integer. Returns undefined or the validated integer.
81
+ *
82
+ * @param v - value to validate (may be undefined)
83
+ * @param name - parameter name used in error messages
84
+ * @param min - optional minimum value
85
+ * @param max - optional maximum value
86
+ * @returns validated integer or undefined
87
+ * @throws WERR_INVALID_PARAMETER when invalid
88
+ */
89
+ function validateOptionalInteger(v, name, min, max) {
90
+ if (v === undefined)
91
+ return undefined;
92
+ return validateInteger(v, name, undefined, min, max);
93
+ }
94
+ exports.validateOptionalInteger = validateOptionalInteger;
95
+ /**
96
+ * Validate an integer, applying an optional default.
97
+ *
98
+ * @param v - value to validate (may be undefined)
99
+ * @param name - parameter name used in error messages
100
+ * @param defaultValue - value to return when v is undefined
101
+ * @param min - optional minimum allowed value
102
+ * @param max - optional maximum allowed value
103
+ * @returns validated integer
104
+ * @throws WERR_INVALID_PARAMETER when invalid
105
+ */
106
+ function validateInteger(v, name, defaultValue, min, max) {
107
+ if (v === undefined) {
108
+ if (defaultValue !== undefined)
109
+ return defaultValue;
110
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, 'a valid integer');
111
+ }
112
+ if (!Number.isInteger(v))
113
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, 'an integer');
114
+ v = Number(v);
115
+ if (min !== undefined && v < min)
116
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `at least ${min} length.`);
117
+ if (max !== undefined && v > max)
118
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `no more than ${max} length.`);
119
+ return v;
120
+ }
121
+ exports.validateInteger = validateInteger;
122
+ /**
123
+ * Validate a non-negative integer (zero allowed).
124
+ *
125
+ * @param v - value to validate
126
+ * @param name - parameter name used in error messages
127
+ * @returns validated integer
128
+ * @throws WERR_INVALID_PARAMETER when invalid
129
+ */
130
+ function validatePositiveIntegerOrZero(v, name) {
131
+ return validateInteger(v, name, 0, 0);
132
+ }
133
+ exports.validatePositiveIntegerOrZero = validatePositiveIntegerOrZero;
134
+ /**
135
+ * Validate string length in bytes for UTF-8 encoded string.
136
+ *
137
+ * @param s - string to validate
138
+ * @param name - parameter name used in error messages
139
+ * @param min - optional minimum byte length
140
+ * @param max - optional maximum byte length
141
+ * @returns the original string when valid
142
+ * @throws WERR_INVALID_PARAMETER when invalid
143
+ */
144
+ function validateStringLength(s, name, min, max) {
145
+ const bytes = Utils.toArray(s, 'utf8').length;
146
+ if (min !== undefined && bytes < min)
147
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `at least ${min} length.`);
148
+ if (max !== undefined && bytes > max)
149
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `no more than ${max} length.`);
150
+ return s;
151
+ }
152
+ exports.validateStringLength = validateStringLength;
153
+ /**
154
+ * Validate an optional basket string (1..300 bytes).
155
+ *
156
+ * @param s - basket string or undefined
157
+ * @returns validated basket string or undefined
158
+ */
159
+ function validateOptionalBasket(s) {
160
+ if (s === undefined)
161
+ return undefined;
162
+ return validateBasket(s);
163
+ }
164
+ /**
165
+ * Validate basket identifier (1..300 bytes).
166
+ *
167
+ * @param s - basket string
168
+ * @returns validated basket string
169
+ */
170
+ function validateBasket(s) {
171
+ return validateIdentifier(s, 'basket', 1, 300);
172
+ }
173
+ /**
174
+ * Validate label identifier (1..300 bytes).
175
+ *
176
+ * @param s - label string
177
+ * @returns validated label string
178
+ */
179
+ function validateLabel(s) {
180
+ return validateIdentifier(s, 'label', 1, 300);
181
+ }
182
+ /**
183
+ * Validate tag identifier (1..300 bytes).
184
+ *
185
+ * @param s - tag string
186
+ * @returns validated tag string
187
+ */
188
+ function validateTag(s) {
189
+ return validateIdentifier(s, 'tag', 1, 300);
190
+ }
191
+ /**
192
+ * Normalize and validate an identifier (trim, lowercase, byte length).
193
+ *
194
+ * @param s - input string
195
+ * @param name - name used in errors
196
+ * @param min - optional minimum byte length
197
+ * @param max - optional maximum byte length
198
+ * @returns normalized identifier
199
+ * @throws WERR_INVALID_PARAMETER when invalid
200
+ */
201
+ function validateIdentifier(s, name, min, max) {
202
+ s = s.trim().toLowerCase();
203
+ const bytes = Utils.toArray(s, 'utf8').length;
204
+ if (min !== undefined && bytes < min)
205
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `at least ${min} length.`);
206
+ if (max !== undefined && bytes > max)
207
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `no more than ${max} length.`);
208
+ return s;
209
+ }
210
+ /**
211
+ * Validate an optional Base64 encoded string.
212
+ *
213
+ * @param s - base64 string or undefined
214
+ * @param name - parameter name used in error messages
215
+ * @param min - optional minimum decoded byte length
216
+ * @param max - optional maximum decoded byte length
217
+ * @returns validated base64 string or undefined
218
+ */
219
+ function validateOptionalBase64String(s, name, min, max) {
220
+ if (s === undefined)
221
+ return undefined;
222
+ return validateBase64String(s, name, min, max);
223
+ }
224
+ /**
225
+ * Validate a Base64 string (structure and decoded size).
226
+ *
227
+ * @param s - base64 string
228
+ * @param name - parameter name used in error messages
229
+ * @param min - optional minimum decoded byte length
230
+ * @param max - optional maximum decoded byte length
231
+ * @returns validated base64 string
232
+ * @throws WERR_INVALID_PARAMETER when invalid
233
+ */
234
+ function validateBase64String(s, name, min, max) {
235
+ s = s.trim();
236
+ if (s.length === 0) {
237
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, 'valid base64 string');
238
+ }
239
+ let paddingCount = 0;
240
+ for (let i = 0; i < s.length; i++) {
241
+ const char = s.charCodeAt(i);
242
+ if (char >= 65 && char <= 90)
243
+ continue; // A-Z
244
+ if (char >= 97 && char <= 122)
245
+ continue; // a-z
246
+ if (char >= 48 && char <= 57)
247
+ continue; // 0-9
248
+ if (char === 43)
249
+ continue; // +
250
+ if (char === 47)
251
+ continue; // /
252
+ if (char === 61) { // =
253
+ if (i < s.length - 2) {
254
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, 'valid base64 string');
255
+ }
256
+ paddingCount++;
257
+ continue;
258
+ }
259
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, 'valid base64 string');
260
+ }
261
+ // Padding rules
262
+ if (paddingCount > 2) {
263
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, 'valid base64 string');
264
+ }
265
+ if (paddingCount > 0 && s.length % 4 !== 0) {
266
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, 'valid base64 string');
267
+ }
268
+ // Length must be multiple of 4 if no padding, or valid with padding
269
+ const mod = s.length % 4;
270
+ if (mod !== 0 && mod !== (4 - paddingCount)) {
271
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, 'valid base64 string');
272
+ }
273
+ // Calculate decoded byte length: (valid chars * 6) / 8
274
+ const encodedLength = s.length - paddingCount;
275
+ const bytes = Math.floor(encodedLength * 3 / 4);
276
+ if (min !== undefined && bytes < min) {
277
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `at least ${min} bytes`);
278
+ }
279
+ if (max !== undefined && bytes > max) {
280
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `no more than ${max} bytes`);
281
+ }
282
+ return s;
283
+ }
284
+ exports.validateBase64String = validateBase64String;
285
+ function validateOptionalHexString(s, name, min, max) {
286
+ if (s === undefined)
287
+ return undefined;
288
+ return validateHexString(s, name, min, max);
289
+ }
290
+ /**
291
+ * Validate a hex string (even length, hex chars) and optional length bounds (character count).
292
+ *
293
+ * @param s - hex string
294
+ * @param name - parameter name used in error messages
295
+ * @param min if valid, string length minimum (not bytes)
296
+ * @param max if valid, string length maximum (not bytes)
297
+ * @returns
298
+ */
299
+ function validateHexString(s, name, min, max) {
300
+ s = s.trim().toLowerCase();
301
+ if (s.length % 2 === 1)
302
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `even length, not ${s.length}.`);
303
+ const hexRegex = /^[0-9A-Fa-f]+$/;
304
+ if (!hexRegex.test(s))
305
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, 'hexadecimal string.');
306
+ if (min !== undefined && s.length < min)
307
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `at least ${min} length.`);
308
+ if (max !== undefined && s.length > max)
309
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, `no more than ${max} length.`);
310
+ return s;
311
+ }
312
+ /**
313
+ * Check whether a string is a valid hex string (even length and hex characters).
314
+ *
315
+ * @param s - input string
316
+ * @returns true when s is a valid hex string
317
+ */
318
+ function isHexString(s) {
319
+ s = s.trim();
320
+ if (s.length % 2 === 1)
321
+ return false;
322
+ const hexRegex = /^[0-9A-Fa-f]+$/;
323
+ if (!hexRegex.test(s))
324
+ return false;
325
+ return true;
326
+ }
327
+ exports.isHexString = isHexString;
328
+ /**
329
+ * Validate a CreateActionInput structure.
330
+ *
331
+ * Ensures either unlockingScript or unlockingScriptLength is provided and consistent,
332
+ * validates outpoint, description length, and sequence number.
333
+ *
334
+ * @param i - CreateActionInput to validate
335
+ * @returns ValidCreateActionInput
336
+ * @throws WERR_INVALID_PARAMETER when invalid
337
+ */
338
+ function validateCreateActionInput(i) {
339
+ if (i.unlockingScript === undefined && i.unlockingScriptLength === undefined) {
340
+ throw new WERR_INVALID_PARAMETER_js_1.default('unlockingScript, unlockingScriptLength', 'at least one valid value.');
341
+ }
342
+ const unlockingScript = validateOptionalHexString(i.unlockingScript, 'unlockingScript');
343
+ const unlockingScriptLength = i.unlockingScriptLength ?? (unlockingScript != null ? unlockingScript.length / 2 : 0);
344
+ if (unlockingScript && unlockingScriptLength !== unlockingScript.length / 2) {
345
+ throw new WERR_INVALID_PARAMETER_js_1.default('unlockingScriptLength', 'length unlockingScript if both valid.');
346
+ }
347
+ const vi = {
348
+ outpoint: parseWalletOutpoint(i.outpoint),
349
+ inputDescription: validateStringLength(i.inputDescription, 'inputDescription', 5, 2000),
350
+ unlockingScript,
351
+ unlockingScriptLength,
352
+ sequenceNumber: default0xffffffff(i.sequenceNumber)
353
+ };
354
+ return vi;
355
+ }
356
+ exports.validateCreateActionInput = validateCreateActionInput;
357
+ /**
358
+ * Validate CreateActionOutput fields: locking script, satoshis, description, basket, tags.
359
+ *
360
+ * @param o - CreateActionOutput to validate
361
+ * @returns ValidCreateActionOutput
362
+ * @throws WERR_INVALID_PARAMETER when invalid
363
+ */
364
+ function validateCreateActionOutput(o) {
365
+ const vo = {
366
+ lockingScript: validateHexString(o.lockingScript, 'lockingScript'),
367
+ satoshis: validateSatoshis(o.satoshis, 'satoshis'),
368
+ outputDescription: validateStringLength(o.outputDescription, 'outputDescription', 5, 2000),
369
+ basket: validateOptionalBasket(o.basket),
370
+ customInstructions: o.customInstructions,
371
+ tags: defaultEmpty(o.tags).map(t => validateTag(t))
372
+ };
373
+ return vo;
374
+ }
375
+ exports.validateCreateActionOutput = validateCreateActionOutput;
376
+ /**
377
+ * Normalize and validate CreateActionOptions, applying defaults for booleans/numbers/arrays.
378
+ *
379
+ * @param options - CreateActionOptions or undefined
380
+ * @returns ValidCreateActionOptions with defaults applied
381
+ */
382
+ function validateCreateActionOptions(options) {
383
+ const o = options != null ? options : {};
384
+ const vo = {
385
+ signAndProcess: defaultTrue(o.signAndProcess),
386
+ acceptDelayedBroadcast: defaultTrue(o.acceptDelayedBroadcast),
387
+ knownTxids: defaultEmpty(o.knownTxids),
388
+ returnTXIDOnly: defaultFalse(o.returnTXIDOnly),
389
+ noSend: defaultFalse(o.noSend),
390
+ noSendChange: defaultEmpty(o.noSendChange).map(nsc => parseWalletOutpoint(nsc)),
391
+ sendWith: defaultEmpty(o.sendWith),
392
+ randomizeOutputs: defaultTrue(o.randomizeOutputs)
393
+ };
394
+ return vo;
395
+ }
396
+ exports.validateCreateActionOptions = validateCreateActionOptions;
397
+ /**
398
+ * Validate the arguments for creating a new action.
399
+ *
400
+ * @param args
401
+ * @returns validated arguments
402
+ * @throws primarily WERR_INVALID_PARAMETER if args are invalid.
403
+ */
404
+ function validateCreateActionArgs(args) {
405
+ const vargs = {
406
+ description: validateStringLength(args.description, 'description', 5, 2000),
407
+ inputBEEF: args.inputBEEF,
408
+ inputs: defaultEmpty(args.inputs).map(i => validateCreateActionInput(i)),
409
+ outputs: defaultEmpty(args.outputs).map(o => validateCreateActionOutput(o)),
410
+ lockTime: defaultZero(args.lockTime),
411
+ version: defaultOne(args.version),
412
+ labels: defaultEmpty(args.labels?.map(l => validateLabel(l))),
413
+ options: validateCreateActionOptions(args.options),
414
+ isSendWith: false,
415
+ isDelayed: false,
416
+ isNoSend: false,
417
+ isNewTx: false,
418
+ isRemixChange: false,
419
+ isSignAction: false,
420
+ randomVals: undefined,
421
+ includeAllSourceTransactions: false,
422
+ isTestWerrReviewActions: false
423
+ };
424
+ vargs.isTestWerrReviewActions = vargs.labels.includes(exports.specOpThrowReviewActions);
425
+ vargs.isSendWith = vargs.options.sendWith.length > 0;
426
+ vargs.isRemixChange = !vargs.isSendWith && vargs.inputs.length === 0 && vargs.outputs.length === 0;
427
+ vargs.isNewTx = vargs.isRemixChange || vargs.inputs.length > 0 || vargs.outputs.length > 0;
428
+ vargs.isSignAction =
429
+ vargs.isNewTx && (!vargs.options.signAndProcess || vargs.inputs.some(i => i.unlockingScript === undefined));
430
+ vargs.isDelayed = vargs.options.acceptDelayedBroadcast;
431
+ vargs.isNoSend = vargs.options.noSend;
432
+ return vargs;
433
+ }
434
+ exports.validateCreateActionArgs = validateCreateActionArgs;
435
+ /**
436
+ * Set all default true/false booleans to true or false if undefined.
437
+ * Set all possibly undefined numbers to their default values.
438
+ * Set all possibly undefined arrays to empty arrays.
439
+ * Convert string outpoints to `{ txid: string, vout: number }`
440
+ */
441
+ function validateSignActionOptions(options) {
442
+ const o = options != null ? options : {};
443
+ const vo = {
444
+ acceptDelayedBroadcast: defaultTrue(o.acceptDelayedBroadcast),
445
+ returnTXIDOnly: defaultFalse(o.returnTXIDOnly),
446
+ noSend: defaultFalse(o.noSend),
447
+ sendWith: defaultEmpty(o.sendWith)
448
+ };
449
+ return vo;
450
+ }
451
+ exports.validateSignActionOptions = validateSignActionOptions;
452
+ /**
453
+ * Validate SignActionArgs and apply defaults/flags.
454
+ *
455
+ * @param args - SignActionArgs to validate
456
+ * @returns ValidSignActionArgs
457
+ */
458
+ function validateSignActionArgs(args) {
459
+ const vargs = {
460
+ spends: args.spends,
461
+ reference: args.reference,
462
+ options: validateSignActionOptions(args.options),
463
+ isSendWith: false,
464
+ isDelayed: false,
465
+ isNoSend: false,
466
+ isNewTx: true,
467
+ isRemixChange: false,
468
+ isTestWerrReviewActions: false
469
+ };
470
+ vargs.isSendWith = vargs.options.sendWith.length > 0;
471
+ vargs.isDelayed = vargs.options.acceptDelayedBroadcast;
472
+ vargs.isNoSend = vargs.options.noSend;
473
+ return vargs;
474
+ }
475
+ exports.validateSignActionArgs = validateSignActionArgs;
476
+ /**
477
+ * Validate AbortActionArgs (ensures reference is a valid base64 string).
478
+ *
479
+ * @param args - AbortActionArgs
480
+ * @returns ValidAbortActionArgs
481
+ */
482
+ function validateAbortActionArgs(args) {
483
+ const vargs = {
484
+ reference: validateBase64String(args.reference, 'reference')
485
+ };
486
+ return vargs;
487
+ }
488
+ exports.validateAbortActionArgs = validateAbortActionArgs;
489
+ /**
490
+ * Validate wallet payment remittance structure.
491
+ *
492
+ * @param args - WalletPayment or undefined
493
+ * @returns ValidWalletPayment or undefined
494
+ */
495
+ function validateWalletPayment(args) {
496
+ if (args === undefined)
497
+ return undefined;
498
+ const v = {
499
+ derivationPrefix: validateBase64String(args.derivationPrefix, 'derivationPrefix'),
500
+ derivationSuffix: validateBase64String(args.derivationSuffix, 'derivationSuffix'),
501
+ senderIdentityKey: validateHexString(args.senderIdentityKey, 'senderIdentityKey')
502
+ };
503
+ return v;
504
+ }
505
+ exports.validateWalletPayment = validateWalletPayment;
506
+ /**
507
+ * Validate a BasketInsertion structure (basket, custom instructions, tags).
508
+ *
509
+ * @param args - BasketInsertion or undefined
510
+ * @returns ValidBasketInsertion or undefined
511
+ */
512
+ function validateBasketInsertion(args) {
513
+ if (args === undefined)
514
+ return undefined;
515
+ const v = {
516
+ basket: validateBasket(args.basket),
517
+ customInstructions: validateOptionalStringLength(args.customInstructions, 'customInstructions', 0, 1000),
518
+ tags: defaultEmpty(args.tags).map(t => validateTag(t))
519
+ };
520
+ return v;
521
+ }
522
+ exports.validateBasketInsertion = validateBasketInsertion;
523
+ /**
524
+ * Validate an InternalizeOutput entry.
525
+ *
526
+ * @param args - InternalizeOutput to validate
527
+ * @returns ValidInternalizeOutput
528
+ */
529
+ function validateInternalizeOutput(args) {
530
+ if (args.protocol !== 'basket insertion' && args.protocol !== 'wallet payment') {
531
+ throw new WERR_INVALID_PARAMETER_js_1.default('protocol', '\'basket insertion\' or \'wallet payment\'');
532
+ }
533
+ const v = {
534
+ outputIndex: validatePositiveIntegerOrZero(args.outputIndex, 'outputIndex'),
535
+ protocol: args.protocol,
536
+ paymentRemittance: validateWalletPayment(args.paymentRemittance),
537
+ insertionRemittance: validateBasketInsertion(args.insertionRemittance)
538
+ };
539
+ return v;
540
+ }
541
+ exports.validateInternalizeOutput = validateInternalizeOutput;
542
+ /**
543
+ * Validate originator string (trim/lowercase and part length checks).
544
+ *
545
+ * @param s - originator string or undefined
546
+ * @returns normalized originator or undefined
547
+ */
548
+ function validateOriginator(s) {
549
+ if (s === undefined)
550
+ return undefined;
551
+ s = s.trim().toLowerCase();
552
+ validateStringLength(s, 'originator', 1, 250);
553
+ const sps = s.split('.');
554
+ for (const sp of sps) {
555
+ validateStringLength(sp, 'originator part', 1, 63);
556
+ }
557
+ return s;
558
+ }
559
+ exports.validateOriginator = validateOriginator;
560
+ /**
561
+ * Validate InternalizeActionArgs: tx, outputs, description, labels, permission flag.
562
+ *
563
+ * @param args - InternalizeActionArgs to validate
564
+ * @returns ValidInternalizeActionArgs
565
+ * @throws WERR_INVALID_PARAMETER when invalid
566
+ */
567
+ function validateInternalizeActionArgs(args) {
568
+ const vargs = {
569
+ tx: args.tx,
570
+ outputs: args.outputs.map(o => validateInternalizeOutput(o)),
571
+ description: validateStringLength(args.description, 'description', 5, 2000),
572
+ labels: (args.labels != null ? args.labels : []).map(t => validateLabel(t)),
573
+ seekPermission: defaultTrue(args.seekPermission)
574
+ };
575
+ try {
576
+ const beef = Beef_js_1.default.fromBinary(vargs.tx);
577
+ if (beef.txs.length < 1) {
578
+ throw new WERR_INVALID_PARAMETER_js_1.default('tx', 'at least one transaction to internalize an output from');
579
+ }
580
+ }
581
+ catch {
582
+ throw new WERR_INVALID_PARAMETER_js_1.default('tx', 'valid with at least one transaction to internalize an output from');
583
+ }
584
+ if (vargs.outputs.length < 1) {
585
+ throw new WERR_INVALID_PARAMETER_js_1.default('outputs', 'at least one output to internalize from the transaction');
586
+ }
587
+ return vargs;
588
+ }
589
+ exports.validateInternalizeActionArgs = validateInternalizeActionArgs;
590
+ /**
591
+ * Validate an optional outpoint string (txid.vout).
592
+ *
593
+ * @param outpoint - outpoint string or undefined
594
+ * @param name - parameter name used in error messages
595
+ * @returns validated outpoint string or undefined
596
+ */
597
+ function validateOptionalOutpointString(outpoint, name) {
598
+ if (outpoint === undefined)
599
+ return undefined;
600
+ return validateOutpointString(outpoint, name);
601
+ }
602
+ exports.validateOptionalOutpointString = validateOptionalOutpointString;
603
+ /**
604
+ * Validate an outpoint string of the form txid.vout.
605
+ *
606
+ * @param outpoint - outpoint string
607
+ * @param name - parameter name used in error messages
608
+ * @returns normalized outpoint string (validated txid and vout)
609
+ * @throws WERR_INVALID_PARAMETER when invalid
610
+ */
611
+ function validateOutpointString(outpoint, name) {
612
+ const s = outpoint.split('.');
613
+ if (s.length !== 2 || !Number.isInteger(Number(s[1]))) {
614
+ throw new WERR_INVALID_PARAMETER_js_1.default(name, 'txid as hex string and numeric output index joined with \'.\'');
615
+ }
616
+ const txid = validateHexString(s[0], `${name} txid`, undefined, 64);
617
+ const vout = validatePositiveIntegerOrZero(Number(s[1]), `${name} vout`);
618
+ return `${txid}.${vout}`;
619
+ }
620
+ exports.validateOutpointString = validateOutpointString;
621
+ /**
622
+ * Validate RelinquishOutputArgs (basket and output).
623
+ *
624
+ * @param args - RelinquishOutputArgs
625
+ * @returns ValidRelinquishOutputArgs
626
+ */
627
+ function validateRelinquishOutputArgs(args) {
628
+ const vargs = {
629
+ basket: validateBasket(args.basket),
630
+ output: validateOutpointString(args.output, 'output')
631
+ };
632
+ return vargs;
633
+ }
634
+ exports.validateRelinquishOutputArgs = validateRelinquishOutputArgs;
635
+ /**
636
+ * Validate RelinquishCertificateArgs (type, serialNumber, certifier).
637
+ *
638
+ * @param args - RelinquishCertificateArgs
639
+ * @returns ValidRelinquishCertificateArgs
640
+ */
641
+ function validateRelinquishCertificateArgs(args) {
642
+ const vargs = {
643
+ type: validateBase64String(args.type, 'type'),
644
+ serialNumber: validateBase64String(args.serialNumber, 'serialNumber'),
645
+ certifier: validateHexString(args.certifier, 'certifier')
646
+ };
647
+ return vargs;
648
+ }
649
+ exports.validateRelinquishCertificateArgs = validateRelinquishCertificateArgs;
650
+ /**
651
+ * Validate ListCertificatesArgs: certifiers, types, paging, and optional privileged reason.
652
+ *
653
+ * @param args - ListCertificatesArgs
654
+ * @returns ValidListCertificatesArgs
655
+ */
656
+ function validateListCertificatesArgs(args) {
657
+ const vargs = {
658
+ certifiers: defaultEmpty(args.certifiers.map(c => validateHexString(c.trim(), 'certifiers'))),
659
+ types: defaultEmpty(args.types.map(t => validateBase64String(t.trim(), 'types'))),
660
+ limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
661
+ offset: validatePositiveIntegerOrZero(defaultZero(args.offset), 'offset'),
662
+ privileged: defaultFalse(args.privileged),
663
+ privilegedReason: validateOptionalStringLength(args.privilegedReason, 'privilegedReason', 5, 50),
664
+ partial: undefined
665
+ };
666
+ return vargs;
667
+ }
668
+ exports.validateListCertificatesArgs = validateListCertificatesArgs;
669
+ function validateCertificateFields(fields) {
670
+ for (const fieldName of Object.keys(fields)) {
671
+ validateStringLength(fieldName, 'field name', 1, 50);
672
+ }
673
+ return fields;
674
+ }
675
+ function validateKeyringRevealer(kr, name) {
676
+ if (kr === 'certifier')
677
+ return kr;
678
+ return validateHexString(kr, name);
679
+ }
680
+ function validateKeyringForSubject(kr, name) {
681
+ for (const fn of Object.keys(kr)) {
682
+ validateStringLength(fn, `${name} field name`, 1, 50);
683
+ validateBase64String(kr[fn], `${name} field value`);
684
+ }
685
+ return kr;
686
+ }
687
+ /**
688
+ * Validate issuance-specific acquire certificate args.
689
+ *
690
+ * @param args - AcquireCertificateArgs with acquisitionProtocol === 'issuance'
691
+ * @returns ValidAcquireIssuanceCertificateArgs
692
+ * @throws when args contain fields invalid for issuance
693
+ */
694
+ function validateAcquireIssuanceCertificateArgs(args) {
695
+ if (args.acquisitionProtocol !== 'issuance') {
696
+ throw new Error('Only acquire certificate via issuance requests allowed here.');
697
+ }
698
+ if (args.serialNumber)
699
+ throw new WERR_INVALID_PARAMETER_js_1.default('serialNumber', 'valid when acquisitionProtocol is "direct"');
700
+ if (args.signature)
701
+ throw new WERR_INVALID_PARAMETER_js_1.default('signature', 'valid when acquisitionProtocol is "direct"');
702
+ if (args.revocationOutpoint) {
703
+ throw new WERR_INVALID_PARAMETER_js_1.default('revocationOutpoint', 'valid when acquisitionProtocol is "direct"');
704
+ }
705
+ if (args.keyringRevealer) {
706
+ throw new WERR_INVALID_PARAMETER_js_1.default('keyringRevealer', 'valid when acquisitionProtocol is "direct"');
707
+ }
708
+ if (args.keyringForSubject != null) {
709
+ throw new WERR_INVALID_PARAMETER_js_1.default('keyringForSubject', 'valid when acquisitionProtocol is "direct"');
710
+ }
711
+ if (!args.certifierUrl) {
712
+ throw new WERR_INVALID_PARAMETER_js_1.default('certifierUrl', 'valid when acquisitionProtocol is "issuance"');
713
+ }
714
+ if (args.privileged && !args.privilegedReason) {
715
+ throw new WERR_INVALID_PARAMETER_js_1.default('privilegedReason', 'valid when \'privileged\' is true ');
716
+ }
717
+ const vargs = {
718
+ type: validateBase64String(args.type, 'type'),
719
+ certifier: validateHexString(args.certifier, 'certifier'),
720
+ certifierUrl: args.certifierUrl,
721
+ fields: validateCertificateFields(args.fields),
722
+ privileged: defaultFalse(args.privileged),
723
+ privilegedReason: validateOptionalStringLength(args.privilegedReason, 'privilegedReason', 5, 50),
724
+ subject: ''
725
+ };
726
+ return vargs;
727
+ }
728
+ exports.validateAcquireIssuanceCertificateArgs = validateAcquireIssuanceCertificateArgs;
729
+ /**
730
+ * Validate direct-acquisition-specific acquire certificate args.
731
+ *
732
+ * @param args - AcquireCertificateArgs with acquisitionProtocol === 'direct'
733
+ * @returns ValidAcquireDirectCertificateArgs
734
+ * @throws when args contain fields invalid for direct acquisition
735
+ */
736
+ function validateAcquireDirectCertificateArgs(args) {
737
+ if (args.acquisitionProtocol !== 'direct') {
738
+ throw new Error('Only acquire direct certificate requests allowed here.');
739
+ }
740
+ if (!args.serialNumber)
741
+ throw new WERR_INVALID_PARAMETER_js_1.default('serialNumber', 'valid when acquisitionProtocol is "direct"');
742
+ if (!args.signature)
743
+ throw new WERR_INVALID_PARAMETER_js_1.default('signature', 'valid when acquisitionProtocol is "direct"');
744
+ if (!args.revocationOutpoint) {
745
+ throw new WERR_INVALID_PARAMETER_js_1.default('revocationOutpoint', 'valid when acquisitionProtocol is "direct"');
746
+ }
747
+ if (!args.keyringRevealer) {
748
+ throw new WERR_INVALID_PARAMETER_js_1.default('keyringRevealer', 'valid when acquisitionProtocol is "direct"');
749
+ }
750
+ if (args.keyringForSubject == null) {
751
+ throw new WERR_INVALID_PARAMETER_js_1.default('keyringForSubject', 'valid when acquisitionProtocol is "direct"');
752
+ }
753
+ if (args.privileged && !args.privilegedReason) {
754
+ throw new WERR_INVALID_PARAMETER_js_1.default('privilegedReason', 'valid when \'privileged\' is true ');
755
+ }
756
+ const vargs = {
757
+ type: validateBase64String(args.type, 'type'),
758
+ serialNumber: validateBase64String(args.serialNumber, 'serialNumber'),
759
+ certifier: validateHexString(args.certifier, 'certifier'),
760
+ revocationOutpoint: validateOutpointString(args.revocationOutpoint, 'revocationOutpoint'),
761
+ fields: validateCertificateFields(args.fields),
762
+ signature: validateHexString(args.signature, 'signature'),
763
+ keyringRevealer: validateKeyringRevealer(args.keyringRevealer, 'keyringRevealer'),
764
+ keyringForSubject: validateKeyringForSubject(args.keyringForSubject, 'keyringForSubject'),
765
+ privileged: defaultFalse(args.privileged),
766
+ privilegedReason: validateOptionalStringLength(args.privilegedReason, 'privilegedReason', 5, 50),
767
+ subject: ''
768
+ };
769
+ return vargs;
770
+ }
771
+ exports.validateAcquireDirectCertificateArgs = validateAcquireDirectCertificateArgs;
772
+ /**
773
+ * Validate ProveCertificateArgs including optional certificate fields and reveal list.
774
+ *
775
+ * @param args - ProveCertificateArgs
776
+ * @returns ValidProveCertificateArgs
777
+ */
778
+ function validateProveCertificateArgs(args) {
779
+ if (args.privileged && !args.privilegedReason) {
780
+ throw new WERR_INVALID_PARAMETER_js_1.default('privilegedReason', 'valid when \'privileged\' is true ');
781
+ }
782
+ const vargs = {
783
+ type: validateOptionalBase64String(args.certificate.type, 'certificate.type'),
784
+ serialNumber: validateOptionalBase64String(args.certificate.serialNumber, 'certificate.serialNumber'),
785
+ certifier: validateOptionalHexString(args.certificate.certifier, 'certificate.certifier'),
786
+ subject: validateOptionalHexString(args.certificate.subject, 'certificate.subject'),
787
+ revocationOutpoint: validateOptionalOutpointString(args.certificate.revocationOutpoint, 'certificate.revocationOutpoint'),
788
+ signature: validateOptionalHexString(args.certificate.signature, 'certificate.signature'),
789
+ fieldsToReveal: defaultEmpty(args.fieldsToReveal).map(fieldName => validateStringLength(fieldName, `fieldsToReveal ${fieldName}`, 1, 50)),
790
+ verifier: validateHexString(args.verifier, 'verifier'),
791
+ privileged: defaultFalse(args.privileged),
792
+ privilegedReason: validateOptionalStringLength(args.privilegedReason, 'privilegedReason', 5, 50)
793
+ };
794
+ return vargs;
795
+ }
796
+ exports.validateProveCertificateArgs = validateProveCertificateArgs;
797
+ /**
798
+ * Validate DiscoverByIdentityKeyArgs, enforcing identity key length and defaults.
799
+ *
800
+ * @param args - DiscoverByIdentityKeyArgs
801
+ * @returns ValidDiscoverByIdentityKeyArgs
802
+ */
803
+ function validateDiscoverByIdentityKeyArgs(args) {
804
+ const vargs = {
805
+ identityKey: validateHexString(args.identityKey, 'identityKey', 66, 66),
806
+ limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
807
+ offset: validatePositiveIntegerOrZero(defaultZero(args.offset), 'offset'),
808
+ seekPermission: defaultFalse(args.seekPermission)
809
+ };
810
+ return vargs;
811
+ }
812
+ exports.validateDiscoverByIdentityKeyArgs = validateDiscoverByIdentityKeyArgs;
813
+ function validateAttributes(attributes) {
814
+ for (const fieldName of Object.keys(attributes)) {
815
+ validateStringLength(fieldName, `field name ${fieldName}`, 1, 50);
816
+ }
817
+ return attributes;
818
+ }
819
+ /**
820
+ * Validate DiscoverByAttributesArgs: attributes, limit, offset, and permission flag.
821
+ *
822
+ * @param args - DiscoverByAttributesArgs
823
+ * @returns ValidDiscoverByAttributesArgs
824
+ */
825
+ function validateDiscoverByAttributesArgs(args) {
826
+ const vargs = {
827
+ attributes: validateAttributes(args.attributes),
828
+ limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
829
+ offset: validatePositiveIntegerOrZero(defaultZero(args.offset), 'offset'),
830
+ seekPermission: defaultFalse(args.seekPermission)
831
+ };
832
+ return vargs;
833
+ }
834
+ exports.validateDiscoverByAttributesArgs = validateDiscoverByAttributesArgs;
835
+ /**
836
+ * @param {BasketStringUnder300Bytes} args.basket - Required. The associated basket name whose outputs should be listed.
837
+ * @param {OutputTagStringUnder300Bytes[]} [args.tags] - Optional. Filter outputs based on these tags.
838
+ * @param {'all' | 'any'} [args.tagQueryMode] - Optional. Filter mode, defining whether all or any of the tags must match. By default, any tag can match.
839
+ * @param {'locking scripts' | 'entire transactions'} [args.include] - Optional. Whether to include locking scripts (with each output) or entire transactions (as aggregated BEEF, at the top level) in the result. By default, unless specified, neither are returned.
840
+ * @param {BooleanDefaultFalse} [args.includeEntireTransactions] - Optional. Whether to include the entire transaction(s) in the result.
841
+ * @param {BooleanDefaultFalse} [args.includeCustomInstructions] - Optional. Whether custom instructions should be returned in the result.
842
+ * @param {BooleanDefaultFalse} [args.includeTags] - Optional. Whether the tags associated with the output should be returned.
843
+ * @param {BooleanDefaultFalse} [args.includeLabels] - Optional. Whether the labels associated with the transaction containing the output should be returned.
844
+ * @param {PositiveIntegerDefault10Max10000} [args.limit] - Optional limit on the number of outputs to return.
845
+ * @param {number} [args.offset] - If positive or zero: Number of outputs to skip before starting to return results, oldest first.
846
+ * If negative: Outputs are returned newest first and offset of -1 is the newest output.
847
+ * When using negative offsets, caution is required as new outputs may be added between calls,
848
+ * potentially causing outputs to be duplicated across calls.
849
+ * @param {BooleanDefaultTrue} [args.seekPermission] — Optional. Whether to seek permission from the user for this operation if required. Default true, will return an error rather than proceed if set to false.
850
+ */
851
+ function validateListOutputsArgs(args) {
852
+ let tagQueryMode;
853
+ if (args.tagQueryMode === undefined || args.tagQueryMode === 'any')
854
+ tagQueryMode = 'any';
855
+ else if (args.tagQueryMode === 'all')
856
+ tagQueryMode = 'all';
857
+ else
858
+ throw new WERR_INVALID_PARAMETER_js_1.default('tagQueryMode', 'undefined, \'any\', or \'all\'');
859
+ const vargs = {
860
+ basket: validateStringLength(args.basket, 'basket', 1, 300),
861
+ tags: (args.tags != null ? args.tags : []).map(t => validateStringLength(t, 'tag', 1, 300)),
862
+ tagQueryMode,
863
+ includeLockingScripts: args.include === 'locking scripts',
864
+ includeTransactions: args.include === 'entire transactions',
865
+ includeCustomInstructions: defaultFalse(args.includeCustomInstructions),
866
+ includeTags: defaultFalse(args.includeTags),
867
+ includeLabels: defaultFalse(args.includeLabels),
868
+ limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
869
+ offset: validateInteger(args.offset, 'offset', 0, undefined, undefined),
870
+ seekPermission: defaultTrue(args.seekPermission),
871
+ knownTxids: []
872
+ };
873
+ return vargs;
874
+ }
875
+ exports.validateListOutputsArgs = validateListOutputsArgs;
876
+ /**
877
+ * @param {LabelStringUnder300Bytes[]} args.labels - An array of labels used to filter actions.
878
+ * @param {'any' | 'all'} [args.labelQueryMode] - Optional. Specifies how to match labels (default is any which matches any of the labels).
879
+ * @param {BooleanDefaultFalse} [args.includeLabels] - Optional. Whether to include transaction labels in the result set.
880
+ * @param {BooleanDefaultFalse} [args.includeInputs] - Optional. Whether to include input details in the result set.
881
+ * @param {BooleanDefaultFalse} [args.includeInputSourceLockingScripts] - Optional. Whether to include input source locking scripts in the result set.
882
+ * @param {BooleanDefaultFalse} [args.includeInputUnlockingScripts] - Optional. Whether to include input unlocking scripts in the result set.
883
+ * @param {BooleanDefaultFalse} [args.includeOutputs] - Optional. Whether to include output details in the result set.
884
+ * @param {BooleanDefaultFalse} [args.includeOutputLockingScripts] - Optional. Whether to include output locking scripts in the result set.
885
+ * @param {PositiveIntegerDefault10Max10000} [args.limit] - Optional. The maximum number of transactions to retrieve.
886
+ * @param {PositiveIntegerOrZero} [args.offset] - Optional. Number of transactions to skip before starting to return the results.
887
+ * @param {BooleanDefaultTrue} [args.seekPermission] — Optional. Whether to seek permission from the user for this operation if required. Default true, will return an error rather than proceed if set to false.
888
+ */
889
+ function validateListActionsArgs(args) {
890
+ let labelQueryMode;
891
+ if (args.labelQueryMode === undefined || args.labelQueryMode === 'any')
892
+ labelQueryMode = 'any';
893
+ else if (args.labelQueryMode === 'all')
894
+ labelQueryMode = 'all';
895
+ else
896
+ throw new WERR_INVALID_PARAMETER_js_1.default('labelQueryMode', 'undefined, \'any\', or \'all\'');
897
+ const vargs = {
898
+ labels: (args.labels != null ? args.labels : []).map(t => validateLabel(t)),
899
+ labelQueryMode,
900
+ includeLabels: defaultFalse(args.includeLabels),
901
+ includeInputs: defaultFalse(args.includeInputs),
902
+ includeInputSourceLockingScripts: defaultFalse(args.includeInputSourceLockingScripts),
903
+ includeInputUnlockingScripts: defaultFalse(args.includeInputUnlockingScripts),
904
+ includeOutputs: defaultFalse(args.includeOutputs),
905
+ includeOutputLockingScripts: defaultFalse(args.includeOutputLockingScripts),
906
+ limit: validateInteger(args.limit, 'limit', 10, 1, 10000),
907
+ offset: validateInteger(args.offset, 'offset', 0, 0),
908
+ seekPermission: defaultTrue(args.seekPermission)
909
+ };
910
+ return vargs;
911
+ }
912
+ exports.validateListActionsArgs = validateListActionsArgs;
913
+ /**
914
+ * `createAction` special operation label name value.
915
+ *
916
+ * Causes WERR_REVIEW_ACTIONS throw with dummy properties.
917
+ *
918
+ */
919
+ exports.specOpThrowReviewActions = 'a496e747fc3ad5fabdd4ae8f91184e71f87539bd3d962aa2548942faaaf0047a';
920
+ //# sourceMappingURL=validationHelpers.js.map