diff options
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/index.js | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/js/index.js b/src/js/index.js index c502208..68c74f6 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 entropyTypeAutoDetect = true; | 20 | var entropyTypeAutoDetect = true; |
20 | var entropyChangeTimeoutEvent = null; | 21 | var entropyChangeTimeoutEvent = null; |
@@ -76,6 +77,7 @@ | |||
76 | DOM.bip44accountXprv = $("#bip44 .account-xprv"); | 77 | DOM.bip44accountXprv = $("#bip44 .account-xprv"); |
77 | DOM.bip44accountXpub = $("#bip44 .account-xpub"); | 78 | DOM.bip44accountXpub = $("#bip44 .account-xpub"); |
78 | DOM.bip44change = $("#bip44 .change"); | 79 | DOM.bip44change = $("#bip44 .change"); |
80 | DOM.defaultBip44ChangeValue = $("#bip44 .default-bip44-change-value"); | ||
79 | DOM.bip49unavailable = $("#bip49 .unavailable"); | 81 | DOM.bip49unavailable = $("#bip49 .unavailable"); |
80 | DOM.bip49available = $("#bip49 .available"); | 82 | DOM.bip49available = $("#bip49 .available"); |
81 | DOM.bip49path = $("#bip49-path"); | 83 | DOM.bip49path = $("#bip49-path"); |
@@ -157,7 +159,9 @@ | |||
157 | DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged); | 159 | DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged); |
158 | DOM.bip32path.on("input", calcForDerivationPath); | 160 | DOM.bip32path.on("input", calcForDerivationPath); |
159 | DOM.bip44account.on("input", calcForDerivationPath); | 161 | DOM.bip44account.on("input", calcForDerivationPath); |
162 | DOM.bip44change.on("input", modifiedDefaultBip44ChangeValue); | ||
160 | DOM.bip44change.on("input", calcForDerivationPath); | 163 | DOM.bip44change.on("input", calcForDerivationPath); |
164 | DOM.defaultBip44ChangeValue.on("click", resetDefaultBip44ChangeValue); | ||
161 | DOM.bip49account.on("input", calcForDerivationPath); | 165 | DOM.bip49account.on("input", calcForDerivationPath); |
162 | DOM.bip49change.on("input", calcForDerivationPath); | 166 | DOM.bip49change.on("input", calcForDerivationPath); |
163 | DOM.bip84account.on("input", calcForDerivationPath); | 167 | DOM.bip84account.on("input", calcForDerivationPath); |
@@ -924,12 +928,14 @@ | |||
924 | var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44); | 928 | var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44); |
925 | var coin = parseIntNoNaN(DOM.bip44coin.val(), 0); | 929 | var coin = parseIntNoNaN(DOM.bip44coin.val(), 0); |
926 | var account = parseIntNoNaN(DOM.bip44account.val(), 0); | 930 | var account = parseIntNoNaN(DOM.bip44account.val(), 0); |
927 | var change = parseIntNoNaN(DOM.bip44change.val(), 0); | 931 | var change = parseIntNoNaN(DOM.bip44change.val(), ""); |
928 | var path = "m/"; | 932 | var path = "m"; |
929 | path += purpose + "'/"; | 933 | path += "/" + purpose + "'"; |
930 | path += coin + "'/"; | 934 | path += "/" + coin + "'"; |
931 | path += account + "'/"; | 935 | path += "/" + account + "'"; |
932 | path += change; | 936 | if (change !== "") { |
937 | path += "/" + change; | ||
938 | } | ||
933 | DOM.bip44path.val(path); | 939 | DOM.bip44path.val(path); |
934 | var derivationPath = DOM.bip44path.val(); | 940 | var derivationPath = DOM.bip44path.val(); |
935 | console.log("Using derivation path from BIP44 tab: " + derivationPath); | 941 | console.log("Using derivation path from BIP44 tab: " + derivationPath); |
@@ -2074,10 +2080,30 @@ | |||
2074 | return DOM.bip141tab.hasClass("active"); | 2080 | return DOM.bip141tab.hasClass("active"); |
2075 | } | 2081 | } |
2076 | 2082 | ||
2083 | function setBip44ChangeValue() { | ||
2084 | if (isDefaultBip44ChangeValue) { | ||
2085 | if (networkIsEthereum()) { | ||
2086 | DOM.bip44change.val(""); | ||
2087 | } else { | ||
2088 | DOM.bip44change.val(0); | ||
2089 | } | ||
2090 | } | ||
2091 | } | ||
2092 | |||
2093 | function modifiedDefaultBip44ChangeValue() { | ||
2094 | isDefaultBip44ChangeValue = false; | ||
2095 | } | ||
2096 | |||
2097 | function resetDefaultBip44ChangeValue() { | ||
2098 | isDefaultBip44ChangeValue = true; | ||
2099 | setBip44ChangeValue(); | ||
2100 | } | ||
2101 | |||
2077 | function setHdCoin(coinValue) { | 2102 | function setHdCoin(coinValue) { |
2078 | DOM.bip44coin.val(coinValue); | 2103 | DOM.bip44coin.val(coinValue); |
2079 | DOM.bip49coin.val(coinValue); | 2104 | DOM.bip49coin.val(coinValue); |
2080 | DOM.bip84coin.val(coinValue); | 2105 | DOM.bip84coin.val(coinValue); |
2106 | setBip44ChangeValue(); | ||
2081 | } | 2107 | } |
2082 | 2108 | ||
2083 | function showSegwitAvailable() { | 2109 | function showSegwitAvailable() { |