Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(app): store temp wallets in os tmpdir
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Oct 14, 2019
1 parent 9a74f4e commit 91060e0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion utils/lndConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import untildify from 'untildify'
import tildify from 'tildify'
import lndconnect from 'lndconnect'
import fs from 'fs'
import { tmpdir } from 'os'
import util from 'util'
import pick from 'lodash/pick'
import get from 'lodash/get'
Expand Down Expand Up @@ -38,6 +39,7 @@ export const networks = {

const _isReady = new WeakMap()
const _lndconnectQRCode = new WeakMap()
const _tmpDir = new WeakMap()

// Utility methods to clean and prepare data.
const safeTrim = val => (typeof val === 'string' ? val.trim() : val)
Expand Down Expand Up @@ -82,10 +84,19 @@ class LndConfig {
lndDir: {
enumerable: true,
get() {
if (this.id === 'tmp') {
const cache = _tmpDir.get(this)
if (cache) {
return cache
}
const lndDir = fs.mkdtempSync(join(tmpdir(), 'zap-tmp-wallet'))
_tmpDir.set(this, lndDir)
return lndDir
}
if (this.type === LNDCONFIG_TYPE_LOCAL) {
return join(options.userDataDir, 'lnd', this.chain, this.network, this.wallet)
}
return
return null
},
},
host: {
Expand Down

0 comments on commit 91060e0

Please sign in to comment.