var showPrivKey = true;
var showQr = false;
var litecoinUseLtub = true;
+ var isDefaultBip44ChangeValue = true;
var entropyChangeTimeoutEvent = null;
var phraseChangeTimeoutEvent = null;
DOM.bip44accountXprv = $("#bip44 .account-xprv");
DOM.bip44accountXpub = $("#bip44 .account-xpub");
DOM.bip44change = $("#bip44 .change");
+ DOM.defaultBip44ChangeValue = $("#bip44 .default-bip44-change-value");
DOM.bip49unavailable = $("#bip49 .unavailable");
DOM.bip49available = $("#bip49 .available");
DOM.bip49path = $("#bip49-path");
DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged);
DOM.bip32path.on("input", calcForDerivationPath);
DOM.bip44account.on("input", calcForDerivationPath);
+ DOM.bip44change.on("input", modifiedDefaultBip44ChangeValue);
DOM.bip44change.on("input", calcForDerivationPath);
+ DOM.defaultBip44ChangeValue.on("click", resetDefaultBip44ChangeValue);
DOM.bip49account.on("input", calcForDerivationPath);
DOM.bip49change.on("input", calcForDerivationPath);
DOM.bip84account.on("input", calcForDerivationPath);
function calcBip32RootKeyFromSeed(phrase, passphrase) {
seed = mnemonic.toSeed(phrase, passphrase);
bip32RootKey = bitcoinjs.bitcoin.HDNode.fromSeedHex(seed, network);
+ if(isGRS())
+ bip32RootKey = groestlcoinjs.HDNode.fromSeedHex(seed, network);
+
}
function calcBip32RootKeyFromBase58(rootKeyBase58) {
+ if(isGRS()) {
+ calcBip32RootKeyFromBase58GRS(rootKeyBase58);
+ return;
+ }
// try parsing with various segwit network params since this extended
// key may be from any one of them.
if (networkHasSegwit()) {
bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
}
+ function calcBip32RootKeyFromBase58GRS(rootKeyBase58) {
+ // try parsing with various segwit network params since this extended
+ // key may be from any one of them.
+ if (networkHasSegwit()) {
+ var n = network;
+ if ("baseNetwork" in n) {
+ n = bitcoinjs.bitcoin.networks[n.baseNetwork];
+ }
+ // try parsing using base network params
+ try {
+ bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n);
+ return;
+ }
+ catch (e) {}
+ // try parsing using p2wpkh params
+ if ("p2wpkh" in n) {
+ try {
+ bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
+ return;
+ }
+ catch (e) {}
+ }
+ // try parsing using p2wpkh-in-p2sh network params
+ if ("p2wpkhInP2sh" in n) {
+ try {
+ bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
+ return;
+ }
+ catch (e) {}
+ }
+ }
+ // try the network params as currently specified
+ bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, network);
+ }
+
function calcBip32ExtendedKey(path) {
// Check there's a root key to derive from
if (!bip32RootKey) {
}
function validateRootKey(rootKeyBase58) {
+ if(isGRS())
+ return validateRootKeyGRS(rootKeyBase58);
+
// try various segwit network params since this extended key may be from
// any one of them.
if (networkHasSegwit()) {
return "";
}
+ function validateRootKeyGRS(rootKeyBase58) {
+ // try various segwit network params since this extended key may be from
+ // any one of them.
+ if (networkHasSegwit()) {
+ var n = network;
+ if ("baseNetwork" in n) {
+ n = bitcoinjs.bitcoin.networks[n.baseNetwork];
+ }
+ // try parsing using base network params
+ try {
+ groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n);
+ return "";
+ }
+ catch (e) {}
+ // try parsing using p2wpkh params
+ if ("p2wpkh" in n) {
+ try {
+ groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
+ return "";
+ }
+ catch (e) {}
+ }
+ // try parsing using p2wpkh-in-p2sh network params
+ if ("p2wpkhInP2sh" in n) {
+ try {
+ groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
+ return "";
+ }
+ catch (e) {}
+ }
+ }
+ // try the network params as currently specified
+ try {
+ groestlcoinjs.HDNode.fromBase58(rootKeyBase58, network);
+ }
+ catch (e) {
+ return "Invalid root key";
+ }
+ return "";
+ }
+
function getDerivationPath() {
if (bip44TabSelected()) {
var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
var account = parseIntNoNaN(DOM.bip44account.val(), 0);
- var change = parseIntNoNaN(DOM.bip44change.val(), 0);
- var path = "m/";
- path += purpose + "'/";
- path += coin + "'/";
- path += account + "'/";
- path += change;
+ var change = parseIntNoNaN(DOM.bip44change.val(), "");
+ var path = "m";
+ path += "/" + purpose + "'";
+ path += "/" + coin + "'";
+ path += "/" + account + "'";
+ if (change !== "") {
+ path += "/" + change;
+ }
DOM.bip44path.val(path);
var derivationPath = DOM.bip44path.val();
console.log("Using derivation path from BIP44 tab: " + derivationPath);
return false;
}
+ function isGRS() {
+ return networks[DOM.network.val()].name == "GRS - Groestlcoin" || networks[DOM.network.val()].name == "GRS - Groestlcoin Testnet";
+ }
+
function displayBip44Info() {
// Get the derivation path for the account
var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
var useUncompressed = useBip38;
if (useUncompressed) {
keyPair = new bitcoinjs.bitcoin.ECPair(keyPair.d, null, { network: network, compressed: false });
+ if(isGRS())
+ keyPair = new groestlcoinjs.ECPair(keyPair.d, null, { network: network, compressed: false });
+
}
// get address
var address = keyPair.getAddress().toString();
privkey = keyPair.toWIF();
// BIP38 encode private key if required
if (useBip38) {
- privkey = bitcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
- console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
- });
+ if(isGRS())
+ privkey = groestlcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
+ console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
+ }, null, networks[DOM.network.val()].name.includes("Testnet"));
+ else
+ privkey = bitcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
+ console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
+ });
}
}
// get pubkey
indexText = indexText + "'";
}
// Ethereum values are different
- if ((networks[DOM.network.val()].name == "ETH - Ethereum")
- || (networks[DOM.network.val()].name == "ETC - Ethereum Classic")
- || (networks[DOM.network.val()].name == "PIRL - Pirl")
- || (networks[DOM.network.val()].name == "MIX - MIX")
- || (networks[DOM.network.val()].name == "MUSIC - Musicoin")
- || (networks[DOM.network.val()].name == "POA - Poa")
- || (networks[DOM.network.val()].name == "EXP - Expanse")
- || (networks[DOM.network.val()].name == "CLO - Callisto")
- || (networks[DOM.network.val()].name == "DXN - DEXON")
- || (networks[DOM.network.val()].name == "ELLA - Ellaism")
- || (networks[DOM.network.val()].name == "ESN - Ethersocial Network")
- || (networks[DOM.network.val()].name == "VET - VeChain")
- ) {
+ if (networkIsEthereum()) {
var privKeyBuffer = keyPair.d.toBuffer(32);
privkey = privKeyBuffer.toString('hex');
var addressBuffer = ethUtil.privateToAddress(privKeyBuffer);
privkey = eosUtil.bufferToPrivate(keyPair.d.toBuffer(32));
}
+ //Groestlcoin Addresses are different
+ if(isGRS()) {
+
+ if (isSegwit) {
+ if (!segwitAvailable) {
+ return;
+ }
+ if (isP2wpkh) {
+ address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network)
+ }
+ else if (isP2wpkhInP2sh) {
+ address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network)
+ }
+ }
+ //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
+ }
+
addAddressToList(indexText, address, pubkey, privkey);
if (isLast) {
hidePending();
return DOM.bip32tab.hasClass("active");
}
+ function networkIsEthereum() {
+ var name = networks[DOM.network.val()].name;
+ return (name == "ETH - Ethereum")
+ || (name == "ETC - Ethereum Classic")
+ || (name == "PIRL - Pirl")
+ || (name == "MIX - MIX")
+ || (name == "MUSIC - Musicoin")
+ || (name == "POA - Poa")
+ || (name == "EXP - Expanse")
+ || (name == "CLO - Callisto")
+ || (name == "DXN - DEXON")
+ || (name == "ELLA - Ellaism")
+ || (name == "ESN - Ethersocial Network")
+ || (name == "VET - VeChain")
+ }
+
function networkHasSegwit() {
var n = network;
if ("baseNetwork" in network) {
return DOM.bip141tab.hasClass("active");
}
+ function setBip44ChangeValue() {
+ if (isDefaultBip44ChangeValue) {
+ if (networkIsEthereum()) {
+ DOM.bip44change.val("");
+ } else {
+ DOM.bip44change.val(0);
+ }
+ }
+ }
+
+ function modifiedDefaultBip44ChangeValue() {
+ isDefaultBip44ChangeValue = false;
+ }
+
+ function resetDefaultBip44ChangeValue() {
+ isDefaultBip44ChangeValue = true;
+ setBip44ChangeValue();
+ }
+
function setHdCoin(coinValue) {
DOM.bip44coin.val(coinValue);
DOM.bip49coin.val(coinValue);
DOM.bip84coin.val(coinValue);
+ setBip44ChangeValue();
}
function showSegwitAvailable() {
setHdCoin(161);
},
},
+ {
+ name: "ARYA - Aryacoin",
+ onSelect: function() {
+ network = bitcoinjs.bitcoin.networks.aryacoin;
+ setHdCoin(357);
+ },
+ },
{
name: "AUR - Auroracoin",
onSelect: function() {
setHdCoin(183);
},
},
+ {
+ name: "BSV - BitcoinSV",
+ onSelect: function() {
+ network = bitcoinjs.bitcoin.networks.bitcoinsv;
+ setHdCoin(236);
+ },
+ },
{
name: "BTCZ - Bitcoinz",
onSelect: function() {
setHdCoin(84);
},
},
+ {
+ name: "GRS - Groestlcoin",
+ onSelect: function() {
+ network = bitcoinjs.bitcoin.networks.groestlcoin;
+ setHdCoin(17);
+ },
+ },
+ {
+ name: "GRS - Groestlcoin Testnet",
+ onSelect: function() {
+ network = bitcoinjs.bitcoin.networks.groestlcointestnet;
+ setHdCoin(1);
+ },
+ },
{
name: "HNC - Helleniccoin",
onSelect: function() {
setHdCoin(22);
},
},
+ {
+ name: "MONK - Monkey Project",
+ onSelect: function() {
+ network = bitcoinjs.bitcoin.networks.monkeyproject,
+ setHdCoin(214);
+ },
+ },
{
name: "MUSIC - Musicoin",
segwitAvailable: false,
setHdCoin(122);
},
},
+ {
+ name: "RPD - Rapids",
+ onSelect: function() {
+ network = bitcoinjs.bitcoin.networks.rapids;
+ setHdCoin(320);
+ },
+ },
{
name: "RVN - Ravencoin",
onSelect: function() {
},
},
{
- name: "ZEN - Zencash",
+ name: "ZEN - Horizen",
onSelect: function() {
network = bitcoinjs.bitcoin.networks.zencash;
setHdCoin(121);