diff options
-rw-r--r-- | src/index.html | 5 | ||||
-rw-r--r-- | src/js/index.js | 70 |
2 files changed, 54 insertions, 21 deletions
diff --git a/src/index.html b/src/index.html index 2684c9f..096274d 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -280,7 +280,10 @@ | |||
280 | <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a> | 280 | <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a> |
281 | </label> | 281 | </label> |
282 | <div class="col-sm-10"> | 282 | <div class="col-sm-10"> |
283 | <input id="change-bip44" type="text" class="change form-control" value="0"> | 283 | <div class="input-group"> |
284 | <input id="change-bip44" type="text" class="change form-control" value="0"> | ||
285 | <a class="default-bip44-change-value btn btn-primary input-group-addon" role="button">Default</a> | ||
286 | </div> | ||
284 | </div> | 287 | </div> |
285 | </div> | 288 | </div> |
286 | <div class="form-group"> | 289 | <div class="form-group"> |
diff --git a/src/js/index.js b/src/js/index.js index 9ace962..23eaa47 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; |
@@ -71,6 +72,7 @@ | |||
71 | DOM.bip44accountXprv = $("#bip44 .account-xprv"); | 72 | DOM.bip44accountXprv = $("#bip44 .account-xprv"); |
72 | DOM.bip44accountXpub = $("#bip44 .account-xpub"); | 73 | DOM.bip44accountXpub = $("#bip44 .account-xpub"); |
73 | DOM.bip44change = $("#bip44 .change"); | 74 | DOM.bip44change = $("#bip44 .change"); |
75 | DOM.defaultBip44ChangeValue = $("#bip44 .default-bip44-change-value"); | ||
74 | DOM.bip49unavailable = $("#bip49 .unavailable"); | 76 | DOM.bip49unavailable = $("#bip49 .unavailable"); |
75 | DOM.bip49available = $("#bip49 .available"); | 77 | DOM.bip49available = $("#bip49 .available"); |
76 | DOM.bip49path = $("#bip49-path"); | 78 | DOM.bip49path = $("#bip49-path"); |
@@ -136,7 +138,9 @@ | |||
136 | DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged); | 138 | DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged); |
137 | DOM.bip32path.on("input", calcForDerivationPath); | 139 | DOM.bip32path.on("input", calcForDerivationPath); |
138 | DOM.bip44account.on("input", calcForDerivationPath); | 140 | DOM.bip44account.on("input", calcForDerivationPath); |
141 | DOM.bip44change.on("input", modifiedDefaultBip44ChangeValue); | ||
139 | DOM.bip44change.on("input", calcForDerivationPath); | 142 | DOM.bip44change.on("input", calcForDerivationPath); |
143 | DOM.defaultBip44ChangeValue.on("click", resetDefaultBip44ChangeValue); | ||
140 | DOM.bip49account.on("input", calcForDerivationPath); | 144 | DOM.bip49account.on("input", calcForDerivationPath); |
141 | DOM.bip49change.on("input", calcForDerivationPath); | 145 | DOM.bip49change.on("input", calcForDerivationPath); |
142 | DOM.bip84account.on("input", calcForDerivationPath); | 146 | DOM.bip84account.on("input", calcForDerivationPath); |
@@ -739,12 +743,14 @@ | |||
739 | var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44); | 743 | var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44); |
740 | var coin = parseIntNoNaN(DOM.bip44coin.val(), 0); | 744 | var coin = parseIntNoNaN(DOM.bip44coin.val(), 0); |
741 | var account = parseIntNoNaN(DOM.bip44account.val(), 0); | 745 | var account = parseIntNoNaN(DOM.bip44account.val(), 0); |
742 | var change = parseIntNoNaN(DOM.bip44change.val(), 0); | 746 | var change = parseIntNoNaN(DOM.bip44change.val(), ""); |
743 | var path = "m/"; | 747 | var path = "m"; |
744 | path += purpose + "'/"; | 748 | path += "/" + purpose + "'"; |
745 | path += coin + "'/"; | 749 | path += "/" + coin + "'"; |
746 | path += account + "'/"; | 750 | path += "/" + account + "'"; |
747 | path += change; | 751 | if (change !== "") { |
752 | path += "/" + change; | ||
753 | } | ||
748 | DOM.bip44path.val(path); | 754 | DOM.bip44path.val(path); |
749 | var derivationPath = DOM.bip44path.val(); | 755 | var derivationPath = DOM.bip44path.val(); |
750 | console.log("Using derivation path from BIP44 tab: " + derivationPath); | 756 | console.log("Using derivation path from BIP44 tab: " + derivationPath); |
@@ -1034,20 +1040,7 @@ | |||
1034 | indexText = indexText + "'"; | 1040 | indexText = indexText + "'"; |
1035 | } | 1041 | } |
1036 | // Ethereum values are different | 1042 | // Ethereum values are different |
1037 | if ((networks[DOM.network.val()].name == "ETH - Ethereum") | 1043 | if (networkIsEthereum()) { |
1038 | || (networks[DOM.network.val()].name == "ETC - Ethereum Classic") | ||
1039 | || (networks[DOM.network.val()].name == "EWT - EnergyWeb") | ||
1040 | || (networks[DOM.network.val()].name == "PIRL - Pirl") | ||
1041 | || (networks[DOM.network.val()].name == "MIX - MIX") | ||
1042 | || (networks[DOM.network.val()].name == "MUSIC - Musicoin") | ||
1043 | || (networks[DOM.network.val()].name == "POA - Poa") | ||
1044 | || (networks[DOM.network.val()].name == "EXP - Expanse") | ||
1045 | || (networks[DOM.network.val()].name == "CLO - Callisto") | ||
1046 | || (networks[DOM.network.val()].name == "DXN - DEXON") | ||
1047 | || (networks[DOM.network.val()].name == "ELLA - Ellaism") | ||
1048 | || (networks[DOM.network.val()].name == "ESN - Ethersocial Network") | ||
1049 | || (networks[DOM.network.val()].name == "VET - VeChain") | ||
1050 | ) { | ||
1051 | var privKeyBuffer = keyPair.d.toBuffer(32); | 1044 | var privKeyBuffer = keyPair.d.toBuffer(32); |
1052 | privkey = privKeyBuffer.toString('hex'); | 1045 | privkey = privKeyBuffer.toString('hex'); |
1053 | var addressBuffer = ethUtil.privateToAddress(privKeyBuffer); | 1046 | var addressBuffer = ethUtil.privateToAddress(privKeyBuffer); |
@@ -1711,6 +1704,23 @@ | |||
1711 | return DOM.bip32tab.hasClass("active"); | 1704 | return DOM.bip32tab.hasClass("active"); |
1712 | } | 1705 | } |
1713 | 1706 | ||
1707 | function networkIsEthereum() { | ||
1708 | var name = networks[DOM.network.val()].name; | ||
1709 | return (name == "ETH - Ethereum") | ||
1710 | || (name == "ETC - Ethereum Classic") | ||
1711 | || (name == "EWT - EnergyWeb") | ||
1712 | || (name == "PIRL - Pirl") | ||
1713 | || (name == "MIX - MIX") | ||
1714 | || (name == "MUSIC - Musicoin") | ||
1715 | || (name == "POA - Poa") | ||
1716 | || (name == "EXP - Expanse") | ||
1717 | || (name == "CLO - Callisto") | ||
1718 | || (name == "DXN - DEXON") | ||
1719 | || (name == "ELLA - Ellaism") | ||
1720 | || (name == "ESN - Ethersocial Network") | ||
1721 | || (name == "VET - VeChain") | ||
1722 | } | ||
1723 | |||
1714 | function networkHasSegwit() { | 1724 | function networkHasSegwit() { |
1715 | var n = network; | 1725 | var n = network; |
1716 | if ("baseNetwork" in network) { | 1726 | if ("baseNetwork" in network) { |
@@ -1740,10 +1750,30 @@ | |||
1740 | return DOM.bip141tab.hasClass("active"); | 1750 | return DOM.bip141tab.hasClass("active"); |
1741 | } | 1751 | } |
1742 | 1752 | ||
1753 | function setBip44ChangeValue() { | ||
1754 | if (isDefaultBip44ChangeValue) { | ||
1755 | if (networkIsEthereum()) { | ||
1756 | DOM.bip44change.val(""); | ||
1757 | } else { | ||
1758 | DOM.bip44change.val(0); | ||
1759 | } | ||
1760 | } | ||
1761 | } | ||
1762 | |||
1763 | function modifiedDefaultBip44ChangeValue() { | ||
1764 | isDefaultBip44ChangeValue = false; | ||
1765 | } | ||
1766 | |||
1767 | function resetDefaultBip44ChangeValue() { | ||
1768 | isDefaultBip44ChangeValue = true; | ||
1769 | setBip44ChangeValue(); | ||
1770 | } | ||
1771 | |||
1743 | function setHdCoin(coinValue) { | 1772 | function setHdCoin(coinValue) { |
1744 | DOM.bip44coin.val(coinValue); | 1773 | DOM.bip44coin.val(coinValue); |
1745 | DOM.bip49coin.val(coinValue); | 1774 | DOM.bip49coin.val(coinValue); |
1746 | DOM.bip84coin.val(coinValue); | 1775 | DOM.bip84coin.val(coinValue); |
1776 | setBip44ChangeValue(); | ||
1747 | } | 1777 | } |
1748 | 1778 | ||
1749 | function showSegwitAvailable() { | 1779 | function showSegwitAvailable() { |