meriadec
7 years ago
No known key found for this signature in database
GPG Key ID: 1D2FC2305E2CB399
4 changed files with
33 additions and
6 deletions
-
src/init-ledger-core.js
-
src/internals/accounts/helpers.js
-
src/internals/accounts/scanAccountsOnDevice.js
-
src/main/bridge.js
|
|
@ -0,0 +1,21 @@ |
|
|
|
// Yep. That's a singleton.
|
|
|
|
//
|
|
|
|
// Electron needs to tell lib ledger core where to store the sqlite files, when
|
|
|
|
// instanciating wallet pool, but we don't need to do each everytime we
|
|
|
|
// require ledger-core, only the first time, so, eh.
|
|
|
|
|
|
|
|
const core = require('ledger-core') |
|
|
|
|
|
|
|
let instanciated = false |
|
|
|
|
|
|
|
module.exports = () => { |
|
|
|
console.log(`INSTANCIATED = ${instanciated}`) |
|
|
|
if (!instanciated) { |
|
|
|
core.instanciateWalletPool({ |
|
|
|
// sqlite files will be located in the app local data folder
|
|
|
|
dbPath: process.env.LEDGER_LIVE_SQLITE_PATH, |
|
|
|
}) |
|
|
|
instanciated = true |
|
|
|
} |
|
|
|
return core |
|
|
|
} |
|
|
@ -31,7 +31,9 @@ export async function getFreshReceiveAddress({ |
|
|
|
currencyId: string, |
|
|
|
accountIndex: number, |
|
|
|
}) { |
|
|
|
const core = require('ledger-core') |
|
|
|
// TODO: investigate why importing it on file scope causes trouble
|
|
|
|
const core = require('init-ledger-core')() |
|
|
|
|
|
|
|
const wallet = await core.getWallet(currencyId) |
|
|
|
const account = await wallet.getAccount(accountIndex) |
|
|
|
const addresses = await account.getFreshPublicAddresses() |
|
|
|
|
|
@ -69,7 +69,7 @@ async function scanNextAccount(props) { |
|
|
|
} = props |
|
|
|
|
|
|
|
// TODO: investigate why importing it on file scope causes trouble
|
|
|
|
const core = require('ledger-core') |
|
|
|
const core = require('init-ledger-core')() |
|
|
|
|
|
|
|
console.log(`>> Scanning account ${accountIndex}`) |
|
|
|
|
|
|
@ -113,7 +113,7 @@ async function scanNextAccount(props) { |
|
|
|
|
|
|
|
async function getOrCreateWallet(WALLET_IDENTIFIER, currencyId) { |
|
|
|
// TODO: investigate why importing it on file scope causes trouble
|
|
|
|
const core = require('ledger-core') |
|
|
|
const core = require('init-ledger-core')() |
|
|
|
try { |
|
|
|
const wallet = await core.getWallet(WALLET_IDENTIFIER) |
|
|
|
return wallet |
|
|
|
|
|
@ -2,9 +2,9 @@ |
|
|
|
|
|
|
|
import '@babel/polyfill' |
|
|
|
import { fork } from 'child_process' |
|
|
|
import { BrowserWindow, ipcMain } from 'electron' |
|
|
|
import { BrowserWindow, ipcMain, app } from 'electron' |
|
|
|
import objectPath from 'object-path' |
|
|
|
import { resolve } from 'path' |
|
|
|
import path from 'path' |
|
|
|
|
|
|
|
import cpuUsage from 'helpers/cpuUsage' |
|
|
|
|
|
|
@ -12,6 +12,9 @@ import setupAutoUpdater, { quitAndInstall } from './autoUpdate' |
|
|
|
|
|
|
|
const { DEV_TOOLS } = process.env |
|
|
|
|
|
|
|
// sqlite files will be located in the app local data folder
|
|
|
|
const LEDGER_LIVE_SQLITE_PATH = path.resolve(app.getPath('userData'), 'sqlite') |
|
|
|
|
|
|
|
const processes = [] |
|
|
|
|
|
|
|
function cleanProcesses() { |
|
|
@ -29,10 +32,11 @@ function onForkChannel(forkType) { |
|
|
|
return (event: any, payload) => { |
|
|
|
const { type, data } = payload |
|
|
|
|
|
|
|
let compute = fork(resolve(__dirname, `${__DEV__ ? '../../' : './'}dist/internals`), { |
|
|
|
let compute = fork(path.resolve(__dirname, `${__DEV__ ? '../../' : './'}dist/internals`), { |
|
|
|
env: { |
|
|
|
DEV_TOOLS, |
|
|
|
FORK_TYPE: forkType, |
|
|
|
LEDGER_LIVE_SQLITE_PATH, |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|