@xo-cash/engine 0.0.1-development.14111078230 → 0.0.1-development.14141361677
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +48 -25
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +223 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -488,12 +488,6 @@ declare class LockingScriptNotFoundError extends Error {
|
|
|
488
488
|
declare class LockingScriptTypeNotFoundError extends Error {
|
|
489
489
|
constructor(lockingScriptIdentifier?: string);
|
|
490
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
491
|
/**
|
|
498
492
|
* Error thrown when an unlocking script is not found in the template.
|
|
499
493
|
*/
|
|
@@ -743,6 +737,12 @@ declare class UnknownVariableError extends Error {
|
|
|
743
737
|
declare class VariableRequiredError extends Error {
|
|
744
738
|
constructor(variableKey?: string);
|
|
745
739
|
}
|
|
740
|
+
/**
|
|
741
|
+
* Error thrown when a number variable value is not a valid integer for CashAssembly compilation.
|
|
742
|
+
*/
|
|
743
|
+
declare class CashAssemblyVariableNotIntegerError extends Error {
|
|
744
|
+
constructor(variableName: string, value: number);
|
|
745
|
+
}
|
|
746
746
|
/**
|
|
747
747
|
* Error thrown when variable validation fails.
|
|
748
748
|
*/
|
|
@@ -846,9 +846,9 @@ declare class InvalidVariableDefinitionError extends Error {
|
|
|
846
846
|
constructor(variableIdentifier: string);
|
|
847
847
|
}
|
|
848
848
|
/**
|
|
849
|
-
* Error thrown when an output does not have a
|
|
849
|
+
* Error thrown when an output does not have a locking script.
|
|
850
850
|
*/
|
|
851
|
-
declare class
|
|
851
|
+
declare class OutputLockingScriptNotFoundError extends Error {
|
|
852
852
|
constructor(outputIdentifier: string);
|
|
853
853
|
}
|
|
854
854
|
/**
|
|
@@ -1015,7 +1015,7 @@ declare class InvitationBuilder {
|
|
|
1015
1015
|
* @param params.variables - Optional array of variables to add
|
|
1016
1016
|
* @param params.transactionVersion - Optional transaction version
|
|
1017
1017
|
* @param params.transactionLocktime - Optional transaction locktime
|
|
1018
|
-
* @param params.expiresAtTimestamp - Optional expiration timestamp (defaults to now +
|
|
1018
|
+
* @param params.expiresAtTimestamp - Optional expiration timestamp (defaults to now + DEFAULT_COMMIT_EXPIRATION_IN_MILLISECONDS)
|
|
1019
1019
|
* @returns The unsigned commit (without signature)
|
|
1020
1020
|
*/
|
|
1021
1021
|
createUnsignedCommit(params: {
|
|
@@ -1275,14 +1275,26 @@ declare class Template {
|
|
|
1275
1275
|
getTransactionForAction(actionIdentifier: string): XOTemplateTransaction;
|
|
1276
1276
|
}
|
|
1277
1277
|
//#endregion
|
|
1278
|
-
//#region source/utils/
|
|
1278
|
+
//#region source/utils/cashassembly.d.ts
|
|
1279
|
+
/**
|
|
1280
|
+
* Supported decode modes for compiled CashAssembly evaluation bytes.
|
|
1281
|
+
*/
|
|
1282
|
+
type CompiledCashAssemblyDecodeMode = 'utf8' | 'hex' | 'boolean' | 'bigint' | 'uint8array';
|
|
1283
|
+
/**
|
|
1284
|
+
* Parameters for compiling CashAssembly string.
|
|
1285
|
+
*/
|
|
1286
|
+
type CompileCashAssemblyStringParameters = {
|
|
1287
|
+
cashAssemblyText: string;
|
|
1288
|
+
variables: Record<string, XOInvitationVariableValue | Uint8Array>;
|
|
1289
|
+
evaluationDecodeMode?: CompiledCashAssemblyDecodeMode;
|
|
1290
|
+
};
|
|
1279
1291
|
/**
|
|
1280
1292
|
* Checks if the expression is a CashAssembly expression.
|
|
1281
1293
|
*
|
|
1282
1294
|
* @param expression - The expression to check.
|
|
1283
1295
|
* @returns True if the expression is a CashAssembly expression, false otherwise.
|
|
1284
1296
|
*/
|
|
1285
|
-
declare const
|
|
1297
|
+
declare const isCashAssemblyExpression: (expression: unknown) => boolean;
|
|
1286
1298
|
/**
|
|
1287
1299
|
* Extracts all CashAssembly evaluations (i.e., substrings like $(...)) from the input text.
|
|
1288
1300
|
*
|
|
@@ -1295,28 +1307,39 @@ declare const isCashAsmExpression: (expression: string | number | null | bigint)
|
|
|
1295
1307
|
*/
|
|
1296
1308
|
declare const extractCashAssemblyEvaluations: (text: string) => string[];
|
|
1297
1309
|
/**
|
|
1298
|
-
* Extracts variable
|
|
1310
|
+
* Extracts unique variable identifiers enclosed in angle brackets from each evaluation string.
|
|
1311
|
+
*
|
|
1312
|
+
* CashAssembly literal tokens such as hex bytes, numbers, and quoted strings are excluded.
|
|
1313
|
+
* For example, `<0x02>` and `<"minting">` are not returned.
|
|
1299
1314
|
*
|
|
1300
1315
|
* @param evaluations - An array of evaluation strings from which to extract variable names.
|
|
1301
|
-
* @returns An array of variable names
|
|
1316
|
+
* @returns An array of variable names
|
|
1302
1317
|
*/
|
|
1303
1318
|
declare const extractVariablesFromEvaluations: (evaluations: string[]) => string[];
|
|
1304
1319
|
/**
|
|
1305
|
-
*
|
|
1306
|
-
* Each evaluation is replaced with its compiled bytecode (hex string).
|
|
1320
|
+
* Decodes compiled CashAssembly evaluation bytes into a string representation.
|
|
1307
1321
|
*
|
|
1308
|
-
*
|
|
1309
|
-
*
|
|
1322
|
+
* 'evaluationDecodeMode' determines how the evaluation bytes are interpreted and presented.
|
|
1323
|
+
* Choose based on what the evaluation is expected to produce:
|
|
1324
|
+
* `bigint` for numeric values like satoshis, `utf8` for text labels, `hex` for binary data such
|
|
1325
|
+
* as hashes, and `boolean` to represent boolean values.
|
|
1310
1326
|
*
|
|
1311
|
-
*
|
|
1327
|
+
* @param compiledResult - The compiled evaluation bytecode.
|
|
1328
|
+
* @param evaluationDecodeMode - The decode mode used to convert bytes to text.
|
|
1329
|
+
* @returns The decoded value as a string suitable for inline replacement.
|
|
1330
|
+
*/
|
|
1331
|
+
declare const decodeCompiledCashAssemblyEvaluation: (compiledResult: Uint8Array, evaluationDecodeMode?: CompiledCashAssemblyDecodeMode) => string;
|
|
1332
|
+
/**
|
|
1333
|
+
* Compiles all CashAssembly evaluations in a text string and replaces each evaluation
|
|
1334
|
+
* with a decoded string representation.
|
|
1312
1335
|
*
|
|
1313
|
-
* @param
|
|
1336
|
+
* @param cashAssemblyText - The string with CashAssembly evaluations.
|
|
1314
1337
|
* @param variables - Object mapping variable names to values for compilation.
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
* @
|
|
1338
|
+
* @param evaluationDecodeMode - The decode mode used after each evaluation is compiled.
|
|
1339
|
+
* @returns Compiled text with all evaluations replaced by decoded string values.
|
|
1340
|
+
* @throws VariableValidationFailedError when a required variable is not present in the variables map.
|
|
1318
1341
|
*/
|
|
1319
|
-
declare const compileCashAssemblyString: (
|
|
1342
|
+
declare const compileCashAssemblyString: (parameters: CompileCashAssemblyStringParameters) => string;
|
|
1320
1343
|
//#endregion
|
|
1321
1344
|
//#region source/utils/libauth-utils.d.ts
|
|
1322
1345
|
/**
|
|
@@ -1366,7 +1389,7 @@ declare const assignTypeToVariablesForLibauthCompiler: (template: XOTemplate) =>
|
|
|
1366
1389
|
*/
|
|
1367
1390
|
declare const convertXOLockingTypeToLibauth: (lockingType: XOTemplateLockingType) => "p2sh20" | "p2sh32" | "standard";
|
|
1368
1391
|
/**
|
|
1369
|
-
* Creates the libauth
|
|
1392
|
+
* Creates the libauth compatible compiler data for a unspent output.
|
|
1370
1393
|
*
|
|
1371
1394
|
* @param template - The template used to generate the compiler data for.
|
|
1372
1395
|
* @param unspentOutput - The unspent output to create the compiler data for.
|
|
@@ -1401,5 +1424,5 @@ declare const createLibauthCompilerDataFromUnspentOutput: (template: Template, u
|
|
|
1401
1424
|
*/
|
|
1402
1425
|
declare const updateUnspentOutputsForScriptHashInStore: (state: State, scriptHash: string, fetchUnspentOutputsCallback: (scriptHash: string) => Promise<ScriptHashListUnspentResponse>) => Promise<void>;
|
|
1403
1426
|
//#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,
|
|
1427
|
+
export { AcceptInvitationParameters, ActionNotFoundError, AppendInvitationParameters, BlockchainMonitor, CashAssemblyCompilationFailedError, CashAssemblyVariableNotIntegerError, CircularMergeReferenceError, CommitEntityIdentifierNotFoundError, CommitNotFoundInInvitationError, CommitNotSignedError, CompileCashAssemblyStringParameters, CompiledCashAssemblyDecodeMode, 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, MergedCommitNotFoundError, MergedInvitation, MergesWithCommitNotFoundError, MissingRequiredDataError, MissingRequiredFieldError, MissingRequiredRoleForEntityError, MissingRequiredSignatureByEntityError, MissingRequiredVariableError, MultipleRolesForStartingActionError, NoRoleSpecifiedAndMultipleRolesAvailableToBeAcceptedError, OutputLockingScriptNotFoundError, 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, decodeCompiledCashAssemblyEvaluation, entityOwnershipForLibauthCompiler, extractCashAssemblyEvaluations, extractVariablesFromEvaluations, findRootCommitIdentifierInInvitation, generateCashAssemblyBytecode, generateCommitIdentifier, generateTemplateIdentifier, hasInvitationExpired, isCashAssemblyExpression, listAvailableRolesForInvitation, listMissingRequirements, listPopulatedRequirementsInInvitation, listRequirementsFromTemplate, mergeInvitationCommits, parseTemplate, scriptsForLibauthCompiler, updateUnspentOutputsForScriptHashInStore, validateInvitationCommits, validateInvitationEntities, validateRoleRequirements };
|
|
1405
1428
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../source/interfaces.ts","../source/engine.ts","../source/errors.ts","../source/monitor/blockchain.ts","../source/invitation/builder.ts","../source/invitation/commit.ts","../source/invitation/merger.ts","../source/invitation/queries.ts","../source/invitation/validation.ts","../source/utils/template.ts","../source/utils/cashasm-utils.ts","../source/utils/libauth-utils.ts","../source/utils/store-utils.ts"],"mappings":";;;;;;;;;;;;;UAOiB,eAAA;;;;EAKb,WAAA,GAAc,WAAA;EALc;;;EAU5B,YAAA;EALc;;;EAUd,gBAAA;EAUA;;;EALA,qBAAA;EAe2B;;AAM/B;EAhBI,eAAA,GAAkB,eAAA;;;;EAKlB,6BAAA;EA2BuC;;;EAtBvC,2BAAA;AAAA;;;;UAMa,4BAAA;EA+Bb;;;EA1BA,kBAAA;EAoCA;;;EA/BA,gBAAA;AAAA;AA0CJ;;;AAAA,UApCiB,0BAAA;EAoCkD;AAKnE;;EApCI,OAAA;EAyCA;;AAMJ;EA1CI,QAAA;;;;EAKA,MAAA,GAAS,iBAAA;;;ACXb;EDgBI,OAAA,GAAU,kBAAA;;;;EAKV,SAAA,GAAY,oBAAA;EC8EE;;;EDzEd,kBAAA;AAAA;;;;KAMQ,0BAAA,GAA6B,0BAAA;;;;UAKxB,uBAAA;ECsJsD;;;EDjJnE,oBAAA;AAAA;;;;UAMa,+BAAA;ECsSkF;;;EDjS/F,kBAAA;ECoW8F;;;ED/V9F,gBAAA;AAAA;;;;;;cC1DS,MAAA;ED7DI;;;EAAA,QCiEL,MAAA;ED5DR;;;EAAA,QCiEQ,KAAA;EDlDR;;;EAAA,QCuDQ,iBAAA;EDxCR;;;EAAA,QCgDQ,y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;;;;cAuChH,8BAAA,GAAkC,WAAA,eAAwB,WAAA;;;;;AXjBvE;;;cW+Ca,iCAAA,GAAqC,QAAA,EAAU,UAAA,EAAY,IAAA,aAAe,MAAA;;AX/BvF;;;;;cWmDa,yBAAA,GAA6B,QAAA,EAAU,UAAA,KAAa,qBAAA;;;;;;;cAoBpD,uCAAA,GAA2C,QAAA,EAAU,UAAA,KAAa,qBAAA;;;;;;;cAsDlE,6BAAA,GAAiC,WAAA,EAAa,qBAAA;;;;;AXpF3D;;;;;AAWA;;;cWyFa,0CAAA,GACT,QAAA,EAAU,QAAA,EACV,aAAA,EAAe,iBAAA,KAChB,OAAA;EACC,QAAA,EAAU,WAAA;EACV,MAAA;EACA,aAAA;AAAA;;;;;;;;;;;AX5MJ;;;;;;;cYaa,wCAAA,GACT,KAAA,EAAO,KAAA,EACP,UAAA,UACA,2BAAA,GAA8B,UAAA,aAAuB,OAAA,CAAQ,6BAAA,MAC9D,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../source/interfaces.ts","../source/engine.ts","../source/errors.ts","../source/monitor/blockchain.ts","../source/invitation/builder.ts","../source/invitation/commit.ts","../source/invitation/merger.ts","../source/invitation/queries.ts","../source/invitation/validation.ts","../source/utils/template.ts","../source/utils/cashassembly.ts","../source/utils/libauth-utils.ts","../source/utils/store-utils.ts"],"mappings":";;;;;;;;;;;;;UAOiB,eAAA;;;;EAKb,WAAA,GAAc,WAAA;EALc;;;EAU5B,YAAA;EALc;;;EAUd,gBAAA;EAUA;;;EALA,qBAAA;EAe2B;;AAM/B;EAhBI,eAAA,GAAkB,eAAA;;;;EAKlB,6BAAA;EA2BuC;;;EAtBvC,2BAAA;AAAA;;;;UAMa,4BAAA;EA+Bb;;;EA1BA,kBAAA;EAoCA;;;EA/BA,gBAAA;AAAA;AA0CJ;;;AAAA,UApCiB,0BAAA;EAoCkD;AAKnE;;EApCI,OAAA;EAyCA;;AAMJ;EA1CI,QAAA;;;;EAKA,MAA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 +1,4 @@
|
|
|
1
|
-
import { binToHex, createCompilerBch, encodeTransaction, generateRandomBytes, generateTransaction, hash256, hashTransaction, hexToBin, sha256, stringify, utf8ToBin } from "@bitauth/libauth";
|
|
1
|
+
import { bigIntToVmNumber, binToHex, binToUtf8, createCompilerBch, encodeTransaction, generateRandomBytes, generateTransaction, hash256, hashTransaction, hexToBin, sha256, stringify, utf8ToBin, vmNumberToBigInt } from "@bitauth/libauth";
|
|
2
2
|
import { Crypto, buildInvitationCommitSigningPayload, convertMnemonicToSeedBytes, verifySchnorrSignature } from "@xo-cash/crypto";
|
|
3
3
|
import { State, StorageType, UnspentOutputStatus, createStorageAdapter } from "@xo-cash/state";
|
|
4
4
|
import { generateTemplateIdentifier, generateTemplateIdentifier as generateTemplateIdentifier$1, parseTemplate, parseTemplate as parseTemplate$1, scriptToScriptHash } from "@xo-cash/utils";
|
|
@@ -54,15 +54,6 @@ var LockingScriptTypeNotFoundError = class extends Error {
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
|
-
* Error thrown when a lockscript is not found in the template.
|
|
58
|
-
*/
|
|
59
|
-
var LockscriptNotFoundError = class extends Error {
|
|
60
|
-
constructor(lockscriptIdentifier) {
|
|
61
|
-
const defaultMessage = "Lockscript not found in template";
|
|
62
|
-
super(lockscriptIdentifier ? `${defaultMessage}: lockscriptIdentifier "${lockscriptIdentifier}"` : defaultMessage);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
57
|
* Error thrown when an unlocking script is not found in the template.
|
|
67
58
|
*/
|
|
68
59
|
var UnlockingScriptNotFoundError = class extends Error {
|
|
@@ -438,6 +429,14 @@ var VariableRequiredError = class extends Error {
|
|
|
438
429
|
}
|
|
439
430
|
};
|
|
440
431
|
/**
|
|
432
|
+
* Error thrown when a number variable value is not a valid integer for CashAssembly compilation.
|
|
433
|
+
*/
|
|
434
|
+
var CashAssemblyVariableNotIntegerError = class extends Error {
|
|
435
|
+
constructor(variableName, value) {
|
|
436
|
+
super(`CashAssembly variable value is not a valid integer: variableName "${variableName}", got ${value}`);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
441
440
|
* Error thrown when variable validation fails.
|
|
442
441
|
*/
|
|
443
442
|
var VariableValidationFailedError = class extends Error {
|
|
@@ -584,11 +583,11 @@ var InvalidVariableDefinitionError = class extends Error {
|
|
|
584
583
|
}
|
|
585
584
|
};
|
|
586
585
|
/**
|
|
587
|
-
* Error thrown when an output does not have a
|
|
586
|
+
* Error thrown when an output does not have a locking script.
|
|
588
587
|
*/
|
|
589
|
-
var
|
|
588
|
+
var OutputLockingScriptNotFoundError = class extends Error {
|
|
590
589
|
constructor(outputIdentifier) {
|
|
591
|
-
super(`Output does not have a
|
|
590
|
+
super(`Output does not have a locking script: outputIdentifier "${outputIdentifier}"`);
|
|
592
591
|
}
|
|
593
592
|
};
|
|
594
593
|
/**
|
|
@@ -596,7 +595,7 @@ var OutputLockscriptNotFoundError = class extends Error {
|
|
|
596
595
|
*/
|
|
597
596
|
var InvalidLockingScriptTypeError = class extends Error {
|
|
598
597
|
constructor(outputIdentifier, expectedType, actualType) {
|
|
599
|
-
super(`Locking script has invalid
|
|
598
|
+
super(`Locking script has invalid locking type: outputIdentifier "${outputIdentifier}", expected ${expectedType}, got ${actualType}`);
|
|
600
599
|
}
|
|
601
600
|
};
|
|
602
601
|
/**
|
|
@@ -632,6 +631,93 @@ var ElectrumClientNotFoundError = class extends Error {
|
|
|
632
631
|
}
|
|
633
632
|
};
|
|
634
633
|
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region source/defaults.ts
|
|
636
|
+
/**
|
|
637
|
+
* When an entity opts to participate in an invitation, it reserves resources (e.g., UTXOs)
|
|
638
|
+
* that would otherwise be available to other invitations. To prevent resources from remaining
|
|
639
|
+
* locked indefinitely, each reservation requires an expiration time, after which the resources
|
|
640
|
+
* can be released.
|
|
641
|
+
*
|
|
642
|
+
* By default, the expiration time is set to 1 hour.
|
|
643
|
+
*/
|
|
644
|
+
const DEFAULT_COMMIT_EXPIRATION_IN_MILLISECONDS = 3600 * 1e3;
|
|
645
|
+
/**
|
|
646
|
+
* The default storage backend is IndexedDB.
|
|
647
|
+
*/
|
|
648
|
+
const DEFAULT_STORAGE_TYPE = StorageType.INDEXEDDB;
|
|
649
|
+
/**
|
|
650
|
+
* The default sequence number is 0, which disables relative locktime on the input.
|
|
651
|
+
*/
|
|
652
|
+
const DEFAULT_SEQUENCE_NUMBER = 0;
|
|
653
|
+
/**
|
|
654
|
+
* The default locktime is 0, which means the transaction is valid in any block and has no absolute locktime constraint.
|
|
655
|
+
*/
|
|
656
|
+
const DEFAULT_LOCKTIME = 0;
|
|
657
|
+
/**
|
|
658
|
+
* The default transaction version is 2.
|
|
659
|
+
*/
|
|
660
|
+
const DEFAULT_VERSION = 2;
|
|
661
|
+
/**
|
|
662
|
+
* An empty unlocking bytecode used as a placeholder for inputs (unlockingBytecode) within an invitation.
|
|
663
|
+
* This placeholder is used when the entities responsible for signing those inputs
|
|
664
|
+
* have not yet provided their signatures for the resulting transaction.
|
|
665
|
+
*
|
|
666
|
+
* Using a placeholder unlocking bytecode enables the engine to construct transaction structures for the
|
|
667
|
+
* libauth compiler when working on template actions, even before all participant signatures are available.
|
|
668
|
+
* This is especially helpful when invitation commits are merged, as it allows the transaction to be built and it's
|
|
669
|
+
* parts can be validated before all unlocking scripts have been provided.
|
|
670
|
+
*/
|
|
671
|
+
const PLACEHOLDER_UNLOCKING_BYTECODE = new Uint8Array(0);
|
|
672
|
+
/**
|
|
673
|
+
* The default electrum application identifier.
|
|
674
|
+
*/
|
|
675
|
+
const DEFAULT_ELECTRUM_APPLICATION_IDENTIFIER = "xo";
|
|
676
|
+
/**
|
|
677
|
+
* Detects whether a string is a pure CashAssembly expression.
|
|
678
|
+
*
|
|
679
|
+
* CashAssembly expressions look like `$(<variable>)` or `$(<a> <b>)`. This pattern checks
|
|
680
|
+
* that the entire string is one such expression and nothing else. It will not match if
|
|
681
|
+
* there is other text surrounding the expression.
|
|
682
|
+
*
|
|
683
|
+
* For example:
|
|
684
|
+
* `$(<fee>)` matches (a full expression)
|
|
685
|
+
* `OP_DUP $(<fee>)` does not match (extra text before it)
|
|
686
|
+
* `$()` does not match (empty expression)
|
|
687
|
+
*/
|
|
688
|
+
const CASHASSEMBLY_EXPRESSION_PATTERN = /^\$\([^)]+\)$/;
|
|
689
|
+
/**
|
|
690
|
+
* Finds all CashAssembly evaluations embedded in a larger string.
|
|
691
|
+
*
|
|
692
|
+
* An evaluation looks like `$(...)`, for example `$(<fee>)` or `$(<a> <b>)`. This pattern
|
|
693
|
+
* locates every occurrence in the input and returns them all (global flag `g`).
|
|
694
|
+
* Empty evaluations `$()` are intentionally excluded because they reference no variables.
|
|
695
|
+
*
|
|
696
|
+
* For example, scanning `"OP_DUP <$(<pubkeyHash>)> OP_HASH160 $(<fee>)"` would return
|
|
697
|
+
* `['$(<pubkeyHash>)', '$(<fee>)']`.
|
|
698
|
+
*/
|
|
699
|
+
const CASHASSEMBLY_EVALUATION_PATTERN = /\$\([^)]+\)/g;
|
|
700
|
+
/**
|
|
701
|
+
* Extracts variable names from angle-bracket references inside a CashAssembly evaluation.
|
|
702
|
+
*
|
|
703
|
+
* Inside an evaluation like `$(<pubkeyHash> <fee>)`, variables are referenced as `<name>`.
|
|
704
|
+
* This pattern captures the name between the brackets. The global flag `g` allows iterating
|
|
705
|
+
* over every variable reference in a single evaluation string.
|
|
706
|
+
*
|
|
707
|
+
* For example, running this against `$(<pubkeyHash> <fee>)` would return the variable names
|
|
708
|
+
* `["pubkeyHash", "fee"]`.
|
|
709
|
+
*/
|
|
710
|
+
const CASHASSEMBLY_VARIABLE_PATTERN = /<([^>]+)>/g;
|
|
711
|
+
/**
|
|
712
|
+
* Identifies CashAssembly literal tokens that appear inside angle-bracket push statements.
|
|
713
|
+
*
|
|
714
|
+
* Inside an evaluation, not everything between `<` and `>` is a variable name. Literals are
|
|
715
|
+
* also valid push contents: numeric literals (e.g. `<0>`, `<32>`), hex literals (`<0x02>`),
|
|
716
|
+
* binary literals (`<0b1010>`), and string literals (`<"minting">`, `<'hello'>`). This pattern
|
|
717
|
+
* matches any captured token that starts with a digit or a quote character.
|
|
718
|
+
*/
|
|
719
|
+
const CASHASSEMBLY_LITERAL_TOKEN_PATTERN = /^[0-9"']/;
|
|
720
|
+
|
|
635
721
|
//#endregion
|
|
636
722
|
//#region source/utils/libauth-utils.ts
|
|
637
723
|
/**
|
|
@@ -741,7 +827,7 @@ const convertXOLockingTypeToLibauth = (lockingType) => {
|
|
|
741
827
|
return XO_LOCKING_TYPE_TO_LIBAUTH_MAP[lockingType];
|
|
742
828
|
};
|
|
743
829
|
/**
|
|
744
|
-
* Creates the libauth
|
|
830
|
+
* Creates the libauth compatible compiler data for a unspent output.
|
|
745
831
|
*
|
|
746
832
|
* @param template - The template used to generate the compiler data for.
|
|
747
833
|
* @param unspentOutput - The unspent output to create the compiler data for.
|
|
@@ -790,15 +876,52 @@ const createLibauthCompilerDataFromUnspentOutput = async (template, unspentOutpu
|
|
|
790
876
|
};
|
|
791
877
|
|
|
792
878
|
//#endregion
|
|
793
|
-
//#region source/utils/
|
|
879
|
+
//#region source/utils/cashassembly.ts
|
|
880
|
+
/**
|
|
881
|
+
* Utilities for parsing, extracting, and compiling CashAssembly expressions.
|
|
882
|
+
*
|
|
883
|
+
* CashAssembly is the scripting language used by Bitauth templates to describe Bitcoin Cash
|
|
884
|
+
* locking and unlocking scripts.
|
|
885
|
+
*
|
|
886
|
+
* ## Syntax
|
|
887
|
+
*
|
|
888
|
+
* `<expression>` — a push statement. Compiles the contents and pushes the result onto the VM stack.
|
|
889
|
+
* `<someKey.public_key>` pushes the 33-byte compressed public key. `<1>` pushes the integer 1.
|
|
890
|
+
*
|
|
891
|
+
* `$(<expression>)` — an evaluation. Runs the inner script in the VM and inserts the top stack
|
|
892
|
+
* item as VM bytecode.
|
|
893
|
+
* `$(<someKey.public_key> OP_HASH160)` inserts the HASH160 of the public key.
|
|
894
|
+
*
|
|
895
|
+
* `<$(<expression>)>` — a push of an evaluation result. Combines the two above: evaluates first,
|
|
896
|
+
* then pushes. Example: P2PKH locking script:
|
|
897
|
+
* `OP_DUP OP_HASH160 <$(<someKey.public_key> OP_HASH160)> OP_EQUALVERIFY OP_CHECKSIG`.
|
|
898
|
+
*
|
|
899
|
+
* `variableId.operation` — a variable with a compiler-resolved operation. `someKey.public_key`
|
|
900
|
+
* produces the public key bytes. `someKey.schnorr_signature.all_outputs` produces a Schnorr
|
|
901
|
+
* signature.
|
|
902
|
+
*
|
|
903
|
+
* Opcodes (`OP_DUP`, `OP_HASH160`, etc.) are inserted as their bytecode equivalent directly.
|
|
904
|
+
*
|
|
905
|
+
* ## Name resolution priority
|
|
906
|
+
*
|
|
907
|
+
* When the compiler encounters an identifier it resolves it in this order:
|
|
908
|
+
* 1. Opcode — always wins. Naming a variable or script `OP_ADD` will not shadow it.
|
|
909
|
+
* 2. Variable — shadows scripts of the same name.
|
|
910
|
+
* 3. Script — the script's bytecode.
|
|
911
|
+
*
|
|
912
|
+
* NOTE: In future development of the XO, there will be XO_CODE taking the highest priority.
|
|
913
|
+
*
|
|
914
|
+
* @see playground/examples/cashassembly-evaluations.js for runnable examples covering all syntax forms,
|
|
915
|
+
* VM evaluation, and name resolution priority.
|
|
916
|
+
*/
|
|
794
917
|
/**
|
|
795
918
|
* Checks if the expression is a CashAssembly expression.
|
|
796
919
|
*
|
|
797
920
|
* @param expression - The expression to check.
|
|
798
921
|
* @returns True if the expression is a CashAssembly expression, false otherwise.
|
|
799
922
|
*/
|
|
800
|
-
const
|
|
801
|
-
return typeof expression === "string" &&
|
|
923
|
+
const isCashAssemblyExpression = (expression) => {
|
|
924
|
+
return typeof expression === "string" && CASHASSEMBLY_EXPRESSION_PATTERN.test(expression);
|
|
802
925
|
};
|
|
803
926
|
/**
|
|
804
927
|
* Extracts all CashAssembly evaluations (i.e., substrings like $(...)) from the input text.
|
|
@@ -811,52 +934,88 @@ const isCashAsmExpression = (expression) => {
|
|
|
811
934
|
* // returns ['$(<foo>)', '$(<bar>)']
|
|
812
935
|
*/
|
|
813
936
|
const extractCashAssemblyEvaluations = (text) => {
|
|
814
|
-
return text.match(
|
|
937
|
+
return text.match(CASHASSEMBLY_EVALUATION_PATTERN) ?? [];
|
|
815
938
|
};
|
|
816
939
|
/**
|
|
817
|
-
* Extracts variable
|
|
940
|
+
* Extracts unique variable identifiers enclosed in angle brackets from each evaluation string.
|
|
941
|
+
*
|
|
942
|
+
* CashAssembly literal tokens such as hex bytes, numbers, and quoted strings are excluded.
|
|
943
|
+
* For example, `<0x02>` and `<"minting">` are not returned.
|
|
818
944
|
*
|
|
819
945
|
* @param evaluations - An array of evaluation strings from which to extract variable names.
|
|
820
|
-
* @returns An array of variable names
|
|
946
|
+
* @returns An array of variable names
|
|
821
947
|
*/
|
|
822
948
|
const extractVariablesFromEvaluations = (evaluations) => {
|
|
823
|
-
const
|
|
824
|
-
const
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
949
|
+
const uniqueVariables = /* @__PURE__ */ new Set();
|
|
950
|
+
for (const evaluation of evaluations) for (const match of evaluation.matchAll(CASHASSEMBLY_VARIABLE_PATTERN)) {
|
|
951
|
+
const extractedIdentifier = match[1];
|
|
952
|
+
if (CASHASSEMBLY_LITERAL_TOKEN_PATTERN.test(extractedIdentifier)) continue;
|
|
953
|
+
uniqueVariables.add(extractedIdentifier);
|
|
954
|
+
}
|
|
955
|
+
return [...uniqueVariables];
|
|
956
|
+
};
|
|
957
|
+
/**
|
|
958
|
+
* Converts a variable value to its byte representation.
|
|
959
|
+
*
|
|
960
|
+
* @param value - The variable value to convert.
|
|
961
|
+
* @param variableName - The name of the variable, used in error messages.
|
|
962
|
+
* @returns The byte representation of the value.
|
|
963
|
+
* @throws {CashAssemblyVariableNotIntegerError} If a number value is not a valid integer.
|
|
964
|
+
*/
|
|
965
|
+
const convertVariableToBytes = (value, variableName) => {
|
|
966
|
+
if (value instanceof Uint8Array) return value;
|
|
967
|
+
if (typeof value === "bigint") return bigIntToVmNumber(value);
|
|
968
|
+
if (typeof value === "number") {
|
|
969
|
+
if (!Number.isInteger(value)) throw new CashAssemblyVariableNotIntegerError(variableName, value);
|
|
970
|
+
return bigIntToVmNumber(BigInt(value));
|
|
832
971
|
}
|
|
833
|
-
return
|
|
972
|
+
if (typeof value === "boolean") return new Uint8Array(value ? [1] : []);
|
|
973
|
+
return utf8ToBin(value);
|
|
834
974
|
};
|
|
835
975
|
/**
|
|
836
|
-
*
|
|
837
|
-
* Each evaluation is replaced with its compiled bytecode (hex string).
|
|
976
|
+
* Decodes compiled CashAssembly evaluation bytes into a string representation.
|
|
838
977
|
*
|
|
839
|
-
*
|
|
840
|
-
*
|
|
978
|
+
* 'evaluationDecodeMode' determines how the evaluation bytes are interpreted and presented.
|
|
979
|
+
* Choose based on what the evaluation is expected to produce:
|
|
980
|
+
* `bigint` for numeric values like satoshis, `utf8` for text labels, `hex` for binary data such
|
|
981
|
+
* as hashes, and `boolean` to represent boolean values.
|
|
841
982
|
*
|
|
842
|
-
*
|
|
983
|
+
* @param compiledResult - The compiled evaluation bytecode.
|
|
984
|
+
* @param evaluationDecodeMode - The decode mode used to convert bytes to text.
|
|
985
|
+
* @returns The decoded value as a string suitable for inline replacement.
|
|
986
|
+
*/
|
|
987
|
+
const decodeCompiledCashAssemblyEvaluation = (compiledResult, evaluationDecodeMode = "utf8") => {
|
|
988
|
+
if (evaluationDecodeMode === "uint8array") return String(compiledResult);
|
|
989
|
+
if (evaluationDecodeMode === "boolean") return compiledResult.length === 0 ? "false" : "true";
|
|
990
|
+
if (evaluationDecodeMode === "hex") return binToHex(compiledResult);
|
|
991
|
+
if (evaluationDecodeMode === "bigint") {
|
|
992
|
+
const vmNumberResult = vmNumberToBigInt(compiledResult);
|
|
993
|
+
if (typeof vmNumberResult === "bigint") return vmNumberResult.toString();
|
|
994
|
+
}
|
|
995
|
+
return binToUtf8(compiledResult);
|
|
996
|
+
};
|
|
997
|
+
/**
|
|
998
|
+
* Compiles all CashAssembly evaluations in a text string and replaces each evaluation
|
|
999
|
+
* with a decoded string representation.
|
|
843
1000
|
*
|
|
844
|
-
* @param
|
|
1001
|
+
* @param cashAssemblyText - The string with CashAssembly evaluations.
|
|
845
1002
|
* @param variables - Object mapping variable names to values for compilation.
|
|
846
|
-
*
|
|
847
|
-
*
|
|
848
|
-
* @
|
|
849
|
-
*/
|
|
850
|
-
const compileCashAssemblyString = (
|
|
851
|
-
|
|
852
|
-
|
|
1003
|
+
* @param evaluationDecodeMode - The decode mode used after each evaluation is compiled.
|
|
1004
|
+
* @returns Compiled text with all evaluations replaced by decoded string values.
|
|
1005
|
+
* @throws VariableValidationFailedError when a required variable is not present in the variables map.
|
|
1006
|
+
*/
|
|
1007
|
+
const compileCashAssemblyString = (parameters) => {
|
|
1008
|
+
const { cashAssemblyText, variables, evaluationDecodeMode = "utf8" } = parameters;
|
|
1009
|
+
let compiledText = cashAssemblyText;
|
|
1010
|
+
const evaluations = extractCashAssemblyEvaluations(cashAssemblyText);
|
|
853
1011
|
for (const evaluation of evaluations) {
|
|
854
1012
|
const variableNames = extractVariablesFromEvaluations([evaluation]);
|
|
855
|
-
|
|
1013
|
+
const missingVariables = variableNames.filter((variableName) => !Object.hasOwn(variables, variableName));
|
|
1014
|
+
if (missingVariables.length > 0) throw new VariableValidationFailedError(missingVariables);
|
|
856
1015
|
const convertedVariables = {};
|
|
857
|
-
for (const variableName of variableNames) convertedVariables[variableName] =
|
|
858
|
-
const
|
|
859
|
-
compiledText = compiledText.replace(evaluation,
|
|
1016
|
+
for (const variableName of variableNames) convertedVariables[variableName] = convertVariableToBytes(variables[variableName], variableName);
|
|
1017
|
+
const decodedResult = decodeCompiledCashAssemblyEvaluation(generateCashAssemblyBytecode(compileCashAssemblyEvaluations([evaluation]), evaluation, convertedVariables), evaluationDecodeMode);
|
|
1018
|
+
compiledText = compiledText.replace(evaluation, decodedResult);
|
|
860
1019
|
}
|
|
861
1020
|
return compiledText;
|
|
862
1021
|
};
|
|
@@ -1008,19 +1167,6 @@ var BlockchainMonitor = class {
|
|
|
1008
1167
|
}
|
|
1009
1168
|
};
|
|
1010
1169
|
|
|
1011
|
-
//#endregion
|
|
1012
|
-
//#region source/defaults.ts
|
|
1013
|
-
const DEFAULT_INVITATION_EXPIRATION_IN_MILLISECONDS = 3600 * 1e3;
|
|
1014
|
-
const DEFAULT_STORAGE_TYPE = StorageType.INDEXEDDB;
|
|
1015
|
-
const DEFAULT_SEQUENCE_NUMBER = 0;
|
|
1016
|
-
const DEFAULT_LOCKTIME = 0;
|
|
1017
|
-
const DEFAULT_VERSION = 2;
|
|
1018
|
-
const PLACEHOLDER_UNLOCKING_BYTECODE = new Uint8Array(0);
|
|
1019
|
-
/**
|
|
1020
|
-
* The default electrum application identifier.
|
|
1021
|
-
*/
|
|
1022
|
-
const DEFAULT_ELECTRUM_APPLICATION_IDENTIFIER = "xo";
|
|
1023
|
-
|
|
1024
1170
|
//#endregion
|
|
1025
1171
|
//#region source/invitation/builder.ts
|
|
1026
1172
|
/**
|
|
@@ -1145,7 +1291,7 @@ var InvitationBuilder = class InvitationBuilder {
|
|
|
1145
1291
|
* @param params.variables - Optional array of variables to add
|
|
1146
1292
|
* @param params.transactionVersion - Optional transaction version
|
|
1147
1293
|
* @param params.transactionLocktime - Optional transaction locktime
|
|
1148
|
-
* @param params.expiresAtTimestamp - Optional expiration timestamp (defaults to now +
|
|
1294
|
+
* @param params.expiresAtTimestamp - Optional expiration timestamp (defaults to now + DEFAULT_COMMIT_EXPIRATION_IN_MILLISECONDS)
|
|
1149
1295
|
* @returns The unsigned commit (without signature)
|
|
1150
1296
|
*/
|
|
1151
1297
|
createUnsignedCommit(params) {
|
|
@@ -1159,7 +1305,7 @@ var InvitationBuilder = class InvitationBuilder {
|
|
|
1159
1305
|
variables,
|
|
1160
1306
|
transactionVersion,
|
|
1161
1307
|
transactionLocktime,
|
|
1162
|
-
expiresAtTimestamp: expiresAtTimestamp ?? Date.now() +
|
|
1308
|
+
expiresAtTimestamp: expiresAtTimestamp ?? Date.now() + DEFAULT_COMMIT_EXPIRATION_IN_MILLISECONDS
|
|
1163
1309
|
});
|
|
1164
1310
|
}
|
|
1165
1311
|
/**
|
|
@@ -1536,16 +1682,24 @@ const resolveOutputFromTemplate = (output, variables, templateInstance) => {
|
|
|
1536
1682
|
}
|
|
1537
1683
|
const templateOutput = templateInstance.getOutput(output.outputIdentifier);
|
|
1538
1684
|
if (resolvedOutput.valueSatoshis === void 0) {
|
|
1539
|
-
if (templateOutput.valueSatoshis &&
|
|
1540
|
-
if (typeof templateOutput.valueSatoshis !== "string") throw new InvalidTemplateOutputSatoshisTypeError(typeof templateOutput.valueSatoshis);
|
|
1685
|
+
if (templateOutput.valueSatoshis && isCashAssemblyExpression(templateOutput.valueSatoshis)) {
|
|
1541
1686
|
const variablesObject = convertCommitVariablesIntoObject(variables);
|
|
1542
|
-
|
|
1687
|
+
const compiledResult = compileCashAssemblyString({
|
|
1688
|
+
cashAssemblyText: templateOutput.valueSatoshis,
|
|
1689
|
+
variables: variablesObject,
|
|
1690
|
+
evaluationDecodeMode: "bigint"
|
|
1691
|
+
});
|
|
1692
|
+
resolvedOutput.valueSatoshis = BigInt(compiledResult);
|
|
1543
1693
|
}
|
|
1544
1694
|
}
|
|
1545
1695
|
if (resolvedOutput.lockingBytecode === void 0) {
|
|
1546
|
-
if (templateOutput.lockingScript &&
|
|
1696
|
+
if (templateOutput.lockingScript && isCashAssemblyExpression(templateOutput.lockingScript)) {
|
|
1547
1697
|
const variablesObject = convertCommitVariablesIntoObject(variables);
|
|
1548
|
-
resolvedOutput.lockingBytecode = hexToBin(compileCashAssemblyString(
|
|
1698
|
+
resolvedOutput.lockingBytecode = hexToBin(compileCashAssemblyString({
|
|
1699
|
+
cashAssemblyText: templateOutput.lockingScript,
|
|
1700
|
+
variables: variablesObject,
|
|
1701
|
+
evaluationDecodeMode: "hex"
|
|
1702
|
+
}));
|
|
1549
1703
|
}
|
|
1550
1704
|
}
|
|
1551
1705
|
if (!resolvedOutput.lockingBytecode) throw new LockingBytecodeNotFoundForOutputError(output.outputIdentifier ?? "unknown", output.transactionIndex);
|
|
@@ -2720,5 +2874,5 @@ var Engine = class Engine {
|
|
|
2720
2874
|
};
|
|
2721
2875
|
|
|
2722
2876
|
//#endregion
|
|
2723
|
-
export { ActionNotFoundError, BlockchainMonitor, CashAssemblyCompilationFailedError, CircularMergeReferenceError, CommitEntityIdentifierNotFoundError, CommitNotFoundInInvitationError, CommitNotSignedError, CreatedByIdentifierAlreadySetError, CreatedByIdentifierSignatureAlreadySetError, DataNotFoundError, DuplicateTransactionIndexError, DuplicateTransactionLocktimeError, DuplicateTransactionVersionError, ElectrumClientNotFoundError, Engine, InvalidActionError, InvalidCommitSignaturesError, InvalidDataTypeError, InvalidDerivativeIndexTypeError, InvalidEntityIdentifierError, InvalidInputError, InvalidInvitationError, InvalidLockingScriptTypeError, InvalidLockingTypeError, InvalidRequirementsError, InvalidRoleError, InvalidTemplateOutputSatoshisTypeError, InvalidVariableDefinitionError, InvalidVariableTypeError, InvitationAlreadyAcceptedError, InvitationBuilder, InvitationCreatedInFutureError, InvitationExpiredError, InvitationNotAcceptedError, InvitationNotFoundInStoreError, ItemNotFoundInCommitError, LockingBytecodeGenerationFailedError, LockingBytecodeNotFoundForOutputError, LockingDataNotFoundError, LockingScriptNotFoundError, LockingScriptTypeNotFoundError,
|
|
2877
|
+
export { ActionNotFoundError, BlockchainMonitor, CashAssemblyCompilationFailedError, CashAssemblyVariableNotIntegerError, CircularMergeReferenceError, CommitEntityIdentifierNotFoundError, CommitNotFoundInInvitationError, CommitNotSignedError, CreatedByIdentifierAlreadySetError, CreatedByIdentifierSignatureAlreadySetError, DataNotFoundError, DuplicateTransactionIndexError, DuplicateTransactionLocktimeError, DuplicateTransactionVersionError, ElectrumClientNotFoundError, Engine, InvalidActionError, InvalidCommitSignaturesError, InvalidDataTypeError, InvalidDerivativeIndexTypeError, InvalidEntityIdentifierError, InvalidInputError, InvalidInvitationError, InvalidLockingScriptTypeError, InvalidLockingTypeError, InvalidRequirementsError, InvalidRoleError, InvalidTemplateOutputSatoshisTypeError, InvalidVariableDefinitionError, InvalidVariableTypeError, InvitationAlreadyAcceptedError, InvitationBuilder, InvitationCreatedInFutureError, InvitationExpiredError, InvitationNotAcceptedError, InvitationNotFoundInStoreError, ItemNotFoundInCommitError, LockingBytecodeGenerationFailedError, LockingBytecodeNotFoundForOutputError, LockingDataNotFoundError, LockingScriptNotFoundError, LockingScriptTypeNotFoundError, MergedCommitNotFoundError, MergesWithCommitNotFoundError, MissingRequiredDataError, MissingRequiredFieldError, MissingRequiredRoleForEntityError, MissingRequiredSignatureByEntityError, MissingRequiredVariableError, MultipleRolesForStartingActionError, NoRoleSpecifiedAndMultipleRolesAvailableToBeAcceptedError, OutputLockingScriptNotFoundError, OutputNotFoundError, ParentCommitNotFoundError, ReserveResourcesFailedError, RoleAlreadyAcceptedByAnotherEntityError, RoleCannotStartActionError, RoleNotAvailableToBeAcceptedError, RoleNotDefinedForActionError, RoleNotFoundError, RootCommitNotFoundError, ScriptHashDataNotFoundError, ScriptNotFoundError, SignatureVerificationFailedError, StartingActionNotFoundError, Template, TemplateIdentifierMismatchError, TemplateNotFoundError, TransactionGenerationFailedError, TransactionNotFoundError, UnknownVariableError, UnlockingScriptNotFoundError, UnspentOutputNotFoundError, VariableRequiredError, VariableValidationFailedError, assignTypeToVariablesForLibauthCompiler, compileCashAssemblyEvaluations, compileCashAssemblyString, convertCommitVariablesIntoObject, convertXOLockingTypeToLibauth, createLibauthCompilerDataFromUnspentOutput, decodeCompiledCashAssemblyEvaluation, entityOwnershipForLibauthCompiler, extractCashAssemblyEvaluations, extractVariablesFromEvaluations, findRootCommitIdentifierInInvitation, generateCashAssemblyBytecode, generateCommitIdentifier, generateTemplateIdentifier, hasInvitationExpired, isCashAssemblyExpression, listAvailableRolesForInvitation, listMissingRequirements, listPopulatedRequirementsInInvitation, listRequirementsFromTemplate, mergeInvitationCommits, parseTemplate, scriptsForLibauthCompiler, updateUnspentOutputsForScriptHashInStore, validateInvitationCommits, validateInvitationEntities, validateRoleRequirements };
|
|
2724
2878
|
//# sourceMappingURL=index.mjs.map
|