diff options
-rw-r--r-- | src/index.html | 5 | ||||
-rw-r--r-- | src/js/index.js | 38 |
2 files changed, 36 insertions, 7 deletions
diff --git a/src/index.html b/src/index.html index 0588171..491b4be 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -431,7 +431,10 @@ | |||
431 | <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a> | 431 | <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a> |
432 | </label> | 432 | </label> |
433 | <div class="col-sm-10"> | 433 | <div class="col-sm-10"> |
434 | <input id="change-bip44" type="text" class="change form-control" value="0"> | 434 | <div class="input-group"> |
435 | <input id="change-bip44" type="text" class="change form-control" value="0"> | ||
436 | <a class="default-bip44-change-value btn btn-primary input-group-addon" role="button">Default</a> | ||
437 | </div> | ||
435 | </div> | 438 | </div> |
436 | </div> | 439 | </div> |
437 | <div class="form-group"> | 440 | <div class="form-group"> |
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() { |