@xo-cash/engine 0.0.1-development.14109350676
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/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/index.d.mts +1405 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2724 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +73 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1405 @@
|
|
|
1
|
+
import { CompilerBch, CompilerConfiguration } from "@bitauth/libauth";
|
|
2
|
+
import { PrivateKeyRecordForLibauthCompiler } from "@xo-cash/crypto";
|
|
3
|
+
import { ScriptHashData, State, StorageType, StoredInvitation, UnspentOutputData } from "@xo-cash/state";
|
|
4
|
+
import { generateTemplateIdentifier, parseTemplate } from "@xo-cash/utils";
|
|
5
|
+
import { ChainStatus } from "@electrum-cash/application";
|
|
6
|
+
import { ScriptHashListUnspentResponse, ScriptHashSubscribeNotification, TransactionHash } from "@electrum-cash/protocol";
|
|
7
|
+
import { ElectrumServers } from "@electrum-cash/servers";
|
|
8
|
+
import { XOInvitation, XOInvitationCommit, XOInvitationInput, XOInvitationOutput, XOInvitationRequirements, XOInvitationVariable, XOInvitationVariableValue, XOTemplate, XOTemplateAction, XOTemplateActionIntent, XOTemplateLockingScript, XOTemplateLockingScriptRole, XOTemplateLockingType, XOTemplateOutput, XOTemplateTransaction } from "@xo-cash/types";
|
|
9
|
+
|
|
10
|
+
//#region source/interfaces.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Configuration options for the XO Engine.
|
|
13
|
+
*/
|
|
14
|
+
interface XOEngineOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The storage type to use.
|
|
17
|
+
*/
|
|
18
|
+
storageType?: StorageType;
|
|
19
|
+
/**
|
|
20
|
+
* Directory path where the database will be stored.
|
|
21
|
+
*/
|
|
22
|
+
databasePath?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Filename of the database file.
|
|
25
|
+
*/
|
|
26
|
+
databaseFilename?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The default URL for the template hub used by the engine.
|
|
29
|
+
*/
|
|
30
|
+
defaultTemplateHubUrl?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The Electrum servers to use.
|
|
33
|
+
*/
|
|
34
|
+
electrumServers?: ElectrumServers;
|
|
35
|
+
/**
|
|
36
|
+
* The Electrum application identifier to use.
|
|
37
|
+
*/
|
|
38
|
+
electrumApplicationIdentifier?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Remote encrypted state servers to use.
|
|
41
|
+
*/
|
|
42
|
+
remoteEncryptedStateServers?: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parameters required for creating a new XO invitation.
|
|
46
|
+
*/
|
|
47
|
+
interface InvitationCreationParameters {
|
|
48
|
+
/**
|
|
49
|
+
* Identifier of the template to use for this invitation.
|
|
50
|
+
*/
|
|
51
|
+
templateIdentifier: string;
|
|
52
|
+
/**
|
|
53
|
+
* Identifier of the action within the template to initiate.
|
|
54
|
+
*/
|
|
55
|
+
actionIdentifier: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Parameters for extending an invitation.
|
|
59
|
+
*/
|
|
60
|
+
interface AppendInvitationParameters {
|
|
61
|
+
/**
|
|
62
|
+
* Optional transaction version.
|
|
63
|
+
*/
|
|
64
|
+
version?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Optional transaction locktime.
|
|
67
|
+
*/
|
|
68
|
+
locktime?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Optional array of inputs.
|
|
71
|
+
*/
|
|
72
|
+
inputs?: XOInvitationInput[];
|
|
73
|
+
/**
|
|
74
|
+
* Optional array of outputs.
|
|
75
|
+
*/
|
|
76
|
+
outputs?: XOInvitationOutput[];
|
|
77
|
+
/**
|
|
78
|
+
* Optional array of variables.
|
|
79
|
+
*/
|
|
80
|
+
variables?: XOInvitationVariable[];
|
|
81
|
+
/**
|
|
82
|
+
* Optional expiration timestamp.
|
|
83
|
+
*/
|
|
84
|
+
expiresAtTimestamp?: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Parameters for accepting an invitation.
|
|
88
|
+
*/
|
|
89
|
+
type AcceptInvitationParameters = AppendInvitationParameters;
|
|
90
|
+
/**
|
|
91
|
+
* Parameters for executing an action.
|
|
92
|
+
*/
|
|
93
|
+
interface ExecuteActionParameters {
|
|
94
|
+
/**
|
|
95
|
+
* Whether to broadcast the transaction to the blockchain.
|
|
96
|
+
*/
|
|
97
|
+
broadcastTransaction: boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Parameters for finding suitable resources.
|
|
101
|
+
*/
|
|
102
|
+
interface GetSpendableResourcesParameters {
|
|
103
|
+
/**
|
|
104
|
+
* Identifier of the template to use for resource selection.
|
|
105
|
+
*/
|
|
106
|
+
templateIdentifier: string;
|
|
107
|
+
/**
|
|
108
|
+
* Identifier of the output within the template.
|
|
109
|
+
*/
|
|
110
|
+
outputIdentifier: string;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region source/engine.d.ts
|
|
114
|
+
/**
|
|
115
|
+
* XO Engine class: Acts like an orchestrator for the XO system.
|
|
116
|
+
*/
|
|
117
|
+
declare class Engine {
|
|
118
|
+
/**
|
|
119
|
+
* The crypto instance.
|
|
120
|
+
*/
|
|
121
|
+
private crypto;
|
|
122
|
+
/**
|
|
123
|
+
* The state instance.
|
|
124
|
+
*/
|
|
125
|
+
private state;
|
|
126
|
+
/**
|
|
127
|
+
* The blockchain monitor instance.
|
|
128
|
+
*/
|
|
129
|
+
private blockchainMonitor;
|
|
130
|
+
/**
|
|
131
|
+
* The default template identifier.
|
|
132
|
+
*/
|
|
133
|
+
private defaultTemplateIdentifier;
|
|
134
|
+
/**
|
|
135
|
+
* The default role identifier.
|
|
136
|
+
*/
|
|
137
|
+
private defaultRoleIdentifier;
|
|
138
|
+
/**
|
|
139
|
+
* The default output identifier.
|
|
140
|
+
*/
|
|
141
|
+
private defaultOutputIdentifier;
|
|
142
|
+
/**
|
|
143
|
+
* Constructs a new instance of XO Engine.
|
|
144
|
+
* @private
|
|
145
|
+
* @param {string} seed - The wallet seed.
|
|
146
|
+
* @param {State} store - Store instance.
|
|
147
|
+
* @param {BlockchainMonitor} blockchainMonitor - Blockchain monitor instance.
|
|
148
|
+
*/
|
|
149
|
+
private constructor();
|
|
150
|
+
/**
|
|
151
|
+
* Initializes and creates a new XO Engine instance.
|
|
152
|
+
* Configures the state, initializes the sync server and monitor for app and blockchain events
|
|
153
|
+
*
|
|
154
|
+
* @param {string} seed - Wallet seed used for signing and/or key derivation.
|
|
155
|
+
* @param {XOEngineOptions} options - Database configuration options.
|
|
156
|
+
* @returns {Promise<Engine>} An initialized Engine instance.
|
|
157
|
+
*/
|
|
158
|
+
static create(seed: string, options: XOEngineOptions): Promise<Engine>;
|
|
159
|
+
/**
|
|
160
|
+
* Stops the engine instance and cleans up resources.
|
|
161
|
+
* @returns {Promise<void>} Resolves when the engine is stopped.
|
|
162
|
+
*/
|
|
163
|
+
stop(): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Retrieves the current chain status from the electrum application.
|
|
166
|
+
* @returns {Promise<ChainStatus>} The current chain status.
|
|
167
|
+
*/
|
|
168
|
+
getChainStatus(): Promise<ChainStatus>;
|
|
169
|
+
/**
|
|
170
|
+
* Retrieves a template by its identifier from the state.
|
|
171
|
+
* @param {string} templateIdentifier - Template identifier.
|
|
172
|
+
* @returns {Promise<XOTemplate | undefined>} The template object.
|
|
173
|
+
*/
|
|
174
|
+
getTemplate(templateIdentifier: string): Promise<XOTemplate | undefined>;
|
|
175
|
+
/**
|
|
176
|
+
* Imports a template into the Engine after sanitization and validation.
|
|
177
|
+
* @param {string | XOTemplate} untrustedJsonOrObject - JSON or object containing the untrusted template to import.
|
|
178
|
+
* @returns {Promise<void>} Resolves when the template is imported.
|
|
179
|
+
* @throws {TemplateImportFailedError} If the template is invalid.
|
|
180
|
+
*/
|
|
181
|
+
importTemplate(untrustedJsonOrObject: string | XOTemplate): Promise<{
|
|
182
|
+
template: XOTemplate;
|
|
183
|
+
templateIdentifier: string;
|
|
184
|
+
}>;
|
|
185
|
+
/**
|
|
186
|
+
* Lists all the imported templates.
|
|
187
|
+
* @returns {Promise<XOTemplate[]>} The list of imported templates.
|
|
188
|
+
*/
|
|
189
|
+
listImportedTemplates(): Promise<XOTemplate[]>;
|
|
190
|
+
/**
|
|
191
|
+
* Lists the starting actions available in a specified template.
|
|
192
|
+
* @param {string} templateIdentifier - Template identifier.
|
|
193
|
+
* @returns {Promise<Array<XOTemplateActionIntent>>} The list of starting actions.
|
|
194
|
+
*/
|
|
195
|
+
listStartingActions(templateIdentifier: string): Promise<Array<XOTemplateActionIntent>>;
|
|
196
|
+
/**
|
|
197
|
+
* Update the unspent outputs for all of a templates lockingBytecodes.
|
|
198
|
+
*
|
|
199
|
+
* TODO: Make this an private/internal method.
|
|
200
|
+
*
|
|
201
|
+
* @param {string} templateIdentifier - Template identifier.
|
|
202
|
+
* @returns {Promise<void>} Resolves when the unspent outputs are updated.
|
|
203
|
+
*/
|
|
204
|
+
updateUnspentOutputsForTemplate(templateIdentifier: string): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Subscribe to the script hashes for a template.
|
|
207
|
+
*
|
|
208
|
+
* TODO: Make this a private/internal method. We may change how/where this is defined in the future.
|
|
209
|
+
* We'd like to ensure events are propagated to the sync server with an ACK and that the states match between remote and local.
|
|
210
|
+
*
|
|
211
|
+
* @param {string} templateIdentifier - Template identifier.
|
|
212
|
+
* @returns {Promise<void>} Resolves when the script hashes are subscribed.
|
|
213
|
+
*/
|
|
214
|
+
subscribeToScriptHashForTemplate(templateIdentifier: string): Promise<void>;
|
|
215
|
+
/**
|
|
216
|
+
* TENTATIVE METHOD: DEFAULT LOCKING STRATEGY UNKNOWN
|
|
217
|
+
*
|
|
218
|
+
* Sets the default locking parameters (template, output, and role identifiers) for the engine.
|
|
219
|
+
* TODO: The default identifiers exist as the strategy on how to create the change and default
|
|
220
|
+
* unlocking conditions are unclear. This is likely to change in the future.
|
|
221
|
+
*
|
|
222
|
+
* @param {string} templateIdentifier - The identifier of the template to use as default.
|
|
223
|
+
* @param {string} outputIdentifier - The identifier of the output within the specified template.
|
|
224
|
+
* @param {string} roleIdentifier - The identifier of the role to use as default for this output.
|
|
225
|
+
* @returns {Promise<void>} Resolves when the default parameters have been successfully set.
|
|
226
|
+
* @throws {Error} If the template or output cannot be found.
|
|
227
|
+
*/
|
|
228
|
+
setDefaultLockingParameters(templateIdentifier: string, outputIdentifier: string, roleIdentifier: string): Promise<void>;
|
|
229
|
+
/**
|
|
230
|
+
* TODO: Implement this.
|
|
231
|
+
*
|
|
232
|
+
* State sync should always be working, any hiccups in the sync process should be resolved
|
|
233
|
+
* Unable to do so should halt all operations unless no remote servers are provided.
|
|
234
|
+
*
|
|
235
|
+
* Initializes the state sync process.
|
|
236
|
+
* @returns {Promise<void>} Resolves when the state sync is initialized.
|
|
237
|
+
*/
|
|
238
|
+
initializeStateSync(): Promise<void>;
|
|
239
|
+
/**
|
|
240
|
+
* Creates an invitation that can be shared with other entities, user, application, etc.
|
|
241
|
+
* Invitation is the fundamental communication unit in XO, all the interactions done using the
|
|
242
|
+
* xo template are done using invitations.
|
|
243
|
+
*
|
|
244
|
+
* @param {InvitationCreationParameters} params - The parameters for invitation creation.
|
|
245
|
+
* @param {string} params.templateIdentifier - Identifier for the template to use.
|
|
246
|
+
* @param {string} params.actionIdentifier - Identifier for the action to initiate.
|
|
247
|
+
* @returns {Promise<XOInvitation>} A promise that resolves to the constructed invitation.
|
|
248
|
+
* @throws {TemplateNotFoundError} If the template is not found.
|
|
249
|
+
* @throws {ActionNotFoundError} If the action is not found.
|
|
250
|
+
*
|
|
251
|
+
* TODO: Add all the throws that happen during the execution of the method.
|
|
252
|
+
*/
|
|
253
|
+
createInvitation(params: InvitationCreationParameters): Promise<XOInvitation>;
|
|
254
|
+
/**
|
|
255
|
+
* Accepts an invitation, an entity accepts an invitation and becomes part of the invitation.
|
|
256
|
+
*
|
|
257
|
+
* @param {XOInvitation} invitation - The invitation to be accepted.
|
|
258
|
+
* @param {AcceptInvitationParameters} params - Optional parameters for accepting the invitation.
|
|
259
|
+
* @returns {Promise<XOInvitation>} The updated XOInvitation instance.
|
|
260
|
+
* @throws {TemplateNotFoundError} If the template is not found.
|
|
261
|
+
* @throws {ActionNotFoundError} If the action is not found.
|
|
262
|
+
* @throws {InvalidEntityIdentifierError} If the entity identifiers are invalid.
|
|
263
|
+
* @throws {InvalidRequirementsError} If the requirements are invalid.
|
|
264
|
+
* @throws {InvalidCommitSignaturesError} If the commit signatures are invalid.
|
|
265
|
+
*/
|
|
266
|
+
acceptInvitation(invitation: XOInvitation, params?: AcceptInvitationParameters): Promise<XOInvitation>;
|
|
267
|
+
/**
|
|
268
|
+
* Appends the invitation with the new information.
|
|
269
|
+
*
|
|
270
|
+
* @param {XOInvitation} invitation - The invitation to append.
|
|
271
|
+
* @param {AppendInvitationParameters} params - The parameters to append the invitation with.
|
|
272
|
+
* @returns {Promise<XOInvitation>} The appended invitation.
|
|
273
|
+
*/
|
|
274
|
+
appendInvitation(invitation: XOInvitation, params: AppendInvitationParameters): Promise<XOInvitation>;
|
|
275
|
+
/**
|
|
276
|
+
* Signs the provided invitation once all the resources are reserved and the invitation is complete.
|
|
277
|
+
* This method is used to sign own inputs and provide unlocking data for them, this appends the
|
|
278
|
+
* invitation and adds new commit with unlocking data.
|
|
279
|
+
*
|
|
280
|
+
* @param {XOInvitation} invitation - The invitation to sign.
|
|
281
|
+
* @returns {Promise<XOInvitation>} Resolves when signing is complete.
|
|
282
|
+
*
|
|
283
|
+
* TODO: Add all the throws that happen during the execution of the method.
|
|
284
|
+
*/
|
|
285
|
+
signInvitation(invitation: XOInvitation): Promise<XOInvitation>;
|
|
286
|
+
/**
|
|
287
|
+
* Executes an action for a given invitation.
|
|
288
|
+
* @param {XOInvitation} invitation - The invitation whose action to execute.
|
|
289
|
+
* @param {ExecuteActionParameters} params - Parameters for executing the action.
|
|
290
|
+
* @returns {Promise<void>} Resolves when the action is executed.
|
|
291
|
+
*
|
|
292
|
+
* TODO: Add all the throws that happen during the execution of the method.
|
|
293
|
+
*/
|
|
294
|
+
executeAction(invitation: XOInvitation, params: ExecuteActionParameters): Promise<TransactionHash>;
|
|
295
|
+
/**
|
|
296
|
+
* Fully validates a given XOInvitation according to template and signature checks.
|
|
297
|
+
*
|
|
298
|
+
* @param {XOInvitation} invitation - The invitation to validate.
|
|
299
|
+
* @returns {Promise<void>} Resolves if invitation is valid.
|
|
300
|
+
* @throws {TemplateNotFoundError} If the template is not found.
|
|
301
|
+
* @throws {ActionNotFoundError} If the action is not found.
|
|
302
|
+
* @throws {InvitationExpiredError} If the invitation has expired.
|
|
303
|
+
* @throws {InvalidEntityIdentifierError} If the entity identifiers are invalid.
|
|
304
|
+
* @throws {InvalidRequirementsError} If the requirements are invalid.
|
|
305
|
+
* @throws {InvalidCommitSignaturesError} If the commit signatures are invalid.
|
|
306
|
+
*/
|
|
307
|
+
isInvitationValid(invitation: XOInvitation): Promise<boolean>;
|
|
308
|
+
/**
|
|
309
|
+
* Lists available roles for the given invitation.
|
|
310
|
+
*
|
|
311
|
+
* @param {XOInvitation} invitation - The invitation to examine.
|
|
312
|
+
* @returns {Promise<string[]>} The list of roles that still require data.
|
|
313
|
+
* @throws {TemplateNotFoundError} If the template is not found.
|
|
314
|
+
* @throws {ActionNotFoundError} If the action is not found.
|
|
315
|
+
*/
|
|
316
|
+
listAvailableRoles(invitation: XOInvitation): Promise<string[]>;
|
|
317
|
+
/**
|
|
318
|
+
* Lists requirements for the provided invitation.
|
|
319
|
+
*
|
|
320
|
+
* @param {XOInvitation} invitation - The invitation to analyze requirements for.
|
|
321
|
+
* @returns {Promise<XOInvitationRequirements>} The requirements information.
|
|
322
|
+
*
|
|
323
|
+
*/
|
|
324
|
+
listRequirements(invitation: XOInvitation): Promise<XOInvitationRequirements>;
|
|
325
|
+
/**
|
|
326
|
+
* Lists missing requirements for the provided invitation.
|
|
327
|
+
*
|
|
328
|
+
* @param {XOInvitation} invitation - The invitation to analyze.
|
|
329
|
+
* @returns {Promise<XOInvitationRequirements>} The missing requirements.
|
|
330
|
+
*/
|
|
331
|
+
listMissingRequirements(invitation: XOInvitation): Promise<XOInvitationRequirements>;
|
|
332
|
+
/**
|
|
333
|
+
* Lists all the unspent outputs.
|
|
334
|
+
*
|
|
335
|
+
* @returns {Promise<UnspentOutputData[]>} The list of unspent outputs.
|
|
336
|
+
*/
|
|
337
|
+
listUnspentOutputsData(): Promise<UnspentOutputData[]>;
|
|
338
|
+
/**
|
|
339
|
+
* Finds suitable resources for an invitation.
|
|
340
|
+
*
|
|
341
|
+
* TODO: May become private. This may change in the future and become a more advanced coin selection method used directly by the engine.
|
|
342
|
+
* The current behavior is that it finds "spendable" outputs, but we may adjust this to actually find "suitable" outputs.
|
|
343
|
+
*
|
|
344
|
+
* @param {XOInvitation} invitation - The invitation to find resources for.
|
|
345
|
+
* @param {GetSpendableResourcesParameters} options - Parameters for finding suitable resources.
|
|
346
|
+
* @returns {Promise<{ unspentOutputs: UnspentOutputData[] }>} The list of suitable resources.
|
|
347
|
+
*/
|
|
348
|
+
getSpendableResources(invitation: XOInvitation, options?: GetSpendableResourcesParameters): Promise<{
|
|
349
|
+
unspentOutputs: UnspentOutputData[];
|
|
350
|
+
}>;
|
|
351
|
+
/**
|
|
352
|
+
* Retrieves a list of script hash data stored for a given template identifier.
|
|
353
|
+
*
|
|
354
|
+
* @param {string} templateIdentifier - The identifier of the template.
|
|
355
|
+
* @returns {Promise<ScriptHashData[]>} An array of script hash data objects.
|
|
356
|
+
*/
|
|
357
|
+
listScriptHashesForTemplate(templateIdentifier: string): Promise<ScriptHashData[]>;
|
|
358
|
+
/**
|
|
359
|
+
* Gets all the script hashes from all the templates.
|
|
360
|
+
*
|
|
361
|
+
* @returns {Promise<ScriptHashData[]>} An array of script hash data objects.
|
|
362
|
+
*/
|
|
363
|
+
listScriptHashes(): Promise<ScriptHashData[]>;
|
|
364
|
+
/**
|
|
365
|
+
* Generates the locking bytecode for a specified template output and role.
|
|
366
|
+
*
|
|
367
|
+
* Role is important because in the template definition it can direct to a different secret or a locking script
|
|
368
|
+
* for that to be discovered and used, it must know what role is provided. Also, it's important for libauth compiler
|
|
369
|
+
* to know what role is being used to generate the locking bytecode.
|
|
370
|
+
*
|
|
371
|
+
* Currently, only "standard" type (e.g. P2PKH) locking scripts are supported.
|
|
372
|
+
* In the future, this method will be extended to support more output script types based on template definitions.
|
|
373
|
+
*
|
|
374
|
+
* Future definition of primitives is going to define how other non-p2pkh locking scripts are validated,
|
|
375
|
+
* for example, p2pkh is possible because the engine know what a private key and public key is more such primitives
|
|
376
|
+
* will be defined and they will be helpful in generating and validating locking scripts of different types.
|
|
377
|
+
*
|
|
378
|
+
* Process overview:
|
|
379
|
+
* - Fetch the template and output definition by their identifiers.
|
|
380
|
+
* - Find the relevant locking script and roles.
|
|
381
|
+
* - Select the specified role or fallback to the first available role.
|
|
382
|
+
* - Build the entity ownership mapping, scripts, and variable definitions for Libauth.
|
|
383
|
+
* - Set up unlocking scripts and locking script type for the compiler configuration.
|
|
384
|
+
* - For "standard" lock scripts, generate entropy if required. (TODO: Improve entropy generation.)
|
|
385
|
+
* - Compile the locking bytecode with the Libauth compiler.
|
|
386
|
+
* - Subscribe to blockchain updates for the script hash and store the resulting bytecode.
|
|
387
|
+
*
|
|
388
|
+
* TODO: Support additional types of outputs/scripts tied to template specification.
|
|
389
|
+
* TODO: If important to make this process faster, consider emitting an event and pushing process to the event loop.
|
|
390
|
+
* TODO: Encrypt the new information, update the encrypted state servers.
|
|
391
|
+
*
|
|
392
|
+
* @param {string} templateIdentifier - Identifier of the template.
|
|
393
|
+
* @param {string} outputIdentifier - Identifier of the output (from the template).
|
|
394
|
+
* @param {string} roleIdentifier - Role identifier (corresponding to a role in the output's script).
|
|
395
|
+
* @returns {Promise<string>} The generated locking bytecode as a hexadecimal string.
|
|
396
|
+
* @throws {Error} If any required template, output, or configuration is not found, or if compilation fails.
|
|
397
|
+
*/
|
|
398
|
+
generateLockingBytecode(templateIdentifier: string, outputIdentifier: string, roleIdentifier?: string): Promise<string>;
|
|
399
|
+
/**
|
|
400
|
+
* Generates a locking bytecode using the engine's default template, output, and role identifiers.
|
|
401
|
+
*
|
|
402
|
+
* @returns A promise that resolves to the generated locking bytecode as a string.
|
|
403
|
+
*/
|
|
404
|
+
generateLockingBytecodeForDefaultParameters(): Promise<string>;
|
|
405
|
+
/**
|
|
406
|
+
* Generate locking data and derivative index for P2PKH.
|
|
407
|
+
*/
|
|
408
|
+
generateLockingDataForStandardP2PKH(templateIdentifier: string, outputIdentifier: string, roleIdentifier: string, lockingScriptForOutput: XOTemplateLockingScript): Promise<{
|
|
409
|
+
lockingData: PrivateKeyRecordForLibauthCompiler;
|
|
410
|
+
derivativeIndex: string;
|
|
411
|
+
}>;
|
|
412
|
+
/**
|
|
413
|
+
* Fetches a stored invitation by identifier
|
|
414
|
+
*
|
|
415
|
+
* @param {string} invitationIdentifier - The identifier to look up.
|
|
416
|
+
* @returns {Promise<StoredInvitation | undefined>} The stored invitation, or undefined.
|
|
417
|
+
*/
|
|
418
|
+
getInvitationOrThrow(invitationIdentifier: string): Promise<StoredInvitation>;
|
|
419
|
+
/**
|
|
420
|
+
* Fetches a stored template by identifier
|
|
421
|
+
*
|
|
422
|
+
* @param {string} templateIdentifier - The identifier to look up.
|
|
423
|
+
* @returns {Promise<XOTemplate>} The stored template.
|
|
424
|
+
*/
|
|
425
|
+
getTemplateOrThrow(templateIdentifier: string): Promise<XOTemplate>;
|
|
426
|
+
/**
|
|
427
|
+
* Synchronizes the store of unspent outputs for a given script hash with the current state of the blockchain.
|
|
428
|
+
*
|
|
429
|
+
* This method performs the following:
|
|
430
|
+
* 1. Retrieves the stored script hash data from the store.
|
|
431
|
+
* 2. Fetches the current list of unspent outputs for the script hash from the store.
|
|
432
|
+
* 3. Computes the corresponding scripthash from the script hash.
|
|
433
|
+
* 4. Queries the blockchain for all unspent transaction outputs associated with the scripthash.
|
|
434
|
+
* 5. Adds any new unspent outputs found on the blockchain but missing from the store to the store.
|
|
435
|
+
* 6. Removes any unspent outputs present in the store but no longer in the blockchain.
|
|
436
|
+
*
|
|
437
|
+
* @param scriptHash - The script hash for which to update the stored unspent outputs.
|
|
438
|
+
* @throws If the script hash is not found in the store.
|
|
439
|
+
*/
|
|
440
|
+
updateUnspentOutputsForScriptHashInStore(scriptHash: string): Promise<void>;
|
|
441
|
+
/**
|
|
442
|
+
* TODO: Internal function, move elsewhere.
|
|
443
|
+
*
|
|
444
|
+
* Finds own inputs and prepares a list for the lookup in the store.
|
|
445
|
+
*
|
|
446
|
+
* @param {XOInvitationInput[]} inputs - The inputs to find resources for.
|
|
447
|
+
* @returns {Promise<XOInvitationInput[]>} The list of own inputs for reservation.
|
|
448
|
+
*/
|
|
449
|
+
private findOwnResources;
|
|
450
|
+
/**
|
|
451
|
+
* Reserves utxos and store information in the storage.
|
|
452
|
+
*
|
|
453
|
+
* @param {XOInvitationInput[]} inputs - The inputs to reserve.
|
|
454
|
+
* @param {string} invitationIdentifier - The identifier of the invitation for which the resources are being reserved.
|
|
455
|
+
* @returns {Promise<void>} Resolves when the reservation is complete.
|
|
456
|
+
*/
|
|
457
|
+
private reserveResources;
|
|
458
|
+
}
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region source/errors.d.ts
|
|
461
|
+
/**
|
|
462
|
+
* Error thrown when an action is not found in the template.
|
|
463
|
+
*/
|
|
464
|
+
declare class ActionNotFoundError extends Error {
|
|
465
|
+
constructor(actionIdentifier?: string);
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Error thrown when an output is not found in the template.
|
|
469
|
+
*/
|
|
470
|
+
declare class OutputNotFoundError extends Error {
|
|
471
|
+
constructor(outputIdentifier?: string);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Error thrown when a template is not found.
|
|
475
|
+
*/
|
|
476
|
+
declare class TemplateNotFoundError extends Error {
|
|
477
|
+
constructor(templateIdentifier?: string);
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Error thrown when a locking script is not found in the template.
|
|
481
|
+
*/
|
|
482
|
+
declare class LockingScriptNotFoundError extends Error {
|
|
483
|
+
constructor(lockingScriptIdentifier?: string);
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Error thrown when a locking script type is not found in the template.
|
|
487
|
+
*/
|
|
488
|
+
declare class LockingScriptTypeNotFoundError extends Error {
|
|
489
|
+
constructor(lockingScriptIdentifier?: string);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Error thrown when a lockscript is not found in the template.
|
|
493
|
+
*/
|
|
494
|
+
declare class LockscriptNotFoundError extends Error {
|
|
495
|
+
constructor(lockscriptIdentifier?: string);
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Error thrown when an unlocking script is not found in the template.
|
|
499
|
+
*/
|
|
500
|
+
declare class UnlockingScriptNotFoundError extends Error {
|
|
501
|
+
constructor(unlockingScriptIdentifier?: string);
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Error thrown when a script is not found in the template.
|
|
505
|
+
*/
|
|
506
|
+
declare class ScriptNotFoundError extends Error {
|
|
507
|
+
constructor(scriptIdentifier?: string);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Error thrown when a starting action is not found in the template.
|
|
511
|
+
*/
|
|
512
|
+
declare class StartingActionNotFoundError extends Error {
|
|
513
|
+
constructor(templateIdentifier?: string);
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Error thrown when a transaction is not found in the template.
|
|
517
|
+
*/
|
|
518
|
+
declare class TransactionNotFoundError extends Error {
|
|
519
|
+
constructor(transactionIdentifier?: string);
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Error thrown when a commit entity identifier is not found.
|
|
523
|
+
*/
|
|
524
|
+
declare class CommitEntityIdentifierNotFoundError extends Error {
|
|
525
|
+
constructor(commitIdentifier?: string);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Error thrown when a commit is not signed.
|
|
529
|
+
*/
|
|
530
|
+
declare class CommitNotSignedError extends Error {
|
|
531
|
+
constructor(commitIdentifier?: string);
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Error thrown when a commit is not found in the invitation.
|
|
535
|
+
*/
|
|
536
|
+
declare class CommitNotFoundInInvitationError extends Error {
|
|
537
|
+
constructor(commitIdentifier?: string);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Error thrown when one or more entity identifiers are invalid.
|
|
541
|
+
*/
|
|
542
|
+
declare class InvalidEntityIdentifierError extends Error {
|
|
543
|
+
constructor(entityIdentifiers?: string[]);
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Error thrown when one or more provided requirements were not expected by the template.
|
|
547
|
+
*/
|
|
548
|
+
declare class InvalidRequirementsError extends Error {
|
|
549
|
+
constructor(requirementIdentifiers?: string[]);
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Error thrown when one or more commit signatures are invalid.
|
|
553
|
+
*/
|
|
554
|
+
declare class InvalidCommitSignaturesError extends Error {
|
|
555
|
+
constructor(commitIdentifiers?: string[]);
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Error thrown when an invitation is not found in the store.
|
|
559
|
+
*/
|
|
560
|
+
declare class InvitationNotFoundInStoreError extends Error {
|
|
561
|
+
constructor(invitationIdentifier?: string);
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Error thrown when an invitation has already been accepted.
|
|
565
|
+
*/
|
|
566
|
+
declare class InvitationAlreadyAcceptedError extends Error {
|
|
567
|
+
constructor(invitationIdentifier?: string);
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Error thrown when an invitation was created in the future.
|
|
571
|
+
*/
|
|
572
|
+
declare class InvitationCreatedInFutureError extends Error {
|
|
573
|
+
constructor(invitationIdentifier?: string);
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Error thrown when an invitation has expired.
|
|
577
|
+
*/
|
|
578
|
+
declare class InvitationExpiredError extends Error {
|
|
579
|
+
constructor(invitationIdentifier?: string);
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Error thrown when an invitation has not been accepted.
|
|
583
|
+
*/
|
|
584
|
+
declare class InvitationNotAcceptedError extends Error {
|
|
585
|
+
constructor(invitationIdentifier?: string);
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Error thrown when an invitation is invalid.
|
|
589
|
+
*/
|
|
590
|
+
declare class InvalidInvitationError extends Error {
|
|
591
|
+
constructor(invitationIdentifier?: string);
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Error thrown when a merged commit is not found.
|
|
595
|
+
*/
|
|
596
|
+
declare class MergedCommitNotFoundError extends Error {
|
|
597
|
+
constructor();
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Error thrown when the script hash data record for a given script hash is not found in the store.
|
|
601
|
+
*/
|
|
602
|
+
declare class ScriptHashDataNotFoundError extends Error {
|
|
603
|
+
constructor(scriptHash?: string);
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Error thrown when the root commit for an entity cannot be found in the invitation.
|
|
607
|
+
*/
|
|
608
|
+
declare class RootCommitNotFoundError extends Error {
|
|
609
|
+
constructor(entityIdentifier?: string);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Error thrown when a parent commit is not found.
|
|
613
|
+
*/
|
|
614
|
+
declare class ParentCommitNotFoundError extends Error {
|
|
615
|
+
constructor(parentCommitIdentifier: string, commitIdentifier: string);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Error thrown when duplicate transactionIndex values are found.
|
|
619
|
+
*/
|
|
620
|
+
declare class DuplicateTransactionIndexError extends Error {
|
|
621
|
+
constructor(itemType: 'input' | 'output', duplicateIndices: number[]);
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Error thrown when a circular merge reference is detected.
|
|
625
|
+
*/
|
|
626
|
+
declare class CircularMergeReferenceError extends Error {
|
|
627
|
+
constructor(itemType: 'input' | 'output', mergeKey: string, commitIdentifier: string);
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Error thrown when a mergesWith commit is not found.
|
|
631
|
+
*/
|
|
632
|
+
declare class MergesWithCommitNotFoundError extends Error {
|
|
633
|
+
constructor(mergesWithCommitIdentifier: string, currentCommitIdentifier: string);
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Error thrown when an item at a specific index is not found in a commit.
|
|
637
|
+
*/
|
|
638
|
+
declare class ItemNotFoundInCommitError extends Error {
|
|
639
|
+
constructor(itemType: 'input' | 'output', index: number, commitIdentifier: string);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Error thrown when locking bytecode is not found for an output.
|
|
643
|
+
*/
|
|
644
|
+
declare class LockingBytecodeNotFoundForOutputError extends Error {
|
|
645
|
+
constructor(outputIdentifier: string, transactionIndex?: number);
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Error thrown when transaction version is defined multiple times in commits.
|
|
649
|
+
*/
|
|
650
|
+
declare class DuplicateTransactionVersionError extends Error {
|
|
651
|
+
constructor(commitIdentifiers: string[]);
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Error thrown when transaction locktime is defined multiple times in commits.
|
|
655
|
+
*/
|
|
656
|
+
declare class DuplicateTransactionLocktimeError extends Error {
|
|
657
|
+
constructor(commitIdentifiers: string[]);
|
|
658
|
+
}
|
|
659
|
+
declare class TemplateIdentifierMismatchError extends Error {
|
|
660
|
+
constructor();
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Error thrown when an unspent output is not found.
|
|
664
|
+
*/
|
|
665
|
+
declare class UnspentOutputNotFoundError extends Error {
|
|
666
|
+
constructor(outpointIdentifier?: string);
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Error thrown when a role is invalid.
|
|
670
|
+
*/
|
|
671
|
+
declare class InvalidRoleError extends Error {
|
|
672
|
+
constructor(roleIdentifier?: string);
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Error thrown when there are multiple roles for the starting action.
|
|
676
|
+
*/
|
|
677
|
+
declare class MultipleRolesForStartingActionError extends Error {
|
|
678
|
+
constructor(actionIdentifier?: string);
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Error thrown when no role is specified and multiple roles are available to be accepted.
|
|
682
|
+
*/
|
|
683
|
+
declare class NoRoleSpecifiedAndMultipleRolesAvailableToBeAcceptedError extends Error {
|
|
684
|
+
constructor();
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Error thrown when a role has already been accepted by another entity.
|
|
688
|
+
*/
|
|
689
|
+
declare class RoleAlreadyAcceptedByAnotherEntityError extends Error {
|
|
690
|
+
constructor(roleIdentifier?: string);
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Error thrown when a role cannot start an action.
|
|
694
|
+
*/
|
|
695
|
+
declare class RoleCannotStartActionError extends Error {
|
|
696
|
+
constructor(roleIdentifier?: string, actionIdentifier?: string);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Error thrown when a role is not available to be accepted.
|
|
700
|
+
*/
|
|
701
|
+
declare class RoleNotAvailableToBeAcceptedError extends Error {
|
|
702
|
+
constructor(roleIdentifier?: string);
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Error thrown when a role is not defined for an action.
|
|
706
|
+
*/
|
|
707
|
+
declare class RoleNotDefinedForActionError extends Error {
|
|
708
|
+
constructor(roleIdentifier?: string, actionIdentifier?: string);
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Error thrown when a role is not found.
|
|
712
|
+
*/
|
|
713
|
+
declare class RoleNotFoundError extends Error {
|
|
714
|
+
constructor(roleIdentifier?: string);
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Error thrown when a data type is invalid.
|
|
718
|
+
*/
|
|
719
|
+
declare class InvalidDataTypeError extends Error {
|
|
720
|
+
constructor();
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Error thrown when a variable type is invalid.
|
|
724
|
+
*/
|
|
725
|
+
declare class InvalidVariableTypeError extends Error {
|
|
726
|
+
constructor(variableKey: string, expectedType: string, actualType: string);
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Error thrown when a required variable is missing.
|
|
730
|
+
*/
|
|
731
|
+
declare class MissingRequiredVariableError extends Error {
|
|
732
|
+
constructor(variableNames?: string[]);
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Error thrown when an unknown variable is provided.
|
|
736
|
+
*/
|
|
737
|
+
declare class UnknownVariableError extends Error {
|
|
738
|
+
constructor(variableKey?: string);
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Error thrown when a variable is required but not provided.
|
|
742
|
+
*/
|
|
743
|
+
declare class VariableRequiredError extends Error {
|
|
744
|
+
constructor(variableKey?: string);
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Error thrown when variable validation fails.
|
|
748
|
+
*/
|
|
749
|
+
declare class VariableValidationFailedError extends Error {
|
|
750
|
+
constructor(variableNames?: string[]);
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Error thrown when an action is invalid for an invitation.
|
|
754
|
+
*/
|
|
755
|
+
declare class InvalidActionError extends Error {
|
|
756
|
+
constructor(actionIdentifier?: string);
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Error thrown when cash assembly compilation fails.
|
|
760
|
+
*/
|
|
761
|
+
declare class CashAssemblyCompilationFailedError extends Error {
|
|
762
|
+
constructor(message?: string);
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Error thrown when locking bytecode generation fails.
|
|
766
|
+
*/
|
|
767
|
+
declare class LockingBytecodeGenerationFailedError extends Error {
|
|
768
|
+
constructor();
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Error thrown when locking data is not found.
|
|
772
|
+
*/
|
|
773
|
+
declare class LockingDataNotFoundError extends Error {
|
|
774
|
+
constructor();
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Error thrown when transaction generation fails.
|
|
778
|
+
*/
|
|
779
|
+
declare class TransactionGenerationFailedError extends Error {
|
|
780
|
+
constructor();
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Error thrown when the created by identifier is already set.
|
|
784
|
+
*/
|
|
785
|
+
declare class CreatedByIdentifierAlreadySetError extends Error {
|
|
786
|
+
constructor();
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Error thrown when the created by identifier signature is already set.
|
|
790
|
+
*/
|
|
791
|
+
declare class CreatedByIdentifierSignatureAlreadySetError extends Error {
|
|
792
|
+
constructor();
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Error thrown when data is not found in the template.
|
|
796
|
+
*/
|
|
797
|
+
declare class DataNotFoundError extends Error {
|
|
798
|
+
constructor();
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Error thrown when input is invalid.
|
|
802
|
+
*/
|
|
803
|
+
declare class InvalidInputError extends Error {
|
|
804
|
+
constructor();
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Error thrown when required data is missing.
|
|
808
|
+
*/
|
|
809
|
+
declare class MissingRequiredDataError extends Error {
|
|
810
|
+
constructor();
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Error thrown when a required field is missing.
|
|
814
|
+
*/
|
|
815
|
+
declare class MissingRequiredFieldError extends Error {
|
|
816
|
+
constructor(fieldName?: string);
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Error thrown when a required role for an entity is missing.
|
|
820
|
+
*/
|
|
821
|
+
declare class MissingRequiredRoleForEntityError extends Error {
|
|
822
|
+
constructor(roleIdentifier?: string, entityIdentifier?: string);
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Error thrown when a required signature by an entity is missing.
|
|
826
|
+
*/
|
|
827
|
+
declare class MissingRequiredSignatureByEntityError extends Error {
|
|
828
|
+
constructor(entityIdentifier?: string);
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Error thrown when resource reservation fails.
|
|
832
|
+
*/
|
|
833
|
+
declare class ReserveResourcesFailedError extends Error {
|
|
834
|
+
constructor();
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Error thrown when signature verification fails.
|
|
838
|
+
*/
|
|
839
|
+
declare class SignatureVerificationFailedError extends Error {
|
|
840
|
+
constructor();
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Error thrown when a variable definition is invalid.
|
|
844
|
+
*/
|
|
845
|
+
declare class InvalidVariableDefinitionError extends Error {
|
|
846
|
+
constructor(variableIdentifier: string);
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Error thrown when an output does not have a lockscript.
|
|
850
|
+
*/
|
|
851
|
+
declare class OutputLockscriptNotFoundError extends Error {
|
|
852
|
+
constructor(outputIdentifier: string);
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Error thrown when a locking script has an invalid type.
|
|
856
|
+
*/
|
|
857
|
+
declare class InvalidLockingScriptTypeError extends Error {
|
|
858
|
+
constructor(outputIdentifier: string, expectedType: string, actualType: string);
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Error thrown when a locking type is invalid.
|
|
862
|
+
*/
|
|
863
|
+
declare class InvalidLockingTypeError extends Error {
|
|
864
|
+
constructor(outputIdentifier: string, validTypes: string[], actualType: string | undefined);
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Error thrown when a derivative index has an invalid type.
|
|
868
|
+
*/
|
|
869
|
+
declare class InvalidDerivativeIndexTypeError extends Error {
|
|
870
|
+
constructor(expectedType: string, actualType: string);
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Error thrown when a template output valueSatoshis has an invalid type for CashAssembly expression.
|
|
874
|
+
*/
|
|
875
|
+
declare class InvalidTemplateOutputSatoshisTypeError extends Error {
|
|
876
|
+
constructor(actualType: string);
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Error thrown when an electrum client is not found.
|
|
880
|
+
*/
|
|
881
|
+
declare class ElectrumClientNotFoundError extends Error {
|
|
882
|
+
constructor();
|
|
883
|
+
}
|
|
884
|
+
//#endregion
|
|
885
|
+
//#region source/monitor/blockchain.d.ts
|
|
886
|
+
/**
|
|
887
|
+
* BlockchainMonitor class that provides blockchain monitoring operations.
|
|
888
|
+
*/
|
|
889
|
+
declare class BlockchainMonitor {
|
|
890
|
+
/**
|
|
891
|
+
* The state instance for data persistence.
|
|
892
|
+
*/
|
|
893
|
+
private state;
|
|
894
|
+
/**
|
|
895
|
+
* Flag indicating whether event listeners have been initialized.
|
|
896
|
+
*/
|
|
897
|
+
private eventListenersInitialized;
|
|
898
|
+
/**
|
|
899
|
+
* Creates a new instance of BlockchainMonitor.
|
|
900
|
+
*
|
|
901
|
+
* @param {State} state - The State instance for data persistence.
|
|
902
|
+
*/
|
|
903
|
+
constructor(state: State);
|
|
904
|
+
/**
|
|
905
|
+
* Initializes event listeners for electrum application events.
|
|
906
|
+
* Registers listeners for all available events from the electrum application,
|
|
907
|
+
* including system, chain status, block, transaction, output, and address events.
|
|
908
|
+
* This should be called after the electrum application is initialized.
|
|
909
|
+
* Note: Event data is not stored, listeners are registered but remain empty.
|
|
910
|
+
*
|
|
911
|
+
* @returns {void}
|
|
912
|
+
*/
|
|
913
|
+
initializeEventListeners(): void;
|
|
914
|
+
/**
|
|
915
|
+
* Stops the blockchain monitor and releases resources.
|
|
916
|
+
* @returns {Promise<void>} Resolves when the blockchain monitor is stopped.
|
|
917
|
+
*/
|
|
918
|
+
stop(): Promise<void>;
|
|
919
|
+
/**
|
|
920
|
+
* Handles the creation of a new unspent output by storing it in the state.
|
|
921
|
+
*
|
|
922
|
+
* @param {UnspentOutputData} data - The unspent output data to store.
|
|
923
|
+
* @returns {Promise<void>} Resolves when the unspent output data is stored.
|
|
924
|
+
*/
|
|
925
|
+
handleUnspentOutputCreated(data: UnspentOutputData): Promise<void>;
|
|
926
|
+
/**
|
|
927
|
+
* Handles script hash update notifications from the electrum protocol.
|
|
928
|
+
* When a script hash update is received, this method finds all associated
|
|
929
|
+
* locking bytecodes and updates their unspent outputs in the store.
|
|
930
|
+
*
|
|
931
|
+
* @param {ScriptHashSubscribeNotification} data - The script hash subscription notification data.
|
|
932
|
+
* @returns {Promise<void>} Resolves when all unspent outputs are updated.
|
|
933
|
+
*/
|
|
934
|
+
onScriptHashUpdate(data: ScriptHashSubscribeNotification): Promise<void>;
|
|
935
|
+
}
|
|
936
|
+
//#endregion
|
|
937
|
+
//#region source/invitation/builder.d.ts
|
|
938
|
+
/**
|
|
939
|
+
* Builder for the XOInvitation
|
|
940
|
+
*/
|
|
941
|
+
declare class InvitationBuilder {
|
|
942
|
+
/**
|
|
943
|
+
* The identifier of the current invitation.
|
|
944
|
+
*
|
|
945
|
+
* TODO: Add validations and type checks to the identifier e.g length.
|
|
946
|
+
*/
|
|
947
|
+
invitationIdentifier: string;
|
|
948
|
+
/**
|
|
949
|
+
* The identifier of the template for the invitation.
|
|
950
|
+
*
|
|
951
|
+
* TODO: Add validations and type checks to the identifier e.g it should be a 32 byte hex string, etc.
|
|
952
|
+
*/
|
|
953
|
+
templateIdentifier: string;
|
|
954
|
+
/**
|
|
955
|
+
* The identifier of the action for the invitation.
|
|
956
|
+
*/
|
|
957
|
+
actionIdentifier: string;
|
|
958
|
+
/**
|
|
959
|
+
* The timestamp when the invitation is created.
|
|
960
|
+
*
|
|
961
|
+
*/
|
|
962
|
+
private createdAtTimestamp;
|
|
963
|
+
/**
|
|
964
|
+
* The commits in the invitation.
|
|
965
|
+
*/
|
|
966
|
+
private commits;
|
|
967
|
+
/**
|
|
968
|
+
* Create a new InvitationBuilder.
|
|
969
|
+
* @param invitation Context for invitation creation.
|
|
970
|
+
*/
|
|
971
|
+
constructor(invitation: InvitationCreationParameters);
|
|
972
|
+
/**
|
|
973
|
+
* Create a builder from an existing invitation.
|
|
974
|
+
* @param invitation An existing XOInvitation.
|
|
975
|
+
*/
|
|
976
|
+
static fromInvitation(invitation: XOInvitation): InvitationBuilder;
|
|
977
|
+
/**
|
|
978
|
+
* Build the XOInvitation object to be shared.
|
|
979
|
+
* @returns The built XOInvitation.
|
|
980
|
+
*/
|
|
981
|
+
build(): XOInvitation;
|
|
982
|
+
/**
|
|
983
|
+
* Fully validates a given XOInvitation.
|
|
984
|
+
*
|
|
985
|
+
* @param template - The template to validate against.
|
|
986
|
+
* @throws {InvitationExpiredError} If the invitation has expired.
|
|
987
|
+
* @throws {InvalidEntityIdentifierError} If the entity identifiers are invalid.
|
|
988
|
+
* @throws {InvalidRequirementsError} If the requirements are invalid.
|
|
989
|
+
* @throws {InvalidCommitSignaturesError} If the commit signatures are invalid.
|
|
990
|
+
*/
|
|
991
|
+
validate(template: XOTemplate): this;
|
|
992
|
+
/**
|
|
993
|
+
* Add a commit to the invitation.
|
|
994
|
+
* @param commit The commit to add.
|
|
995
|
+
* @returns The builder instance.
|
|
996
|
+
*/
|
|
997
|
+
addCommit(commit: XOInvitationCommit): this;
|
|
998
|
+
/**
|
|
999
|
+
* Returns the commitIdentifier of the last commit in the invitation.
|
|
1000
|
+
* @returns The commitIdentifier as a string, or undefined if there are no commits.
|
|
1001
|
+
*/
|
|
1002
|
+
getLastCommitIdentifier(): string | undefined;
|
|
1003
|
+
/**
|
|
1004
|
+
* Returns the last InvitationCommit in the invitation.
|
|
1005
|
+
* @returns The last InvitationCommit object, or undefined if there are no commits.
|
|
1006
|
+
*/
|
|
1007
|
+
getLastCommit(): XOInvitationCommit | undefined;
|
|
1008
|
+
/**
|
|
1009
|
+
* Creates an unsigned commit without adding it to the invitation.
|
|
1010
|
+
* This allows for atomic commit creation with signature.
|
|
1011
|
+
*
|
|
1012
|
+
* @param params - Parameters for creating the commit
|
|
1013
|
+
* @param params.inputs - Optional array of inputs to add
|
|
1014
|
+
* @param params.outputs - Optional array of outputs to add
|
|
1015
|
+
* @param params.variables - Optional array of variables to add
|
|
1016
|
+
* @param params.transactionVersion - Optional transaction version
|
|
1017
|
+
* @param params.transactionLocktime - Optional transaction locktime
|
|
1018
|
+
* @param params.expiresAtTimestamp - Optional expiration timestamp (defaults to now + DEFAULT_INVITATION_EXPIRATION_IN_MILLISECONDS)
|
|
1019
|
+
* @returns The unsigned commit (without signature)
|
|
1020
|
+
*/
|
|
1021
|
+
createUnsignedCommit(params: {
|
|
1022
|
+
inputs?: XOInvitationInput[];
|
|
1023
|
+
outputs?: XOInvitationOutput[];
|
|
1024
|
+
variables?: XOInvitationVariable[];
|
|
1025
|
+
transactionVersion?: number;
|
|
1026
|
+
transactionLocktime?: number;
|
|
1027
|
+
expiresAtTimestamp?: number;
|
|
1028
|
+
}): Omit<XOInvitationCommit, 'signature' | 'entityIdentifier'>;
|
|
1029
|
+
/**
|
|
1030
|
+
* Creates a new commit from the provided data.
|
|
1031
|
+
* This is a private helper method that initializes the commit building logic.
|
|
1032
|
+
*/
|
|
1033
|
+
private createCommit;
|
|
1034
|
+
/**
|
|
1035
|
+
* Validates mergesWith references for inputs and outputs.
|
|
1036
|
+
* @private
|
|
1037
|
+
*/
|
|
1038
|
+
private validateMergesWithReferences;
|
|
1039
|
+
}
|
|
1040
|
+
//#endregion
|
|
1041
|
+
//#region source/invitation/commit.d.ts
|
|
1042
|
+
/**
|
|
1043
|
+
* Generates a random 16-byte commit identifier.
|
|
1044
|
+
*
|
|
1045
|
+
* @returns {string} The generated commit identifier as a hex string.
|
|
1046
|
+
*/
|
|
1047
|
+
declare const generateCommitIdentifier: () => string;
|
|
1048
|
+
/**
|
|
1049
|
+
* Finds the root commit identifier for a given entity in an invitation. The root commit is
|
|
1050
|
+
* the first commit the entity added to the invitation.
|
|
1051
|
+
*
|
|
1052
|
+
* @param {XOInvitation} invitation The invitation whose commits are searched.
|
|
1053
|
+
* @param {string} entityIdentifier The entity identifier to search for among the invitation commits.
|
|
1054
|
+
* @returns {string | undefined} The root commit identifier if the entity has a commit in the invitation, otherwise undefined.
|
|
1055
|
+
*/
|
|
1056
|
+
declare const findRootCommitIdentifierInInvitation: (invitation: XOInvitation, entityIdentifier: string) => string | undefined;
|
|
1057
|
+
//#endregion
|
|
1058
|
+
//#region source/invitation/merger.d.ts
|
|
1059
|
+
/**
|
|
1060
|
+
* The final resultant of merging invitation commits.
|
|
1061
|
+
*/
|
|
1062
|
+
type MergedInvitation = {
|
|
1063
|
+
inputs: XOInvitationInput[];
|
|
1064
|
+
outputs: XOInvitationOutput[];
|
|
1065
|
+
variables: XOInvitationVariable[];
|
|
1066
|
+
transactionVersion: number;
|
|
1067
|
+
transactionLocktime: number;
|
|
1068
|
+
};
|
|
1069
|
+
/**
|
|
1070
|
+
* Converts an array of XOInvitationVariable objects into an object,
|
|
1071
|
+
* where each key is the variable's identifier and the value is the variable's value.
|
|
1072
|
+
*
|
|
1073
|
+
* @param variables - Array of XOInvitationVariable objects to convert.
|
|
1074
|
+
* @returns An object mapping each variable identifier to its corresponding value.
|
|
1075
|
+
*/
|
|
1076
|
+
declare const convertCommitVariablesIntoObject: (variables: XOInvitationVariable[]) => Record<string, XOInvitationVariableValue>;
|
|
1077
|
+
/**
|
|
1078
|
+
* Merges invitation commits and transforms it into MergedInvitation structure.
|
|
1079
|
+
*
|
|
1080
|
+
* @param invitation - The invitation containing commits to merge.
|
|
1081
|
+
* @param template - The template used for resolving output identifiers.
|
|
1082
|
+
* @returns MergedInvitation structure, or null if no commits exist.
|
|
1083
|
+
* @throws {Error} If merge conflicts or missing references are detected.
|
|
1084
|
+
*/
|
|
1085
|
+
declare const mergeInvitationCommits: (invitation: XOInvitation, template: XOTemplate) => MergedInvitation | null;
|
|
1086
|
+
//#endregion
|
|
1087
|
+
//#region source/invitation/queries.d.ts
|
|
1088
|
+
/**
|
|
1089
|
+
* Extracts and lists all requirements from the template and action for an invitation.
|
|
1090
|
+
* Analyzes the template action to determine what variables, inputs, outputs, and role-specific
|
|
1091
|
+
* requirements are needed to fulfill the action.
|
|
1092
|
+
*
|
|
1093
|
+
* @param template - The template.
|
|
1094
|
+
* @param action - The action that has requirements.
|
|
1095
|
+
* @returns {XOInvitationRequirements} An object containing all the requirements.
|
|
1096
|
+
*/
|
|
1097
|
+
declare const listRequirementsFromTemplate: (template: XOTemplate, action: XOTemplateAction) => XOInvitationRequirements;
|
|
1098
|
+
/**
|
|
1099
|
+
* Lists all requirements that have been populated in the invitation by examining all commits.
|
|
1100
|
+
* Extracts variable, input, and output identifiers from all commits in the invitation and
|
|
1101
|
+
* organizes them into top-level and role-specific requirements.
|
|
1102
|
+
*
|
|
1103
|
+
* @param invitation - The invitation object to analyze for populated requirements.
|
|
1104
|
+
* @returns An object containing all populated requirements found in the invitation's commits,
|
|
1105
|
+
* including top-level requirements and role-specific requirements. Only includes roles
|
|
1106
|
+
* that have at least one requirement populated.
|
|
1107
|
+
*/
|
|
1108
|
+
declare const listPopulatedRequirementsInInvitation: (invitation: XOInvitation) => XOInvitationRequirements;
|
|
1109
|
+
/**
|
|
1110
|
+
* Lists all missing requirements for the invitation that have not yet been supplied.
|
|
1111
|
+
* Compares the requirements expected from the template with what has been populated in the invitation
|
|
1112
|
+
* to determine what is still needed.
|
|
1113
|
+
*
|
|
1114
|
+
* Logic: `missing_requirements = requirements_from_template - populated_requirements_in_invitation`
|
|
1115
|
+
*
|
|
1116
|
+
* @param invitation - The invitation object to check for missing requirements.
|
|
1117
|
+
* @param template - The template defining what requirements are expected.
|
|
1118
|
+
* @param action - The template action being analyzed to determine required requirements.
|
|
1119
|
+
* @returns An object containing all missing requirements, including top-level missing requirements
|
|
1120
|
+
* and role-specific missing requirements. Only includes roles that have at least one missing requirement.
|
|
1121
|
+
*/
|
|
1122
|
+
declare const listMissingRequirements: (invitation: XOInvitation, template: XOTemplate, action: XOTemplateAction) => XOInvitationRequirements;
|
|
1123
|
+
/**
|
|
1124
|
+
* Lists role identifiers for roles that still have capacity for additional participants.
|
|
1125
|
+
* A role is considered available if the number of distinct entities that have filled it
|
|
1126
|
+
* is less than the role's maximum slot count. If max is undefined, the role has unlimited capacity.
|
|
1127
|
+
*
|
|
1128
|
+
* @param invitation - The invitation object to check for available roles.
|
|
1129
|
+
* @param template - The template defining the invitation structure and requirements.
|
|
1130
|
+
* @param action - The template action being analyzed to determine which roles are expected.
|
|
1131
|
+
* @returns Array of role identifier strings representing roles that can still accept participants.
|
|
1132
|
+
* Returns an empty array if no roles are defined in the action.
|
|
1133
|
+
*/
|
|
1134
|
+
declare const listAvailableRolesForInvitation: (invitation: XOInvitation, action: XOTemplateAction) => string[];
|
|
1135
|
+
//#endregion
|
|
1136
|
+
//#region source/invitation/validation.d.ts
|
|
1137
|
+
/**
|
|
1138
|
+
* Validates that the invitation has not expired for any of the commits.
|
|
1139
|
+
*
|
|
1140
|
+
* @param invitation - The XOInvitation object containing creation and expiration timestamps.
|
|
1141
|
+
* @returns True if the invitation is expired, false if it is valid.
|
|
1142
|
+
*/
|
|
1143
|
+
declare const hasInvitationExpired: (invitation: XOInvitation) => boolean;
|
|
1144
|
+
/**
|
|
1145
|
+
* Validates that all entity identifiers in the invitation are valid public keys.
|
|
1146
|
+
* Extracts unique entity identifiers from all commits.
|
|
1147
|
+
*
|
|
1148
|
+
* @param invitation - The invitation to validate.
|
|
1149
|
+
* @returns True if all entities are valid, false otherwise.
|
|
1150
|
+
*/
|
|
1151
|
+
declare const validateInvitationEntities: (invitation: XOInvitation) => boolean;
|
|
1152
|
+
/**
|
|
1153
|
+
* Validates that all provided requirements in the invitation were expected by the template.
|
|
1154
|
+
*
|
|
1155
|
+
* @param invitation - The invitation to validate.
|
|
1156
|
+
* @param template - The template to validate against.
|
|
1157
|
+
* @param action - The action to validate against.
|
|
1158
|
+
* @returns True if all requirements are expected, false otherwise.
|
|
1159
|
+
*/
|
|
1160
|
+
declare const validateRoleRequirements: (invitation: XOInvitation, template: XOTemplate, action: XOTemplateAction) => boolean;
|
|
1161
|
+
/**
|
|
1162
|
+
* Validates commit signatures.
|
|
1163
|
+
* Signature signs: stringify(data) + templateIdentifier + actionIdentifier + invitationIdentifier + commitIdentifier + previousCommitIdentifier
|
|
1164
|
+
*
|
|
1165
|
+
* @param invitation - The invitation containing commits to validate.
|
|
1166
|
+
* @returns True if all commit signatures are valid, false otherwise.
|
|
1167
|
+
*/
|
|
1168
|
+
declare const validateInvitationCommits: (invitation: XOInvitation) => boolean;
|
|
1169
|
+
//#endregion
|
|
1170
|
+
//#region source/utils/template.d.ts
|
|
1171
|
+
/**
|
|
1172
|
+
* Template class for accessing template data.
|
|
1173
|
+
*/
|
|
1174
|
+
declare class Template {
|
|
1175
|
+
/**
|
|
1176
|
+
* The template object.
|
|
1177
|
+
*/
|
|
1178
|
+
private readonly template;
|
|
1179
|
+
/**
|
|
1180
|
+
* Creates a Template class from a template object.
|
|
1181
|
+
*/
|
|
1182
|
+
constructor(template: XOTemplate | undefined);
|
|
1183
|
+
/**
|
|
1184
|
+
* Gets the underlying template object.
|
|
1185
|
+
*/
|
|
1186
|
+
getTemplate(): XOTemplate;
|
|
1187
|
+
/**
|
|
1188
|
+
* Gets the starting actions for the template.
|
|
1189
|
+
* @returns {Array<XOTemplateActionIntent>} The list of starting actions.
|
|
1190
|
+
*/
|
|
1191
|
+
getStartingActions(): Array<XOTemplateActionIntent>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Retrieves an output definition by identifier.
|
|
1194
|
+
* Step 1 in the flow: template → output
|
|
1195
|
+
* @throws {OutputNotFoundError} If the output is not found.
|
|
1196
|
+
*/
|
|
1197
|
+
getOutput(outputIdentifier: string): XOTemplateOutput;
|
|
1198
|
+
/**
|
|
1199
|
+
* Retrieves the locking script identifier from an output.
|
|
1200
|
+
* Step 2 in the flow: output → locking script identifier
|
|
1201
|
+
* @throws {OutputNotFoundError} If the output is not found.
|
|
1202
|
+
* @throws {LockingScriptNotFoundError} If the output doesn't have a locking script identifier.
|
|
1203
|
+
*/
|
|
1204
|
+
getLockingScriptIdentifier(outputIdentifier: string): string;
|
|
1205
|
+
/**
|
|
1206
|
+
* Retrieves a locking script definition by identifier.
|
|
1207
|
+
* Step 3 in the flow: locking script identifier → locking script
|
|
1208
|
+
* @throws {LockingScriptNotFoundError} If the locking script is not found.
|
|
1209
|
+
*/
|
|
1210
|
+
getLockingScript(lockingScriptIdentifier: string): XOTemplateLockingScript;
|
|
1211
|
+
/**
|
|
1212
|
+
* Retrieves the locking script for a given output.
|
|
1213
|
+
* Combines steps 1-3: output → locking script identifier → locking script
|
|
1214
|
+
* @throws {OutputNotFoundError} If the output is not found.
|
|
1215
|
+
* @throws {LockingScriptNotFoundError} If the output doesn't have a locking script identifier.
|
|
1216
|
+
* @throws {LockingScriptNotFoundError} If the locking script is not found.
|
|
1217
|
+
*/
|
|
1218
|
+
getLockingScriptForOutput(outputIdentifier: string): XOTemplateLockingScript;
|
|
1219
|
+
/**
|
|
1220
|
+
* Validates that a locking script has required unlocking script and locking type.
|
|
1221
|
+
* Step 4 in the flow: validate locking script
|
|
1222
|
+
* @param lockingScript - The locking script to validate.
|
|
1223
|
+
* @param lockingScriptIdentifier - The identifier of the locking script (for error messages).
|
|
1224
|
+
* @throws {LockingScriptTypeNotFoundError} If lockingType is missing.
|
|
1225
|
+
*/
|
|
1226
|
+
validateLockingScript(lockingScript: XOTemplateLockingScript, lockingScriptIdentifier: string): void;
|
|
1227
|
+
/**
|
|
1228
|
+
* Retrieves a role within a locking script.
|
|
1229
|
+
* Step 5 in the flow: locking script → role
|
|
1230
|
+
* @param lockingScriptIdentifier - The locking script identifier.
|
|
1231
|
+
* @param roleIdentifier - The role identifier.
|
|
1232
|
+
* @throws {LockingScriptNotFoundError} If the locking script is not found.
|
|
1233
|
+
* @throws {RoleNotFoundError} If the role is not found.
|
|
1234
|
+
*/
|
|
1235
|
+
getRole(lockingScriptIdentifier: string, roleIdentifier: string): XOTemplateLockingScriptRole;
|
|
1236
|
+
/**
|
|
1237
|
+
* Retrieves the first available role in a locking script, or throws if none exist.
|
|
1238
|
+
* @param lockingScriptIdentifier - The locking script identifier.
|
|
1239
|
+
* @returns A tuple of [roleIdentifier, role].
|
|
1240
|
+
* @throws {LockingScriptNotFoundError} If the locking script is not found.
|
|
1241
|
+
* @throws {RoleNotFoundError} If no roles exist.
|
|
1242
|
+
*/
|
|
1243
|
+
getFirstRole(lockingScriptIdentifier: string): [string, XOTemplateLockingScriptRole];
|
|
1244
|
+
/**
|
|
1245
|
+
* Retrieves secrets for a locking script.
|
|
1246
|
+
* If roleIdentifier is provided, returns secrets from the role's state.
|
|
1247
|
+
* Otherwise, returns secrets from the locking script itself.
|
|
1248
|
+
* Step 6 in the flow: role → secrets (or locking script → secrets)
|
|
1249
|
+
* @param lockingScriptIdentifier - The locking script identifier.
|
|
1250
|
+
* @param roleIdentifier - The role identifier (optional, if not provided uses locking script secrets).
|
|
1251
|
+
* @returns Array of secret identifiers.
|
|
1252
|
+
* @throws {LockingScriptNotFoundError} If the locking script is not found.
|
|
1253
|
+
* @throws {RoleNotFoundError} If roleIdentifier is provided but the role is not found.
|
|
1254
|
+
*/
|
|
1255
|
+
getSecrets(lockingScriptIdentifier: string, roleIdentifier?: string): string[];
|
|
1256
|
+
/**
|
|
1257
|
+
* Retrieves an action definition by identifier.
|
|
1258
|
+
* @param actionIdentifier - The identifier of the action.
|
|
1259
|
+
* @throws {ActionNotFoundError} If the action is not found.
|
|
1260
|
+
*/
|
|
1261
|
+
getActionOrThrow(actionIdentifier: string): XOTemplateAction;
|
|
1262
|
+
/**
|
|
1263
|
+
* Retrieves a transaction definition by identifier.
|
|
1264
|
+
* @param transactionIdentifier - The identifier of the transaction.
|
|
1265
|
+
* @throws {TransactionNotFoundError} If the transaction is not found.
|
|
1266
|
+
*/
|
|
1267
|
+
getTransaction(transactionIdentifier: string): XOTemplateTransaction;
|
|
1268
|
+
/**
|
|
1269
|
+
* Retrieves the transaction for a given action.
|
|
1270
|
+
* Flow: action → transaction identifier → transaction
|
|
1271
|
+
* @param actionIdentifier - The identifier of the action.
|
|
1272
|
+
* @throws {ActionNotFoundError} If the action is not found.
|
|
1273
|
+
* @throws {TransactionNotFoundError} If the action doesn't have a transaction or it's not found.
|
|
1274
|
+
*/
|
|
1275
|
+
getTransactionForAction(actionIdentifier: string): XOTemplateTransaction;
|
|
1276
|
+
}
|
|
1277
|
+
//#endregion
|
|
1278
|
+
//#region source/utils/cashasm-utils.d.ts
|
|
1279
|
+
/**
|
|
1280
|
+
* Checks if the expression is a CashAssembly expression.
|
|
1281
|
+
*
|
|
1282
|
+
* @param expression - The expression to check.
|
|
1283
|
+
* @returns True if the expression is a CashAssembly expression, false otherwise.
|
|
1284
|
+
*/
|
|
1285
|
+
declare const isCashAsmExpression: (expression: string | number | null | bigint) => boolean;
|
|
1286
|
+
/**
|
|
1287
|
+
* Extracts all CashAssembly evaluations (i.e., substrings like $(...)) from the input text.
|
|
1288
|
+
*
|
|
1289
|
+
* @param text - The input string to scan for CashAssembly evaluations.
|
|
1290
|
+
* @returns An array of evaluation strings found in the input.
|
|
1291
|
+
*
|
|
1292
|
+
* @example
|
|
1293
|
+
* extractCashAssemblyEvaluations("OP_DUP <$(<foo>)> OP_HASH160 $(<bar>)");
|
|
1294
|
+
* // returns ['$(<foo>)', '$(<bar>)']
|
|
1295
|
+
*/
|
|
1296
|
+
declare const extractCashAssemblyEvaluations: (text: string) => string[];
|
|
1297
|
+
/**
|
|
1298
|
+
* Extracts variable names enclosed in angle brackets (e.g., <variableName>) from each evaluation string.
|
|
1299
|
+
*
|
|
1300
|
+
* @param evaluations - An array of evaluation strings from which to extract variable names.
|
|
1301
|
+
* @returns An array of variable names (no angle brackets), as strings.
|
|
1302
|
+
*/
|
|
1303
|
+
declare const extractVariablesFromEvaluations: (evaluations: string[]) => string[];
|
|
1304
|
+
/**
|
|
1305
|
+
* Compiles all CashAssembly evaluations in a text string, using the provided variables.
|
|
1306
|
+
* Each evaluation is replaced with its compiled bytecode (hex string).
|
|
1307
|
+
*
|
|
1308
|
+
* Handles complex expressions like $(<variable1> <variable2>) and simple ones like $(<variable>).
|
|
1309
|
+
* Returns error string if required variables are missing or compilation fails.
|
|
1310
|
+
*
|
|
1311
|
+
* Supports variables of type: string (hex), bigint, number, boolean, and Uint8Array.
|
|
1312
|
+
*
|
|
1313
|
+
* @param text - The full string with possible CashAssembly evaluations.
|
|
1314
|
+
* @param variables - Object mapping variable names to values for compilation.
|
|
1315
|
+
* For invitation variables, use XOInvitationVariableValue types (bigint | boolean | number | string).
|
|
1316
|
+
* For other use cases, Uint8Array is also supported.
|
|
1317
|
+
* @returns Compiled text with all evaluations replaced with hex bytecode, or error string.
|
|
1318
|
+
*/
|
|
1319
|
+
declare const compileCashAssemblyString: (text: string, variables: Record<string, XOInvitationVariableValue | Uint8Array>) => string;
|
|
1320
|
+
//#endregion
|
|
1321
|
+
//#region source/utils/libauth-utils.d.ts
|
|
1322
|
+
/**
|
|
1323
|
+
* Generates bytecode for a specific CashAssembly evaluation using given variable values and a prepared compiler.
|
|
1324
|
+
* Returns libauth result or error string.
|
|
1325
|
+
*
|
|
1326
|
+
* @param compiler - The libauth compiler.
|
|
1327
|
+
* @param evaluation - The specific evaluation string to compile.
|
|
1328
|
+
* @param variables - A record mapping variable names to their values.
|
|
1329
|
+
* @returns Bytecode result object on success, otherwise an error string.
|
|
1330
|
+
*/
|
|
1331
|
+
declare const generateCashAssemblyBytecode: (compiler: CompilerBch, evaluation: string, variables: Record<string, unknown>) => Uint8Array;
|
|
1332
|
+
/**
|
|
1333
|
+
* Prepares a compiler for the provided CashAssembly evaluations, setting required variables as 'WalletData'.
|
|
1334
|
+
*
|
|
1335
|
+
* @param evaluations - Array of evaluation strings (e.g., ['$(<var1>)', '$(<var2> <var3>)'])
|
|
1336
|
+
* @returns A Libauth compiler instance for use with these evaluations.
|
|
1337
|
+
*/
|
|
1338
|
+
declare const compileCashAssemblyEvaluations: (evaluations: string[]) => CompilerBch;
|
|
1339
|
+
/**
|
|
1340
|
+
* Creates a map of variable identifiers to role identifiers for the libauth compiler configuration.
|
|
1341
|
+
*
|
|
1342
|
+
* @param template - The template used to gather the variable identifiers.
|
|
1343
|
+
* @param role - The role identifier to assign to the variables.
|
|
1344
|
+
* @returns {Record<string, string>} A map of variable identifiers to role identifiers.
|
|
1345
|
+
*/
|
|
1346
|
+
declare const entityOwnershipForLibauthCompiler: (template: XOTemplate, role: string) => Record<string, string>;
|
|
1347
|
+
/**
|
|
1348
|
+
* Creates a map of script identifiers to script definitions for the libauth compiler configuration.
|
|
1349
|
+
*
|
|
1350
|
+
* @param template - The template used to gather the scripts.
|
|
1351
|
+
* @returns {CompilerConfiguration['scripts']} A map of script identifiers to script definitions.
|
|
1352
|
+
*/
|
|
1353
|
+
declare const scriptsForLibauthCompiler: (template: XOTemplate) => CompilerConfiguration["scripts"];
|
|
1354
|
+
/**
|
|
1355
|
+
* Converts template variables into libauth variables with types.
|
|
1356
|
+
*
|
|
1357
|
+
* @param template - The template to assign types to the variables.
|
|
1358
|
+
* @returns CompilerConfiguration['variables']
|
|
1359
|
+
*/
|
|
1360
|
+
declare const assignTypeToVariablesForLibauthCompiler: (template: XOTemplate) => CompilerConfiguration["variables"];
|
|
1361
|
+
/**
|
|
1362
|
+
* Converts an XO template locking type to the corresponding libauth compiler locking script type.
|
|
1363
|
+
*
|
|
1364
|
+
* @param lockingType - The XO template locking type to convert.
|
|
1365
|
+
* @returns The corresponding libauth compiler locking script type string.
|
|
1366
|
+
*/
|
|
1367
|
+
declare const convertXOLockingTypeToLibauth: (lockingType: XOTemplateLockingType) => "p2sh20" | "p2sh32" | "standard";
|
|
1368
|
+
/**
|
|
1369
|
+
* Creates the libauth compatiblecompiler data for a unspent output.
|
|
1370
|
+
*
|
|
1371
|
+
* @param template - The template used to generate the compiler data for.
|
|
1372
|
+
* @param unspentOutput - The unspent output to create the compiler data for.
|
|
1373
|
+
* @returns The compiler data for the unspent output.
|
|
1374
|
+
* @returns {Promise<{
|
|
1375
|
+
* compiler: CompilerBch;
|
|
1376
|
+
* script: string;
|
|
1377
|
+
* valueSatoshis: bigint;
|
|
1378
|
+
* }>} The compiler data for the unspent output.
|
|
1379
|
+
*/
|
|
1380
|
+
declare const createLibauthCompilerDataFromUnspentOutput: (template: Template, unspentOutput: UnspentOutputData) => Promise<{
|
|
1381
|
+
compiler: CompilerBch;
|
|
1382
|
+
script: string;
|
|
1383
|
+
valueSatoshis: bigint;
|
|
1384
|
+
}>;
|
|
1385
|
+
//#endregion
|
|
1386
|
+
//#region source/utils/store-utils.d.ts
|
|
1387
|
+
/**
|
|
1388
|
+
* Synchronizes the store of unspent outputs for a given script hash with the current state of the blockchain.
|
|
1389
|
+
*
|
|
1390
|
+
* This method performs the following:
|
|
1391
|
+
* 1. Retrieves the stored script hash data from the state.
|
|
1392
|
+
* 2. Fetches the current list of unspent outputs for the script hash from the state.
|
|
1393
|
+
* 3. Queries the blockchain for all unspent transaction outputs associated with the script hash.
|
|
1394
|
+
* 4. Adds any new unspent outputs found on the blockchain but missing from the state to the state.
|
|
1395
|
+
* 5. Removes any unspent outputs present in the state but no longer in the blockchain.
|
|
1396
|
+
*
|
|
1397
|
+
* @param state - The State instance to use for data operations.
|
|
1398
|
+
* @param scriptHash - The script hash for which to update the stored unspent outputs.
|
|
1399
|
+
* @param fetchUnspentOutputsCallback - Callback function to fetch unspent outputs from the blockchain.
|
|
1400
|
+
* @throws If the script hash is not found in the state.
|
|
1401
|
+
*/
|
|
1402
|
+
declare const updateUnspentOutputsForScriptHashInStore: (state: State, scriptHash: string, fetchUnspentOutputsCallback: (scriptHash: string) => Promise<ScriptHashListUnspentResponse>) => Promise<void>;
|
|
1403
|
+
//#endregion
|
|
1404
|
+
export { AcceptInvitationParameters, ActionNotFoundError, AppendInvitationParameters, BlockchainMonitor, CashAssemblyCompilationFailedError, CircularMergeReferenceError, CommitEntityIdentifierNotFoundError, CommitNotFoundInInvitationError, CommitNotSignedError, CreatedByIdentifierAlreadySetError, CreatedByIdentifierSignatureAlreadySetError, DataNotFoundError, DuplicateTransactionIndexError, DuplicateTransactionLocktimeError, DuplicateTransactionVersionError, ElectrumClientNotFoundError, Engine, ExecuteActionParameters, GetSpendableResourcesParameters, InvalidActionError, InvalidCommitSignaturesError, InvalidDataTypeError, InvalidDerivativeIndexTypeError, InvalidEntityIdentifierError, InvalidInputError, InvalidInvitationError, InvalidLockingScriptTypeError, InvalidLockingTypeError, InvalidRequirementsError, InvalidRoleError, InvalidTemplateOutputSatoshisTypeError, InvalidVariableDefinitionError, InvalidVariableTypeError, InvitationAlreadyAcceptedError, InvitationBuilder, InvitationCreatedInFutureError, InvitationCreationParameters, InvitationExpiredError, InvitationNotAcceptedError, InvitationNotFoundInStoreError, ItemNotFoundInCommitError, LockingBytecodeGenerationFailedError, LockingBytecodeNotFoundForOutputError, LockingDataNotFoundError, LockingScriptNotFoundError, LockingScriptTypeNotFoundError, LockscriptNotFoundError, MergedCommitNotFoundError, MergedInvitation, MergesWithCommitNotFoundError, MissingRequiredDataError, MissingRequiredFieldError, MissingRequiredRoleForEntityError, MissingRequiredSignatureByEntityError, MissingRequiredVariableError, MultipleRolesForStartingActionError, NoRoleSpecifiedAndMultipleRolesAvailableToBeAcceptedError, OutputLockscriptNotFoundError, OutputNotFoundError, ParentCommitNotFoundError, ReserveResourcesFailedError, RoleAlreadyAcceptedByAnotherEntityError, RoleCannotStartActionError, RoleNotAvailableToBeAcceptedError, RoleNotDefinedForActionError, RoleNotFoundError, RootCommitNotFoundError, ScriptHashDataNotFoundError, ScriptNotFoundError, SignatureVerificationFailedError, StartingActionNotFoundError, Template, TemplateIdentifierMismatchError, TemplateNotFoundError, TransactionGenerationFailedError, TransactionNotFoundError, UnknownVariableError, UnlockingScriptNotFoundError, UnspentOutputNotFoundError, VariableRequiredError, VariableValidationFailedError, XOEngineOptions, assignTypeToVariablesForLibauthCompiler, compileCashAssemblyEvaluations, compileCashAssemblyString, convertCommitVariablesIntoObject, convertXOLockingTypeToLibauth, createLibauthCompilerDataFromUnspentOutput, entityOwnershipForLibauthCompiler, extractCashAssemblyEvaluations, extractVariablesFromEvaluations, findRootCommitIdentifierInInvitation, generateCashAssemblyBytecode, generateCommitIdentifier, generateTemplateIdentifier, hasInvitationExpired, isCashAsmExpression, listAvailableRolesForInvitation, listMissingRequirements, listPopulatedRequirementsInInvitation, listRequirementsFromTemplate, mergeInvitationCommits, parseTemplate, scriptsForLibauthCompiler, updateUnspentOutputsForScriptHashInStore, validateInvitationCommits, validateInvitationEntities, validateRoleRequirements };
|
|
1405
|
+
//# sourceMappingURL=index.d.mts.map
|