|
|
@ -2,18 +2,19 @@ module.exports = (shepherd) => { |
|
|
|
shepherd.post('/electrum/login', (req, res, next) => { |
|
|
|
for (let key in shepherd.electrumServers) { |
|
|
|
const _abbr = shepherd.electrumServers[key].abbr; |
|
|
|
const _seed = req.body.seed; |
|
|
|
let keys; |
|
|
|
|
|
|
|
if (req.body.seed.length === 52 && |
|
|
|
req.body.seed.indexOf(' ') === -1 && |
|
|
|
req.body.seed.match(/^[a-zA-Z0-9]*$/)) { |
|
|
|
let key = shepherd.bitcoinJS.ECPair.fromWIF(req.body.seed, shepherd.electrumJSNetworks.komodo); |
|
|
|
if ((_seed.length === 51 || _seed.length === 52) && |
|
|
|
_seed.indexOf(' ') === -1 && |
|
|
|
_seed.match(/^[a-zA-Z0-9]*$/)) { |
|
|
|
let key = shepherd.bitcoinJS.ECPair.fromWIF(_seed, shepherd.electrumJSNetworks.komodo); |
|
|
|
keys = { |
|
|
|
priv: key.toWIF(), |
|
|
|
pub: key.getAddress(), |
|
|
|
}; |
|
|
|
} else { |
|
|
|
keys = shepherd.seedToWif(req.body.seed, shepherd.findNetworkObj(_abbr), req.body.iguana, req.body.old); |
|
|
|
keys = shepherd.seedToWif(_seed, shepherd.findNetworkObj(_abbr), req.body.iguana); |
|
|
|
} |
|
|
|
|
|
|
|
shepherd.electrumKeys[_abbr] = { |
|
|
|