WIP: feature: add windows support
This commit is contained in:
parent
698bfe6280
commit
85f9f2e133
|
@ -0,0 +1,20 @@
|
|||
@echo off
|
||||
|
||||
IF NOT EXIST %AppData%\Zcash (
|
||||
mkdir %AppData%\Zcash
|
||||
)
|
||||
|
||||
IF NOT EXIST %AppData%\ZcashParams (
|
||||
mkdir %AppData%\ZcashParams
|
||||
)
|
||||
|
||||
IF NOT EXIST %AppData%\Zcash\zcash.conf (
|
||||
(
|
||||
echo addnode=mainnet.z.cash
|
||||
echo rpcuser=username
|
||||
echo rpcpassword=password%random%%random%
|
||||
echo daemon=1
|
||||
echo showmetrics=0
|
||||
echo gen=0
|
||||
) > %AppData%\Zcash\zcash.conf
|
||||
)
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
// @flow
|
||||
|
||||
import path from 'path';
|
||||
import cp from 'child_process';
|
||||
|
||||
import getBinariesPath from './get-binaries-path';
|
||||
import log from './logger';
|
||||
|
||||
export default (): Promise<*> => new Promise((resolve, reject) => {
|
||||
const processName = path.join(getBinariesPath(), 'zcash-fetch-params');
|
||||
|
||||
const childProcess = cp.spawn(processName);
|
||||
|
||||
childProcess.stdout.on('data', data => log(data.toString()));
|
||||
childProcess.stderr.on('data', data => log(data.toString()));
|
||||
childProcess.on('error', reject);
|
||||
childProcess.on('exit', (code, err) => {
|
||||
if (code !== 0 || err) {
|
||||
reject(new Error(err));
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,43 @@
|
|||
// @flow
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import cp from 'child_process';
|
||||
|
||||
import got from 'got';
|
||||
|
||||
// eslint-disable-next-line
|
||||
import { app } from '../electron';
|
||||
import getBinariesPath from './get-binaries-path';
|
||||
import log from './logger';
|
||||
|
||||
const httpClient = got.extend({ baseUrl: 'https://z.cash/downloads/', retry: 3, useElectronNet: true });
|
||||
|
||||
const FILES = [
|
||||
'sprout-proving.key',
|
||||
'sprout-verifying.key',
|
||||
'sapling-spend.params',
|
||||
'sapling-output.params',
|
||||
'sprout-groth16.params',
|
||||
];
|
||||
|
||||
export default (): Promise<*> => new Promise((resolve, reject) => {
|
||||
const firstRunProcess = cp.spawn(path.join(getBinariesPath(), 'win', 'first-run.bat'));
|
||||
firstRunProcess.stdout.on('data', data => log(data.toString()));
|
||||
firstRunProcess.stderr.on('data', data => reject(data.toString()));
|
||||
firstRunProcess.on('exit', (code, err) => {
|
||||
if (code !== 0 || err) {
|
||||
reject(new Error(err));
|
||||
}
|
||||
|
||||
FILES.forEach((filename) => {
|
||||
// TODO: Log download progress
|
||||
|
||||
log(`Downloading ${filename}...`);
|
||||
|
||||
httpClient
|
||||
.stream(filename)
|
||||
.on('end', () => log(`Download ${filename} finished!`))
|
||||
.pipe(fs.createWriteStream(`${path.join(app.getPath('userData'), '..', 'ZcashParams', filename)}`));
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,23 +1,16 @@
|
|||
// @flow
|
||||
import cp from 'child_process';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
|
||||
import getBinariesPath from './get-binaries-path';
|
||||
import log from './logger';
|
||||
import fetchWindowsParams from './fetch-windows-params';
|
||||
import runUnixFetchParams from './fetch-unix-params';
|
||||
|
||||
export default (): Promise<*> => new Promise((resolve, reject) => {
|
||||
export default (): Promise<*> => {
|
||||
log('Fetching params');
|
||||
const processName = path.join(getBinariesPath(), 'zcash-fetch-params');
|
||||
|
||||
const childProcess = cp.spawn(processName);
|
||||
if (os.platform() === 'win32') {
|
||||
return fetchWindowsParams();
|
||||
}
|
||||
|
||||
childProcess.stdout.on('data', data => log(data.toString()));
|
||||
childProcess.stderr.on('data', data => log(data.toString()));
|
||||
childProcess.on('error', reject);
|
||||
childProcess.on('exit', (code, err) => {
|
||||
if (code !== 0 || err) {
|
||||
reject(new Error(err));
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
return runUnixFetchParams();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue