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