Large amount of changes. Successfully broadcasts txs

This commit is contained in:
2026-03-08 15:53:50 +00:00
parent 66e9918e04
commit 9ef1720e1f
19 changed files with 1374 additions and 352 deletions

View File

@@ -6,8 +6,8 @@
* - UTXOs we own (with descriptions derived from template outputs)
*/
import type { Engine } from '@xo-cash/engine';
import type { XOInvitation, XOTemplate } from '@xo-cash/types';
import { type Engine, compileCashAssemblyString } from '@xo-cash/engine';
import type { XOInvitation, XOInvitationVariableValue, XOTemplate } from '@xo-cash/types';
import type { UnspentOutputData } from '@xo-cash/state';
import type { Invitation } from './invitation.js';
import { binToHex } from '@bitauth/libauth';
@@ -203,7 +203,7 @@ export class HistoryService {
const outputDef = template.outputs?.[utxo.outputIdentifier];
if (!outputDef) {
return `${utxo.outputIdentifier} output`;
return `[${template.name}] ${utxo.outputIdentifier} output`;
}
// Start with the output name or identifier
@@ -211,11 +211,7 @@ export class HistoryService {
// If there's a description, parse it and replace variable placeholders
if (outputDef.description) {
description = outputDef.description
// Replace <variableName> placeholders (we don't have variable values here, so just clean up)
.replace(/<([^>]+)>/g, (_, varId) => varId)
// Remove $() wrappers
.replace(/\$\(([^)]+)\)/g, '$1');
description = compileCashAssemblyString(outputDef.description, {})
}
return description;
@@ -239,14 +235,13 @@ export class HistoryService {
}
const committedVariables = invitation.commits.flatMap(c => c.data.variables ?? []);
const formattedVariables = committedVariables.reduce((acc, v) => {
acc[v.variableIdentifier ?? ''] = v.value;
return acc;
}, {} as Record<string, XOInvitationVariableValue>);
const description = compileCashAssemblyString(transaction.description, formattedVariables);
return transaction.description
// Replace <variableName> with actual values
.replace(/<([^>]+)>/g, (match, varId) => {
const variable = committedVariables.find(v => v.variableIdentifier === varId);
return variable ? String(variable.value) : match;
})
// Remove the $() wrapper around variable expressions
.replace(/\$\(([^)]+)\)/g, '$1');
return description;
}
}