From b4d82b8b1fd45c6686c125f517facfc7613f1320 Mon Sep 17 00:00:00 2001 From: Harvmaster Date: Sat, 16 May 2026 05:59:55 +0000 Subject: [PATCH] Before bliss --- package-lock.json | 40 +++++++++++++++++++++++++++++++--------- package.json | 2 +- src/services/app.ts | 41 +++++++++++++++++++++++++++-------------- src/services/history.ts | 6 ++++++ 4 files changed, 65 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1e3807c..af0656a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@xo-cash/crypto": "^0.0.1", "@xo-cash/engine": "file:../engine", "@xo-cash/state": "file:../state", - "@xo-cash/templates": "^0.0.1", + "@xo-cash/templates": "file:../templates", "@xo-cash/types": "^0.0.1", "better-sqlite3": "^12.6.2", "clipboardy": "^5.1.0", @@ -51,7 +51,7 @@ "@electrum-cash/network": "^4.2.2", "@electrum-cash/protocol": "^2.3.1", "@electrum-cash/servers": "^3.1.0", - "@xo-cash/crypto": "0.0.1", + "@xo-cash/crypto": "file:../crypto", "@xo-cash/primitives": "0.0.1", "@xo-cash/state": "0.0.2", "@xo-cash/templates": "0.0.1", @@ -113,6 +113,33 @@ "vitest": "^4.0.17" } }, + "../templates": { + "name": "@xo-cash/templates", + "version": "0.0.1", + "license": "MIT", + "dependencies": { + "@xo-cash/types": "0.0.1" + }, + "devDependencies": { + "@chalp/eslint-airbnb": "^1.3.0", + "@generalprotocols/cspell-dictionary": "^1.0.1", + "@stylistic/eslint-plugin": "^5.7.0", + "@typescript-eslint/eslint-plugin": "^8.53.1", + "@typescript-eslint/parser": "^8.53.1", + "@vitest/coverage-v8": "^4.0.17", + "@viz-kit/esbuild-analyzer": "^1.0.0", + "@xo-cash/eslint-config": "1.0.1", + "cspell": "^9.6.0", + "eslint": "^9.39.2", + "prettier": "^3.6.2", + "tsdown": "^0.20.0-beta.4", + "typedoc": "^0.28.16", + "typedoc-plugin-coverage": "^4.0.2", + "typescript": "^5.3.2", + "typescript-eslint": "^8.53.1", + "vitest": "^4.0.17" + } + }, "node_modules/@alcalzone/ansi-tokenize": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/@alcalzone/ansi-tokenize/-/ansi-tokenize-0.2.4.tgz", @@ -929,13 +956,8 @@ "link": true }, "node_modules/@xo-cash/templates": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/@xo-cash/templates/-/templates-0.0.1.tgz", - "integrity": "sha512-v5f0YeH9Bw6lNThdE0fI878T4L2jbM8RI1quxdKxnvqHn9hu2jzebqvveEB2TfJWG3sP1GpE1go0Yn87R4sXfw==", - "license": "MIT", - "dependencies": { - "@xo-cash/types": "0.0.1" - } + "resolved": "../templates", + "link": true }, "node_modules/@xo-cash/types": { "version": "0.0.1", diff --git a/package.json b/package.json index bdf7338..00e6ed2 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@xo-cash/crypto": "^0.0.1", "@xo-cash/engine": "file:../engine", "@xo-cash/state": "file:../state", - "@xo-cash/templates": "^0.0.1", + "@xo-cash/templates": "file:../templates", "@xo-cash/types": "^0.0.1", "better-sqlite3": "^12.6.2", "clipboardy": "^5.1.0", diff --git a/src/services/app.ts b/src/services/app.ts index 70d07a6..d404138 100644 --- a/src/services/app.ts +++ b/src/services/app.ts @@ -83,20 +83,33 @@ export class AppService extends EventEmitter { // Import the default P2PKH template const { templateIdentifier } = await engine.importTemplate(p2pkhTemplate); - engine - .subscribeToLockingBytecodesForTemplate(templateIdentifier) - .catch((err) => - console.error( - `Error subscribing to locking bytecodes for template ${templateIdentifier}: ${err}`, - ), - ); - engine - .updateUnspentOutputsForTemplate(templateIdentifier) - .catch((err) => - console.error( - `Error updating unspent outputs for template ${templateIdentifier}: ${err}`, - ), - ); + // engine + // .subscribeToLockingBytecodesForTemplate(templateIdentifier) + // .catch((err) => + // console.error( + // `Error subscribing to locking bytecodes for template ${templateIdentifier}: ${err}`, + // ), + // ); + // engine + // .updateUnspentOutputsForTemplate(templateIdentifier) + // .catch((err) => + // console.error( + // `Error updating unspent outputs for template ${templateIdentifier}: ${err}`, + // ), + // ); + + // Update all the unspents for every template, and subscribe to the locking bytecodes for changes + // TODO: Remove the above lines that do the same thing. Minimising changes for BLISS. + const updateTemplates = async () => { + const templates = await engine.listImportedTemplates(); + + templates.forEach(async (template) => { + // engine.updateUnspentOutputsForTemplate(generateTemplateIdentifier(template)); + engine.subscribeToLockingBytecodesForTemplate(generateTemplateIdentifier(template)); + }); + }; + + updateTemplates(); // Set default locking parameters for P2PKH // To my knowledge, this doesnt generate any lockscript, so discovery of funds will not work automatically. diff --git a/src/services/history.ts b/src/services/history.ts index a70bc38..959f798 100644 --- a/src/services/history.ts +++ b/src/services/history.ts @@ -96,6 +96,12 @@ export class HistoryService { private invitations: Invitation[], ) {} + + /** + * I Might swap this over to invitation based history before the event to make it a bit more evident... Really not happy with the UTXO for demo purposes + * But for the actual usage, UTXO is easier to follow - just not good for demo + * Long term, this is intended to be in the Engine, so we will just be a consumer of history state. + */ async getHistory(): Promise { const allUtxos = await this.engine.listUnspentOutputsData(); const metadataIndex = await this.buildWalletMetadataIndex(allUtxos);