From 84ed7c7b3f4023f251b25e2d321e540a49ff20cf Mon Sep 17 00:00:00 2001 From: boufni95 Date: Mon, 15 Dec 2025 15:31:04 +0000 Subject: [PATCH 1/3] seed fix --- src/services/main/unlocker.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/services/main/unlocker.ts b/src/services/main/unlocker.ts index f129834f..e18ab600 100644 --- a/src/services/main/unlocker.ts +++ b/src/services/main/unlocker.ts @@ -214,8 +214,9 @@ export class Unlocker { if (!encrypted || !encrypted.seed) { throw new Error("seed not found") } - + this.log("seed found, decrypting") const decrypted = this.DecryptWalletSeed(JSON.parse(encrypted.seed)) + this.log("seed decrypted") return { seed: decrypted } } @@ -277,9 +278,12 @@ export class Unlocker { const secret = Buffer.from(sec, 'hex') const iv = Buffer.from(data.iv, 'hex') const encrypted = Buffer.from(data.encrypted, 'hex') + this.log("decoded encrypted data") const decipher = crypto.createDecipheriv('aes-256-cbc', secret, iv) const decrypted = decipher.update(encrypted) + this.log("decrypted data") const raw = Buffer.concat([decrypted, decipher.final()]) + this.log("got raw data") return raw.toString('utf-8') } From d79f058d96d35d8386d6ed410b0cf01849108cfb Mon Sep 17 00:00:00 2001 From: boufni95 Date: Mon, 15 Dec 2025 15:55:48 +0000 Subject: [PATCH 2/3] more log --- src/services/serverMethods/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/serverMethods/index.ts b/src/services/serverMethods/index.ts index c9f92932..456eac22 100644 --- a/src/services/serverMethods/index.ts +++ b/src/services/serverMethods/index.ts @@ -110,6 +110,7 @@ export default (mainHandler: Main): Types.ServerMethods => { return mainHandler.appUserManager.BanUser(req.user_id) }, GetSeed: async ({ ctx }) => { + console.log("admin getting seed") return mainHandler.unlocker.GetSeed() }, SetMockInvoiceAsPaid: async ({ ctx, req }) => { From 77ba507c69dbffdf7ad4aa3eb435aa083616042f Mon Sep 17 00:00:00 2001 From: boufni95 Date: Mon, 15 Dec 2025 18:56:05 +0000 Subject: [PATCH 3/3] fix and clean --- src/services/main/unlocker.ts | 9 ++------- src/services/serverMethods/index.ts | 1 - src/services/storage/liquidityStorage.ts | 3 ++- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/services/main/unlocker.ts b/src/services/main/unlocker.ts index e18ab600..2f1ade76 100644 --- a/src/services/main/unlocker.ts +++ b/src/services/main/unlocker.ts @@ -211,12 +211,10 @@ export class Unlocker { throw new Error("node pub not found") } const encrypted = await this.storage.liquidityStorage.GetNoodeSeed(this.nodePub) - if (!encrypted || !encrypted.seed) { + if (!encrypted) { throw new Error("seed not found") } - this.log("seed found, decrypting") - const decrypted = this.DecryptWalletSeed(JSON.parse(encrypted.seed)) - this.log("seed decrypted") + const decrypted = this.DecryptWalletSeed(JSON.parse(encrypted)) return { seed: decrypted } } @@ -278,12 +276,9 @@ export class Unlocker { const secret = Buffer.from(sec, 'hex') const iv = Buffer.from(data.iv, 'hex') const encrypted = Buffer.from(data.encrypted, 'hex') - this.log("decoded encrypted data") const decipher = crypto.createDecipheriv('aes-256-cbc', secret, iv) const decrypted = decipher.update(encrypted) - this.log("decrypted data") const raw = Buffer.concat([decrypted, decipher.final()]) - this.log("got raw data") return raw.toString('utf-8') } diff --git a/src/services/serverMethods/index.ts b/src/services/serverMethods/index.ts index 456eac22..c9f92932 100644 --- a/src/services/serverMethods/index.ts +++ b/src/services/serverMethods/index.ts @@ -110,7 +110,6 @@ export default (mainHandler: Main): Types.ServerMethods => { return mainHandler.appUserManager.BanUser(req.user_id) }, GetSeed: async ({ ctx }) => { - console.log("admin getting seed") return mainHandler.unlocker.GetSeed() }, SetMockInvoiceAsPaid: async ({ ctx, req }) => { diff --git a/src/services/storage/liquidityStorage.ts b/src/services/storage/liquidityStorage.ts index 0a609ed5..74364e33 100644 --- a/src/services/storage/liquidityStorage.ts +++ b/src/services/storage/liquidityStorage.ts @@ -18,7 +18,8 @@ export class LiquidityStorage { } async GetNoodeSeed(pubkey: string) { - return this.dbs.FindOne('LndNodeInfo', { where: { pubkey, seed: Not(IsNull()) } }) + const node = await this.dbs.FindOne('LndNodeInfo', { where: { pubkey/* , seed: Not(IsNull()) */ } }) + return node?.seed } async SaveNodeSeed(pubkey: string, seed: string) {