diff options
author | Ian Coleman <ian@iancoleman.io> | 2017-11-22 09:40:35 +1100 |
---|---|---|
committer | Ian Coleman <ian@iancoleman.io> | 2017-11-22 09:40:35 +1100 |
commit | 1c2b8c6b2d77cdb0162f040c07d25bbe7cafe7c2 (patch) | |
tree | 27d2ba3ee3452f03ed9e0af7b6dbb422f92df55c | |
parent | 9f59e99bec5cc5faa63c0296f064a09b0745291f (diff) | |
download | BIP39-1c2b8c6b2d77cdb0162f040c07d25bbe7cafe7c2.tar.gz BIP39-1c2b8c6b2d77cdb0162f040c07d25bbe7cafe7c2.tar.zst BIP39-1c2b8c6b2d77cdb0162f040c07d25bbe7cafe7c2.zip |
Use ltub for litecoin by default instead of xprv
Introduced when upgrading from bitcoinjs-lib v3.3.0
-rw-r--r-- | src/index.html | 2 | ||||
-rw-r--r-- | src/js/bitcoinjs-extensions.js | 11 | ||||
-rw-r--r-- | src/js/index.js | 6 | ||||
-rw-r--r-- | tests/spec/tests.js | 10 |
4 files changed, 20 insertions, 9 deletions
diff --git a/src/index.html b/src/index.html index 659f572..9c126b9 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -277,7 +277,7 @@ | |||
277 | <label for="litecoin-use-ltub" class="col-sm-2 control-label">Prefixes</label> | 277 | <label for="litecoin-use-ltub" class="col-sm-2 control-label">Prefixes</label> |
278 | <div class="col-sm-10 checkbox"> | 278 | <div class="col-sm-10 checkbox"> |
279 | <label> | 279 | <label> |
280 | <input type="checkbox" id="litecoin-use-ltub" class="litecoin-use-ltub"> | 280 | <input type="checkbox" id="litecoin-use-ltub" class="litecoin-use-ltub" checked="checked"> |
281 | Use <code>Ltpv / Ltub</code> instead of <code>xprv / xpub</code> | 281 | Use <code>Ltpv / Ltub</code> instead of <code>xprv / xpub</code> |
282 | </label> | 282 | </label> |
283 | </div> | 283 | </div> |
diff --git a/src/js/bitcoinjs-extensions.js b/src/js/bitcoinjs-extensions.js index c98ff63..63f7c6e 100644 --- a/src/js/bitcoinjs-extensions.js +++ b/src/js/bitcoinjs-extensions.js | |||
@@ -316,3 +316,14 @@ bitcoinjs.bitcoin.networks.litecoinBip49 = { | |||
316 | scriptHash: 0x32, | 316 | scriptHash: 0x32, |
317 | wif: 0xb0 | 317 | wif: 0xb0 |
318 | }; | 318 | }; |
319 | |||
320 | bitcoinjs.bitcoin.networks.litecoinXprv = { | ||
321 | messagePrefix: '\x19Litecoin Signed Message:\n', | ||
322 | bip32: { | ||
323 | public: 0x0488b21e, | ||
324 | private: 0x0488ade4, | ||
325 | }, | ||
326 | pubKeyHash: 0x30, | ||
327 | scriptHash: 0x32, | ||
328 | wif: 0xb0 | ||
329 | }; | ||
diff --git a/src/js/index.js b/src/js/index.js index 38a7efd..e4920ce 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -14,7 +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 | var litecoinUseLtub = true; |
18 | 18 | ||
19 | var entropyChangeTimeoutEvent = null; | 19 | var entropyChangeTimeoutEvent = null; |
20 | var phraseChangeTimeoutEvent = null; | 20 | var phraseChangeTimeoutEvent = null; |
@@ -318,10 +318,10 @@ | |||
318 | function litecoinUseLtubChanged() { | 318 | function litecoinUseLtubChanged() { |
319 | litecoinUseLtub = DOM.litecoinUseLtub.prop("checked"); | 319 | litecoinUseLtub = DOM.litecoinUseLtub.prop("checked"); |
320 | if (litecoinUseLtub) { | 320 | if (litecoinUseLtub) { |
321 | network = bitcoinjs.bitcoin.networks.litecoinLtub; | 321 | network = bitcoinjs.bitcoin.networks.litecoin; |
322 | } | 322 | } |
323 | else { | 323 | else { |
324 | network = bitcoinjs.bitcoin.networks.litecoin; | 324 | network = bitcoinjs.bitcoin.networks.litecoinXprv; |
325 | } | 325 | } |
326 | phraseChanged(); | 326 | phraseChanged(); |
327 | } | 327 | } |
diff --git a/tests/spec/tests.js b/tests/spec/tests.js index f10f7a4..4f774e8 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js | |||
@@ -2473,11 +2473,11 @@ it('Shows error for hardened addresses with xpub root key', function(done) { | |||
2473 | }); | 2473 | }); |
2474 | }); | 2474 | }); |
2475 | 2475 | ||
2476 | // Litecoin uses xprv by default, and can optionally be set to ltpv | 2476 | // Litecoin uses ltub by default, and can optionally be set to xprv |
2477 | // github issue 96 | 2477 | // github issue 96 |
2478 | // https://github.com/iancoleman/bip39/issues/96 | 2478 | // https://github.com/iancoleman/bip39/issues/96 |
2479 | // Issue with extended keys on Litecoin | 2479 | // Issue with extended keys on Litecoin |
2480 | it('Uses xprv by default for litecoin, but can be set to ltpv', function(done) { | 2480 | it('Uses ltub by default for litecoin, but can be set to xprv', function(done) { |
2481 | driver.findElement(By.css('.phrase')) | 2481 | driver.findElement(By.css('.phrase')) |
2482 | .sendKeys("abandon abandon ability"); | 2482 | .sendKeys("abandon abandon ability"); |
2483 | selectNetwork("LTC - Litecoin"); | 2483 | selectNetwork("LTC - Litecoin"); |
@@ -2486,17 +2486,17 @@ it('Uses xprv by default for litecoin, but can be set to ltpv', function(done) { | |||
2486 | driver.findElement(By.css('.root-key')) | 2486 | driver.findElement(By.css('.root-key')) |
2487 | .getAttribute("value") | 2487 | .getAttribute("value") |
2488 | .then(function(rootKey) { | 2488 | .then(function(rootKey) { |
2489 | expect(rootKey).toBe("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi"); | 2489 | expect(rootKey).toBe("Ltpv71G8qDifUiNesiPqf6h5V6eQ8ic77oxQiYtawiACjBEx3sTXNR2HGDGnHETYxESjqkMLFBkKhWVq67ey1B2MKQXannUqNy1RZVHbmrEjnEU"); |
2490 | // set litecoin to use ltub | 2490 | // set litecoin to use ltub |
2491 | driver.executeScript(function() { | 2491 | driver.executeScript(function() { |
2492 | $(".litecoin-use-ltub").prop("checked", true); | 2492 | $(".litecoin-use-ltub").prop("checked", false); |
2493 | $(".litecoin-use-ltub").trigger("change"); | 2493 | $(".litecoin-use-ltub").trigger("change"); |
2494 | }); | 2494 | }); |
2495 | driver.sleep(generateDelay).then(function() { | 2495 | driver.sleep(generateDelay).then(function() { |
2496 | driver.findElement(By.css('.root-key')) | 2496 | driver.findElement(By.css('.root-key')) |
2497 | .getAttribute("value") | 2497 | .getAttribute("value") |
2498 | .then(function(rootKey) { | 2498 | .then(function(rootKey) { |
2499 | expect(rootKey).toBe("Ltpv71G8qDifUiNesiPqf6h5V6eQ8ic77oxQiYtawiACjBEx3sTXNR2HGDGnHETYxESjqkMLFBkKhWVq67ey1B2MKQXannUqNy1RZVHbmrEjnEU"); | 2499 | expect(rootKey).toBe("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi"); |
2500 | done(); | 2500 | done(); |
2501 | }); | 2501 | }); |
2502 | }) | 2502 | }) |