Browse Source

stop/remove native coin; spv auth fixes

v0.25
pbca26 7 years ago
parent
commit
077a27c398
  1. 3
      main.js
  2. 1
      package.json
  3. 1
      routes/shepherd/daemonControl.js
  4. 15
      routes/shepherd/electrum/keys.js
  5. 69
      routes/shepherd/quitDaemon.js
  6. 2
      routes/shepherd/rpc.js
  7. 2
      version

3
main.js

@ -476,7 +476,8 @@ function createWindow(status) {
let _appClosingInterval;
if (!Object.keys(shepherd.coindInstanceRegistry).length) {
if (!Object.keys(shepherd.coindInstanceRegistry).length ||
!appConfig.stopNativeDaemonsOnQuit) {
closeApp();
} else {
createAppCloseWindow();

1
package.json

@ -38,6 +38,7 @@
"fix-path": "^2.1.0",
"fs-extra": "^1.0.0",
"graceful-fs": "^4.1.11",
"js-sha256": "^0.7.1",
"nodejs-aes256": "^1.0.1",
"portscanner": "^2.1.1",
"ps-node": "^0.1.5",

1
routes/shepherd/daemonControl.js

@ -726,6 +726,7 @@ module.exports = (shepherd) => {
.then(RemoveLines)
.then(CheckConf);
}
/*
* type: POST
* params: herd

15
routes/shepherd/electrum/keys.js

@ -1,6 +1,15 @@
const sha256 = require('js-sha256');
module.exports = (shepherd) => {
shepherd.seedToWif = (seed, network, iguana) => {
const bytes = shepherd.sha256(seed, { asBytes: true });
shepherd.seedToWif = (seed, network, iguana, old) => {
let bytes;
if (old) {
bytes = shepherd.sha256(seed, { asBytes: true });
} else {
const hash = sha256.create().update(seed);
bytes = hash.array();
}
if (iguana) {
bytes[0] &= 248;
@ -23,6 +32,8 @@ module.exports = (shepherd) => {
key.compressed = true;
// shepherd.log(`seed: ${seed}`, true);
// shepherd.log(`network ${network}`, true);
// shepherd.log(`seedtowif priv key ${key.privateWif}`, true);
// shepherd.log(`seedtowif pub key ${key.publicAddress}`, true);

69
routes/shepherd/quitDaemon.js

@ -77,5 +77,74 @@ module.exports = (shepherd) => {
}
}
shepherd.post('/coind/stop', (req, res) => {
const _chain = req.body.chain;
let _coindQuitCmd = shepherd.komodocliBin;
let _arg = [];
if (_chain) {
_arg.push(`-ac_name=${_chain}`);
if (shepherd.appConfig.dataDir.length) {
_arg.push(`-datadir=${shepherd.appConfig.dataDir + (_chain ? '/' + _chain : '')}`);
}
} else if (!_chain && shepherd.appConfig.dataDir.length) {
_arg.push(`-datadir=${shepherd.appConfig.dataDir}`);
}
console.log(JSON.stringify(shepherd.coindInstanceRegistry, null, '\t'));
_arg.push('stop');
shepherd.execFile(`${_coindQuitCmd}`, _arg, (error, stdout, stderr) => {
shepherd.log(`stdout: ${stdout}`);
shepherd.log(`stderr: ${stderr}`);
if (stdout.indexOf('EOF reached') > -1 ||
stderr.indexOf('EOF reached') > -1 ||
(error && error.toString().indexOf('Command failed') > -1 && !stderr) || // win "special snowflake" case
stdout.indexOf('connect to server: unknown (code -1)') > -1 ||
stderr.indexOf('connect to server: unknown (code -1)') > -1) {
delete shepherd.coindInstanceRegistry[_chain ? _chain : 'komodo'];
const obj = {
msg: 'success',
result: 'result',
};
res.end(JSON.stringify(obj));
} else {
if (stdout.indexOf('Komodo server stopping') > -1) {
delete shepherd.coindInstanceRegistry[_chain ? _chain : 'komodo'];
const obj = {
msg: 'success',
result: 'result',
};
res.end(JSON.stringify(obj));
} else {
const obj = {
msg: 'error',
result: 'result',
};
res.end(JSON.stringify(obj));
}
}
});
});
shepherd.post('/coins/remove', (req, res) => {
const _chain = req.body.chain;
delete shepherd.coindInstanceRegistry[_chain ? _chain : 'komodo'];
const obj = {
msg: 'success',
result: 'result',
};
res.end(JSON.stringify(obj));
});
return shepherd;
};

2
routes/shepherd/rpc.js

@ -74,8 +74,8 @@ module.exports = (shepherd) => {
} else {
const _mode = req.body.payload.mode === 'passthru' ? 'passthru' : 'default';
const _chain = req.body.payload.chain === 'KMD' ? null : req.body.payload.chain;
let _cmd = req.body.payload.cmd;
const _params = req.body.payload.params ? ` ${req.body.payload.params}` : '';
let _cmd = req.body.payload.cmd;
if (!shepherd.rpcConf[_chain]) {
shepherd.getConf(req.body.payload.chain === 'KMD' || !req.body.payload.chain && shepherd.kmdMainPassiveMode ? 'komodod' : req.body.payload.chain);

2
version

@ -1,3 +1,3 @@
version=0.2.0.23a
version=0.2.0.24a
type=e-beta
minversion=0.2.0.2
Loading…
Cancel
Save