]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blob - src/js/index.js
Merge pull request #279 from mctrivia/master
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / src / js / index.js
1 (function() {
2
3 // mnemonics is populated as required by getLanguage
4 var mnemonics = { "english": new Mnemonic("english") };
5 var mnemonic = mnemonics["english"];
6 var seed = null;
7 var bip32RootKey = null;
8 var bip32ExtendedKey = null;
9 var network = bitcoinjs.bitcoin.networks.bitcoin;
10 var addressRowTemplate = $("#address-row-template");
11
12 var showIndex = true;
13 var showAddress = true;
14 var showPubKey = true;
15 var showPrivKey = true;
16 var showQr = false;
17 var litecoinUseLtub = true;
18
19 var entropyChangeTimeoutEvent = null;
20 var phraseChangeTimeoutEvent = null;
21 var rootKeyChangedTimeoutEvent = null;
22
23 var generationProcesses = [];
24
25 var DOM = {};
26 DOM.privacyScreenToggle = $(".privacy-screen-toggle");
27 DOM.network = $(".network");
28 DOM.bip32Client = $("#bip32-client");
29 DOM.phraseNetwork = $("#network-phrase");
30 DOM.useEntropy = $(".use-entropy");
31 DOM.entropyContainer = $(".entropy-container");
32 DOM.entropy = $(".entropy");
33 DOM.entropyFiltered = DOM.entropyContainer.find(".filtered");
34 DOM.entropyType = DOM.entropyContainer.find(".type");
35 DOM.entropyCrackTime = DOM.entropyContainer.find(".crack-time");
36 DOM.entropyEventCount = DOM.entropyContainer.find(".event-count");
37 DOM.entropyBits = DOM.entropyContainer.find(".bits");
38 DOM.entropyBitsPerEvent = DOM.entropyContainer.find(".bits-per-event");
39 DOM.entropyWordCount = DOM.entropyContainer.find(".word-count");
40 DOM.entropyBinary = DOM.entropyContainer.find(".binary");
41 DOM.entropyWordIndexes = DOM.entropyContainer.find(".word-indexes");
42 DOM.entropyChecksum = DOM.entropyContainer.find(".checksum");
43 DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length");
44 DOM.entropyWeakEntropyOverrideWarning = DOM.entropyContainer.find(".weak-entropy-override-warning");
45 DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning");
46 DOM.phrase = $(".phrase");
47 DOM.splitPhrase = $(".phraseSplit");
48 DOM.passphrase = $(".passphrase");
49 DOM.generateContainer = $(".generate-container");
50 DOM.generate = $(".generate");
51 DOM.seed = $(".seed");
52 DOM.rootKey = $(".root-key");
53 DOM.litecoinLtubContainer = $(".litecoin-ltub-container");
54 DOM.litecoinUseLtub = $(".litecoin-use-ltub");
55 DOM.extendedPrivKey = $(".extended-priv-key");
56 DOM.extendedPubKey = $(".extended-pub-key");
57 DOM.bip32tab = $("#bip32-tab");
58 DOM.bip44tab = $("#bip44-tab");
59 DOM.bip49tab = $("#bip49-tab");
60 DOM.bip84tab = $("#bip84-tab");
61 DOM.bip141tab = $("#bip141-tab");
62 DOM.bip32panel = $("#bip32");
63 DOM.bip44panel = $("#bip44");
64 DOM.bip49panel = $("#bip49");
65 DOM.bip32path = $("#bip32-path");
66 DOM.bip44path = $("#bip44-path");
67 DOM.bip44purpose = $("#bip44 .purpose");
68 DOM.bip44coin = $("#bip44 .coin");
69 DOM.bip44account = $("#bip44 .account");
70 DOM.bip44accountXprv = $("#bip44 .account-xprv");
71 DOM.bip44accountXpub = $("#bip44 .account-xpub");
72 DOM.bip44change = $("#bip44 .change");
73 DOM.bip49unavailable = $("#bip49 .unavailable");
74 DOM.bip49available = $("#bip49 .available");
75 DOM.bip49path = $("#bip49-path");
76 DOM.bip49purpose = $("#bip49 .purpose");
77 DOM.bip49coin = $("#bip49 .coin");
78 DOM.bip49account = $("#bip49 .account");
79 DOM.bip49accountXprv = $("#bip49 .account-xprv");
80 DOM.bip49accountXpub = $("#bip49 .account-xpub");
81 DOM.bip49change = $("#bip49 .change");
82 DOM.bip84unavailable = $("#bip84 .unavailable");
83 DOM.bip84available = $("#bip84 .available");
84 DOM.bip84path = $("#bip84-path");
85 DOM.bip84purpose = $("#bip84 .purpose");
86 DOM.bip84coin = $("#bip84 .coin");
87 DOM.bip84account = $("#bip84 .account");
88 DOM.bip84accountXprv = $("#bip84 .account-xprv");
89 DOM.bip84accountXpub = $("#bip84 .account-xpub");
90 DOM.bip84change = $("#bip84 .change");
91 DOM.bip141unavailable = $("#bip141 .unavailable");
92 DOM.bip141available = $("#bip141 .available");
93 DOM.bip141path = $("#bip141-path");
94 DOM.bip141semantics = $(".bip141-semantics");
95 DOM.generatedStrength = $(".generate-container .strength");
96 DOM.generatedStrengthWarning = $(".generate-container .warning");
97 DOM.hardenedAddresses = $(".hardened-addresses");
98 DOM.bitcoinCashAddressTypeContainer = $(".bch-addr-type-container");
99 DOM.bitcoinCashAddressType = $("[name=bch-addr-type]")
100 DOM.useBip38 = $(".use-bip38");
101 DOM.bip38Password = $(".bip38-password");
102 DOM.addresses = $(".addresses");
103 DOM.csvTab = $("#csv-tab a");
104 DOM.csv = $(".csv");
105 DOM.rowsToAdd = $(".rows-to-add");
106 DOM.more = $(".more");
107 DOM.moreRowsStartIndex = $(".more-rows-start-index");
108 DOM.feedback = $(".feedback");
109 DOM.tab = $(".derivation-type a");
110 DOM.indexToggle = $(".index-toggle");
111 DOM.addressToggle = $(".address-toggle");
112 DOM.publicKeyToggle = $(".public-key-toggle");
113 DOM.privateKeyToggle = $(".private-key-toggle");
114 DOM.languages = $(".languages a");
115 DOM.qrContainer = $(".qr-container");
116 DOM.qrHider = DOM.qrContainer.find(".qr-hider");
117 DOM.qrImage = DOM.qrContainer.find(".qr-image");
118 DOM.qrHint = DOM.qrContainer.find(".qr-hint");
119 DOM.showQrEls = $("[data-show-qr]");
120
121 function init() {
122 // Events
123 DOM.privacyScreenToggle.on("change", privacyScreenToggled);
124 DOM.generatedStrength.on("change", generatedStrengthChanged);
125 DOM.network.on("change", networkChanged);
126 DOM.bip32Client.on("change", bip32ClientChanged);
127 DOM.useEntropy.on("change", setEntropyVisibility);
128 DOM.entropy.on("input", delayedEntropyChanged);
129 DOM.entropyMnemonicLength.on("change", entropyChanged);
130 DOM.phrase.on("input", delayedPhraseChanged);
131 DOM.passphrase.on("input", delayedPhraseChanged);
132 DOM.generate.on("click", generateClicked);
133 DOM.more.on("click", showMore);
134 DOM.rootKey.on("input", delayedRootKeyChanged);
135 DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged);
136 DOM.bip32path.on("input", calcForDerivationPath);
137 DOM.bip44account.on("input", calcForDerivationPath);
138 DOM.bip44change.on("input", calcForDerivationPath);
139 DOM.bip49account.on("input", calcForDerivationPath);
140 DOM.bip49change.on("input", calcForDerivationPath);
141 DOM.bip84account.on("input", calcForDerivationPath);
142 DOM.bip84change.on("input", calcForDerivationPath);
143 DOM.bip141path.on("input", calcForDerivationPath);
144 DOM.bip141semantics.on("change", tabChanged);
145 DOM.tab.on("shown.bs.tab", tabChanged);
146 DOM.hardenedAddresses.on("change", calcForDerivationPath);
147 DOM.useBip38.on("change", calcForDerivationPath);
148 DOM.bip38Password.on("change", calcForDerivationPath);
149 DOM.indexToggle.on("click", toggleIndexes);
150 DOM.addressToggle.on("click", toggleAddresses);
151 DOM.publicKeyToggle.on("click", togglePublicKeys);
152 DOM.privateKeyToggle.on("click", togglePrivateKeys);
153 DOM.csvTab.on("click", updateCsv);
154 DOM.languages.on("click", languageChanged);
155 DOM.bitcoinCashAddressType.on("change", bitcoinCashAddressTypeChange);
156 setQrEvents(DOM.showQrEls);
157 disableForms();
158 hidePending();
159 hideValidationError();
160 populateNetworkSelect();
161 populateClientSelect();
162 }
163
164 // Event handlers
165
166 function generatedStrengthChanged() {
167 var strength = parseInt(DOM.generatedStrength.val());
168 if (strength < 12) {
169 DOM.generatedStrengthWarning.removeClass("hidden");
170 }
171 else {
172 DOM.generatedStrengthWarning.addClass("hidden");
173 }
174 }
175
176 function networkChanged(e) {
177 clearDerivedKeys();
178 clearAddressesList();
179 DOM.litecoinLtubContainer.addClass("hidden");
180 DOM.bitcoinCashAddressTypeContainer.addClass("hidden");
181 var networkIndex = e.target.value;
182 var network = networks[networkIndex];
183 network.onSelect();
184 adjustNetworkForSegwit();
185 if (seed != null) {
186 phraseChanged();
187 }
188 else {
189 rootKeyChanged();
190 }
191 }
192
193 function bip32ClientChanged(e) {
194 var clientIndex = DOM.bip32Client.val();
195 if (clientIndex == "custom") {
196 DOM.bip32path.prop("readonly", false);
197 }
198 else {
199 DOM.bip32path.prop("readonly", true);
200 clients[clientIndex].onSelect();
201 if (seed != null) {
202 phraseChanged();
203 }
204 else {
205 rootKeyChanged();
206 }
207 }
208 }
209
210 function setEntropyVisibility() {
211 if (isUsingOwnEntropy()) {
212 DOM.entropyContainer.removeClass("hidden");
213 DOM.generateContainer.addClass("hidden");
214 DOM.phrase.prop("readonly", true);
215 DOM.entropy.focus();
216 entropyChanged();
217 }
218 else {
219 DOM.entropyContainer.addClass("hidden");
220 DOM.generateContainer.removeClass("hidden");
221 DOM.phrase.prop("readonly", false);
222 hidePending();
223 }
224 }
225
226 function delayedPhraseChanged() {
227 hideValidationError();
228 seed = null;
229 bip32RootKey = null;
230 bip32ExtendedKey = null;
231 clearAddressesList();
232 showPending();
233 if (phraseChangeTimeoutEvent != null) {
234 clearTimeout(phraseChangeTimeoutEvent);
235 }
236 phraseChangeTimeoutEvent = setTimeout(function() {
237 phraseChanged();
238 var entropy = mnemonic.toRawEntropyHex(DOM.phrase.val());
239 if (entropy !== null) {
240 DOM.entropyMnemonicLength.val("raw");
241 DOM.entropy.val(entropy);
242 }
243 }, 400);
244 }
245
246 function phraseChanged() {
247 showPending();
248 setMnemonicLanguage();
249 // Get the mnemonic phrase
250 var phrase = DOM.phrase.val();
251 var errorText = findPhraseErrors(phrase);
252 if (errorText) {
253 showValidationError(errorText);
254 return;
255 }
256 // Calculate and display
257 var passphrase = DOM.passphrase.val();
258 calcBip32RootKeyFromSeed(phrase, passphrase);
259 calcForDerivationPath();
260 // Show the word indexes
261 showWordIndexes();
262 }
263
264 function tabChanged() {
265 showPending();
266 adjustNetworkForSegwit();
267 var phrase = DOM.phrase.val();
268 if (phrase != "") {
269 // Calculate and display for mnemonic
270 var errorText = findPhraseErrors(phrase);
271 if (errorText) {
272 showValidationError(errorText);
273 return;
274 }
275 // Calculate and display
276 var passphrase = DOM.passphrase.val();
277 calcBip32RootKeyFromSeed(phrase, passphrase);
278 }
279 else {
280 // Calculate and display for root key
281 var rootKeyBase58 = DOM.rootKey.val();
282 var errorText = validateRootKey(rootKeyBase58);
283 if (errorText) {
284 showValidationError(errorText);
285 return;
286 }
287 // Calculate and display
288 calcBip32RootKeyFromBase58(rootKeyBase58);
289 }
290 calcForDerivationPath();
291 }
292
293 function delayedEntropyChanged() {
294 hideValidationError();
295 showPending();
296 if (entropyChangeTimeoutEvent != null) {
297 clearTimeout(entropyChangeTimeoutEvent);
298 }
299 entropyChangeTimeoutEvent = setTimeout(entropyChanged, 400);
300 }
301
302 function entropyChanged() {
303 // If blank entropy, clear mnemonic, addresses, errors
304 if (DOM.entropy.val().trim().length == 0) {
305 clearDisplay();
306 clearEntropyFeedback();
307 DOM.phrase.val("");
308 DOM.phraseSplit.val("");
309 showValidationError("Blank entropy");
310 return;
311 }
312 // Get the current phrase to detect changes
313 var phrase = DOM.phrase.val();
314 // Set the phrase from the entropy
315 setMnemonicFromEntropy();
316 // Recalc addresses if the phrase has changed
317 var newPhrase = DOM.phrase.val();
318 if (newPhrase != phrase) {
319 if (newPhrase.length == 0) {
320 clearDisplay();
321 }
322 else {
323 phraseChanged();
324 }
325 }
326 else {
327 hidePending();
328 }
329 }
330
331 function delayedRootKeyChanged() {
332 // Warn if there is an existing mnemonic or passphrase.
333 if (DOM.phrase.val().length > 0 || DOM.passphrase.val().length > 0) {
334 if (!confirm("This will clear existing mnemonic and passphrase")) {
335 DOM.rootKey.val(bip32RootKey);
336 return
337 }
338 }
339 hideValidationError();
340 showPending();
341 // Clear existing mnemonic and passphrase
342 DOM.phrase.val("");
343 DOM.phraseSplit.val("");
344 DOM.passphrase.val("");
345 seed = null;
346 if (rootKeyChangedTimeoutEvent != null) {
347 clearTimeout(rootKeyChangedTimeoutEvent);
348 }
349 rootKeyChangedTimeoutEvent = setTimeout(rootKeyChanged, 400);
350 }
351
352 function rootKeyChanged() {
353 showPending();
354 hideValidationError();
355 var rootKeyBase58 = DOM.rootKey.val();
356 var errorText = validateRootKey(rootKeyBase58);
357 if (errorText) {
358 showValidationError(errorText);
359 return;
360 }
361 // Calculate and display
362 calcBip32RootKeyFromBase58(rootKeyBase58);
363 calcForDerivationPath();
364 }
365
366 function litecoinUseLtubChanged() {
367 litecoinUseLtub = DOM.litecoinUseLtub.prop("checked");
368 if (litecoinUseLtub) {
369 network = bitcoinjs.bitcoin.networks.litecoin;
370 }
371 else {
372 network = bitcoinjs.bitcoin.networks.litecoinXprv;
373 }
374 phraseChanged();
375 }
376
377 function calcForDerivationPath() {
378 clearDerivedKeys();
379 clearAddressesList();
380 showPending();
381 // Don't show segwit if it's selected but network doesn't support it
382 if (segwitSelected() && !networkHasSegwit()) {
383 showSegwitUnavailable();
384 hidePending();
385 return;
386 }
387 showSegwitAvailable();
388 // Get the derivation path
389 var derivationPath = getDerivationPath();
390 var errorText = findDerivationPathErrors(derivationPath);
391 if (errorText) {
392 showValidationError(errorText);
393 return;
394 }
395 bip32ExtendedKey = calcBip32ExtendedKey(derivationPath);
396 if (bip44TabSelected()) {
397 displayBip44Info();
398 }
399 else if (bip49TabSelected()) {
400 displayBip49Info();
401 }
402 else if (bip84TabSelected()) {
403 displayBip84Info();
404 }
405 displayBip32Info();
406 }
407
408 function generateClicked() {
409 if (isUsingOwnEntropy()) {
410 return;
411 }
412 clearDisplay();
413 showPending();
414 setTimeout(function() {
415 setMnemonicLanguage();
416 var phrase = generateRandomPhrase();
417 if (!phrase) {
418 return;
419 }
420 phraseChanged();
421 }, 50);
422 }
423
424 function languageChanged() {
425 setTimeout(function() {
426 setMnemonicLanguage();
427 if (DOM.phrase.val().length > 0) {
428 var newPhrase = convertPhraseToNewLanguage();
429 DOM.phrase.val(newPhrase);
430 writeSplitPhrase(newPhrase);
431 phraseChanged();
432 }
433 else {
434 DOM.generate.trigger("click");
435 }
436 }, 50);
437 }
438
439 function bitcoinCashAddressTypeChange() {
440 phraseChanged();
441 }
442
443 function toggleIndexes() {
444 showIndex = !showIndex;
445 $("td.index span").toggleClass("invisible");
446 }
447
448 function toggleAddresses() {
449 showAddress = !showAddress;
450 $("td.address span").toggleClass("invisible");
451 }
452
453 function togglePublicKeys() {
454 showPubKey = !showPubKey;
455 $("td.pubkey span").toggleClass("invisible");
456 }
457
458 function togglePrivateKeys() {
459 showPrivKey = !showPrivKey;
460 $("td.privkey span").toggleClass("invisible");
461 }
462
463 function privacyScreenToggled() {
464 // private-data contains elements added to DOM at runtime
465 // so catch all by adding visual privacy class to the root of the DOM
466 if (DOM.privacyScreenToggle.prop("checked")) {
467 $("body").addClass("visual-privacy");
468 }
469 else {
470 $("body").removeClass("visual-privacy");
471 }
472 }
473
474 // Private methods
475
476 function generateRandomPhrase() {
477 if (!hasStrongRandom()) {
478 var errorText = "This browser does not support strong randomness";
479 showValidationError(errorText);
480 return;
481 }
482 // get the amount of entropy to use
483 var numWords = parseInt(DOM.generatedStrength.val());
484 var strength = numWords / 3 * 32;
485 var buffer = new Uint8Array(strength / 8);
486 // create secure entropy
487 var data = crypto.getRandomValues(buffer);
488 // show the words
489 var words = mnemonic.toMnemonic(data);
490 DOM.phrase.val(words);
491 writeSplitPhrase(words);
492 // show the entropy
493 var entropyHex = uint8ArrayToHex(data);
494 DOM.entropy.val(entropyHex);
495 // ensure entropy fields are consistent with what is being displayed
496 DOM.entropyMnemonicLength.val("raw");
497 return words;
498 }
499
500 function calcBip32RootKeyFromSeed(phrase, passphrase) {
501 seed = mnemonic.toSeed(phrase, passphrase);
502 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromSeedHex(seed, network);
503 if(isGRS())
504 bip32RootKey = groestlcoinjs.HDNode.fromSeedHex(seed, network);
505
506 }
507
508 function calcBip32RootKeyFromBase58(rootKeyBase58) {
509 if(isGRS()) {
510 calcBip32RootKeyFromBase58GRS(rootKeyBase58);
511 return;
512 }
513 // try parsing with various segwit network params since this extended
514 // key may be from any one of them.
515 if (networkHasSegwit()) {
516 var n = network;
517 if ("baseNetwork" in n) {
518 n = bitcoinjs.bitcoin.networks[n.baseNetwork];
519 }
520 // try parsing using base network params
521 try {
522 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n);
523 return;
524 }
525 catch (e) {}
526 // try parsing using p2wpkh params
527 if ("p2wpkh" in n) {
528 try {
529 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
530 return;
531 }
532 catch (e) {}
533 }
534 // try parsing using p2wpkh-in-p2sh network params
535 if ("p2wpkhInP2sh" in n) {
536 try {
537 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
538 return;
539 }
540 catch (e) {}
541 }
542 }
543 // try the network params as currently specified
544 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
545 }
546
547 function calcBip32RootKeyFromBase58GRS(rootKeyBase58) {
548 // try parsing with various segwit network params since this extended
549 // key may be from any one of them.
550 if (networkHasSegwit()) {
551 var n = network;
552 if ("baseNetwork" in n) {
553 n = bitcoinjs.bitcoin.networks[n.baseNetwork];
554 }
555 // try parsing using base network params
556 try {
557 bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n);
558 return;
559 }
560 catch (e) {}
561 // try parsing using p2wpkh params
562 if ("p2wpkh" in n) {
563 try {
564 bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
565 return;
566 }
567 catch (e) {}
568 }
569 // try parsing using p2wpkh-in-p2sh network params
570 if ("p2wpkhInP2sh" in n) {
571 try {
572 bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
573 return;
574 }
575 catch (e) {}
576 }
577 }
578 // try the network params as currently specified
579 bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, network);
580 }
581
582 function calcBip32ExtendedKey(path) {
583 // Check there's a root key to derive from
584 if (!bip32RootKey) {
585 return bip32RootKey;
586 }
587 var extendedKey = bip32RootKey;
588 // Derive the key from the path
589 var pathBits = path.split("/");
590 for (var i=0; i<pathBits.length; i++) {
591 var bit = pathBits[i];
592 var index = parseInt(bit);
593 if (isNaN(index)) {
594 continue;
595 }
596 var hardened = bit[bit.length-1] == "'";
597 var isPriv = !(extendedKey.isNeutered());
598 var invalidDerivationPath = hardened && !isPriv;
599 if (invalidDerivationPath) {
600 extendedKey = null;
601 }
602 else if (hardened) {
603 extendedKey = extendedKey.deriveHardened(index);
604 }
605 else {
606 extendedKey = extendedKey.derive(index);
607 }
608 }
609 return extendedKey
610 }
611
612 function showValidationError(errorText) {
613 DOM.feedback
614 .text(errorText)
615 .show();
616 }
617
618 function hideValidationError() {
619 DOM.feedback
620 .text("")
621 .hide();
622 }
623
624 function findPhraseErrors(phrase) {
625 // Preprocess the words
626 phrase = mnemonic.normalizeString(phrase);
627 var words = phraseToWordArray(phrase);
628 // Detect blank phrase
629 if (words.length == 0) {
630 return "Blank mnemonic";
631 }
632 // Check each word
633 for (var i=0; i<words.length; i++) {
634 var word = words[i];
635 var language = getLanguage();
636 if (WORDLISTS[language].indexOf(word) == -1) {
637 console.log("Finding closest match to " + word);
638 var nearestWord = findNearestWord(word);
639 return word + " not in wordlist, did you mean " + nearestWord + "?";
640 }
641 }
642 // Check the words are valid
643 var properPhrase = wordArrayToPhrase(words);
644 var isValid = mnemonic.check(properPhrase);
645 if (!isValid) {
646 return "Invalid mnemonic";
647 }
648 return false;
649 }
650
651 function validateRootKey(rootKeyBase58) {
652 if(isGRS())
653 return validateRootKeyGRS(rootKeyBase58);
654
655 // try various segwit network params since this extended key may be from
656 // any one of them.
657 if (networkHasSegwit()) {
658 var n = network;
659 if ("baseNetwork" in n) {
660 n = bitcoinjs.bitcoin.networks[n.baseNetwork];
661 }
662 // try parsing using base network params
663 try {
664 bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n);
665 return "";
666 }
667 catch (e) {}
668 // try parsing using p2wpkh params
669 if ("p2wpkh" in n) {
670 try {
671 bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
672 return "";
673 }
674 catch (e) {}
675 }
676 // try parsing using p2wpkh-in-p2sh network params
677 if ("p2wpkhInP2sh" in n) {
678 try {
679 bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
680 return "";
681 }
682 catch (e) {}
683 }
684 }
685 // try the network params as currently specified
686 try {
687 bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
688 }
689 catch (e) {
690 return "Invalid root key";
691 }
692 return "";
693 }
694
695 function validateRootKeyGRS(rootKeyBase58) {
696 // try various segwit network params since this extended key may be from
697 // any one of them.
698 if (networkHasSegwit()) {
699 var n = network;
700 if ("baseNetwork" in n) {
701 n = bitcoinjs.bitcoin.networks[n.baseNetwork];
702 }
703 // try parsing using base network params
704 try {
705 groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n);
706 return "";
707 }
708 catch (e) {}
709 // try parsing using p2wpkh params
710 if ("p2wpkh" in n) {
711 try {
712 groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
713 return "";
714 }
715 catch (e) {}
716 }
717 // try parsing using p2wpkh-in-p2sh network params
718 if ("p2wpkhInP2sh" in n) {
719 try {
720 groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
721 return "";
722 }
723 catch (e) {}
724 }
725 }
726 // try the network params as currently specified
727 try {
728 groestlcoinjs.HDNode.fromBase58(rootKeyBase58, network);
729 }
730 catch (e) {
731 return "Invalid root key";
732 }
733 return "";
734 }
735
736 function getDerivationPath() {
737 if (bip44TabSelected()) {
738 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
739 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
740 var account = parseIntNoNaN(DOM.bip44account.val(), 0);
741 var change = parseIntNoNaN(DOM.bip44change.val(), 0);
742 var path = "m/";
743 path += purpose + "'/";
744 path += coin + "'/";
745 path += account + "'/";
746 path += change;
747 DOM.bip44path.val(path);
748 var derivationPath = DOM.bip44path.val();
749 console.log("Using derivation path from BIP44 tab: " + derivationPath);
750 return derivationPath;
751 }
752 else if (bip49TabSelected()) {
753 var purpose = parseIntNoNaN(DOM.bip49purpose.val(), 49);
754 var coin = parseIntNoNaN(DOM.bip49coin.val(), 0);
755 var account = parseIntNoNaN(DOM.bip49account.val(), 0);
756 var change = parseIntNoNaN(DOM.bip49change.val(), 0);
757 var path = "m/";
758 path += purpose + "'/";
759 path += coin + "'/";
760 path += account + "'/";
761 path += change;
762 DOM.bip49path.val(path);
763 var derivationPath = DOM.bip49path.val();
764 console.log("Using derivation path from BIP49 tab: " + derivationPath);
765 return derivationPath;
766 }
767 else if (bip84TabSelected()) {
768 var purpose = parseIntNoNaN(DOM.bip84purpose.val(), 84);
769 var coin = parseIntNoNaN(DOM.bip84coin.val(), 0);
770 var account = parseIntNoNaN(DOM.bip84account.val(), 0);
771 var change = parseIntNoNaN(DOM.bip84change.val(), 0);
772 var path = "m/";
773 path += purpose + "'/";
774 path += coin + "'/";
775 path += account + "'/";
776 path += change;
777 DOM.bip84path.val(path);
778 var derivationPath = DOM.bip84path.val();
779 console.log("Using derivation path from BIP84 tab: " + derivationPath);
780 return derivationPath;
781 }
782 else if (bip32TabSelected()) {
783 var derivationPath = DOM.bip32path.val();
784 console.log("Using derivation path from BIP32 tab: " + derivationPath);
785 return derivationPath;
786 }
787 else if (bip141TabSelected()) {
788 var derivationPath = DOM.bip141path.val();
789 console.log("Using derivation path from BIP141 tab: " + derivationPath);
790 return derivationPath;
791 }
792 else {
793 console.log("Unknown derivation path");
794 }
795 }
796
797 function findDerivationPathErrors(path) {
798 // TODO is not perfect but is better than nothing
799 // Inspired by
800 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
801 // and
802 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
803 var maxDepth = 255; // TODO verify this!!
804 var maxIndexValue = Math.pow(2, 31); // TODO verify this!!
805 if (path[0] != "m") {
806 return "First character must be 'm'";
807 }
808 if (path.length > 1) {
809 if (path[1] != "/") {
810 return "Separator must be '/'";
811 }
812 var indexes = path.split("/");
813 if (indexes.length > maxDepth) {
814 return "Derivation depth is " + indexes.length + ", must be less than " + maxDepth;
815 }
816 for (var depth = 1; depth<indexes.length; depth++) {
817 var index = indexes[depth];
818 var invalidChars = index.replace(/^[0-9]+'?$/g, "")
819 if (invalidChars.length > 0) {
820 return "Invalid characters " + invalidChars + " found at depth " + depth;
821 }
822 var indexValue = parseInt(index.replace("'", ""));
823 if (isNaN(depth)) {
824 return "Invalid number at depth " + depth;
825 }
826 if (indexValue > maxIndexValue) {
827 return "Value of " + indexValue + " at depth " + depth + " must be less than " + maxIndexValue;
828 }
829 }
830 }
831 // Check root key exists or else derivation path is useless!
832 if (!bip32RootKey) {
833 return "No root key";
834 }
835 // Check no hardened derivation path when using xpub keys
836 var hardenedPath = path.indexOf("'") > -1;
837 var hardenedAddresses = bip32TabSelected() && DOM.hardenedAddresses.prop("checked");
838 var hardened = hardenedPath || hardenedAddresses;
839 var isXpubkey = bip32RootKey.isNeutered();
840 if (hardened && isXpubkey) {
841 return "Hardened derivation path is invalid with xpub key";
842 }
843 return false;
844 }
845
846 function isGRS() {
847 return networks[DOM.network.val()].name == "GRS - Groestlcoin" || networks[DOM.network.val()].name == "GRS - Groestlcoin Testnet";
848 }
849
850 function displayBip44Info() {
851 // Get the derivation path for the account
852 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
853 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
854 var account = parseIntNoNaN(DOM.bip44account.val(), 0);
855 var path = "m/";
856 path += purpose + "'/";
857 path += coin + "'/";
858 path += account + "'/";
859 // Calculate the account extended keys
860 var accountExtendedKey = calcBip32ExtendedKey(path);
861 var accountXprv = accountExtendedKey.toBase58();
862 var accountXpub = accountExtendedKey.neutered().toBase58();
863 // Display the extended keys
864 DOM.bip44accountXprv.val(accountXprv);
865 DOM.bip44accountXpub.val(accountXpub);
866 }
867
868 function displayBip49Info() {
869 // Get the derivation path for the account
870 var purpose = parseIntNoNaN(DOM.bip49purpose.val(), 49);
871 var coin = parseIntNoNaN(DOM.bip49coin.val(), 0);
872 var account = parseIntNoNaN(DOM.bip49account.val(), 0);
873 var path = "m/";
874 path += purpose + "'/";
875 path += coin + "'/";
876 path += account + "'/";
877 // Calculate the account extended keys
878 var accountExtendedKey = calcBip32ExtendedKey(path);
879 var accountXprv = accountExtendedKey.toBase58();
880 var accountXpub = accountExtendedKey.neutered().toBase58();
881 // Display the extended keys
882 DOM.bip49accountXprv.val(accountXprv);
883 DOM.bip49accountXpub.val(accountXpub);
884 }
885
886 function displayBip84Info() {
887 // Get the derivation path for the account
888 var purpose = parseIntNoNaN(DOM.bip84purpose.val(), 84);
889 var coin = parseIntNoNaN(DOM.bip84coin.val(), 0);
890 var account = parseIntNoNaN(DOM.bip84account.val(), 0);
891 var path = "m/";
892 path += purpose + "'/";
893 path += coin + "'/";
894 path += account + "'/";
895 // Calculate the account extended keys
896 var accountExtendedKey = calcBip32ExtendedKey(path);
897 var accountXprv = accountExtendedKey.toBase58();
898 var accountXpub = accountExtendedKey.neutered().toBase58();
899 // Display the extended keys
900 DOM.bip84accountXprv.val(accountXprv);
901 DOM.bip84accountXpub.val(accountXpub);
902 }
903
904 function displayBip32Info() {
905 // Display the key
906 DOM.seed.val(seed);
907 var rootKey = bip32RootKey.toBase58();
908 DOM.rootKey.val(rootKey);
909 var xprvkeyB58 = "NA";
910 if (!bip32ExtendedKey.isNeutered()) {
911 xprvkeyB58 = bip32ExtendedKey.toBase58();
912 }
913 var extendedPrivKey = xprvkeyB58;
914 DOM.extendedPrivKey.val(extendedPrivKey);
915 var extendedPubKey = bip32ExtendedKey.neutered().toBase58();
916 DOM.extendedPubKey.val(extendedPubKey);
917 // Display the addresses and privkeys
918 clearAddressesList();
919 var initialAddressCount = parseInt(DOM.rowsToAdd.val());
920 displayAddresses(0, initialAddressCount);
921 }
922
923 function displayAddresses(start, total) {
924 generationProcesses.push(new (function() {
925
926 var rows = [];
927
928 this.stop = function() {
929 for (var i=0; i<rows.length; i++) {
930 rows[i].shouldGenerate = false;
931 }
932 hidePending();
933 }
934
935 for (var i=0; i<total; i++) {
936 var index = i + start;
937 var isLast = i == total - 1;
938 rows.push(new TableRow(index, isLast));
939 }
940
941 })());
942 }
943
944 function segwitSelected() {
945 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
946 }
947
948 function p2wpkhSelected() {
949 return bip84TabSelected() ||
950 bip141TabSelected() && DOM.bip141semantics.val() == "p2wpkh";
951 }
952
953 function p2wpkhInP2shSelected() {
954 return bip49TabSelected() ||
955 (bip141TabSelected() && DOM.bip141semantics.val() == "p2wpkh-p2sh");
956 }
957
958 function TableRow(index, isLast) {
959
960 var self = this;
961 this.shouldGenerate = true;
962 var useHardenedAddresses = DOM.hardenedAddresses.prop("checked");
963 var useBip38 = DOM.useBip38.prop("checked");
964 var bip38password = DOM.bip38Password.val();
965 var isSegwit = segwitSelected();
966 var segwitAvailable = networkHasSegwit();
967 var isP2wpkh = p2wpkhSelected();
968 var isP2wpkhInP2sh = p2wpkhInP2shSelected();
969
970 function init() {
971 calculateValues();
972 }
973
974 function calculateValues() {
975 setTimeout(function() {
976 if (!self.shouldGenerate) {
977 return;
978 }
979 // derive HDkey for this row of the table
980 var key = "NA";
981 if (useHardenedAddresses) {
982 key = bip32ExtendedKey.deriveHardened(index);
983 }
984 else {
985 key = bip32ExtendedKey.derive(index);
986 }
987 // bip38 requires uncompressed keys
988 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
989 var keyPair = key.keyPair;
990 var useUncompressed = useBip38;
991 if (useUncompressed) {
992 keyPair = new bitcoinjs.bitcoin.ECPair(keyPair.d, null, { network: network, compressed: false });
993 if(isGRS())
994 keyPair = new groestlcoinjs.ECPair(keyPair.d, null, { network: network, compressed: false });
995
996 }
997 // get address
998 var address = keyPair.getAddress().toString();
999 // get privkey
1000 var hasPrivkey = !key.isNeutered();
1001 var privkey = "NA";
1002 if (hasPrivkey) {
1003 privkey = keyPair.toWIF();
1004 // BIP38 encode private key if required
1005 if (useBip38) {
1006 if(isGRS())
1007 privkey = groestlcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
1008 console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
1009 }, null, networks[DOM.network.val()].name.includes("Testnet"));
1010 else
1011 privkey = bitcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
1012 console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
1013 });
1014 }
1015 }
1016 // get pubkey
1017 var pubkey = keyPair.getPublicKeyBuffer().toString('hex');
1018 var indexText = getDerivationPath() + "/" + index;
1019 if (useHardenedAddresses) {
1020 indexText = indexText + "'";
1021 }
1022 // Ethereum values are different
1023 if ((networks[DOM.network.val()].name == "ETH - Ethereum")
1024 || (networks[DOM.network.val()].name == "ETC - Ethereum Classic")
1025 || (networks[DOM.network.val()].name == "PIRL - Pirl")
1026 || (networks[DOM.network.val()].name == "MIX - MIX")
1027 || (networks[DOM.network.val()].name == "MUSIC - Musicoin")
1028 || (networks[DOM.network.val()].name == "POA - Poa")
1029 || (networks[DOM.network.val()].name == "EXP - Expanse")
1030 || (networks[DOM.network.val()].name == "CLO - Callisto")
1031 || (networks[DOM.network.val()].name == "DXN - DEXON")
1032 || (networks[DOM.network.val()].name == "ELLA - Ellaism")
1033 || (networks[DOM.network.val()].name == "ESN - Ethersocial Network")
1034 || (networks[DOM.network.val()].name == "VET - VeChain")
1035 ) {
1036 var privKeyBuffer = keyPair.d.toBuffer(32);
1037 privkey = privKeyBuffer.toString('hex');
1038 var addressBuffer = ethUtil.privateToAddress(privKeyBuffer);
1039 var hexAddress = addressBuffer.toString('hex');
1040 var checksumAddress = ethUtil.toChecksumAddress(hexAddress);
1041 address = ethUtil.addHexPrefix(checksumAddress);
1042 privkey = ethUtil.addHexPrefix(privkey);
1043 pubkey = ethUtil.addHexPrefix(pubkey);
1044 }
1045
1046 // Stellar is different
1047 if (networks[DOM.network.val()].name == "XLM - Stellar") {
1048 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
1049 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
1050 var path = "m/";
1051 path += purpose + "'/";
1052 path += coin + "'/" + index + "'";
1053 var keypair = stellarUtil.getKeypair(path, seed);
1054 indexText = path;
1055 privkey = keypair.secret();
1056 pubkey = address = keypair.publicKey();
1057 }
1058 if ((networks[DOM.network.val()].name == "NAS - Nebulas")) {
1059 var NasAccount = require("nebulas-account");
1060 var privKeyBuffer = keyPair.d.toBuffer(32);
1061 var nebulasAccount = new NasAccount();
1062 nebulasAccount.setPrivateKey(privKeyBuffer);
1063 address = nebulasAccount.getAddressString();
1064 privkey = nebulasAccount.getPrivateKeyString();
1065 pubkey = nebulasAccount.getPublicKeyString();
1066 }
1067 // Ripple values are different
1068 if (networks[DOM.network.val()].name == "XRP - Ripple") {
1069 privkey = convertRipplePriv(privkey);
1070 address = convertRippleAdrr(address);
1071 }
1072 // CasinoCoin values are different
1073 if (networks[DOM.network.val()].name == "CSC - CasinoCoin") {
1074 privkey = convertCasinoCoinPriv(privkey);
1075 address = convertCasinoCoinAdrr(address);
1076 }
1077 // Bitcoin Cash address format may vary
1078 if (networks[DOM.network.val()].name == "BCH - Bitcoin Cash") {
1079 var bchAddrType = DOM.bitcoinCashAddressType.filter(":checked").val();
1080 if (bchAddrType == "cashaddr") {
1081 address = bchaddr.toCashAddress(address);
1082 }
1083 else if (bchAddrType == "bitpay") {
1084 address = bchaddr.toBitpayAddress(address);
1085 }
1086 }
1087 // Bitcoin Cash address format may vary
1088 if (networks[DOM.network.val()].name == "SLP - Simple Ledger Protocol") {
1089 var bchAddrType = DOM.bitcoinCashAddressType.filter(":checked").val();
1090 if (bchAddrType == "cashaddr") {
1091 address = bchaddr.toSlpAddress(address);
1092 }
1093 }
1094 // Segwit addresses are different
1095 if (isSegwit) {
1096 if (!segwitAvailable) {
1097 return;
1098 }
1099 if (isP2wpkh) {
1100 var keyhash = bitcoinjs.bitcoin.crypto.hash160(key.getPublicKeyBuffer());
1101 var scriptpubkey = bitcoinjs.bitcoin.script.witnessPubKeyHash.output.encode(keyhash);
1102 address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
1103 }
1104 else if (isP2wpkhInP2sh) {
1105 var keyhash = bitcoinjs.bitcoin.crypto.hash160(key.getPublicKeyBuffer());
1106 var scriptsig = bitcoinjs.bitcoin.script.witnessPubKeyHash.output.encode(keyhash);
1107 var addressbytes = bitcoinjs.bitcoin.crypto.hash160(scriptsig);
1108 var scriptpubkey = bitcoinjs.bitcoin.script.scriptHash.output.encode(addressbytes);
1109 address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
1110 }
1111 }
1112
1113 if ((networks[DOM.network.val()].name == "CRW - Crown")) {
1114 address = bitcoinjs.bitcoin.networks.crown.toNewAddress(address);
1115 }
1116
1117 if (networks[DOM.network.val()].name == "EOS - EOSIO") {
1118 address = ""
1119 pubkey = eosUtil.bufferToPublic(keyPair.getPublicKeyBuffer());
1120 privkey = eosUtil.bufferToPrivate(keyPair.d.toBuffer(32));
1121 }
1122
1123 //Groestlcoin Addresses are different
1124 if(isGRS()) {
1125
1126 if (isSegwit) {
1127 if (!segwitAvailable) {
1128 return;
1129 }
1130 if (isP2wpkh) {
1131 address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network)
1132 }
1133 else if (isP2wpkhInP2sh) {
1134 address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network)
1135 }
1136 }
1137 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1138 }
1139
1140 addAddressToList(indexText, address, pubkey, privkey);
1141 if (isLast) {
1142 hidePending();
1143 updateCsv();
1144 }
1145 }, 50)
1146 }
1147
1148 init();
1149
1150 }
1151
1152 function showMore() {
1153 var rowsToAdd = parseInt(DOM.rowsToAdd.val());
1154 if (isNaN(rowsToAdd)) {
1155 rowsToAdd = 20;
1156 DOM.rowsToAdd.val("20");
1157 }
1158 var start = parseInt(DOM.moreRowsStartIndex.val())
1159 if (isNaN(start)) {
1160 start = lastIndexInTable() + 1;
1161 }
1162 else {
1163 var newStart = start + rowsToAdd;
1164 DOM.moreRowsStartIndex.val(newStart);
1165 }
1166 if (rowsToAdd > 200) {
1167 var msg = "Generating " + rowsToAdd + " rows could take a while. ";
1168 msg += "Do you want to continue?";
1169 if (!confirm(msg)) {
1170 return;
1171 }
1172 }
1173 displayAddresses(start, rowsToAdd);
1174 }
1175
1176 function clearDisplay() {
1177 clearAddressesList();
1178 clearKeys();
1179 hideValidationError();
1180 }
1181
1182 function clearAddressesList() {
1183 DOM.addresses.empty();
1184 DOM.csv.val("");
1185 stopGenerating();
1186 }
1187
1188 function stopGenerating() {
1189 while (generationProcesses.length > 0) {
1190 var generation = generationProcesses.shift();
1191 generation.stop();
1192 }
1193 }
1194
1195 function clearKeys() {
1196 clearRootKey();
1197 clearDerivedKeys();
1198 }
1199
1200 function clearRootKey() {
1201 DOM.rootKey.val("");
1202 }
1203
1204 function clearDerivedKeys() {
1205 DOM.extendedPrivKey.val("");
1206 DOM.extendedPubKey.val("");
1207 DOM.bip44accountXprv.val("");
1208 DOM.bip44accountXpub.val("");
1209 }
1210
1211 function addAddressToList(indexText, address, pubkey, privkey) {
1212 var row = $(addressRowTemplate.html());
1213 // Elements
1214 var indexCell = row.find(".index span");
1215 var addressCell = row.find(".address span");
1216 var pubkeyCell = row.find(".pubkey span");
1217 var privkeyCell = row.find(".privkey span");
1218 // Content
1219 indexCell.text(indexText);
1220 addressCell.text(address);
1221 pubkeyCell.text(pubkey);
1222 privkeyCell.text(privkey);
1223 // Visibility
1224 if (!showIndex) {
1225 indexCell.addClass("invisible");
1226 }
1227 if (!showAddress) {
1228 addressCell.addClass("invisible");
1229 }
1230 if (!showPubKey) {
1231 pubkeyCell.addClass("invisible");
1232 }
1233 if (!showPrivKey) {
1234 privkeyCell.addClass("invisible");
1235 }
1236 DOM.addresses.append(row);
1237 var rowShowQrEls = row.find("[data-show-qr]");
1238 setQrEvents(rowShowQrEls);
1239 }
1240
1241 function hasStrongRandom() {
1242 return 'crypto' in window && window['crypto'] !== null;
1243 }
1244
1245 function disableForms() {
1246 $("form").on("submit", function(e) {
1247 e.preventDefault();
1248 });
1249 }
1250
1251 function parseIntNoNaN(val, defaultVal) {
1252 var v = parseInt(val);
1253 if (isNaN(v)) {
1254 return defaultVal;
1255 }
1256 return v;
1257 }
1258
1259 function showPending() {
1260 DOM.feedback
1261 .text("Calculating...")
1262 .show();
1263 }
1264
1265 function findNearestWord(word) {
1266 var language = getLanguage();
1267 var words = WORDLISTS[language];
1268 var minDistance = 99;
1269 var closestWord = words[0];
1270 for (var i=0; i<words.length; i++) {
1271 var comparedTo = words[i];
1272 if (comparedTo.indexOf(word) == 0) {
1273 return comparedTo;
1274 }
1275 var distance = Levenshtein.get(word, comparedTo);
1276 if (distance < minDistance) {
1277 closestWord = comparedTo;
1278 minDistance = distance;
1279 }
1280 }
1281 return closestWord;
1282 }
1283
1284 function hidePending() {
1285 DOM.feedback
1286 .text("")
1287 .hide();
1288 }
1289
1290 function populateNetworkSelect() {
1291 for (var i=0; i<networks.length; i++) {
1292 var network = networks[i];
1293 var option = $("<option>");
1294 option.attr("value", i);
1295 option.text(network.name);
1296 if (network.name == "BTC - Bitcoin") {
1297 option.prop("selected", true);
1298 }
1299 DOM.phraseNetwork.append(option);
1300 }
1301 }
1302
1303 function populateClientSelect() {
1304 for (var i=0; i<clients.length; i++) {
1305 var client = clients[i];
1306 var option = $("<option>");
1307 option.attr("value", i);
1308 option.text(client.name);
1309 DOM.bip32Client.append(option);
1310 }
1311 }
1312
1313 function getLanguage() {
1314 var defaultLanguage = "english";
1315 // Try to get from existing phrase
1316 var language = getLanguageFromPhrase();
1317 // Try to get from url if not from phrase
1318 if (language.length == 0) {
1319 language = getLanguageFromUrl();
1320 }
1321 // Default to English if no other option
1322 if (language.length == 0) {
1323 language = defaultLanguage;
1324 }
1325 return language;
1326 }
1327
1328 function getLanguageFromPhrase(phrase) {
1329 // Check if how many words from existing phrase match a language.
1330 var language = "";
1331 if (!phrase) {
1332 phrase = DOM.phrase.val();
1333 }
1334 if (phrase.length > 0) {
1335 var words = phraseToWordArray(phrase);
1336 var languageMatches = {};
1337 for (l in WORDLISTS) {
1338 // Track how many words match in this language
1339 languageMatches[l] = 0;
1340 for (var i=0; i<words.length; i++) {
1341 var wordInLanguage = WORDLISTS[l].indexOf(words[i]) > -1;
1342 if (wordInLanguage) {
1343 languageMatches[l]++;
1344 }
1345 }
1346 // Find languages with most word matches.
1347 // This is made difficult due to commonalities between Chinese
1348 // simplified vs traditional.
1349 var mostMatches = 0;
1350 var mostMatchedLanguages = [];
1351 for (var l in languageMatches) {
1352 var numMatches = languageMatches[l];
1353 if (numMatches > mostMatches) {
1354 mostMatches = numMatches;
1355 mostMatchedLanguages = [l];
1356 }
1357 else if (numMatches == mostMatches) {
1358 mostMatchedLanguages.push(l);
1359 }
1360 }
1361 }
1362 if (mostMatchedLanguages.length > 0) {
1363 // Use first language and warn if multiple detected
1364 language = mostMatchedLanguages[0];
1365 if (mostMatchedLanguages.length > 1) {
1366 console.warn("Multiple possible languages");
1367 console.warn(mostMatchedLanguages);
1368 }
1369 }
1370 }
1371 return language;
1372 }
1373
1374 function getLanguageFromUrl() {
1375 for (var language in WORDLISTS) {
1376 if (window.location.hash.indexOf(language) > -1) {
1377 return language;
1378 }
1379 }
1380 return "";
1381 }
1382
1383 function setMnemonicLanguage() {
1384 var language = getLanguage();
1385 // Load the bip39 mnemonic generator for this language if required
1386 if (!(language in mnemonics)) {
1387 mnemonics[language] = new Mnemonic(language);
1388 }
1389 mnemonic = mnemonics[language];
1390 }
1391
1392 function convertPhraseToNewLanguage() {
1393 var oldLanguage = getLanguageFromPhrase();
1394 var newLanguage = getLanguageFromUrl();
1395 var oldPhrase = DOM.phrase.val();
1396 var oldWords = phraseToWordArray(oldPhrase);
1397 var newWords = [];
1398 for (var i=0; i<oldWords.length; i++) {
1399 var oldWord = oldWords[i];
1400 var index = WORDLISTS[oldLanguage].indexOf(oldWord);
1401 var newWord = WORDLISTS[newLanguage][index];
1402 newWords.push(newWord);
1403 }
1404 newPhrase = wordArrayToPhrase(newWords);
1405 return newPhrase;
1406 }
1407
1408 // TODO look at jsbip39 - mnemonic.splitWords
1409 function phraseToWordArray(phrase) {
1410 var words = phrase.split(/\s/g);
1411 var noBlanks = [];
1412 for (var i=0; i<words.length; i++) {
1413 var word = words[i];
1414 if (word.length > 0) {
1415 noBlanks.push(word);
1416 }
1417 }
1418 return noBlanks;
1419 }
1420
1421 // TODO look at jsbip39 - mnemonic.joinWords
1422 function wordArrayToPhrase(words) {
1423 var phrase = words.join(" ");
1424 var language = getLanguageFromPhrase(phrase);
1425 if (language == "japanese") {
1426 phrase = words.join("\u3000");
1427 }
1428 return phrase;
1429 }
1430
1431 function writeSplitPhrase(phrase) {
1432 var wordCount = phrase.split(/\s/g).length; //get number of words in phrase
1433 var left=[]; //initialize array of indexs
1434 for (var i=0;i<wordCount;i++) left.push(i); //add all indexs to array
1435 var group=[[],[],[]], //make array for 3 groups
1436 groupI=-1; //initialize group index
1437 var seed = Math.abs(sjcl.hash.sha256.hash(phrase)[0])% 2147483647; //start seed at sudo random value based on hash of words
1438 while (left.length>0) { //while indexs left
1439 groupI=(groupI+1)%3; //get next group to insert index into
1440 seed = seed * 16807 % 2147483647; //change random value.(simple predicatable random number generator works well for this use)
1441 var selected=Math.floor(left.length*(seed - 1) / 2147483646); //get index in left we will use for this group
1442 group[groupI].push(left[selected]); //add index to group
1443 left.splice(selected,1); //remove selected index
1444 }
1445 var cards=[phrase.split(/\s/g),phrase.split(/\s/g),phrase.split(/\s/g)];//make array of cards
1446 for (var i=0;i<3;i++) { //go through each card
1447 for (var ii=0;ii<wordCount/3;ii++) cards[i][group[i][ii]]='XXXX'; //erase words listed in the group
1448 cards[i]='Card '+(i+1)+': '+wordArrayToPhrase(cards[i]); //combine words on card back to string
1449 }
1450 DOM.splitPhrase.val(cards.join("\r\n")); //make words visible
1451 }
1452
1453 function isUsingOwnEntropy() {
1454 return DOM.useEntropy.prop("checked");
1455 }
1456
1457 function setMnemonicFromEntropy() {
1458 clearEntropyFeedback();
1459 // Get entropy value
1460 var entropyStr = DOM.entropy.val();
1461 // Work out minimum base for entropy
1462 var entropy = Entropy.fromString(entropyStr);
1463 if (entropy.binaryStr.length == 0) {
1464 return;
1465 }
1466 // Show entropy details
1467 showEntropyFeedback(entropy);
1468 // Use entropy hash if not using raw entropy
1469 var bits = entropy.binaryStr;
1470 var mnemonicLength = DOM.entropyMnemonicLength.val();
1471 if (mnemonicLength != "raw") {
1472 // Get bits by hashing entropy with SHA256
1473 var hash = sjcl.hash.sha256.hash(entropy.cleanStr);
1474 var hex = sjcl.codec.hex.fromBits(hash);
1475 bits = BigInteger.parse(hex, 16).toString(2);
1476 while (bits.length % 256 != 0) {
1477 bits = "0" + bits;
1478 }
1479 // Truncate hash to suit number of words
1480 mnemonicLength = parseInt(mnemonicLength);
1481 var numberOfBits = 32 * mnemonicLength / 3;
1482 bits = bits.substring(0, numberOfBits);
1483 // show warning for weak entropy override
1484 if (mnemonicLength / 3 * 32 > entropy.binaryStr.length) {
1485 DOM.entropyWeakEntropyOverrideWarning.removeClass("hidden");
1486 }
1487 else {
1488 DOM.entropyWeakEntropyOverrideWarning.addClass("hidden");
1489 }
1490 }
1491 else {
1492 // hide warning for weak entropy override
1493 DOM.entropyWeakEntropyOverrideWarning.addClass("hidden");
1494 }
1495 // Discard trailing entropy
1496 var bitsToUse = Math.floor(bits.length / 32) * 32;
1497 var start = bits.length - bitsToUse;
1498 var binaryStr = bits.substring(start);
1499 // Convert entropy string to numeric array
1500 var entropyArr = [];
1501 for (var i=0; i<binaryStr.length / 8; i++) {
1502 var byteAsBits = binaryStr.substring(i*8, i*8+8);
1503 var entropyByte = parseInt(byteAsBits, 2);
1504 entropyArr.push(entropyByte)
1505 }
1506 // Convert entropy array to mnemonic
1507 var phrase = mnemonic.toMnemonic(entropyArr);
1508 // Set the mnemonic in the UI
1509 DOM.phrase.val(phrase);
1510 writeSplitPhrase(phrase);
1511 // Show the word indexes
1512 showWordIndexes();
1513 // Show the checksum
1514 showChecksum();
1515 }
1516
1517 function clearEntropyFeedback() {
1518 DOM.entropyCrackTime.text("...");
1519 DOM.entropyType.text("");
1520 DOM.entropyWordCount.text("0");
1521 DOM.entropyEventCount.text("0");
1522 DOM.entropyBitsPerEvent.text("0");
1523 DOM.entropyBits.text("0");
1524 DOM.entropyFiltered.html("&nbsp;");
1525 DOM.entropyBinary.html("&nbsp;");
1526 }
1527
1528 function showEntropyFeedback(entropy) {
1529 var numberOfBits = entropy.binaryStr.length;
1530 var timeToCrack = "unknown";
1531 try {
1532 var z = zxcvbn(entropy.base.parts.join(""));
1533 timeToCrack = z.crack_times_display.offline_fast_hashing_1e10_per_second;
1534 if (z.feedback.warning != "") {
1535 timeToCrack = timeToCrack + " - " + z.feedback.warning;
1536 };
1537 }
1538 catch (e) {
1539 console.log("Error detecting entropy strength with zxcvbn:");
1540 console.log(e);
1541 }
1542 var entropyTypeStr = getEntropyTypeStr(entropy);
1543 var wordCount = Math.floor(numberOfBits / 32) * 3;
1544 var bitsPerEvent = entropy.bitsPerEvent.toFixed(2);
1545 var spacedBinaryStr = addSpacesEveryElevenBits(entropy.binaryStr);
1546 DOM.entropyFiltered.html(entropy.cleanHtml);
1547 DOM.entropyType.text(entropyTypeStr);
1548 DOM.entropyCrackTime.text(timeToCrack);
1549 DOM.entropyEventCount.text(entropy.base.ints.length);
1550 DOM.entropyBits.text(numberOfBits);
1551 DOM.entropyWordCount.text(wordCount);
1552 DOM.entropyBinary.text(spacedBinaryStr);
1553 DOM.entropyBitsPerEvent.text(bitsPerEvent);
1554 // detect and warn of filtering
1555 var rawNoSpaces = DOM.entropy.val().replace(/\s/g, "");
1556 var cleanNoSpaces = entropy.cleanStr.replace(/\s/g, "");
1557 var isFiltered = rawNoSpaces.length != cleanNoSpaces.length;
1558 if (isFiltered) {
1559 DOM.entropyFilterWarning.removeClass('hidden');
1560 }
1561 else {
1562 DOM.entropyFilterWarning.addClass('hidden');
1563 }
1564 }
1565
1566 function getEntropyTypeStr(entropy) {
1567 var typeStr = entropy.base.str;
1568 // Add some detail if these are cards
1569 if (entropy.base.asInt == 52) {
1570 var cardDetail = []; // array of message strings
1571 // Detect duplicates
1572 var dupes = [];
1573 var dupeTracker = {};
1574 for (var i=0; i<entropy.base.parts.length; i++) {
1575 var card = entropy.base.parts[i];
1576 var cardUpper = card.toUpperCase();
1577 if (cardUpper in dupeTracker) {
1578 dupes.push(card);
1579 }
1580 dupeTracker[cardUpper] = true;
1581 }
1582 if (dupes.length > 0) {
1583 var dupeWord = "duplicates";
1584 if (dupes.length == 1) {
1585 dupeWord = "duplicate";
1586 }
1587 var msg = dupes.length + " " + dupeWord + ": " + dupes.slice(0,3).join(" ");
1588 if (dupes.length > 3) {
1589 msg += "...";
1590 }
1591 cardDetail.push(msg);
1592 }
1593 // Detect full deck
1594 var uniqueCards = [];
1595 for (var uniqueCard in dupeTracker) {
1596 uniqueCards.push(uniqueCard);
1597 }
1598 if (uniqueCards.length == 52) {
1599 cardDetail.unshift("full deck");
1600 }
1601 // Detect missing cards
1602 var values = "A23456789TJQK";
1603 var suits = "CDHS";
1604 var missingCards = [];
1605 for (var i=0; i<suits.length; i++) {
1606 for (var j=0; j<values.length; j++) {
1607 var card = values[j] + suits[i];
1608 if (!(card in dupeTracker)) {
1609 missingCards.push(card);
1610 }
1611 }
1612 }
1613 // Display missing cards if six or less, ie clearly going for full deck
1614 if (missingCards.length > 0 && missingCards.length <= 6) {
1615 var msg = missingCards.length + " missing: " + missingCards.slice(0,3).join(" ");
1616 if (missingCards.length > 3) {
1617 msg += "...";
1618 }
1619 cardDetail.push(msg);
1620 }
1621 // Add card details to typeStr
1622 if (cardDetail.length > 0) {
1623 typeStr += " (" + cardDetail.join(", ") + ")";
1624 }
1625 }
1626 return typeStr;
1627 }
1628
1629 function setQrEvents(els) {
1630 els.on("mouseenter", createQr);
1631 els.on("mouseleave", destroyQr);
1632 els.on("click", toggleQr);
1633 }
1634
1635 function createQr(e) {
1636 var content = e.target.textContent || e.target.value;
1637 if (content) {
1638 var qrEl = kjua({
1639 text: content,
1640 render: "canvas",
1641 size: 310,
1642 ecLevel: 'H',
1643 });
1644 DOM.qrImage.append(qrEl);
1645 if (!showQr) {
1646 DOM.qrHider.addClass("hidden");
1647 }
1648 else {
1649 DOM.qrHider.removeClass("hidden");
1650 }
1651 DOM.qrContainer.removeClass("hidden");
1652 }
1653 }
1654
1655 function destroyQr() {
1656 DOM.qrImage.text("");
1657 DOM.qrContainer.addClass("hidden");
1658 }
1659
1660 function toggleQr() {
1661 showQr = !showQr;
1662 DOM.qrHider.toggleClass("hidden");
1663 DOM.qrHint.toggleClass("hidden");
1664 }
1665
1666 function bip44TabSelected() {
1667 return DOM.bip44tab.hasClass("active");
1668 }
1669
1670 function bip32TabSelected() {
1671 return DOM.bip32tab.hasClass("active");
1672 }
1673
1674 function networkHasSegwit() {
1675 var n = network;
1676 if ("baseNetwork" in network) {
1677 n = bitcoinjs.bitcoin.networks[network.baseNetwork];
1678 }
1679 // check if only p2wpkh params are required
1680 if (p2wpkhSelected()) {
1681 return "p2wpkh" in n;
1682 }
1683 // check if only p2wpkh-in-p2sh params are required
1684 else if (p2wpkhInP2shSelected()) {
1685 return "p2wpkhInP2sh" in n;
1686 }
1687 // require both if it's unclear which params are required
1688 return "p2wpkh" in n && "p2wpkhInP2sh" in n;
1689 }
1690
1691 function bip49TabSelected() {
1692 return DOM.bip49tab.hasClass("active");
1693 }
1694
1695 function bip84TabSelected() {
1696 return DOM.bip84tab.hasClass("active");
1697 }
1698
1699 function bip141TabSelected() {
1700 return DOM.bip141tab.hasClass("active");
1701 }
1702
1703 function setHdCoin(coinValue) {
1704 DOM.bip44coin.val(coinValue);
1705 DOM.bip49coin.val(coinValue);
1706 DOM.bip84coin.val(coinValue);
1707 }
1708
1709 function showSegwitAvailable() {
1710 DOM.bip49unavailable.addClass("hidden");
1711 DOM.bip49available.removeClass("hidden");
1712 DOM.bip84unavailable.addClass("hidden");
1713 DOM.bip84available.removeClass("hidden");
1714 DOM.bip141unavailable.addClass("hidden");
1715 DOM.bip141available.removeClass("hidden");
1716 }
1717
1718 function showSegwitUnavailable() {
1719 DOM.bip49available.addClass("hidden");
1720 DOM.bip49unavailable.removeClass("hidden");
1721 DOM.bip84available.addClass("hidden");
1722 DOM.bip84unavailable.removeClass("hidden");
1723 DOM.bip141available.addClass("hidden");
1724 DOM.bip141unavailable.removeClass("hidden");
1725 }
1726
1727 function adjustNetworkForSegwit() {
1728 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1729 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1730 // wallet.
1731 // See https://github.com/iancoleman/bip39/issues/125
1732 var segwitNetworks = null;
1733 // if a segwit network is alread selected, need to use base network to
1734 // look up new parameters
1735 if ("baseNetwork" in network) {
1736 network = bitcoinjs.bitcoin.networks[network.baseNetwork];
1737 }
1738 // choose the right segwit params
1739 if (p2wpkhSelected() && "p2wpkh" in network) {
1740 network = network.p2wpkh;
1741 }
1742 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network) {
1743 network = network.p2wpkhInP2sh;
1744 }
1745 }
1746
1747 function lastIndexInTable() {
1748 var pathText = DOM.addresses.find(".index").last().text();
1749 var pathBits = pathText.split("/");
1750 var lastBit = pathBits[pathBits.length-1];
1751 var lastBitClean = lastBit.replace("'", "");
1752 return parseInt(lastBitClean);
1753 }
1754
1755 function uint8ArrayToHex(a) {
1756 var s = ""
1757 for (var i=0; i<a.length; i++) {
1758 var h = a[i].toString(16);
1759 while (h.length < 2) {
1760 h = "0" + h;
1761 }
1762 s = s + h;
1763 }
1764 return s;
1765 }
1766
1767 function showWordIndexes() {
1768 var phrase = DOM.phrase.val();
1769 var words = phraseToWordArray(phrase);
1770 var wordIndexes = [];
1771 var language = getLanguage();
1772 for (var i=0; i<words.length; i++) {
1773 var word = words[i];
1774 var wordIndex = WORDLISTS[language].indexOf(word);
1775 wordIndexes.push(wordIndex);
1776 }
1777 var wordIndexesStr = wordIndexes.join(", ");
1778 DOM.entropyWordIndexes.text(wordIndexesStr);
1779 }
1780
1781 function showChecksum() {
1782 var phrase = DOM.phrase.val();
1783 var words = phraseToWordArray(phrase);
1784 var checksumBitlength = words.length / 3;
1785 var checksum = "";
1786 var binaryStr = "";
1787 var language = getLanguage();
1788 for (var i=words.length-1; i>=0; i--) {
1789 var word = words[i];
1790 var wordIndex = WORDLISTS[language].indexOf(word);
1791 var wordBinary = wordIndex.toString(2);
1792 while (wordBinary.length < 11) {
1793 wordBinary = "0" + wordBinary;
1794 }
1795 var binaryStr = wordBinary + binaryStr;
1796 if (binaryStr.length >= checksumBitlength) {
1797 var start = binaryStr.length - checksumBitlength;
1798 var end = binaryStr.length;
1799 checksum = binaryStr.substring(start, end);
1800 // add spaces so the last group is 11 bits, not the first
1801 checksum = checksum.split("").reverse().join("")
1802 checksum = addSpacesEveryElevenBits(checksum);
1803 checksum = checksum.split("").reverse().join("")
1804 break;
1805 }
1806 }
1807 DOM.entropyChecksum.text(checksum);
1808 }
1809
1810 function updateCsv() {
1811 var tableCsv = "path,address,public key,private key\n";
1812 var rows = DOM.addresses.find("tr");
1813 for (var i=0; i<rows.length; i++) {
1814 var row = $(rows[i]);
1815 var cells = row.find("td");
1816 for (var j=0; j<cells.length; j++) {
1817 var cell = $(cells[j]);
1818 if (!cell.children().hasClass("invisible")) {
1819 tableCsv = tableCsv + cell.text();
1820 }
1821 if (j != cells.length - 1) {
1822 tableCsv = tableCsv + ",";
1823 }
1824 }
1825 tableCsv = tableCsv + "\n";
1826 }
1827 DOM.csv.val(tableCsv);
1828 }
1829
1830 function addSpacesEveryElevenBits(binaryStr) {
1831 return binaryStr.match(/.{1,11}/g).join(" ");
1832 }
1833
1834 var networks = [
1835 {
1836 name: "AC - Asiacoin",
1837 onSelect: function() {
1838 network = bitcoinjs.bitcoin.networks.asiacoin;
1839 setHdCoin(51);
1840 },
1841 },
1842 {
1843 name: "ACC - Adcoin",
1844 onSelect: function() {
1845 network = bitcoinjs.bitcoin.networks.adcoin;
1846 setHdCoin(161);
1847 },
1848 },
1849 {
1850 name: "ARYA - Aryacoin",
1851 onSelect: function() {
1852 network = bitcoinjs.bitcoin.networks.aryacoin;
1853 setHdCoin(357);
1854 },
1855 },
1856 {
1857 name: "AUR - Auroracoin",
1858 onSelect: function() {
1859 network = bitcoinjs.bitcoin.networks.auroracoin;
1860 setHdCoin(85);
1861 },
1862 },
1863 {
1864 name: "AXE - Axe",
1865 onSelect: function() {
1866 network = bitcoinjs.bitcoin.networks.axe;
1867 setHdCoin(4242);
1868 },
1869 },
1870 {
1871 name: "ANON - ANON",
1872 onSelect: function() {
1873 network = bitcoinjs.bitcoin.networks.anon;
1874 setHdCoin(220);
1875 },
1876 },
1877 {
1878 name: "BOLI - Bolivarcoin",
1879 onSelect: function() {
1880 network = bitcoinjs.bitcoin.networks.bolivarcoin;
1881 setHdCoin(278);
1882 },
1883 },
1884 {
1885 name: "BCA - Bitcoin Atom",
1886 onSelect: function() {
1887 network = bitcoinjs.bitcoin.networks.atom;
1888 setHdCoin(185);
1889 },
1890 },
1891 {
1892 name: "BCH - Bitcoin Cash",
1893 onSelect: function() {
1894 DOM.bitcoinCashAddressTypeContainer.removeClass("hidden");
1895 setHdCoin(145);
1896 },
1897 },
1898 {
1899 name: "BEET - Beetlecoin",
1900 onSelect: function() {
1901 network = bitcoinjs.bitcoin.networks.beetlecoin;
1902 setHdCoin(800);
1903 },
1904 },
1905 {
1906 name: "BELA - Belacoin",
1907 onSelect: function() {
1908 network = bitcoinjs.bitcoin.networks.belacoin;
1909 setHdCoin(73);
1910 },
1911 },
1912 {
1913 name: "BLK - BlackCoin",
1914 onSelect: function() {
1915 network = bitcoinjs.bitcoin.networks.blackcoin;
1916 setHdCoin(10);
1917 },
1918 },
1919 {
1920 name: "BND - Blocknode",
1921 onSelect: function() {
1922 network = bitcoinjs.bitcoin.networks.blocknode;
1923 setHdCoin(2941);
1924 },
1925 },
1926 {
1927 name: "tBND - Blocknode Testnet",
1928 onSelect: function() {
1929 network = bitcoinjs.bitcoin.networks.blocknode_testnet;
1930 setHdCoin(1);
1931 },
1932 },
1933 {
1934 name: "BRIT - Britcoin",
1935 onSelect: function() {
1936 network = bitcoinjs.bitcoin.networks.britcoin;
1937 setHdCoin(70);
1938 },
1939 },
1940 {
1941 name: "BSD - Bitsend",
1942 onSelect: function() {
1943 network = bitcoinjs.bitcoin.networks.bitsend;
1944 setHdCoin(91);
1945 },
1946 },
1947 {
1948 name: "BST - BlockStamp",
1949 onSelect: function() {
1950 network = bitcoinjs.bitcoin.networks.blockstamp;
1951 setHdCoin(254);
1952 },
1953 },
1954 {
1955 name: "BTA - Bata",
1956 onSelect: function() {
1957 network = bitcoinjs.bitcoin.networks.bata;
1958 setHdCoin(89);
1959 },
1960 },
1961 {
1962 name: "BTC - Bitcoin",
1963 onSelect: function() {
1964 network = bitcoinjs.bitcoin.networks.bitcoin;
1965 setHdCoin(0);
1966 },
1967 },
1968 {
1969 name: "BTC - Bitcoin Testnet",
1970 onSelect: function() {
1971 network = bitcoinjs.bitcoin.networks.testnet;
1972 setHdCoin(1);
1973 },
1974 },
1975 {
1976 name: "BITG - Bitcoin Green",
1977 onSelect: function() {
1978 network = bitcoinjs.bitcoin.networks.bitcoingreen;
1979 setHdCoin(222);
1980 },
1981 },
1982 {
1983 name: "BTCP - Bitcoin Private",
1984 onSelect: function() {
1985 network = bitcoinjs.bitcoin.networks.bitcoinprivate;
1986 setHdCoin(183);
1987 },
1988 },
1989 {
1990 name: "BSV - BitcoinSV",
1991 onSelect: function() {
1992 network = bitcoinjs.bitcoin.networks.bitcoinsv;
1993 setHdCoin(236);
1994 },
1995 },
1996 {
1997 name: "BTCZ - Bitcoinz",
1998 onSelect: function() {
1999 network = bitcoinjs.bitcoin.networks.bitcoinz;
2000 setHdCoin(177);
2001 },
2002 },
2003 {
2004 name: "BTDX - BitCloud",
2005 onSelect: function() {
2006 network = bitcoinjs.bitcoin.networks.bitcloud;
2007 setHdCoin(218);
2008 },
2009 },
2010 {
2011 name: "BTG - Bitcoin Gold",
2012 onSelect: function() {
2013 network = bitcoinjs.bitcoin.networks.bgold;
2014 setHdCoin(156);
2015 },
2016 },
2017 {
2018 name: "BTX - Bitcore",
2019 onSelect: function() {
2020 network = bitcoinjs.bitcoin.networks.bitcore;
2021 setHdCoin(160);
2022 },
2023 },
2024 {
2025 name: "CCN - Cannacoin",
2026 onSelect: function() {
2027 network = bitcoinjs.bitcoin.networks.cannacoin;
2028 setHdCoin(19);
2029 },
2030 },
2031 {
2032 name: "CESC - Cryptoescudo",
2033 onSelect: function() {
2034 network = bitcoinjs.bitcoin.networks.cannacoin;
2035 setHdCoin(111);
2036 },
2037 },
2038 {
2039 name: "CDN - Canadaecoin",
2040 onSelect: function() {
2041 network = bitcoinjs.bitcoin.networks.canadaecoin;
2042 setHdCoin(34);
2043 },
2044 },
2045 {
2046 name: "CLAM - Clams",
2047 onSelect: function() {
2048 network = bitcoinjs.bitcoin.networks.clam;
2049 setHdCoin(23);
2050 },
2051 },
2052 {
2053 name: "CLO - Callisto",
2054 segwitAvailable: false,
2055 onSelect: function() {
2056 network = bitcoinjs.bitcoin.networks.bitcoin;
2057 setHdCoin(820);
2058 },
2059 },
2060 {
2061 name: "CLUB - Clubcoin",
2062 onSelect: function() {
2063 network = bitcoinjs.bitcoin.networks.clubcoin;
2064 setHdCoin(79);
2065 },
2066 },
2067 {
2068 name: "CMP - Compcoin",
2069 onSelect: function() {
2070 network = bitcoinjs.bitcoin.networks.compcoin;
2071 setHdCoin(71);
2072 },
2073 },
2074 {
2075 name: "CPU - CPUchain",
2076 onSelect: function() {
2077 network = bitcoinjs.bitcoin.networks.cpuchain;
2078 setHdCoin(363);
2079 },
2080 },
2081 {
2082 name: "CRAVE - Crave",
2083 onSelect: function() {
2084 network = bitcoinjs.bitcoin.networks.crave;
2085 setHdCoin(186);
2086 },
2087 },
2088 {
2089 name: "CRW - Crown (Legacy)",
2090 onSelect: function() {
2091 network = bitcoinjs.bitcoin.networks.crown;
2092 setHdCoin(72);
2093 },
2094 },
2095 {
2096 name: "CRW - Crown",
2097 onSelect: function() {
2098 network = bitcoinjs.bitcoin.networks.crown;
2099 setHdCoin(72);
2100 },
2101 },
2102 {
2103 name: "CSC - CasinoCoin",
2104 onSelect: function() {
2105 network = bitcoinjs.bitcoin.networks.bitcoin;
2106 setHdCoin(359);
2107 },
2108 },
2109 {
2110 name: "DASH - Dash",
2111 onSelect: function() {
2112 network = bitcoinjs.bitcoin.networks.dash;
2113 setHdCoin(5);
2114 },
2115 },
2116 {
2117 name: "DASH - Dash Testnet",
2118 onSelect: function() {
2119 network = bitcoinjs.bitcoin.networks.dashtn;
2120 setHdCoin(1);
2121 },
2122 },
2123 {
2124 name: "DFC - Defcoin",
2125 onSelect: function() {
2126 network = bitcoinjs.bitcoin.networks.defcoin;
2127 setHdCoin(1337);
2128 },
2129 },
2130 {
2131 name: "DGB - Digibyte",
2132 onSelect: function() {
2133 network = bitcoinjs.bitcoin.networks.digibyte;
2134 setHdCoin(20);
2135 },
2136 },
2137 {
2138 name: "DGC - Digitalcoin",
2139 onSelect: function() {
2140 network = bitcoinjs.bitcoin.networks.digitalcoin;
2141 setHdCoin(18);
2142 },
2143 },
2144 {
2145 name: "DMD - Diamond",
2146 onSelect: function() {
2147 network = bitcoinjs.bitcoin.networks.diamond;
2148 setHdCoin(152);
2149 },
2150 },
2151 {
2152 name: "DNR - Denarius",
2153 onSelect: function() {
2154 network = bitcoinjs.bitcoin.networks.denarius;
2155 setHdCoin(116);
2156 },
2157 },
2158 {
2159 name: "DOGE - Dogecoin",
2160 onSelect: function() {
2161 network = bitcoinjs.bitcoin.networks.dogecoin;
2162 setHdCoin(3);
2163 },
2164 },
2165 {
2166 name: "DOGEt - Dogecoin Testnet",
2167 onSelect: function() {
2168 network = bitcoinjs.bitcoin.networks.dogecointestnet;
2169 setHdCoin(1);
2170 },
2171 },
2172 {
2173 name: "DXN - DEXON",
2174 onSelect: function() {
2175 network = bitcoinjs.bitcoin.networks.bitcoin;
2176 setHdCoin(237);
2177 },
2178 },
2179 {
2180 name: "ECN - Ecoin",
2181 onSelect: function() {
2182 network = bitcoinjs.bitcoin.networks.ecoin;
2183 setHdCoin(115);
2184 },
2185 },
2186 {
2187 name: "EDRC - Edrcoin",
2188 onSelect: function() {
2189 network = bitcoinjs.bitcoin.networks.edrcoin;
2190 setHdCoin(56);
2191 },
2192 },
2193 {
2194 name: "EFL - Egulden",
2195 onSelect: function() {
2196 network = bitcoinjs.bitcoin.networks.egulden;
2197 setHdCoin(78);
2198 },
2199 },
2200 {
2201 name: "ELLA - Ellaism",
2202 segwitAvailable: false,
2203 onSelect: function() {
2204 network = bitcoinjs.bitcoin.networks.bitcoin;
2205 setHdCoin(163);
2206 },
2207 },
2208 {
2209 name: "EMC2 - Einsteinium",
2210 onSelect: function() {
2211 network = bitcoinjs.bitcoin.networks.einsteinium;
2212 setHdCoin(41);
2213 },
2214 },
2215 {
2216 name: "ERC - Europecoin",
2217 onSelect: function() {
2218 network = bitcoinjs.bitcoin.networks.europecoin;
2219 setHdCoin(151);
2220 },
2221 },
2222 {
2223 name: "EOS - EOSIO",
2224 onSelect: function() {
2225 network = bitcoinjs.bitcoin.networks.bitcoin;
2226 setHdCoin(194);
2227 },
2228 },
2229 {
2230 name: "ESN - Ethersocial Network",
2231 segwitAvailable: false,
2232 onSelect: function() {
2233 network = bitcoinjs.bitcoin.networks.bitcoin;
2234 setHdCoin(31102);
2235 },
2236 },
2237 {
2238 name: "ETC - Ethereum Classic",
2239 segwitAvailable: false,
2240 onSelect: function() {
2241 network = bitcoinjs.bitcoin.networks.bitcoin;
2242 setHdCoin(61);
2243 },
2244 },
2245 {
2246 name: "ETH - Ethereum",
2247 onSelect: function() {
2248 network = bitcoinjs.bitcoin.networks.bitcoin;
2249 setHdCoin(60);
2250 },
2251 },
2252 {
2253 name: "EXCL - Exclusivecoin",
2254 onSelect: function() {
2255 network = bitcoinjs.bitcoin.networks.exclusivecoin;
2256 setHdCoin(190);
2257 },
2258 },
2259 {
2260 name: "EXCC - ExchangeCoin",
2261 onSelect: function() {
2262 network = bitcoinjs.bitcoin.networks.exchangecoin;
2263 setHdCoin(0);
2264 },
2265 },
2266 {
2267 name: "EXP - Expanse",
2268 segwitAvailable: false,
2269 onSelect: function() {
2270 network = bitcoinjs.bitcoin.networks.bitcoin;
2271 setHdCoin(40);
2272 },
2273 },
2274 {
2275 name: "FIX - FIX",
2276 onSelect: function() {
2277 network = bitcoinjs.bitcoin.networks.fix;
2278 setHdCoin(336);
2279 },
2280 },
2281 {
2282 name: "FIX - FIX Testnet",
2283 onSelect: function() {
2284 network = bitcoinjs.bitcoin.networks.fixtestnet;
2285 setHdCoin(1);
2286 },
2287 },
2288 {
2289 name: "FJC - Fujicoin",
2290 onSelect: function() {
2291 network = bitcoinjs.bitcoin.networks.fujicoin;
2292 setHdCoin(75);
2293 },
2294 },
2295 {
2296 name: "FLASH - Flashcoin",
2297 onSelect: function() {
2298 network = bitcoinjs.bitcoin.networks.flashcoin;
2299 setHdCoin(120);
2300 },
2301 },
2302 {
2303 name: "FRST - Firstcoin",
2304 onSelect: function() {
2305 network = bitcoinjs.bitcoin.networks.firstcoin;
2306 setHdCoin(167);
2307 },
2308 },
2309 {
2310 name: "FTC - Feathercoin",
2311 onSelect: function() {
2312 network = bitcoinjs.bitcoin.networks.feathercoin;
2313 setHdCoin(8);
2314 },
2315 },
2316 {
2317 name: "GAME - GameCredits",
2318 onSelect: function() {
2319 network = bitcoinjs.bitcoin.networks.game;
2320 setHdCoin(101);
2321 },
2322 },
2323 {
2324 name: "GBX - Gobyte",
2325 onSelect: function() {
2326 network = bitcoinjs.bitcoin.networks.gobyte;
2327 setHdCoin(176);
2328 },
2329 },
2330 {
2331 name: "GCR - GCRCoin",
2332 onSelect: function() {
2333 network = bitcoinjs.bitcoin.networks.gcr;
2334 setHdCoin(79);
2335 },
2336 },
2337 {
2338 name: "GRC - Gridcoin",
2339 onSelect: function() {
2340 network = bitcoinjs.bitcoin.networks.gridcoin;
2341 setHdCoin(84);
2342 },
2343 },
2344 {
2345 name: "GRS - Groestlcoin",
2346 onSelect: function() {
2347 network = bitcoinjs.bitcoin.networks.groestlcoin;
2348 setHdCoin(17);
2349 },
2350 },
2351 {
2352 name: "GRS - Groestlcoin Testnet",
2353 onSelect: function() {
2354 network = bitcoinjs.bitcoin.networks.groestlcointestnet;
2355 setHdCoin(1);
2356 },
2357 },
2358 {
2359 name: "HNC - Helleniccoin",
2360 onSelect: function() {
2361 network = bitcoinjs.bitcoin.networks.helleniccoin;
2362 setHdCoin(168);
2363 },
2364 },
2365 {
2366 name: "HUSH - Hush (Legacy)",
2367 onSelect: function() {
2368 network = bitcoinjs.bitcoin.networks.hush;
2369 setHdCoin(197);
2370 },
2371 },
2372 {
2373 name: "HUSH - Hush3",
2374 onSelect: function() {
2375 network = bitcoinjs.bitcoin.networks.hush3;
2376 setHdCoin(197);
2377 },
2378 },
2379 {
2380 name: "INSN - Insane",
2381 onSelect: function() {
2382 network = bitcoinjs.bitcoin.networks.insane;
2383 setHdCoin(68);
2384 },
2385 },
2386 {
2387 name: "IOP - Iop",
2388 onSelect: function() {
2389 network = bitcoinjs.bitcoin.networks.iop;
2390 setHdCoin(66);
2391 },
2392 },
2393 {
2394 name: "IXC - Ixcoin",
2395 onSelect: function() {
2396 network = bitcoinjs.bitcoin.networks.ixcoin;
2397 setHdCoin(86);
2398 },
2399 },
2400 {
2401 name: "JBS - Jumbucks",
2402 onSelect: function() {
2403 network = bitcoinjs.bitcoin.networks.jumbucks;
2404 setHdCoin(26);
2405 },
2406 },
2407 {
2408 name: "KMD - Komodo",
2409 bip49available: false,
2410 onSelect: function() {
2411 network = bitcoinjs.bitcoin.networks.komodo;
2412 setHdCoin(141);
2413 },
2414 },
2415 {
2416 name: "KOBO - Kobocoin",
2417 bip49available: false,
2418 onSelect: function() {
2419 network = bitcoinjs.bitcoin.networks.kobocoin;
2420 setHdCoin(196);
2421 },
2422 },
2423 {
2424 name: "LBC - Library Credits",
2425 onSelect: function() {
2426 network = bitcoinjs.bitcoin.networks.lbry;
2427 setHdCoin(140);
2428 },
2429 },
2430 {
2431 name: "LCC - Litecoincash",
2432 onSelect: function() {
2433 network = bitcoinjs.bitcoin.networks.litecoincash;
2434 setHdCoin(192);
2435 },
2436 },
2437 {
2438 name: "LDCN - Landcoin",
2439 onSelect: function() {
2440 network = bitcoinjs.bitcoin.networks.landcoin;
2441 setHdCoin(63);
2442 },
2443 },
2444 {
2445 name: "LINX - Linx",
2446 onSelect: function() {
2447 network = bitcoinjs.bitcoin.networks.linx;
2448 setHdCoin(114);
2449 },
2450 },
2451 {
2452 name: "LKR - Lkrcoin",
2453 segwitAvailable: false,
2454 onSelect: function() {
2455 network = bitcoinjs.bitcoin.networks.lkrcoin;
2456 setHdCoin(557);
2457 },
2458 },
2459 {
2460 name: "LTC - Litecoin",
2461 onSelect: function() {
2462 network = bitcoinjs.bitcoin.networks.litecoin;
2463 setHdCoin(2);
2464 DOM.litecoinLtubContainer.removeClass("hidden");
2465 },
2466 },
2467 {
2468 name: "LTCt - Litecoin Testnet",
2469 onSelect: function() {
2470 network = bitcoinjs.bitcoin.networks.litecointestnet;
2471 setHdCoin(1);
2472 DOM.litecoinLtubContainer.removeClass("hidden");
2473 },
2474 },
2475 {
2476 name: "LTZ - LitecoinZ",
2477 onSelect: function() {
2478 network = bitcoinjs.bitcoin.networks.litecoinz;
2479 setHdCoin(221);
2480 },
2481 },
2482 {
2483 name: "LYNX - Lynx",
2484 onSelect: function() {
2485 network = bitcoinjs.bitcoin.networks.lynx;
2486 setHdCoin(191);
2487 },
2488 },
2489 {
2490 name: "MAZA - Maza",
2491 onSelect: function() {
2492 network = bitcoinjs.bitcoin.networks.maza;
2493 setHdCoin(13);
2494 },
2495 },
2496 {
2497 name: "MEC - Megacoin",
2498 onSelect: function() {
2499 network = bitcoinjs.bitcoin.networks.megacoin;
2500 setHdCoin(217);
2501 },
2502 },
2503 {
2504 name: "MIX - MIX",
2505 segwitAvailable: false,
2506 onSelect: function() {
2507 network = bitcoinjs.bitcoin.networks.bitcoin;
2508 setHdCoin(76);
2509 },
2510 },
2511 {
2512 name: "MNX - Minexcoin",
2513 onSelect: function() {
2514 network = bitcoinjs.bitcoin.networks.minexcoin;
2515 setHdCoin(182);
2516 },
2517 },
2518 {
2519 name: "MONA - Monacoin",
2520 onSelect: function() {
2521 network = bitcoinjs.bitcoin.networks.monacoin,
2522 setHdCoin(22);
2523 },
2524 },
2525 {
2526 name: "MONK - Monkey Project",
2527 onSelect: function() {
2528 network = bitcoinjs.bitcoin.networks.monkeyproject,
2529 setHdCoin(214);
2530 },
2531 },
2532 {
2533 name: "MUSIC - Musicoin",
2534 segwitAvailable: false,
2535 onSelect: function() {
2536 network = bitcoinjs.bitcoin.networks.bitcoin;
2537 setHdCoin(184);
2538 },
2539 },
2540 {
2541 name: "NAV - Navcoin",
2542 onSelect: function() {
2543 network = bitcoinjs.bitcoin.networks.navcoin;
2544 setHdCoin(130);
2545 },
2546 },
2547 {
2548 name: "NAS - Nebulas",
2549 onSelect: function() {
2550 network = bitcoinjs.bitcoin.networks.bitcoin;
2551 setHdCoin(2718);
2552 },
2553 },
2554 {
2555 name: "NEBL - Neblio",
2556 onSelect: function() {
2557 network = bitcoinjs.bitcoin.networks.neblio;
2558 setHdCoin(146);
2559 },
2560 },
2561 {
2562 name: "NEOS - Neoscoin",
2563 onSelect: function() {
2564 network = bitcoinjs.bitcoin.networks.neoscoin;
2565 setHdCoin(25);
2566 },
2567 },
2568 {
2569 name: "NIX - NIX Platform",
2570 onSelect: function() {
2571 network = bitcoinjs.bitcoin.networks.nix;
2572 setHdCoin(400);
2573 },
2574 },
2575 {
2576 name: "NLG - Gulden",
2577 onSelect: function() {
2578 network = bitcoinjs.bitcoin.networks.gulden;
2579 setHdCoin(87);
2580 },
2581 },
2582 {
2583 name: "NMC - Namecoin",
2584 onSelect: function() {
2585 network = bitcoinjs.bitcoin.networks.namecoin;
2586 setHdCoin(7);
2587 },
2588 },
2589 {
2590 name: "NRG - Energi",
2591 onSelect: function() {
2592 network = bitcoinjs.bitcoin.networks.energi;
2593 setHdCoin(204);
2594 },
2595 },
2596 {
2597 name: "NRO - Neurocoin",
2598 onSelect: function() {
2599 network = bitcoinjs.bitcoin.networks.neurocoin;
2600 setHdCoin(110);
2601 },
2602 },
2603 {
2604 name: "NSR - Nushares",
2605 onSelect: function() {
2606 network = bitcoinjs.bitcoin.networks.nushares;
2607 setHdCoin(11);
2608 },
2609 },
2610 {
2611 name: "NYC - Newyorkc",
2612 onSelect: function() {
2613 network = bitcoinjs.bitcoin.networks.newyorkc;
2614 setHdCoin(179);
2615 },
2616 },
2617 {
2618 name: "NVC - Novacoin",
2619 onSelect: function() {
2620 network = bitcoinjs.bitcoin.networks.novacoin;
2621 setHdCoin(50);
2622 },
2623 },
2624 {
2625 name: "OK - Okcash",
2626 onSelect: function() {
2627 network = bitcoinjs.bitcoin.networks.okcash;
2628 setHdCoin(69);
2629 },
2630 },
2631 {
2632 name: "OMNI - Omnicore",
2633 onSelect: function() {
2634 network = bitcoinjs.bitcoin.networks.omnicore;
2635 setHdCoin(200);
2636 },
2637 },
2638 {
2639 name: "ONION - DeepOnion",
2640 onSelect: function() {
2641 network = bitcoinjs.bitcoin.networks.deeponion;
2642 setHdCoin(305);
2643 },
2644 },
2645 {
2646 name: "ONX - Onixcoin",
2647 onSelect: function() {
2648 network = bitcoinjs.bitcoin.networks.onixcoin;
2649 setHdCoin(174);
2650 },
2651 },
2652 {
2653 name: "PHR - Phore",
2654 onSelect: function() {
2655 network = bitcoinjs.bitcoin.networks.phore;
2656 setHdCoin(444);
2657 },
2658 },
2659 {
2660 name: "PINK - Pinkcoin",
2661 onSelect: function() {
2662 network = bitcoinjs.bitcoin.networks.pinkcoin;
2663 setHdCoin(117);
2664 },
2665 },
2666 {
2667 name: "PIRL - Pirl",
2668 segwitAvailable: false,
2669 onSelect: function() {
2670 network = bitcoinjs.bitcoin.networks.bitcoin;
2671 setHdCoin(164);
2672 },
2673 },
2674 {
2675 name: "PIVX - PIVX",
2676 onSelect: function() {
2677 network = bitcoinjs.bitcoin.networks.pivx;
2678 setHdCoin(119);
2679 },
2680 },
2681 {
2682 name: "PIVX - PIVX Testnet",
2683 onSelect: function() {
2684 network = bitcoinjs.bitcoin.networks.pivxtestnet;
2685 setHdCoin(1);
2686 },
2687 },
2688 {
2689 name: "POA - Poa",
2690 segwitAvailable: false,
2691 onSelect: function() {
2692 network = bitcoinjs.bitcoin.networks.bitcoin;
2693 setHdCoin(178);
2694 },
2695 },
2696 {
2697 name: "POSW - POSWcoin",
2698 onSelect: function() {
2699 network = bitcoinjs.bitcoin.networks.poswcoin;
2700 setHdCoin(47);
2701 },
2702 },
2703 {
2704 name: "POT - Potcoin",
2705 onSelect: function() {
2706 network = bitcoinjs.bitcoin.networks.potcoin;
2707 setHdCoin(81);
2708 },
2709 },
2710 {
2711 name: "PPC - Peercoin",
2712 onSelect: function() {
2713 network = bitcoinjs.bitcoin.networks.peercoin;
2714 setHdCoin(6);
2715 },
2716 },
2717 {
2718 name: "PRJ - ProjectCoin",
2719 onSelect: function() {
2720 network = bitcoinjs.bitcoin.networks.projectcoin;
2721 setHdCoin(533);
2722 },
2723 },
2724 {
2725 name: "PSB - Pesobit",
2726 onSelect: function() {
2727 network = bitcoinjs.bitcoin.networks.pesobit;
2728 setHdCoin(62);
2729 },
2730 },
2731 {
2732 name: "PUT - Putincoin",
2733 onSelect: function() {
2734 network = bitcoinjs.bitcoin.networks.putincoin;
2735 setHdCoin(122);
2736 },
2737 },
2738 {
2739 name: "RPD - Rapids",
2740 onSelect: function() {
2741 network = bitcoinjs.bitcoin.networks.rapids;
2742 setHdCoin(320);
2743 },
2744 },
2745 {
2746 name: "RVN - Ravencoin",
2747 onSelect: function() {
2748 network = bitcoinjs.bitcoin.networks.ravencoin;
2749 setHdCoin(175);
2750 },
2751 },
2752 {
2753 name: "RBY - Rubycoin",
2754 onSelect: function() {
2755 network = bitcoinjs.bitcoin.networks.rubycoin;
2756 setHdCoin(16);
2757 },
2758 },
2759 {
2760 name: "RDD - Reddcoin",
2761 onSelect: function() {
2762 network = bitcoinjs.bitcoin.networks.reddcoin;
2763 setHdCoin(4);
2764 },
2765 },
2766 {
2767 name: "RVR - RevolutionVR",
2768 onSelect: function() {
2769 network = bitcoinjs.bitcoin.networks.revolutionvr;
2770 setHdCoin(129);
2771 },
2772 },
2773 {
2774 name: "SAFE - Safecoin",
2775 onSelect: function() {
2776 network = bitcoinjs.bitcoin.networks.safecoin;
2777 setHdCoin(19165);
2778 },
2779 },
2780 {
2781 name: "SLS - Salus",
2782 onSelect: function() {
2783 network = bitcoinjs.bitcoin.networks.salus;
2784 setHdCoin(63);
2785 },
2786 },
2787 {
2788 name: "SDC - ShadowCash",
2789 onSelect: function() {
2790 network = bitcoinjs.bitcoin.networks.shadow;
2791 setHdCoin(35);
2792 },
2793 },
2794 {
2795 name: "SDC - ShadowCash Testnet",
2796 onSelect: function() {
2797 network = bitcoinjs.bitcoin.networks.shadowtn;
2798 setHdCoin(1);
2799 },
2800 },
2801 {
2802 name: "SLM - Slimcoin",
2803 onSelect: function() {
2804 network = bitcoinjs.bitcoin.networks.slimcoin;
2805 setHdCoin(63);
2806 },
2807 },
2808 {
2809 name: "SLM - Slimcoin Testnet",
2810 onSelect: function() {
2811 network = bitcoinjs.bitcoin.networks.slimcointn;
2812 setHdCoin(111);
2813 },
2814 },
2815 {
2816 name: "SLP - Simple Ledger Protocol",
2817 onSelect: function() {
2818 DOM.bitcoinCashAddressTypeContainer.removeClass("hidden");
2819 setHdCoin(245);
2820 },
2821 },
2822 {
2823 name: "SLR - Solarcoin",
2824 onSelect: function() {
2825 network = bitcoinjs.bitcoin.networks.solarcoin;
2826 setHdCoin(58);
2827 },
2828 },
2829 {
2830 name: "SMLY - Smileycoin",
2831 onSelect: function() {
2832 network = bitcoinjs.bitcoin.networks.smileycoin;
2833 setHdCoin(59);
2834 },
2835 },
2836 {
2837 name: "STASH - Stash",
2838 onSelect: function() {
2839 network = bitcoinjs.bitcoin.networks.stash;
2840 setHdCoin(0xC0C0);
2841 },
2842 },
2843 {
2844 name: "STASH - Stash Testnet",
2845 onSelect: function() {
2846 network = bitcoinjs.bitcoin.networks.stashtn;
2847 setHdCoin(0xCAFE);
2848 },
2849 },
2850 {
2851 name: "STRAT - Stratis",
2852 onSelect: function() {
2853 network = bitcoinjs.bitcoin.networks.stratis;
2854 setHdCoin(105);
2855 },
2856 },
2857 {
2858 name: "TSTRAT - Stratis Testnet",
2859 onSelect: function() {
2860 network = bitcoinjs.bitcoin.networks.stratistest;
2861 setHdCoin(105);
2862 },
2863 },
2864 {
2865 name: "SYS - Syscoin",
2866 onSelect: function() {
2867 network = bitcoinjs.bitcoin.networks.syscoin;
2868 setHdCoin(57);
2869 },
2870 },
2871 {
2872 name: "THC - Hempcoin",
2873 onSelect: function() {
2874 network = bitcoinjs.bitcoin.networks.hempcoin;
2875 setHdCoin(113);
2876 },
2877 },
2878 {
2879 name: "TOA - Toa",
2880 onSelect: function() {
2881 network = bitcoinjs.bitcoin.networks.toa;
2882 setHdCoin(159);
2883 },
2884 },
2885 {
2886 name: "TWINS - TWINS",
2887 onSelect: function() {
2888 network = bitcoinjs.bitcoin.networks.twins;
2889 setHdCoin(970);
2890 },
2891 },
2892 {
2893 name: "TWINS - TWINS Testnet",
2894 onSelect: function() {
2895 network = bitcoinjs.bitcoin.networks.twinstestnet;
2896 setHdCoin(1);
2897 },
2898 },
2899 {
2900 name: "USC - Ultimatesecurecash",
2901 onSelect: function() {
2902 network = bitcoinjs.bitcoin.networks.ultimatesecurecash;
2903 setHdCoin(112);
2904 },
2905 },
2906 {
2907 name: "USNBT - NuBits",
2908 onSelect: function() {
2909 network = bitcoinjs.bitcoin.networks.nubits;
2910 setHdCoin(12);
2911 },
2912 },
2913 {
2914 name: "UNO - Unobtanium",
2915 onSelect: function() {
2916 network = bitcoinjs.bitcoin.networks.unobtanium;
2917 setHdCoin(92);
2918 },
2919 },
2920 {
2921 name: "VASH - Vpncoin",
2922 onSelect: function() {
2923 network = bitcoinjs.bitcoin.networks.vpncoin;
2924 setHdCoin(33);
2925 },
2926 },
2927 {
2928 name: "VET - VeChain",
2929 onSelect: function() {
2930 network = bitcoinjs.bitcoin.networks.bitcoin;
2931 setHdCoin(818);
2932 },
2933 },
2934 {
2935 name: "VIA - Viacoin",
2936 onSelect: function() {
2937 network = bitcoinjs.bitcoin.networks.viacoin;
2938 setHdCoin(14);
2939 },
2940 },
2941 {
2942 name: "VIA - Viacoin Testnet",
2943 onSelect: function() {
2944 network = bitcoinjs.bitcoin.networks.viacointestnet;
2945 setHdCoin(1);
2946 },
2947 },
2948 {
2949 name: "VIVO - Vivo",
2950 onSelect: function() {
2951 network = bitcoinjs.bitcoin.networks.vivo;
2952 setHdCoin(166);
2953 },
2954 },
2955 {
2956 name: "VTC - Vertcoin",
2957 onSelect: function() {
2958 network = bitcoinjs.bitcoin.networks.vertcoin;
2959 setHdCoin(28);
2960 },
2961 },
2962 {
2963 name: "WGR - Wagerr",
2964 onSelect: function() {
2965 network = bitcoinjs.bitcoin.networks.wagerr;
2966 setHdCoin(7825266);
2967 },
2968 },
2969 {
2970 name: "WC - Wincoin",
2971 onSelect: function() {
2972 network = bitcoinjs.bitcoin.networks.wincoin;
2973 setHdCoin(181);
2974 },
2975 },
2976 {
2977 name: "XAX - Artax",
2978 onSelect: function() {
2979 network = bitcoinjs.bitcoin.networks.artax;
2980 setHdCoin(219);
2981 },
2982 },
2983 {
2984 name: "XBC - Bitcoinplus",
2985 onSelect: function() {
2986 network = bitcoinjs.bitcoin.networks.bitcoinplus;
2987 setHdCoin(65);
2988 },
2989 },
2990 {
2991 name: "XLM - Stellar",
2992 onSelect: function() {
2993 network = stellarUtil.dummyNetwork;
2994 setHdCoin(148);
2995 },
2996 },
2997 {
2998 name: "XMY - Myriadcoin",
2999 onSelect: function() {
3000 network = bitcoinjs.bitcoin.networks.myriadcoin;
3001 setHdCoin(90);
3002 },
3003 },
3004 {
3005 name: "XRP - Ripple",
3006 onSelect: function() {
3007 network = bitcoinjs.bitcoin.networks.bitcoin;
3008 setHdCoin(144);
3009 },
3010 },
3011 {
3012 name: "XVC - Vcash",
3013 onSelect: function() {
3014 network = bitcoinjs.bitcoin.networks.vcash;
3015 setHdCoin(127);
3016 },
3017 },
3018 {
3019 name: "XVG - Verge",
3020 onSelect: function() {
3021 network = bitcoinjs.bitcoin.networks.verge;
3022 setHdCoin(77);
3023 },
3024 },
3025 {
3026 name: "XUEZ - Xuez",
3027 segwitAvailable: false,
3028 onSelect: function() {
3029 network = bitcoinjs.bitcoin.networks.xuez;
3030 setHdCoin(225);
3031 },
3032 },
3033 {
3034 name: "XWC - Whitecoin",
3035 onSelect: function() {
3036 network = bitcoinjs.bitcoin.networks.whitecoin;
3037 setHdCoin(155);
3038 },
3039 },
3040 {
3041 name: "XZC - Zcoin",
3042 onSelect: function() {
3043 network = bitcoinjs.bitcoin.networks.zcoin;
3044 setHdCoin(136);
3045 },
3046 },
3047 {
3048 name: "ZCL - Zclassic",
3049 onSelect: function() {
3050 network = bitcoinjs.bitcoin.networks.zclassic;
3051 setHdCoin(147);
3052 },
3053 },
3054 {
3055 name: "ZEC - Zcash",
3056 onSelect: function() {
3057 network = bitcoinjs.bitcoin.networks.zcash;
3058 setHdCoin(133);
3059 },
3060 },
3061 {
3062 name: "ZEN - Horizen",
3063 onSelect: function() {
3064 network = bitcoinjs.bitcoin.networks.zencash;
3065 setHdCoin(121);
3066 },
3067 },
3068 ]
3069
3070 var clients = [
3071 {
3072 name: "Bitcoin Core",
3073 onSelect: function() {
3074 DOM.bip32path.val("m/0'/0'");
3075 DOM.hardenedAddresses.prop('checked', true);
3076 },
3077 },
3078 {
3079 name: "blockchain.info",
3080 onSelect: function() {
3081 DOM.bip32path.val("m/44'/0'/0'");
3082 DOM.hardenedAddresses.prop('checked', false);
3083 },
3084 },
3085 {
3086 name: "MultiBit HD",
3087 onSelect: function() {
3088 DOM.bip32path.val("m/0'/0");
3089 DOM.hardenedAddresses.prop('checked', false);
3090 },
3091 },
3092 {
3093 name: "Coinomi, Ledger",
3094 onSelect: function() {
3095 DOM.bip32path.val("m/44'/"+DOM.bip44coin.val()+"'/0'");
3096 DOM.hardenedAddresses.prop('checked', false);
3097 },
3098 }
3099 ]
3100
3101 init();
3102
3103 })();