fix and clean
This commit is contained in:
parent
d79f058d96
commit
77ba507c69
3 changed files with 4 additions and 9 deletions
|
|
@ -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')
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 }) => {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ export class LiquidityStorage {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue