Browse Source

seed to wif update, wif to wif conversion

pkg_automation_electrum
pbca26 7 years ago
parent
commit
ef35fcf913
  1. 4
      package.json
  2. 10
      routes/electrumjs/electrumjs.networks.js
  3. 18
      routes/shepherd/electrum/auth.js
  4. 2
      routes/shepherd/electrum/keys.js
  5. 4
      version
  6. 2
      version_build

4
package.json

@ -33,8 +33,8 @@
"bigi": "^1.4.2",
"bip39": "^2.4.0",
"bitcoinforksjs-lib": "git://github.com/bitcoinjs/bitcoinjs-lib#opt-in-bitcoincash-sighash",
"bitcoinjs-lib": "^3.2.0",
"bitcoinjs-lib-zcash": "git://github.com/karel-3d/bitcoinjs-lib#zcash",
"bitcoinjs-lib": "git://github.com/SuperNETorg/bitcoinjs-lib",
"bitcoinjs-lib-zcash": "git://github.com/pbca26/bitcoinjs-lib#zcash",
"bitcoinjs-lib-pos": "git://github.com/KomodoPlatform/bitcoinjs-lib-pos",
"bluebird": "^3.4.7",
"body-parser": "^1.15.2",

10
routes/electrumjs/electrumjs.networks.js

@ -269,4 +269,12 @@ networks.btc = networks.bitcoin;
networks.crw = networks.crown;
networks.dgb = networks.digibyte;
networks.arg = networks.argentum;
networks.zec = networks.zcash;
networks.zec = networks.zcash;
networks.nmc = networks.namecoin;
networks.ltc = networks.litecoin;
networks.vtc = networks.vertcoin;
networks.via = networks.viacoin;
networks.fair = networks.faircoin;
networks.doge = networks.dogecoin;
networks.kmd = networks.komodo;
networks.mona = networks.monacoin;

18
routes/shepherd/electrum/auth.js

@ -1,18 +1,28 @@
const bs58check = require('bs58check');
const bitcoinZcash = require('bitcoinjs-lib-zcash');
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;
let isWif = false;
console.log(_seed);
try {
bs58check.decode(_seed);
isWif = true;
} catch (e) {}
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);
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);
keys = {
priv: key.toWIF(),
pub: key.getAddress(),
};
console.log(keys);
} else {
keys = shepherd.seedToWif(_seed, shepherd.findNetworkObj(_abbr), req.body.iguana);
}

2
routes/shepherd/electrum/keys.js

@ -38,7 +38,7 @@ module.exports = (shepherd) => {
}
shepherd.get('/electrum/wiftopub', (req, res, next) => {
let key = shepherd.bitcoinJS.ECPair.fromWIF(req.query.wif, shepherd.electrumJSNetworks[req.query.coin]);
let key = shepherd.isZcash(req.query.coin.toLowerCase()) ? bitcoinZcash.ECPair.fromWIF(req.query.wif, shepherd.electrumJSNetworks[req.query.coin], true) : shepherd.bitcoinJS.ECPair.fromWIF(req.query.wif, shepherd.electrumJSNetworks[req.query.coin], true);
keys = {
priv: key.toWIF(),
pub: key.getAddress(),

4
version

@ -1,3 +1,3 @@
version=0.2.0.25i
type=i-beta
version=0.2.0.25j
type=j-beta
minversion=0.2.0.2

2
version_build

@ -1 +1 @@
0.2.0.25i-beta
0.2.0.25j-beta
Loading…
Cancel
Save