aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/index.html5
-rw-r--r--src/js/index.js68
2 files changed, 53 insertions, 20 deletions
diff --git a/src/index.html b/src/index.html
index 95fccc1..3ce30b3 100644
--- a/src/index.html
+++ b/src/index.html
@@ -273,7 +273,10 @@
273 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a> 273 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a>
274 </label> 274 </label>
275 <div class="col-sm-10"> 275 <div class="col-sm-10">
276 <input id="change-bip44" type="text" class="change form-control" value="0"> 276 <div class="input-group">
277 <input id="change-bip44" type="text" class="change form-control" value="0">
278 <a class="default-bip44-change-value btn btn-primary input-group-addon" role="button">Default</a>
279 </div>
277 </div> 280 </div>
278 </div> 281 </div>
279 <div class="form-group"> 282 <div class="form-group">
diff --git a/src/js/index.js b/src/js/index.js
index f3302a6..b98d979 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -15,6 +15,7 @@
15 var showPrivKey = true; 15 var showPrivKey = true;
16 var showQr = false; 16 var showQr = false;
17 var litecoinUseLtub = true; 17 var litecoinUseLtub = true;
18 var isDefaultBip44ChangeValue = true;
18 19
19 var entropyChangeTimeoutEvent = null; 20 var entropyChangeTimeoutEvent = null;
20 var phraseChangeTimeoutEvent = null; 21 var phraseChangeTimeoutEvent = null;
@@ -69,6 +70,7 @@
69 DOM.bip44accountXprv = $("#bip44 .account-xprv"); 70 DOM.bip44accountXprv = $("#bip44 .account-xprv");
70 DOM.bip44accountXpub = $("#bip44 .account-xpub"); 71 DOM.bip44accountXpub = $("#bip44 .account-xpub");
71 DOM.bip44change = $("#bip44 .change"); 72 DOM.bip44change = $("#bip44 .change");
73 DOM.defaultBip44ChangeValue = $("#bip44 .default-bip44-change-value");
72 DOM.bip49unavailable = $("#bip49 .unavailable"); 74 DOM.bip49unavailable = $("#bip49 .unavailable");
73 DOM.bip49available = $("#bip49 .available"); 75 DOM.bip49available = $("#bip49 .available");
74 DOM.bip49path = $("#bip49-path"); 76 DOM.bip49path = $("#bip49-path");
@@ -134,7 +136,9 @@
134 DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged); 136 DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged);
135 DOM.bip32path.on("input", calcForDerivationPath); 137 DOM.bip32path.on("input", calcForDerivationPath);
136 DOM.bip44account.on("input", calcForDerivationPath); 138 DOM.bip44account.on("input", calcForDerivationPath);
139 DOM.bip44change.on("input", modifiedDefaultBip44ChangeValue);
137 DOM.bip44change.on("input", calcForDerivationPath); 140 DOM.bip44change.on("input", calcForDerivationPath);
141 DOM.defaultBip44ChangeValue.on("click", resetDefaultBip44ChangeValue);
138 DOM.bip49account.on("input", calcForDerivationPath); 142 DOM.bip49account.on("input", calcForDerivationPath);
139 DOM.bip49change.on("input", calcForDerivationPath); 143 DOM.bip49change.on("input", calcForDerivationPath);
140 DOM.bip84account.on("input", calcForDerivationPath); 144 DOM.bip84account.on("input", calcForDerivationPath);
@@ -726,12 +730,14 @@
726 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44); 730 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
727 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0); 731 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
728 var account = parseIntNoNaN(DOM.bip44account.val(), 0); 732 var account = parseIntNoNaN(DOM.bip44account.val(), 0);
729 var change = parseIntNoNaN(DOM.bip44change.val(), 0); 733 var change = parseIntNoNaN(DOM.bip44change.val(), "");
730 var path = "m/"; 734 var path = "m";
731 path += purpose + "'/"; 735 path += "/" + purpose + "'";
732 path += coin + "'/"; 736 path += "/" + coin + "'";
733 path += account + "'/"; 737 path += "/" + account + "'";
734 path += change; 738 if (change !== "") {
739 path += "/" + change;
740 }
735 DOM.bip44path.val(path); 741 DOM.bip44path.val(path);
736 var derivationPath = DOM.bip44path.val(); 742 var derivationPath = DOM.bip44path.val();
737 console.log("Using derivation path from BIP44 tab: " + derivationPath); 743 console.log("Using derivation path from BIP44 tab: " + derivationPath);
@@ -1008,19 +1014,7 @@
1008 indexText = indexText + "'"; 1014 indexText = indexText + "'";
1009 } 1015 }
1010 // Ethereum values are different 1016 // Ethereum values are different
1011 if ((networks[DOM.network.val()].name == "ETH - Ethereum") 1017 if (networkIsEthereum()) {
1012 || (networks[DOM.network.val()].name == "ETC - Ethereum Classic")
1013 || (networks[DOM.network.val()].name == "PIRL - Pirl")
1014 || (networks[DOM.network.val()].name == "MIX - MIX")
1015 || (networks[DOM.network.val()].name == "MUSIC - Musicoin")
1016 || (networks[DOM.network.val()].name == "POA - Poa")
1017 || (networks[DOM.network.val()].name == "EXP - Expanse")
1018 || (networks[DOM.network.val()].name == "CLO - Callisto")
1019 || (networks[DOM.network.val()].name == "DXN - DEXON")
1020 || (networks[DOM.network.val()].name == "ELLA - Ellaism")
1021 || (networks[DOM.network.val()].name == "ESN - Ethersocial Network")
1022 || (networks[DOM.network.val()].name == "VET - VeChain")
1023 ) {
1024 var privKeyBuffer = keyPair.d.toBuffer(32); 1018 var privKeyBuffer = keyPair.d.toBuffer(32);
1025 privkey = privKeyBuffer.toString('hex'); 1019 privkey = privKeyBuffer.toString('hex');
1026 var addressBuffer = ethUtil.privateToAddress(privKeyBuffer); 1020 var addressBuffer = ethUtil.privateToAddress(privKeyBuffer);
@@ -1636,6 +1630,22 @@
1636 return DOM.bip32tab.hasClass("active"); 1630 return DOM.bip32tab.hasClass("active");
1637 } 1631 }
1638 1632
1633 function networkIsEthereum() {
1634 var name = networks[DOM.network.val()].name;
1635 return (name == "ETH - Ethereum")
1636 || (name == "ETC - Ethereum Classic")
1637 || (name == "PIRL - Pirl")
1638 || (name == "MIX - MIX")
1639 || (name == "MUSIC - Musicoin")
1640 || (name == "POA - Poa")
1641 || (name == "EXP - Expanse")
1642 || (name == "CLO - Callisto")
1643 || (name == "DXN - DEXON")
1644 || (name == "ELLA - Ellaism")
1645 || (name == "ESN - Ethersocial Network")
1646 || (name == "VET - VeChain")
1647 }
1648
1639 function networkHasSegwit() { 1649 function networkHasSegwit() {
1640 var n = network; 1650 var n = network;
1641 if ("baseNetwork" in network) { 1651 if ("baseNetwork" in network) {
@@ -1665,10 +1675,30 @@
1665 return DOM.bip141tab.hasClass("active"); 1675 return DOM.bip141tab.hasClass("active");
1666 } 1676 }
1667 1677
1678 function setBip44ChangeValue() {
1679 if (isDefaultBip44ChangeValue) {
1680 if (networkIsEthereum()) {
1681 DOM.bip44change.val("");
1682 } else {
1683 DOM.bip44change.val(0);
1684 }
1685 }
1686 }
1687
1688 function modifiedDefaultBip44ChangeValue() {
1689 isDefaultBip44ChangeValue = false;
1690 }
1691
1692 function resetDefaultBip44ChangeValue() {
1693 isDefaultBip44ChangeValue = true;
1694 setBip44ChangeValue();
1695 }
1696
1668 function setHdCoin(coinValue) { 1697 function setHdCoin(coinValue) {
1669 DOM.bip44coin.val(coinValue); 1698 DOM.bip44coin.val(coinValue);
1670 DOM.bip49coin.val(coinValue); 1699 DOM.bip49coin.val(coinValue);
1671 DOM.bip84coin.val(coinValue); 1700 DOM.bip84coin.val(coinValue);
1701 setBip44ChangeValue();
1672 } 1702 }
1673 1703
1674 function showSegwitAvailable() { 1704 function showSegwitAvailable() {