fix and clean

This commit is contained in:
boufni95 2025-12-15 18:56:05 +00:00
parent d79f058d96
commit 77ba507c69
3 changed files with 4 additions and 9 deletions

View file

@ -211,12 +211,10 @@ export class Unlocker {
throw new Error("node pub not found") throw new Error("node pub not found")
} }
const encrypted = await this.storage.liquidityStorage.GetNoodeSeed(this.nodePub) const encrypted = await this.storage.liquidityStorage.GetNoodeSeed(this.nodePub)
if (!encrypted || !encrypted.seed) { if (!encrypted) {
throw new Error("seed not found") throw new Error("seed not found")
} }
this.log("seed found, decrypting") const decrypted = this.DecryptWalletSeed(JSON.parse(encrypted))
const decrypted = this.DecryptWalletSeed(JSON.parse(encrypted.seed))
this.log("seed decrypted")
return { seed: decrypted } return { seed: decrypted }
} }
@ -278,12 +276,9 @@ export class Unlocker {
const secret = Buffer.from(sec, 'hex') const secret = Buffer.from(sec, 'hex')
const iv = Buffer.from(data.iv, 'hex') const iv = Buffer.from(data.iv, 'hex')
const encrypted = Buffer.from(data.encrypted, 'hex') const encrypted = Buffer.from(data.encrypted, 'hex')
this.log("decoded encrypted data")
const decipher = crypto.createDecipheriv('aes-256-cbc', secret, iv) const decipher = crypto.createDecipheriv('aes-256-cbc', secret, iv)
const decrypted = decipher.update(encrypted) const decrypted = decipher.update(encrypted)
this.log("decrypted data")
const raw = Buffer.concat([decrypted, decipher.final()]) const raw = Buffer.concat([decrypted, decipher.final()])
this.log("got raw data")
return raw.toString('utf-8') return raw.toString('utf-8')
} }

View file

@ -110,7 +110,6 @@ export default (mainHandler: Main): Types.ServerMethods => {
return mainHandler.appUserManager.BanUser(req.user_id) return mainHandler.appUserManager.BanUser(req.user_id)
}, },
GetSeed: async ({ ctx }) => { GetSeed: async ({ ctx }) => {
console.log("admin getting seed")
return mainHandler.unlocker.GetSeed() return mainHandler.unlocker.GetSeed()
}, },
SetMockInvoiceAsPaid: async ({ ctx, req }) => { SetMockInvoiceAsPaid: async ({ ctx, req }) => {

View file

@ -18,7 +18,8 @@ export class LiquidityStorage {
} }
async GetNoodeSeed(pubkey: string) { async GetNoodeSeed(pubkey: string) {
return this.dbs.FindOne<LndNodeInfo>('LndNodeInfo', { where: { pubkey, seed: Not(IsNull()) } }) const node = await this.dbs.FindOne<LndNodeInfo>('LndNodeInfo', { where: { pubkey/* , seed: Not(IsNull()) */ } })
return node?.seed
} }
async SaveNodeSeed(pubkey: string, seed: string) { async SaveNodeSeed(pubkey: string, seed: string) {