Browse Source

wif export fix

pkg_automation_electrum
pbca26 7 years ago
parent
commit
06599079ef
  1. 3
      routes/shepherd/electrum/auth.js
  2. 21
      routes/shepherd/electrum/keys.js

3
routes/shepherd/electrum/auth.js

@ -9,8 +9,6 @@ module.exports = (shepherd) => {
let keys;
let isWif = false;
console.log(_seed);
try {
bs58check.decode(_seed);
isWif = true;
@ -22,7 +20,6 @@ module.exports = (shepherd) => {
priv: key.toWIF(),
pub: key.getAddress(),
};
console.log(keys);
} else {
keys = shepherd.seedToWif(_seed, shepherd.findNetworkObj(_abbr), req.body.iguana);
}

21
routes/shepherd/electrum/keys.js

@ -4,6 +4,7 @@ const crypto = require('crypto');
const bigi = require('bigi');
const bitcoinZcash = require('bitcoinjs-lib-zcash');
const bitcoin = require('bitcoinjs-lib');
const bs58check = require('bs58check');
module.exports = (shepherd) => {
shepherd.seedToWif = (seed, network, iguana) => {
@ -71,10 +72,28 @@ module.exports = (shepherd) => {
let _matchingKeyPairs = 0;
let _totalKeys = 0;
let _electrumKeys = {};
let _seed = req.body.seed;
for (let key in shepherd.electrumServers) {
const _abbr = shepherd.electrumServers[key].abbr;
const { priv, pub } = shepherd.seedToWif(req.body.seed, shepherd.findNetworkObj(_abbr), req.body.iguana);
let isWif = false;
let priv;
let pub;
try {
bs58check.decode(_seed);
isWif = true;
} catch (e) {}
if (isWif) {
let key = shepherd.isZcash(_abbr.toLowerCase()) ? bitcoinZcash.ECPair.fromWIF(_seed, shepherd.getNetworkData(_abbr.toLowerCase()), true) : shepherd.bitcoinJS.ECPair.fromWIF(_seed, shepherd.getNetworkData(_abbr.toLowerCase()), true);
priv = key.toWIF();
pub = key.getAddress();
} else {
let _keys = shepherd.seedToWif(_seed, shepherd.findNetworkObj(_abbr), req.body.iguana);
priv = _keys.priv;
pub = _keys.pub;
}
if (shepherd.electrumKeys[_abbr].pub === pub &&
shepherd.electrumKeys[_abbr].priv === priv) {

Loading…
Cancel
Save