diff options
-rw-r--r-- | src/index.html | 9 | ||||
-rw-r--r-- | src/js/bitcoinjs-3-1-1.js | 12 | ||||
-rw-r--r-- | src/js/index.js | 17 | ||||
-rw-r--r-- | tests.js | 51 |
4 files changed, 88 insertions, 1 deletions
diff --git a/src/index.html b/src/index.html index 21f070f..a48079e 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -266,6 +266,15 @@ | |||
266 | <textarea id="root-key" class="root-key form-control" data-show-qr></textarea> | 266 | <textarea id="root-key" class="root-key form-control" data-show-qr></textarea> |
267 | </div> | 267 | </div> |
268 | </div> | 268 | </div> |
269 | <div class="form-group litecoin-ltub-container hidden"> | ||
270 | <label for="litecoin-use-ltub" class="col-sm-2 control-label" data-translate>Prefixes</label> | ||
271 | <div class="col-sm-10 checkbox"> | ||
272 | <label> | ||
273 | <input type="checkbox" id="litecoin-use-ltub" class="litecoin-use-ltub"> | ||
274 | Use <code>Ltpv / Ltub</code> instead of <code>xprv / xpub</code> | ||
275 | </label> | ||
276 | </div> | ||
277 | </div> | ||
269 | </form> | 278 | </form> |
270 | </div> | 279 | </div> |
271 | </div> | 280 | </div> |
diff --git a/src/js/bitcoinjs-3-1-1.js b/src/js/bitcoinjs-3-1-1.js index e75e15d..e184686 100644 --- a/src/js/bitcoinjs-3-1-1.js +++ b/src/js/bitcoinjs-3-1-1.js | |||
@@ -9651,6 +9651,16 @@ module.exports = { | |||
9651 | litecoin: { | 9651 | litecoin: { |
9652 | messagePrefix: '\x19Litecoin Signed Message:\n', | 9652 | messagePrefix: '\x19Litecoin Signed Message:\n', |
9653 | bip32: { | 9653 | bip32: { |
9654 | public: 0x0488b21e, | ||
9655 | private: 0x0488ade4, | ||
9656 | }, | ||
9657 | pubKeyHash: 0x30, | ||
9658 | scriptHash: 0x32, | ||
9659 | wif: 0xb0 | ||
9660 | }, | ||
9661 | litecoinLtub: { | ||
9662 | messagePrefix: '\x19Litecoin Signed Message:\n', | ||
9663 | bip32: { | ||
9654 | public: 0x019da462, | 9664 | public: 0x019da462, |
9655 | private: 0x019d9cfe | 9665 | private: 0x019d9cfe |
9656 | }, | 9666 | }, |
@@ -14827,4 +14837,4 @@ module.exports = { | |||
14827 | 14837 | ||
14828 | }).call(this,require("buffer").Buffer) | 14838 | }).call(this,require("buffer").Buffer) |
14829 | },{"bs58check":80,"buffer":4}]},{},[33])(33) | 14839 | },{"bs58check":80,"buffer":4}]},{},[33])(33) |
14830 | }); \ No newline at end of file | 14840 | }); |
diff --git a/src/js/index.js b/src/js/index.js index d9d5db3..80c7fa8 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -14,6 +14,7 @@ | |||
14 | var showPubKey = true; | 14 | var showPubKey = true; |
15 | var showPrivKey = true; | 15 | var showPrivKey = true; |
16 | var showQr = false; | 16 | var showQr = false; |
17 | var litecoinUseLtub = false; | ||
17 | 18 | ||
18 | var entropyChangeTimeoutEvent = null; | 19 | var entropyChangeTimeoutEvent = null; |
19 | var phraseChangeTimeoutEvent = null; | 20 | var phraseChangeTimeoutEvent = null; |
@@ -43,6 +44,8 @@ | |||
43 | DOM.generate = $(".generate"); | 44 | DOM.generate = $(".generate"); |
44 | DOM.seed = $(".seed"); | 45 | DOM.seed = $(".seed"); |
45 | DOM.rootKey = $(".root-key"); | 46 | DOM.rootKey = $(".root-key"); |
47 | DOM.litecoinLtubContainer = $(".litecoin-ltub-container"); | ||
48 | DOM.litecoinUseLtub = $(".litecoin-use-ltub"); | ||
46 | DOM.extendedPrivKey = $(".extended-priv-key"); | 49 | DOM.extendedPrivKey = $(".extended-priv-key"); |
47 | DOM.extendedPubKey = $(".extended-pub-key"); | 50 | DOM.extendedPubKey = $(".extended-pub-key"); |
48 | DOM.bip32tab = $("#bip32-tab"); | 51 | DOM.bip32tab = $("#bip32-tab"); |
@@ -98,6 +101,7 @@ | |||
98 | DOM.generate.on("click", generateClicked); | 101 | DOM.generate.on("click", generateClicked); |
99 | DOM.more.on("click", showMore); | 102 | DOM.more.on("click", showMore); |
100 | DOM.rootKey.on("input", delayedRootKeyChanged); | 103 | DOM.rootKey.on("input", delayedRootKeyChanged); |
104 | DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged); | ||
101 | DOM.bip32path.on("input", calcForDerivationPath); | 105 | DOM.bip32path.on("input", calcForDerivationPath); |
102 | DOM.bip44account.on("input", calcForDerivationPath); | 106 | DOM.bip44account.on("input", calcForDerivationPath); |
103 | DOM.bip44change.on("input", calcForDerivationPath); | 107 | DOM.bip44change.on("input", calcForDerivationPath); |
@@ -123,6 +127,7 @@ | |||
123 | function networkChanged(e) { | 127 | function networkChanged(e) { |
124 | clearDerivedKeys(); | 128 | clearDerivedKeys(); |
125 | clearAddressesList(); | 129 | clearAddressesList(); |
130 | DOM.litecoinLtubContainer.addClass("hidden"); | ||
126 | var networkIndex = e.target.value; | 131 | var networkIndex = e.target.value; |
127 | var network = networks[networkIndex]; | 132 | var network = networks[networkIndex]; |
128 | network.onSelect(); | 133 | network.onSelect(); |
@@ -274,6 +279,17 @@ | |||
274 | calcForDerivationPath(); | 279 | calcForDerivationPath(); |
275 | } | 280 | } |
276 | 281 | ||
282 | function litecoinUseLtubChanged() { | ||
283 | litecoinUseLtub = DOM.litecoinUseLtub.prop("checked"); | ||
284 | if (litecoinUseLtub) { | ||
285 | network = bitcoinjs.bitcoin.networks.litecoinLtub; | ||
286 | } | ||
287 | else { | ||
288 | network = bitcoinjs.bitcoin.networks.litecoin; | ||
289 | } | ||
290 | phraseChanged(); | ||
291 | } | ||
292 | |||
277 | function calcForDerivationPath() { | 293 | function calcForDerivationPath() { |
278 | clearDerivedKeys(); | 294 | clearDerivedKeys(); |
279 | clearAddressesList(); | 295 | clearAddressesList(); |
@@ -1267,6 +1283,7 @@ | |||
1267 | onSelect: function() { | 1283 | onSelect: function() { |
1268 | network = bitcoinjs.bitcoin.networks.litecoin; | 1284 | network = bitcoinjs.bitcoin.networks.litecoin; |
1269 | setHdCoin(2); | 1285 | setHdCoin(2); |
1286 | DOM.litecoinLtubContainer.removeClass("hidden"); | ||
1270 | }, | 1287 | }, |
1271 | }, | 1288 | }, |
1272 | { | 1289 | { |
@@ -4216,6 +4216,57 @@ page.open(url, function(status) { | |||
4216 | }); | 4216 | }); |
4217 | }, | 4217 | }, |
4218 | 4218 | ||
4219 | // Litecoin uses xprv by default, and can optionally be set to ltpv | ||
4220 | // github issue 96 | ||
4221 | // https://github.com/iancoleman/bip39/issues/96 | ||
4222 | // Issue with extended keys on Litecoin | ||
4223 | function() { | ||
4224 | page.open(url, function(status) { | ||
4225 | // set the phrase and coin | ||
4226 | page.evaluate(function() { | ||
4227 | $(".phrase").val("abandon abandon ability"); | ||
4228 | $(".network option[selected]").removeAttr("selected"); | ||
4229 | $(".network option").filter(function() { | ||
4230 | return $(this).html() == "LTC - Litecoin"; | ||
4231 | }).prop("selected", true); | ||
4232 | $(".network").trigger("change"); | ||
4233 | $(".phrase").trigger("input"); | ||
4234 | }); | ||
4235 | // check the extended key is generated correctly | ||
4236 | waitForGenerate(function() { | ||
4237 | var expected = "xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi"; | ||
4238 | var actual = page.evaluate(function() { | ||
4239 | return $(".root-key").val(); | ||
4240 | }); | ||
4241 | if (actual != expected) { | ||
4242 | console.log("Litecoin root key does not default to xprv"); | ||
4243 | console.log("Expected: " + expected); | ||
4244 | console.log("Actual: " + actual); | ||
4245 | fail(); | ||
4246 | } | ||
4247 | // set litecoin to use ltub | ||
4248 | page.evaluate(function() { | ||
4249 | $(".addresses").empty(); | ||
4250 | $(".litecoin-use-ltub").prop("checked", true); | ||
4251 | $(".litecoin-use-ltub").trigger("change"); | ||
4252 | }); | ||
4253 | waitForGenerate(function() { | ||
4254 | var expected = "Ltpv71G8qDifUiNesiPqf6h5V6eQ8ic77oxQiYtawiACjBEx3sTXNR2HGDGnHETYxESjqkMLFBkKhWVq67ey1B2MKQXannUqNy1RZVHbmrEjnEU"; | ||
4255 | var actual = page.evaluate(function() { | ||
4256 | return $(".root-key").val(); | ||
4257 | }); | ||
4258 | if (actual != expected) { | ||
4259 | console.log("Litecoin root key cannot be set to use ltub"); | ||
4260 | console.log("Expected: " + expected); | ||
4261 | console.log("Actual: " + actual); | ||
4262 | fail(); | ||
4263 | } | ||
4264 | next(); | ||
4265 | }); | ||
4266 | }); | ||
4267 | }); | ||
4268 | }, | ||
4269 | |||
4219 | // If you wish to add more tests, do so here... | 4270 | // If you wish to add more tests, do so here... |
4220 | 4271 | ||
4221 | // Here is a blank test template | 4272 | // Here is a blank test template |