Add import template into tui. Fix tests that fail on macos. Fix some updates.

This commit is contained in:
2026-05-29 18:16:00 +02:00
parent 85746c3306
commit 2f8dad7d8d
20 changed files with 1748 additions and 46 deletions
-10
View File
@@ -625,34 +625,26 @@ export class Invitation extends EventEmitter<InvitationEventMap> {
);
}
console.dir(this.data, { depth: null });
// Create a list of all the variables from the commits
const variables = this.data.commits.flatMap(
(c) => c.data?.variables ?? [],
);
console.dir(variables, { depth: null });
// Create a dictionary of the variables
const formattedVariables = variables.reduce(
(acc, v) => {
const { variableIdentifier, value } = v;
console.log(typeof value);
acc[variableIdentifier ?? ""] = value;
return acc;
},
{} as Record<string, XOInvitationVariableValue>,
);
console.dir(formattedVariables, { depth: null });
// Compile the CashAssembly expression to get the value satoshis (It handles the variable replacement for us)
const valueSatoshis = compileCashAssemblyString(
{ cashAssemblyText: String(valueSatoshisExpression), variables: formattedVariables, evaluationDecodeMode: 'bigint' },
);
console.dir(valueSatoshis, { depth: null });
// Return the value satoshis as a bigint
// TODO: Check this of a vulnerability or crash - I assume there might be one if someone made the `valueSatoshis` a malicious expression
return BigInt(valueSatoshis);
@@ -707,11 +699,9 @@ export class Invitation extends EventEmitter<InvitationEventMap> {
for (const output of outputs) {
if (typeof output === "string") {
const sats = await this.getSatsOut(output);
console.log(`Sats for output: ${output} is ${sats}`);
totalSats += sats
} else {
const sats = await this.getSatsOut(output.output);
console.log(`Sats for output: ${output.output} is ${sats}`);
totalSats += sats;
}
}