]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blame - src/js/index.js
SYScoin fix for WIF private address format
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / src / js / index.js
CommitLineData
ebd8d4e8
IC
1(function() {
2
5ee7bb9e
IC
3 // mnemonics is populated as required by getLanguage
4 var mnemonics = { "english": new Mnemonic("english") };
5 var mnemonic = mnemonics["english"];
3725abb5 6 var seed = null;
ebd8d4e8
IC
7 var bip32RootKey = null;
8 var bip32ExtendedKey = null;
a0091a40 9 var network = bitcoinjs.bitcoin.networks.bitcoin;
ebd8d4e8
IC
10 var addressRowTemplate = $("#address-row-template");
11
700901cd
IC
12 var showIndex = true;
13 var showAddress = true;
1b12b2f5 14 var showPubKey = true;
700901cd 15 var showPrivKey = true;
8a93952c 16 var showQr = false;
1c2b8c6b 17 var litecoinUseLtub = true;
700901cd 18
c6624d51 19 var entropyChangeTimeoutEvent = null;
ebd8d4e8 20 var phraseChangeTimeoutEvent = null;
efe41586 21 var rootKeyChangedTimeoutEvent = null;
ebd8d4e8 22
40892aba
IC
23 var generationProcesses = [];
24
ebd8d4e8 25 var DOM = {};
0b6e351d 26 DOM.privacyScreenToggle = $(".privacy-screen-toggle");
d6cedc94 27 DOM.network = $(".network");
29bf60f5 28 DOM.bip32Client = $("#bip32-client");
d6cedc94 29 DOM.phraseNetwork = $("#network-phrase");
c6624d51
IC
30 DOM.useEntropy = $(".use-entropy");
31 DOM.entropyContainer = $(".entropy-container");
32 DOM.entropy = $(".entropy");
0a84fe6a
IC
33 DOM.entropyFiltered = DOM.entropyContainer.find(".filtered");
34 DOM.entropyType = DOM.entropyContainer.find(".type");
20f459ce 35 DOM.entropyCrackTime = DOM.entropyContainer.find(".crack-time");
0a84fe6a
IC
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");
74ab4cbe 41 DOM.entropyWordIndexes = DOM.entropyContainer.find(".word-indexes");
09d63290 42 DOM.entropyChecksum = DOM.entropyContainer.find(".checksum");
0a84fe6a 43 DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length");
645945a0 44 DOM.entropyWeakEntropyOverrideWarning = DOM.entropyContainer.find(".weak-entropy-override-warning");
ee0981f1 45 DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning");
ebd8d4e8 46 DOM.phrase = $(".phrase");
1abcc511 47 DOM.passphrase = $(".passphrase");
c6624d51 48 DOM.generateContainer = $(".generate-container");
ebd8d4e8 49 DOM.generate = $(".generate");
3e0ed16a 50 DOM.seed = $(".seed");
ebd8d4e8 51 DOM.rootKey = $(".root-key");
3abab9b0
IC
52 DOM.litecoinLtubContainer = $(".litecoin-ltub-container");
53 DOM.litecoinUseLtub = $(".litecoin-use-ltub");
ebd8d4e8
IC
54 DOM.extendedPrivKey = $(".extended-priv-key");
55 DOM.extendedPubKey = $(".extended-pub-key");
d6cedc94
IC
56 DOM.bip32tab = $("#bip32-tab");
57 DOM.bip44tab = $("#bip44-tab");
6c08f364 58 DOM.bip49tab = $("#bip49-tab");
4e9b492c 59 DOM.bip84tab = $("#bip84-tab");
c49e8812 60 DOM.bip141tab = $("#bip141-tab");
d6cedc94
IC
61 DOM.bip32panel = $("#bip32");
62 DOM.bip44panel = $("#bip44");
6c08f364 63 DOM.bip49panel = $("#bip49");
ebd8d4e8
IC
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");
c554e6ff
IC
69 DOM.bip44accountXprv = $("#bip44 .account-xprv");
70 DOM.bip44accountXpub = $("#bip44 .account-xpub");
ebd8d4e8 71 DOM.bip44change = $("#bip44 .change");
6c08f364
IC
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");
bddd5d9f
IC
81 DOM.bip84unavailable = $("#bip84 .unavailable");
82 DOM.bip84available = $("#bip84 .available");
4e9b492c
IC
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");
c49e8812
IC
90 DOM.bip141unavailable = $("#bip141 .unavailable");
91 DOM.bip141available = $("#bip141 .available");
92 DOM.bip141path = $("#bip141-path");
93 DOM.bip141semantics = $(".bip141-semantics");
88df3739 94 DOM.generatedStrength = $(".generate-container .strength");
85c90672 95 DOM.generatedStrengthWarning = $(".generate-container .warning");
146e089e 96 DOM.hardenedAddresses = $(".hardened-addresses");
e0f91e20
IC
97 DOM.bitcoinCashAddressTypeContainer = $(".bch-addr-type-container");
98 DOM.bitcoinCashAddressType = $("[name=bch-addr-type]")
0b39e9dc
IC
99 DOM.useBip38 = $(".use-bip38");
100 DOM.bip38Password = $(".bip38-password");
ebd8d4e8 101 DOM.addresses = $(".addresses");
a78f4e28
IC
102 DOM.csvTab = $("#csv-tab a");
103 DOM.csv = $(".csv");
ebd8d4e8
IC
104 DOM.rowsToAdd = $(".rows-to-add");
105 DOM.more = $(".more");
9183f9f6 106 DOM.moreRowsStartIndex = $(".more-rows-start-index");
ebd8d4e8
IC
107 DOM.feedback = $(".feedback");
108 DOM.tab = $(".derivation-type a");
109 DOM.indexToggle = $(".index-toggle");
110 DOM.addressToggle = $(".address-toggle");
1b12b2f5 111 DOM.publicKeyToggle = $(".public-key-toggle");
ebd8d4e8 112 DOM.privateKeyToggle = $(".private-key-toggle");
5ee7bb9e 113 DOM.languages = $(".languages a");
e00964cc 114 DOM.qrContainer = $(".qr-container");
97811c29 115 DOM.qrHider = DOM.qrContainer.find(".qr-hider");
e00964cc
IC
116 DOM.qrImage = DOM.qrContainer.find(".qr-image");
117 DOM.qrHint = DOM.qrContainer.find(".qr-hint");
118 DOM.showQrEls = $("[data-show-qr]");
ebd8d4e8 119
ebd8d4e8
IC
120 function init() {
121 // Events
0b6e351d 122 DOM.privacyScreenToggle.on("change", privacyScreenToggled);
85c90672 123 DOM.generatedStrength.on("change", generatedStrengthChanged);
d6cedc94 124 DOM.network.on("change", networkChanged);
29bf60f5 125 DOM.bip32Client.on("change", bip32ClientChanged);
c6624d51
IC
126 DOM.useEntropy.on("change", setEntropyVisibility);
127 DOM.entropy.on("input", delayedEntropyChanged);
3599674d 128 DOM.entropyMnemonicLength.on("change", entropyChanged);
a19a5498
IC
129 DOM.phrase.on("input", delayedPhraseChanged);
130 DOM.passphrase.on("input", delayedPhraseChanged);
ebd8d4e8
IC
131 DOM.generate.on("click", generateClicked);
132 DOM.more.on("click", showMore);
efe41586 133 DOM.rootKey.on("input", delayedRootKeyChanged);
3abab9b0 134 DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged);
efe41586 135 DOM.bip32path.on("input", calcForDerivationPath);
efe41586
IC
136 DOM.bip44account.on("input", calcForDerivationPath);
137 DOM.bip44change.on("input", calcForDerivationPath);
6c08f364
IC
138 DOM.bip49account.on("input", calcForDerivationPath);
139 DOM.bip49change.on("input", calcForDerivationPath);
4e9b492c
IC
140 DOM.bip84account.on("input", calcForDerivationPath);
141 DOM.bip84change.on("input", calcForDerivationPath);
c49e8812
IC
142 DOM.bip141path.on("input", calcForDerivationPath);
143 DOM.bip141semantics.on("change", tabChanged);
93c3ef47 144 DOM.tab.on("shown.bs.tab", tabChanged);
146e089e 145 DOM.hardenedAddresses.on("change", calcForDerivationPath);
0b39e9dc
IC
146 DOM.useBip38.on("change", calcForDerivationPath);
147 DOM.bip38Password.on("change", calcForDerivationPath);
ebd8d4e8
IC
148 DOM.indexToggle.on("click", toggleIndexes);
149 DOM.addressToggle.on("click", toggleAddresses);
1b12b2f5 150 DOM.publicKeyToggle.on("click", togglePublicKeys);
ebd8d4e8 151 DOM.privateKeyToggle.on("click", togglePrivateKeys);
a78f4e28 152 DOM.csvTab.on("click", updateCsv);
5ee7bb9e 153 DOM.languages.on("click", languageChanged);
e0f91e20 154 DOM.bitcoinCashAddressType.on("change", bitcoinCashAddressTypeChange);
e00964cc 155 setQrEvents(DOM.showQrEls);
ebd8d4e8
IC
156 disableForms();
157 hidePending();
158 hideValidationError();
7f15cb6e 159 populateNetworkSelect();
b4fd763c 160 populateClientSelect();
ebd8d4e8
IC
161 }
162
163 // Event handlers
164
85c90672
IC
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
d6cedc94 175 function networkChanged(e) {
6c08f364
IC
176 clearDerivedKeys();
177 clearAddressesList();
3abab9b0 178 DOM.litecoinLtubContainer.addClass("hidden");
e0f91e20 179 DOM.bitcoinCashAddressTypeContainer.addClass("hidden");
54563907 180 var networkIndex = e.target.value;
6c08f364
IC
181 var network = networks[networkIndex];
182 network.onSelect();
c147cb5e 183 adjustNetworkForSegwit();
54563907
IC
184 if (seed != null) {
185 phraseChanged();
186 }
187 else {
188 rootKeyChanged();
189 }
d6cedc94 190 }
29bf60f5
IC
191
192 function bip32ClientChanged(e) {
193 var clientIndex = DOM.bip32Client.val();
194 if (clientIndex == "custom") {
195 DOM.bip32path.prop("readonly", false);
b4fd763c
AG
196 }
197 else {
29bf60f5
IC
198 DOM.bip32path.prop("readonly", true);
199 clients[clientIndex].onSelect();
200 if (seed != null) {
201 phraseChanged();
202 }
203 else {
204 rootKeyChanged();
205 }
b4fd763c
AG
206 }
207 }
d6cedc94 208
c6624d51
IC
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);
057722b0 221 hidePending();
c6624d51
IC
222 }
223 }
224
ebd8d4e8
IC
225 function delayedPhraseChanged() {
226 hideValidationError();
ed6d9d39
IC
227 seed = null;
228 bip32RootKey = null;
229 bip32ExtendedKey = null;
230 clearAddressesList();
ebd8d4e8
IC
231 showPending();
232 if (phraseChangeTimeoutEvent != null) {
233 clearTimeout(phraseChangeTimeoutEvent);
234 }
235 phraseChangeTimeoutEvent = setTimeout(phraseChanged, 400);
236 }
237
238 function phraseChanged() {
239 showPending();
5ee7bb9e 240 setMnemonicLanguage();
ebd8d4e8
IC
241 // Get the mnemonic phrase
242 var phrase = DOM.phrase.val();
243 var errorText = findPhraseErrors(phrase);
244 if (errorText) {
245 showValidationError(errorText);
246 return;
247 }
efe41586
IC
248 // Calculate and display
249 var passphrase = DOM.passphrase.val();
250 calcBip32RootKeyFromSeed(phrase, passphrase);
251 calcForDerivationPath();
74ab4cbe
IC
252 // Show the word indexes
253 showWordIndexes();
efe41586
IC
254 }
255
93c3ef47
IC
256 function tabChanged() {
257 showPending();
0fd67b59 258 adjustNetworkForSegwit();
93c3ef47
IC
259 var phrase = DOM.phrase.val();
260 if (phrase != "") {
261 // Calculate and display for mnemonic
262 var errorText = findPhraseErrors(phrase);
263 if (errorText) {
264 showValidationError(errorText);
265 return;
266 }
267 // Calculate and display
268 var passphrase = DOM.passphrase.val();
269 calcBip32RootKeyFromSeed(phrase, passphrase);
270 }
271 else {
272 // Calculate and display for root key
273 var rootKeyBase58 = DOM.rootKey.val();
274 var errorText = validateRootKey(rootKeyBase58);
275 if (errorText) {
276 showValidationError(errorText);
277 return;
278 }
279 // Calculate and display
280 calcBip32RootKeyFromBase58(rootKeyBase58);
281 }
282 calcForDerivationPath();
283 }
284
c6624d51
IC
285 function delayedEntropyChanged() {
286 hideValidationError();
287 showPending();
288 if (entropyChangeTimeoutEvent != null) {
289 clearTimeout(entropyChangeTimeoutEvent);
290 }
291 entropyChangeTimeoutEvent = setTimeout(entropyChanged, 400);
292 }
293
294 function entropyChanged() {
057722b0
IC
295 // If blank entropy, clear mnemonic, addresses, errors
296 if (DOM.entropy.val().trim().length == 0) {
297 clearDisplay();
0a84fe6a 298 clearEntropyFeedback();
057722b0
IC
299 DOM.phrase.val("");
300 showValidationError("Blank entropy");
301 return;
302 }
303 // Get the current phrase to detect changes
304 var phrase = DOM.phrase.val();
305 // Set the phrase from the entropy
c6624d51 306 setMnemonicFromEntropy();
057722b0
IC
307 // Recalc addresses if the phrase has changed
308 var newPhrase = DOM.phrase.val();
309 if (newPhrase != phrase) {
310 if (newPhrase.length == 0) {
311 clearDisplay();
312 }
313 else {
314 phraseChanged();
315 }
316 }
317 else {
318 hidePending();
319 }
c6624d51
IC
320 }
321
efe41586
IC
322 function delayedRootKeyChanged() {
323 // Warn if there is an existing mnemonic or passphrase.
324 if (DOM.phrase.val().length > 0 || DOM.passphrase.val().length > 0) {
325 if (!confirm("This will clear existing mnemonic and passphrase")) {
326 DOM.rootKey.val(bip32RootKey);
327 return
328 }
329 }
330 hideValidationError();
331 showPending();
332 // Clear existing mnemonic and passphrase
333 DOM.phrase.val("");
334 DOM.passphrase.val("");
335 seed = null;
336 if (rootKeyChangedTimeoutEvent != null) {
337 clearTimeout(rootKeyChangedTimeoutEvent);
338 }
339 rootKeyChangedTimeoutEvent = setTimeout(rootKeyChanged, 400);
340 }
341
342 function rootKeyChanged() {
343 showPending();
344 hideValidationError();
efe41586
IC
345 var rootKeyBase58 = DOM.rootKey.val();
346 var errorText = validateRootKey(rootKeyBase58);
347 if (errorText) {
348 showValidationError(errorText);
349 return;
350 }
351 // Calculate and display
352 calcBip32RootKeyFromBase58(rootKeyBase58);
353 calcForDerivationPath();
efe41586
IC
354 }
355
3abab9b0
IC
356 function litecoinUseLtubChanged() {
357 litecoinUseLtub = DOM.litecoinUseLtub.prop("checked");
358 if (litecoinUseLtub) {
1c2b8c6b 359 network = bitcoinjs.bitcoin.networks.litecoin;
3abab9b0
IC
360 }
361 else {
1c2b8c6b 362 network = bitcoinjs.bitcoin.networks.litecoinXprv;
3abab9b0
IC
363 }
364 phraseChanged();
365 }
366
efe41586 367 function calcForDerivationPath() {
6c08f364 368 clearDerivedKeys();
ba3cb9ec 369 clearAddressesList();
0eda54f5 370 showPending();
0fd67b59
IC
371 // Don't show segwit if it's selected but network doesn't support it
372 if (segwitSelected() && !networkHasSegwit()) {
c147cb5e 373 showSegwitUnavailable();
7733ac32 374 hidePending();
6c08f364
IC
375 return;
376 }
c147cb5e 377 showSegwitAvailable();
ebd8d4e8 378 // Get the derivation path
38523d36
IC
379 var derivationPath = getDerivationPath();
380 var errorText = findDerivationPathErrors(derivationPath);
ebd8d4e8
IC
381 if (errorText) {
382 showValidationError(errorText);
383 return;
384 }
5eaa6877 385 bip32ExtendedKey = calcBip32ExtendedKey(derivationPath);
c554e6ff
IC
386 if (bip44TabSelected()) {
387 displayBip44Info();
388 }
c49e8812 389 else if (bip49TabSelected()) {
6c08f364
IC
390 displayBip49Info();
391 }
4e9b492c
IC
392 else if (bip84TabSelected()) {
393 displayBip84Info();
394 }
ebd8d4e8 395 displayBip32Info();
ebd8d4e8
IC
396 }
397
398 function generateClicked() {
c6624d51
IC
399 if (isUsingOwnEntropy()) {
400 return;
401 }
ebd8d4e8
IC
402 clearDisplay();
403 showPending();
404 setTimeout(function() {
5ee7bb9e 405 setMnemonicLanguage();
ebd8d4e8
IC
406 var phrase = generateRandomPhrase();
407 if (!phrase) {
408 return;
409 }
410 phraseChanged();
411 }, 50);
412 }
413
5ee7bb9e
IC
414 function languageChanged() {
415 setTimeout(function() {
416 setMnemonicLanguage();
417 if (DOM.phrase.val().length > 0) {
418 var newPhrase = convertPhraseToNewLanguage();
419 DOM.phrase.val(newPhrase);
420 phraseChanged();
421 }
422 else {
423 DOM.generate.trigger("click");
424 }
425 }, 50);
426 }
427
e0f91e20 428 function bitcoinCashAddressTypeChange() {
fe8f2d14
IC
429 phraseChanged();
430 }
431
ebd8d4e8 432 function toggleIndexes() {
700901cd 433 showIndex = !showIndex;
ebd8d4e8
IC
434 $("td.index span").toggleClass("invisible");
435 }
436
437 function toggleAddresses() {
700901cd 438 showAddress = !showAddress;
ebd8d4e8
IC
439 $("td.address span").toggleClass("invisible");
440 }
441
1b12b2f5
IC
442 function togglePublicKeys() {
443 showPubKey = !showPubKey;
444 $("td.pubkey span").toggleClass("invisible");
445 }
446
ebd8d4e8 447 function togglePrivateKeys() {
700901cd 448 showPrivKey = !showPrivKey;
ebd8d4e8
IC
449 $("td.privkey span").toggleClass("invisible");
450 }
451
0b6e351d
IC
452 function privacyScreenToggled() {
453 // private-data contains elements added to DOM at runtime
454 // so catch all by adding visual privacy class to the root of the DOM
455 if (DOM.privacyScreenToggle.prop("checked")) {
456 $("body").addClass("visual-privacy");
457 }
458 else {
459 $("body").removeClass("visual-privacy");
460 }
461 }
462
ebd8d4e8
IC
463 // Private methods
464
465 function generateRandomPhrase() {
466 if (!hasStrongRandom()) {
467 var errorText = "This browser does not support strong randomness";
468 showValidationError(errorText);
469 return;
470 }
74ab4cbe 471 // get the amount of entropy to use
88df3739 472 var numWords = parseInt(DOM.generatedStrength.val());
ebd8d4e8 473 var strength = numWords / 3 * 32;
74ab4cbe
IC
474 var buffer = new Uint8Array(strength / 8);
475 // create secure entropy
476 var data = crypto.getRandomValues(buffer);
477 // show the words
478 var words = mnemonic.toMnemonic(data);
ebd8d4e8 479 DOM.phrase.val(words);
74ab4cbe
IC
480 // show the entropy
481 var entropyHex = uint8ArrayToHex(data);
482 DOM.entropy.val(entropyHex);
483 // ensure entropy fields are consistent with what is being displayed
484 DOM.entropyMnemonicLength.val("raw");
ebd8d4e8
IC
485 return words;
486 }
487
efe41586 488 function calcBip32RootKeyFromSeed(phrase, passphrase) {
3e0ed16a 489 seed = mnemonic.toSeed(phrase, passphrase);
a0091a40 490 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromSeedHex(seed, network);
efe41586
IC
491 }
492
493 function calcBip32RootKeyFromBase58(rootKeyBase58) {
6f7fa353
IC
494 // try parsing with various segwit network params since this extended
495 // key may be from any one of them.
496 if (networkHasSegwit()) {
497 var n = network;
498 if ("baseNetwork" in n) {
499 n = bitcoinjs.bitcoin.networks[n.baseNetwork];
500 }
501 // try parsing using base network params
502 try {
503 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n);
504 return;
505 }
506 catch (e) {}
507 // try parsing using p2wpkh params
508 if ("p2wpkh" in n) {
509 try {
510 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
511 return;
512 }
513 catch (e) {}
514 }
515 // try parsing using p2wpkh-in-p2sh network params
516 if ("p2wpkhInP2sh" in n) {
517 try {
518 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
519 return;
520 }
521 catch (e) {}
522 }
523 }
524 // try the network params as currently specified
a0091a40 525 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
efe41586
IC
526 }
527
528 function calcBip32ExtendedKey(path) {
0a1f0259
IC
529 // Check there's a root key to derive from
530 if (!bip32RootKey) {
531 return bip32RootKey;
532 }
5eaa6877 533 var extendedKey = bip32RootKey;
ebd8d4e8
IC
534 // Derive the key from the path
535 var pathBits = path.split("/");
536 for (var i=0; i<pathBits.length; i++) {
537 var bit = pathBits[i];
538 var index = parseInt(bit);
539 if (isNaN(index)) {
540 continue;
541 }
542 var hardened = bit[bit.length-1] == "'";
a0091a40 543 var isPriv = !(extendedKey.isNeutered());
ba3cb9ec
IC
544 var invalidDerivationPath = hardened && !isPriv;
545 if (invalidDerivationPath) {
546 extendedKey = null;
547 }
548 else if (hardened) {
5eaa6877 549 extendedKey = extendedKey.deriveHardened(index);
ebd8d4e8
IC
550 }
551 else {
5eaa6877 552 extendedKey = extendedKey.derive(index);
ebd8d4e8
IC
553 }
554 }
5eaa6877 555 return extendedKey
ebd8d4e8
IC
556 }
557
558 function showValidationError(errorText) {
559 DOM.feedback
560 .text(errorText)
561 .show();
562 }
563
564 function hideValidationError() {
565 DOM.feedback
566 .text("")
567 .hide();
568 }
569
570 function findPhraseErrors(phrase) {
ebd8d4e8 571 // Preprocess the words
783981de 572 phrase = mnemonic.normalizeString(phrase);
5ee7bb9e 573 var words = phraseToWordArray(phrase);
057722b0
IC
574 // Detect blank phrase
575 if (words.length == 0) {
576 return "Blank mnemonic";
577 }
563e401a 578 // Check each word
5ee7bb9e
IC
579 for (var i=0; i<words.length; i++) {
580 var word = words[i];
581 var language = getLanguage();
582 if (WORDLISTS[language].indexOf(word) == -1) {
563e401a
IC
583 console.log("Finding closest match to " + word);
584 var nearestWord = findNearestWord(word);
585 return word + " not in wordlist, did you mean " + nearestWord + "?";
586 }
587 }
ebd8d4e8 588 // Check the words are valid
5ee7bb9e 589 var properPhrase = wordArrayToPhrase(words);
ebd8d4e8
IC
590 var isValid = mnemonic.check(properPhrase);
591 if (!isValid) {
592 return "Invalid mnemonic";
593 }
594 return false;
595 }
596
efe41586 597 function validateRootKey(rootKeyBase58) {
6f7fa353
IC
598 // try various segwit network params since this extended key may be from
599 // any one of them.
600 if (networkHasSegwit()) {
601 var n = network;
602 if ("baseNetwork" in n) {
603 n = bitcoinjs.bitcoin.networks[n.baseNetwork];
604 }
605 // try parsing using base network params
606 try {
607 bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n);
608 return "";
609 }
610 catch (e) {}
611 // try parsing using p2wpkh params
612 if ("p2wpkh" in n) {
613 try {
614 bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
615 return "";
616 }
617 catch (e) {}
618 }
619 // try parsing using p2wpkh-in-p2sh network params
620 if ("p2wpkhInP2sh" in n) {
621 try {
622 bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
623 return "";
624 }
625 catch (e) {}
626 }
627 }
628 // try the network params as currently specified
efe41586 629 try {
cd7c8327 630 bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
efe41586
IC
631 }
632 catch (e) {
633 return "Invalid root key";
634 }
635 return "";
636 }
637
38523d36 638 function getDerivationPath() {
32fab2c3 639 if (bip44TabSelected()) {
38523d36
IC
640 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
641 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
642 var account = parseIntNoNaN(DOM.bip44account.val(), 0);
643 var change = parseIntNoNaN(DOM.bip44change.val(), 0);
644 var path = "m/";
645 path += purpose + "'/";
646 path += coin + "'/";
647 path += account + "'/";
648 path += change;
649 DOM.bip44path.val(path);
650 var derivationPath = DOM.bip44path.val();
651 console.log("Using derivation path from BIP44 tab: " + derivationPath);
652 return derivationPath;
653 }
c49e8812 654 else if (bip49TabSelected()) {
6c08f364
IC
655 var purpose = parseIntNoNaN(DOM.bip49purpose.val(), 49);
656 var coin = parseIntNoNaN(DOM.bip49coin.val(), 0);
657 var account = parseIntNoNaN(DOM.bip49account.val(), 0);
658 var change = parseIntNoNaN(DOM.bip49change.val(), 0);
659 var path = "m/";
660 path += purpose + "'/";
661 path += coin + "'/";
662 path += account + "'/";
663 path += change;
664 DOM.bip49path.val(path);
665 var derivationPath = DOM.bip49path.val();
666 console.log("Using derivation path from BIP49 tab: " + derivationPath);
667 return derivationPath;
668 }
4e9b492c
IC
669 else if (bip84TabSelected()) {
670 var purpose = parseIntNoNaN(DOM.bip84purpose.val(), 84);
671 var coin = parseIntNoNaN(DOM.bip84coin.val(), 0);
672 var account = parseIntNoNaN(DOM.bip84account.val(), 0);
673 var change = parseIntNoNaN(DOM.bip84change.val(), 0);
674 var path = "m/";
675 path += purpose + "'/";
676 path += coin + "'/";
677 path += account + "'/";
678 path += change;
679 DOM.bip84path.val(path);
680 var derivationPath = DOM.bip84path.val();
681 console.log("Using derivation path from BIP84 tab: " + derivationPath);
682 return derivationPath;
683 }
32fab2c3 684 else if (bip32TabSelected()) {
38523d36
IC
685 var derivationPath = DOM.bip32path.val();
686 console.log("Using derivation path from BIP32 tab: " + derivationPath);
687 return derivationPath;
688 }
c49e8812
IC
689 else if (bip141TabSelected()) {
690 var derivationPath = DOM.bip141path.val();
691 console.log("Using derivation path from BIP141 tab: " + derivationPath);
692 return derivationPath;
693 }
38523d36
IC
694 else {
695 console.log("Unknown derivation path");
696 }
697 }
698
ebd8d4e8 699 function findDerivationPathErrors(path) {
30c9e79d
IC
700 // TODO is not perfect but is better than nothing
701 // Inspired by
702 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
703 // and
704 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
705 var maxDepth = 255; // TODO verify this!!
706 var maxIndexValue = Math.pow(2, 31); // TODO verify this!!
707 if (path[0] != "m") {
708 return "First character must be 'm'";
709 }
710 if (path.length > 1) {
711 if (path[1] != "/") {
712 return "Separator must be '/'";
713 }
714 var indexes = path.split("/");
715 if (indexes.length > maxDepth) {
716 return "Derivation depth is " + indexes.length + ", must be less than " + maxDepth;
717 }
718 for (var depth = 1; depth<indexes.length; depth++) {
719 var index = indexes[depth];
720 var invalidChars = index.replace(/^[0-9]+'?$/g, "")
721 if (invalidChars.length > 0) {
722 return "Invalid characters " + invalidChars + " found at depth " + depth;
723 }
724 var indexValue = parseInt(index.replace("'", ""));
725 if (isNaN(depth)) {
726 return "Invalid number at depth " + depth;
727 }
728 if (indexValue > maxIndexValue) {
729 return "Value of " + indexValue + " at depth " + depth + " must be less than " + maxIndexValue;
730 }
731 }
732 }
0a1f0259
IC
733 // Check root key exists or else derivation path is useless!
734 if (!bip32RootKey) {
735 return "No root key";
736 }
ba3cb9ec 737 // Check no hardened derivation path when using xpub keys
b18eb97a
IC
738 var hardenedPath = path.indexOf("'") > -1;
739 var hardenedAddresses = bip32TabSelected() && DOM.hardenedAddresses.prop("checked");
740 var hardened = hardenedPath || hardenedAddresses;
a0091a40 741 var isXpubkey = bip32RootKey.isNeutered();
ba3cb9ec
IC
742 if (hardened && isXpubkey) {
743 return "Hardened derivation path is invalid with xpub key";
744 }
ebd8d4e8
IC
745 return false;
746 }
747
c554e6ff
IC
748 function displayBip44Info() {
749 // Get the derivation path for the account
750 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
751 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
752 var account = parseIntNoNaN(DOM.bip44account.val(), 0);
753 var path = "m/";
754 path += purpose + "'/";
755 path += coin + "'/";
756 path += account + "'/";
757 // Calculate the account extended keys
758 var accountExtendedKey = calcBip32ExtendedKey(path);
759 var accountXprv = accountExtendedKey.toBase58();
a0091a40 760 var accountXpub = accountExtendedKey.neutered().toBase58();
c554e6ff
IC
761 // Display the extended keys
762 DOM.bip44accountXprv.val(accountXprv);
763 DOM.bip44accountXpub.val(accountXpub);
764 }
765
6c08f364
IC
766 function displayBip49Info() {
767 // Get the derivation path for the account
768 var purpose = parseIntNoNaN(DOM.bip49purpose.val(), 49);
769 var coin = parseIntNoNaN(DOM.bip49coin.val(), 0);
770 var account = parseIntNoNaN(DOM.bip49account.val(), 0);
771 var path = "m/";
772 path += purpose + "'/";
773 path += coin + "'/";
774 path += account + "'/";
775 // Calculate the account extended keys
776 var accountExtendedKey = calcBip32ExtendedKey(path);
777 var accountXprv = accountExtendedKey.toBase58();
778 var accountXpub = accountExtendedKey.neutered().toBase58();
779 // Display the extended keys
780 DOM.bip49accountXprv.val(accountXprv);
781 DOM.bip49accountXpub.val(accountXpub);
782 }
783
4e9b492c
IC
784 function displayBip84Info() {
785 // Get the derivation path for the account
786 var purpose = parseIntNoNaN(DOM.bip84purpose.val(), 84);
787 var coin = parseIntNoNaN(DOM.bip84coin.val(), 0);
788 var account = parseIntNoNaN(DOM.bip84account.val(), 0);
789 var path = "m/";
790 path += purpose + "'/";
791 path += coin + "'/";
792 path += account + "'/";
793 // Calculate the account extended keys
794 var accountExtendedKey = calcBip32ExtendedKey(path);
795 var accountXprv = accountExtendedKey.toBase58();
796 var accountXpub = accountExtendedKey.neutered().toBase58();
797 // Display the extended keys
798 DOM.bip84accountXprv.val(accountXprv);
799 DOM.bip84accountXpub.val(accountXpub);
800 }
801
ebd8d4e8
IC
802 function displayBip32Info() {
803 // Display the key
3e0ed16a 804 DOM.seed.val(seed);
ebd8d4e8
IC
805 var rootKey = bip32RootKey.toBase58();
806 DOM.rootKey.val(rootKey);
ba3cb9ec 807 var xprvkeyB58 = "NA";
a0091a40 808 if (!bip32ExtendedKey.isNeutered()) {
ba3cb9ec
IC
809 xprvkeyB58 = bip32ExtendedKey.toBase58();
810 }
811 var extendedPrivKey = xprvkeyB58;
ebd8d4e8 812 DOM.extendedPrivKey.val(extendedPrivKey);
a0091a40 813 var extendedPubKey = bip32ExtendedKey.neutered().toBase58();
ebd8d4e8
IC
814 DOM.extendedPubKey.val(extendedPubKey);
815 // Display the addresses and privkeys
816 clearAddressesList();
ba678b11
IC
817 var initialAddressCount = parseInt(DOM.rowsToAdd.val());
818 displayAddresses(0, initialAddressCount);
ebd8d4e8
IC
819 }
820
821 function displayAddresses(start, total) {
40892aba
IC
822 generationProcesses.push(new (function() {
823
824 var rows = [];
825
826 this.stop = function() {
827 for (var i=0; i<rows.length; i++) {
828 rows[i].shouldGenerate = false;
829 }
0eda54f5 830 hidePending();
40892aba
IC
831 }
832
833 for (var i=0; i<total; i++) {
834 var index = i + start;
0eda54f5
IC
835 var isLast = i == total - 1;
836 rows.push(new TableRow(index, isLast));
40892aba
IC
837 }
838
839 })());
ebd8d4e8
IC
840 }
841
0fd67b59 842 function segwitSelected() {
4e9b492c 843 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
c49e8812
IC
844 }
845
846 function p2wpkhSelected() {
4e9b492c
IC
847 return bip84TabSelected() ||
848 bip141TabSelected() && DOM.bip141semantics.val() == "p2wpkh";
c49e8812
IC
849 }
850
851 function p2wpkhInP2shSelected() {
852 return bip49TabSelected() ||
853 (bip141TabSelected() && DOM.bip141semantics.val() == "p2wpkh-p2sh");
93c3ef47
IC
854 }
855
0eda54f5 856 function TableRow(index, isLast) {
a8c45487 857
40892aba
IC
858 var self = this;
859 this.shouldGenerate = true;
146e089e 860 var useHardenedAddresses = DOM.hardenedAddresses.prop("checked");
0b39e9dc
IC
861 var useBip38 = DOM.useBip38.prop("checked");
862 var bip38password = DOM.bip38Password.val();
0fd67b59
IC
863 var isSegwit = segwitSelected();
864 var segwitAvailable = networkHasSegwit();
c49e8812
IC
865 var isP2wpkh = p2wpkhSelected();
866 var isP2wpkhInP2sh = p2wpkhInP2shSelected();
146e089e 867
a8c45487
IC
868 function init() {
869 calculateValues();
870 }
871
872 function calculateValues() {
873 setTimeout(function() {
40892aba
IC
874 if (!self.shouldGenerate) {
875 return;
876 }
cc61ec30 877 // derive HDkey for this row of the table
a0091a40 878 var key = "NA";
146e089e
IC
879 if (useHardenedAddresses) {
880 key = bip32ExtendedKey.deriveHardened(index);
881 }
882 else {
883 key = bip32ExtendedKey.derive(index);
884 }
cc61ec30
IC
885 // bip38 requires uncompressed keys
886 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
887 var keyPair = key.keyPair;
888 var useUncompressed = useBip38;
889 if (useUncompressed) {
29c30bf3 890 keyPair = new bitcoinjs.bitcoin.ECPair(keyPair.d, null, { network: network, compressed: false });
cc61ec30
IC
891 }
892 // get address
893 var address = keyPair.getAddress().toString();
894 // get privkey
895 var hasPrivkey = !key.isNeutered();
ba3cb9ec 896 var privkey = "NA";
cc61ec30 897 if (hasPrivkey) {
29c30bf3 898 privkey = keyPair.toWIF();
cc61ec30
IC
899 // BIP38 encode private key if required
900 if (useBip38) {
901 privkey = bitcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
902 console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
903 });
904 }
ba3cb9ec 905 }
cc61ec30
IC
906 // get pubkey
907 var pubkey = keyPair.getPublicKeyBuffer().toString('hex');
38523d36 908 var indexText = getDerivationPath() + "/" + index;
146e089e
IC
909 if (useHardenedAddresses) {
910 indexText = indexText + "'";
911 }
0edac945 912 // Ethereum values are different
534481b6 913 if (networks[DOM.network.val()].name == "ETH - Ethereum") {
cc61ec30 914 var privKeyBuffer = keyPair.d.toBuffer(32);
0edac945
IC
915 privkey = privKeyBuffer.toString('hex');
916 var addressBuffer = ethUtil.privateToAddress(privKeyBuffer);
49b21f12
IC
917 var hexAddress = addressBuffer.toString('hex');
918 var checksumAddress = ethUtil.toChecksumAddress(hexAddress);
919 address = ethUtil.addHexPrefix(checksumAddress);
d0239db4
IC
920 privkey = ethUtil.addHexPrefix(privkey);
921 pubkey = ethUtil.addHexPrefix(pubkey);
0edac945 922 }
64a7d2aa 923 // Ripple values are different
534481b6 924 if (networks[DOM.network.val()].name == "XRP - Ripple") {
64a7d2aa 925 privkey = convertRipplePriv(privkey);
926 address = convertRippleAdrr(address);
927 }
e0f91e20
IC
928 // Bitcoin Cash address format may vary
929 if (networks[DOM.network.val()].name == "BCH - Bitcoin Cash") {
930 var bchAddrType = DOM.bitcoinCashAddressType.filter(":checked").val();
931 if (bchAddrType == "cashaddr") {
932 address = bchaddr.toCashAddress(address);
933 }
934 else if (bchAddrType == "bitpay") {
935 address = bchaddr.toBitpayAddress(address);
936 }
937 }
0fd67b59
IC
938 // Segwit addresses are different
939 if (isSegwit) {
940 if (!segwitAvailable) {
6c08f364
IC
941 return;
942 }
c49e8812
IC
943 if (isP2wpkh) {
944 var keyhash = bitcoinjs.bitcoin.crypto.hash160(key.getPublicKeyBuffer());
945 var scriptpubkey = bitcoinjs.bitcoin.script.witnessPubKeyHash.output.encode(keyhash);
946 address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
947 }
948 else if (isP2wpkhInP2sh) {
949 var keyhash = bitcoinjs.bitcoin.crypto.hash160(key.getPublicKeyBuffer());
950 var scriptsig = bitcoinjs.bitcoin.script.witnessPubKeyHash.output.encode(keyhash);
951 var addressbytes = bitcoinjs.bitcoin.crypto.hash160(scriptsig);
952 var scriptpubkey = bitcoinjs.bitcoin.script.scriptHash.output.encode(addressbytes);
953 address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
954 }
6c08f364 955 }
1b12b2f5 956 addAddressToList(indexText, address, pubkey, privkey);
0eda54f5
IC
957 if (isLast) {
958 hidePending();
a78f4e28 959 updateCsv();
0eda54f5 960 }
a8c45487
IC
961 }, 50)
962 }
963
964 init();
965
966 }
967
ebd8d4e8 968 function showMore() {
ebd8d4e8
IC
969 var rowsToAdd = parseInt(DOM.rowsToAdd.val());
970 if (isNaN(rowsToAdd)) {
971 rowsToAdd = 20;
972 DOM.rowsToAdd.val("20");
973 }
9183f9f6
IC
974 var start = parseInt(DOM.moreRowsStartIndex.val())
975 if (isNaN(start)) {
976 start = lastIndexInTable() + 1;
977 }
978 else {
979 var newStart = start + rowsToAdd;
980 DOM.moreRowsStartIndex.val(newStart);
981 }
ebd8d4e8
IC
982 if (rowsToAdd > 200) {
983 var msg = "Generating " + rowsToAdd + " rows could take a while. ";
984 msg += "Do you want to continue?";
985 if (!confirm(msg)) {
986 return;
987 }
988 }
ebd8d4e8 989 displayAddresses(start, rowsToAdd);
ebd8d4e8
IC
990 }
991
992 function clearDisplay() {
993 clearAddressesList();
fa2e4e93 994 clearKeys();
ebd8d4e8
IC
995 hideValidationError();
996 }
997
998 function clearAddressesList() {
999 DOM.addresses.empty();
a78f4e28 1000 DOM.csv.val("");
40892aba
IC
1001 stopGenerating();
1002 }
1003
1004 function stopGenerating() {
1005 while (generationProcesses.length > 0) {
1006 var generation = generationProcesses.shift();
1007 generation.stop();
1008 }
ebd8d4e8
IC
1009 }
1010
fa2e4e93
IC
1011 function clearKeys() {
1012 clearRootKey();
1013 clearDerivedKeys();
1014 }
1015
1016 function clearRootKey() {
ebd8d4e8 1017 DOM.rootKey.val("");
fa2e4e93
IC
1018 }
1019
1020 function clearDerivedKeys() {
ebd8d4e8
IC
1021 DOM.extendedPrivKey.val("");
1022 DOM.extendedPubKey.val("");
fa2e4e93
IC
1023 DOM.bip44accountXprv.val("");
1024 DOM.bip44accountXpub.val("");
ebd8d4e8
IC
1025 }
1026
1b12b2f5 1027 function addAddressToList(indexText, address, pubkey, privkey) {
ebd8d4e8 1028 var row = $(addressRowTemplate.html());
700901cd
IC
1029 // Elements
1030 var indexCell = row.find(".index span");
1031 var addressCell = row.find(".address span");
1b12b2f5 1032 var pubkeyCell = row.find(".pubkey span");
700901cd
IC
1033 var privkeyCell = row.find(".privkey span");
1034 // Content
ae30fed8 1035 indexCell.text(indexText);
700901cd 1036 addressCell.text(address);
1b12b2f5 1037 pubkeyCell.text(pubkey);
700901cd
IC
1038 privkeyCell.text(privkey);
1039 // Visibility
1040 if (!showIndex) {
1041 indexCell.addClass("invisible");
1042 }
1043 if (!showAddress) {
1044 addressCell.addClass("invisible");
1045 }
1b12b2f5
IC
1046 if (!showPubKey) {
1047 pubkeyCell.addClass("invisible");
1048 }
700901cd 1049 if (!showPrivKey) {
6d628db7 1050 privkeyCell.addClass("invisible");
700901cd 1051 }
ebd8d4e8 1052 DOM.addresses.append(row);
e00964cc
IC
1053 var rowShowQrEls = row.find("[data-show-qr]");
1054 setQrEvents(rowShowQrEls);
ebd8d4e8
IC
1055 }
1056
1057 function hasStrongRandom() {
1058 return 'crypto' in window && window['crypto'] !== null;
1059 }
1060
1061 function disableForms() {
1062 $("form").on("submit", function(e) {
1063 e.preventDefault();
1064 });
1065 }
1066
ebd8d4e8
IC
1067 function parseIntNoNaN(val, defaultVal) {
1068 var v = parseInt(val);
1069 if (isNaN(v)) {
1070 return defaultVal;
1071 }
1072 return v;
1073 }
1074
1075 function showPending() {
1076 DOM.feedback
1077 .text("Calculating...")
1078 .show();
1079 }
1080
563e401a 1081 function findNearestWord(word) {
5ee7bb9e
IC
1082 var language = getLanguage();
1083 var words = WORDLISTS[language];
563e401a
IC
1084 var minDistance = 99;
1085 var closestWord = words[0];
1086 for (var i=0; i<words.length; i++) {
1087 var comparedTo = words[i];
6ea15134
IC
1088 if (comparedTo.indexOf(word) == 0) {
1089 return comparedTo;
1090 }
563e401a
IC
1091 var distance = Levenshtein.get(word, comparedTo);
1092 if (distance < minDistance) {
1093 closestWord = comparedTo;
1094 minDistance = distance;
1095 }
1096 }
1097 return closestWord;
1098 }
1099
ebd8d4e8
IC
1100 function hidePending() {
1101 DOM.feedback
1102 .text("")
1103 .hide();
1104 }
1105
7f15cb6e
IC
1106 function populateNetworkSelect() {
1107 for (var i=0; i<networks.length; i++) {
1108 var network = networks[i];
1109 var option = $("<option>");
1110 option.attr("value", i);
1111 option.text(network.name);
7b742f87
IC
1112 if (network.name == "BTC - Bitcoin") {
1113 option.prop("selected", true);
1114 }
7f15cb6e
IC
1115 DOM.phraseNetwork.append(option);
1116 }
1117 }
29bf60f5 1118
b4fd763c
AG
1119 function populateClientSelect() {
1120 for (var i=0; i<clients.length; i++) {
1121 var client = clients[i];
1122 var option = $("<option>");
1123 option.attr("value", i);
1124 option.text(client.name);
29bf60f5 1125 DOM.bip32Client.append(option);
b4fd763c
AG
1126 }
1127 }
7f15cb6e 1128
5ee7bb9e
IC
1129 function getLanguage() {
1130 var defaultLanguage = "english";
1131 // Try to get from existing phrase
1132 var language = getLanguageFromPhrase();
1133 // Try to get from url if not from phrase
1134 if (language.length == 0) {
1135 language = getLanguageFromUrl();
1136 }
1137 // Default to English if no other option
1138 if (language.length == 0) {
1139 language = defaultLanguage;
1140 }
1141 return language;
1142 }
1143
1144 function getLanguageFromPhrase(phrase) {
1145 // Check if how many words from existing phrase match a language.
1146 var language = "";
1147 if (!phrase) {
1148 phrase = DOM.phrase.val();
1149 }
1150 if (phrase.length > 0) {
1151 var words = phraseToWordArray(phrase);
1152 var languageMatches = {};
1153 for (l in WORDLISTS) {
1154 // Track how many words match in this language
1155 languageMatches[l] = 0;
1156 for (var i=0; i<words.length; i++) {
1157 var wordInLanguage = WORDLISTS[l].indexOf(words[i]) > -1;
1158 if (wordInLanguage) {
1159 languageMatches[l]++;
1160 }
1161 }
1162 // Find languages with most word matches.
1163 // This is made difficult due to commonalities between Chinese
1164 // simplified vs traditional.
1165 var mostMatches = 0;
1166 var mostMatchedLanguages = [];
1167 for (var l in languageMatches) {
1168 var numMatches = languageMatches[l];
1169 if (numMatches > mostMatches) {
1170 mostMatches = numMatches;
1171 mostMatchedLanguages = [l];
1172 }
1173 else if (numMatches == mostMatches) {
1174 mostMatchedLanguages.push(l);
1175 }
1176 }
1177 }
1178 if (mostMatchedLanguages.length > 0) {
1179 // Use first language and warn if multiple detected
1180 language = mostMatchedLanguages[0];
1181 if (mostMatchedLanguages.length > 1) {
1182 console.warn("Multiple possible languages");
1183 console.warn(mostMatchedLanguages);
1184 }
1185 }
1186 }
1187 return language;
1188 }
1189
1190 function getLanguageFromUrl() {
c6624d51
IC
1191 for (var language in WORDLISTS) {
1192 if (window.location.hash.indexOf(language) > -1) {
1193 return language;
1194 }
1195 }
1196 return "";
5ee7bb9e
IC
1197 }
1198
1199 function setMnemonicLanguage() {
1200 var language = getLanguage();
1201 // Load the bip39 mnemonic generator for this language if required
1202 if (!(language in mnemonics)) {
1203 mnemonics[language] = new Mnemonic(language);
1204 }
1205 mnemonic = mnemonics[language];
1206 }
1207
1208 function convertPhraseToNewLanguage() {
1209 var oldLanguage = getLanguageFromPhrase();
1210 var newLanguage = getLanguageFromUrl();
1211 var oldPhrase = DOM.phrase.val();
1212 var oldWords = phraseToWordArray(oldPhrase);
1213 var newWords = [];
1214 for (var i=0; i<oldWords.length; i++) {
1215 var oldWord = oldWords[i];
1216 var index = WORDLISTS[oldLanguage].indexOf(oldWord);
1217 var newWord = WORDLISTS[newLanguage][index];
1218 newWords.push(newWord);
1219 }
1220 newPhrase = wordArrayToPhrase(newWords);
1221 return newPhrase;
1222 }
1223
1224 // TODO look at jsbip39 - mnemonic.splitWords
1225 function phraseToWordArray(phrase) {
1226 var words = phrase.split(/\s/g);
1227 var noBlanks = [];
1228 for (var i=0; i<words.length; i++) {
1229 var word = words[i];
1230 if (word.length > 0) {
1231 noBlanks.push(word);
1232 }
1233 }
1234 return noBlanks;
1235 }
1236
1237 // TODO look at jsbip39 - mnemonic.joinWords
1238 function wordArrayToPhrase(words) {
1239 var phrase = words.join(" ");
1240 var language = getLanguageFromPhrase(phrase);
956e44ef 1241 if (language == "japanese") {
5ee7bb9e
IC
1242 phrase = words.join("\u3000");
1243 }
1244 return phrase;
1245 }
1246
c6624d51
IC
1247 function isUsingOwnEntropy() {
1248 return DOM.useEntropy.prop("checked");
1249 }
1250
1251 function setMnemonicFromEntropy() {
0a84fe6a 1252 clearEntropyFeedback();
057722b0 1253 // Get entropy value
c6624d51 1254 var entropyStr = DOM.entropy.val();
057722b0 1255 // Work out minimum base for entropy
c6624d51 1256 var entropy = Entropy.fromString(entropyStr);
057722b0 1257 if (entropy.binaryStr.length == 0) {
c6624d51
IC
1258 return;
1259 }
1260 // Show entropy details
1cf1bbaf 1261 showEntropyFeedback(entropy);
3599674d
IC
1262 // Use entropy hash if not using raw entropy
1263 var bits = entropy.binaryStr;
1264 var mnemonicLength = DOM.entropyMnemonicLength.val();
1265 if (mnemonicLength != "raw") {
1266 // Get bits by hashing entropy with SHA256
1267 var hash = sjcl.hash.sha256.hash(entropy.cleanStr);
1268 var hex = sjcl.codec.hex.fromBits(hash);
1269 bits = BigInteger.parse(hex, 16).toString(2);
53aaab27 1270 while (bits.length % 256 != 0) {
3599674d
IC
1271 bits = "0" + bits;
1272 }
1273 // Truncate hash to suit number of words
1274 mnemonicLength = parseInt(mnemonicLength);
1275 var numberOfBits = 32 * mnemonicLength / 3;
1276 bits = bits.substring(0, numberOfBits);
645945a0
IC
1277 // show warning for weak entropy override
1278 if (mnemonicLength / 3 * 32 > entropy.binaryStr.length) {
1279 DOM.entropyWeakEntropyOverrideWarning.removeClass("hidden");
1280 }
1281 else {
1282 DOM.entropyWeakEntropyOverrideWarning.addClass("hidden");
1283 }
1284 }
1285 else {
1286 // hide warning for weak entropy override
1287 DOM.entropyWeakEntropyOverrideWarning.addClass("hidden");
3599674d 1288 }
c6624d51 1289 // Discard trailing entropy
3599674d 1290 var bitsToUse = Math.floor(bits.length / 32) * 32;
d6fd8ebf
IC
1291 var start = bits.length - bitsToUse;
1292 var binaryStr = bits.substring(start);
c6624d51
IC
1293 // Convert entropy string to numeric array
1294 var entropyArr = [];
adc8ce12
IC
1295 for (var i=0; i<binaryStr.length / 8; i++) {
1296 var byteAsBits = binaryStr.substring(i*8, i*8+8);
1297 var entropyByte = parseInt(byteAsBits, 2);
c6624d51
IC
1298 entropyArr.push(entropyByte)
1299 }
1300 // Convert entropy array to mnemonic
1301 var phrase = mnemonic.toMnemonic(entropyArr);
1302 // Set the mnemonic in the UI
1303 DOM.phrase.val(phrase);
74ab4cbe
IC
1304 // Show the word indexes
1305 showWordIndexes();
09d63290
IC
1306 // Show the checksum
1307 showChecksum();
c6624d51
IC
1308 }
1309
0a84fe6a 1310 function clearEntropyFeedback() {
20f459ce 1311 DOM.entropyCrackTime.text("...");
1cf1bbaf 1312 DOM.entropyType.text("");
0a84fe6a
IC
1313 DOM.entropyWordCount.text("0");
1314 DOM.entropyEventCount.text("0");
1315 DOM.entropyBitsPerEvent.text("0");
1316 DOM.entropyBits.text("0");
1317 DOM.entropyFiltered.html("&nbsp;");
1318 DOM.entropyBinary.html("&nbsp;");
c6624d51
IC
1319 }
1320
1cf1bbaf 1321 function showEntropyFeedback(entropy) {
6422c1cd 1322 var numberOfBits = entropy.binaryStr.length;
20f459ce 1323 var timeToCrack = "unknown";
9bc39377
IC
1324 try {
1325 var z = zxcvbn(entropy.base.parts.join(""));
20f459ce
IC
1326 timeToCrack = z.crack_times_display.offline_fast_hashing_1e10_per_second;
1327 if (z.feedback.warning != "") {
1328 timeToCrack = timeToCrack + " - " + z.feedback.warning;
1329 };
9bc39377
IC
1330 }
1331 catch (e) {
9bc39377
IC
1332 console.log("Error detecting entropy strength with zxcvbn:");
1333 console.log(e);
b299a6a7 1334 }
391c7f26 1335 var entropyTypeStr = getEntropyTypeStr(entropy);
6422c1cd 1336 var wordCount = Math.floor(numberOfBits / 32) * 3;
94959756 1337 var bitsPerEvent = entropy.bitsPerEvent.toFixed(2);
f8ca25c3 1338 var spacedBinaryStr = addSpacesEveryElevenBits(entropy.binaryStr);
b54c1218 1339 DOM.entropyFiltered.html(entropy.cleanHtml);
391c7f26 1340 DOM.entropyType.text(entropyTypeStr);
20f459ce 1341 DOM.entropyCrackTime.text(timeToCrack);
1cf1bbaf 1342 DOM.entropyEventCount.text(entropy.base.ints.length);
6422c1cd 1343 DOM.entropyBits.text(numberOfBits);
0a84fe6a 1344 DOM.entropyWordCount.text(wordCount);
d6cade86 1345 DOM.entropyBinary.text(spacedBinaryStr);
6422c1cd 1346 DOM.entropyBitsPerEvent.text(bitsPerEvent);
ee0981f1
IC
1347 // detect and warn of filtering
1348 var rawNoSpaces = DOM.entropy.val().replace(/\s/g, "");
1349 var cleanNoSpaces = entropy.cleanStr.replace(/\s/g, "");
1350 var isFiltered = rawNoSpaces.length != cleanNoSpaces.length;
1351 if (isFiltered) {
1352 DOM.entropyFilterWarning.removeClass('hidden');
1353 }
1354 else {
1355 DOM.entropyFilterWarning.addClass('hidden');
1356 }
02f05d3e
IC
1357 }
1358
391c7f26
IC
1359 function getEntropyTypeStr(entropy) {
1360 var typeStr = entropy.base.str;
1361 // Add some detail if these are cards
1362 if (entropy.base.asInt == 52) {
1363 var cardDetail = []; // array of message strings
1364 // Detect duplicates
1365 var dupes = [];
1366 var dupeTracker = {};
1367 for (var i=0; i<entropy.base.parts.length; i++) {
1368 var card = entropy.base.parts[i];
5c653a12
IC
1369 var cardUpper = card.toUpperCase();
1370 if (cardUpper in dupeTracker) {
391c7f26
IC
1371 dupes.push(card);
1372 }
5c653a12 1373 dupeTracker[cardUpper] = true;
391c7f26
IC
1374 }
1375 if (dupes.length > 0) {
1376 var dupeWord = "duplicates";
1377 if (dupes.length == 1) {
1378 dupeWord = "duplicate";
1379 }
1380 var msg = dupes.length + " " + dupeWord + ": " + dupes.slice(0,3).join(" ");
1381 if (dupes.length > 3) {
1382 msg += "...";
1383 }
1384 cardDetail.push(msg);
1385 }
1386 // Detect full deck
1387 var uniqueCards = [];
1388 for (var uniqueCard in dupeTracker) {
1389 uniqueCards.push(uniqueCard);
1390 }
1391 if (uniqueCards.length == 52) {
1392 cardDetail.unshift("full deck");
1393 }
bbc29c80
IC
1394 // Detect missing cards
1395 var values = "A23456789TJQK";
1396 var suits = "CDHS";
1397 var missingCards = [];
1398 for (var i=0; i<suits.length; i++) {
1399 for (var j=0; j<values.length; j++) {
1400 var card = values[j] + suits[i];
1401 if (!(card in dupeTracker)) {
1402 missingCards.push(card);
1403 }
1404 }
1405 }
1406 // Display missing cards if six or less, ie clearly going for full deck
1407 if (missingCards.length > 0 && missingCards.length <= 6) {
1408 var msg = missingCards.length + " missing: " + missingCards.slice(0,3).join(" ");
1409 if (missingCards.length > 3) {
1410 msg += "...";
1411 }
1412 cardDetail.push(msg);
1413 }
391c7f26
IC
1414 // Add card details to typeStr
1415 if (cardDetail.length > 0) {
1416 typeStr += " (" + cardDetail.join(", ") + ")";
1417 }
1418 }
1419 return typeStr;
1420 }
1421
e00964cc
IC
1422 function setQrEvents(els) {
1423 els.on("mouseenter", createQr);
1424 els.on("mouseleave", destroyQr);
1425 els.on("click", toggleQr);
1426 }
1427
1428 function createQr(e) {
1429 var content = e.target.textContent || e.target.value;
1430 if (content) {
9225b805
IC
1431 var qrEl = kjua({
1432 text: content,
1433 render: "canvas",
1434 size: 310,
1435 ecLevel: 'H',
1436 });
1437 DOM.qrImage.append(qrEl);
e00964cc 1438 if (!showQr) {
97811c29
IC
1439 DOM.qrHider.addClass("hidden");
1440 }
1441 else {
1442 DOM.qrHider.removeClass("hidden");
e00964cc
IC
1443 }
1444 DOM.qrContainer.removeClass("hidden");
1445 }
1446 }
1447
1448 function destroyQr() {
1449 DOM.qrImage.text("");
1450 DOM.qrContainer.addClass("hidden");
1451 }
1452
1453 function toggleQr() {
1454 showQr = !showQr;
97811c29 1455 DOM.qrHider.toggleClass("hidden");
e00964cc
IC
1456 DOM.qrHint.toggleClass("hidden");
1457 }
1458
32fab2c3
IC
1459 function bip44TabSelected() {
1460 return DOM.bip44tab.hasClass("active");
1461 }
1462
1463 function bip32TabSelected() {
1464 return DOM.bip32tab.hasClass("active");
1465 }
1466
0fd67b59 1467 function networkHasSegwit() {
c147cb5e
IC
1468 var n = network;
1469 if ("baseNetwork" in network) {
1470 n = bitcoinjs.bitcoin.networks[network.baseNetwork];
1471 }
1472 // check if only p2wpkh params are required
1473 if (p2wpkhSelected()) {
1474 return "p2wpkh" in n;
1475 }
1476 // check if only p2wpkh-in-p2sh params are required
1477 else if (p2wpkhInP2shSelected()) {
1478 return "p2wpkhInP2sh" in n;
1479 }
1480 // require both if it's unclear which params are required
1481 return "p2wpkh" in n && "p2wpkhInP2sh" in n;
6c08f364
IC
1482 }
1483
1484 function bip49TabSelected() {
1485 return DOM.bip49tab.hasClass("active");
1486 }
1487
4e9b492c
IC
1488 function bip84TabSelected() {
1489 return DOM.bip84tab.hasClass("active");
1490 }
1491
c49e8812
IC
1492 function bip141TabSelected() {
1493 return DOM.bip141tab.hasClass("active");
1494 }
1495
6c08f364
IC
1496 function setHdCoin(coinValue) {
1497 DOM.bip44coin.val(coinValue);
1498 DOM.bip49coin.val(coinValue);
4e9b492c 1499 DOM.bip84coin.val(coinValue);
6c08f364
IC
1500 }
1501
0fd67b59 1502 function showSegwitAvailable() {
6c08f364
IC
1503 DOM.bip49unavailable.addClass("hidden");
1504 DOM.bip49available.removeClass("hidden");
bddd5d9f
IC
1505 DOM.bip84unavailable.addClass("hidden");
1506 DOM.bip84available.removeClass("hidden");
c49e8812
IC
1507 DOM.bip141unavailable.addClass("hidden");
1508 DOM.bip141available.removeClass("hidden");
6c08f364
IC
1509 }
1510
0fd67b59 1511 function showSegwitUnavailable() {
6c08f364
IC
1512 DOM.bip49available.addClass("hidden");
1513 DOM.bip49unavailable.removeClass("hidden");
bddd5d9f
IC
1514 DOM.bip84available.addClass("hidden");
1515 DOM.bip84unavailable.removeClass("hidden");
c49e8812
IC
1516 DOM.bip141available.addClass("hidden");
1517 DOM.bip141unavailable.removeClass("hidden");
6c08f364
IC
1518 }
1519
0fd67b59
IC
1520 function adjustNetworkForSegwit() {
1521 // If segwit is selected the xpub/xprv prefixes need to be adjusted
93c3ef47
IC
1522 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1523 // wallet.
1524 // See https://github.com/iancoleman/bip39/issues/125
c49e8812
IC
1525 var segwitNetworks = null;
1526 // if a segwit network is alread selected, need to use base network to
1527 // look up new parameters
1528 if ("baseNetwork" in network) {
1529 network = bitcoinjs.bitcoin.networks[network.baseNetwork];
1530 }
1531 // choose the right segwit params
1532 if (p2wpkhSelected() && "p2wpkh" in network) {
1533 network = network.p2wpkh;
1534 }
1535 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network) {
1536 network = network.p2wpkhInP2sh;
93c3ef47
IC
1537 }
1538 }
1539
9183f9f6
IC
1540 function lastIndexInTable() {
1541 var pathText = DOM.addresses.find(".index").last().text();
1542 var pathBits = pathText.split("/");
1543 var lastBit = pathBits[pathBits.length-1];
1544 var lastBitClean = lastBit.replace("'", "");
1545 return parseInt(lastBitClean);
1546 }
1547
74ab4cbe
IC
1548 function uint8ArrayToHex(a) {
1549 var s = ""
1550 for (var i=0; i<a.length; i++) {
1551 var h = a[i].toString(16);
1552 while (h.length < 2) {
1553 h = "0" + h;
1554 }
1555 s = s + h;
1556 }
1557 return s;
1558 }
1559
1560 function showWordIndexes() {
1561 var phrase = DOM.phrase.val();
1562 var words = phraseToWordArray(phrase);
1563 var wordIndexes = [];
1564 var language = getLanguage();
1565 for (var i=0; i<words.length; i++) {
1566 var word = words[i];
1567 var wordIndex = WORDLISTS[language].indexOf(word);
1568 wordIndexes.push(wordIndex);
1569 }
1570 var wordIndexesStr = wordIndexes.join(", ");
1571 DOM.entropyWordIndexes.text(wordIndexesStr);
1572 }
a78f4e28 1573
09d63290
IC
1574 function showChecksum() {
1575 var phrase = DOM.phrase.val();
1576 var words = phraseToWordArray(phrase);
1577 var checksumBitlength = words.length / 3;
1578 var checksum = "";
1579 var binaryStr = "";
1580 var language = getLanguage();
1581 for (var i=words.length-1; i>=0; i--) {
1582 var word = words[i];
1583 var wordIndex = WORDLISTS[language].indexOf(word);
1584 var wordBinary = wordIndex.toString(2);
1585 while (wordBinary.length < 11) {
1586 wordBinary = "0" + wordBinary;
1587 }
1588 var binaryStr = wordBinary + binaryStr;
1589 if (binaryStr.length >= checksumBitlength) {
1590 var start = binaryStr.length - checksumBitlength;
1591 var end = binaryStr.length;
1592 checksum = binaryStr.substring(start, end);
f8ca25c3
IC
1593 // add spaces so the last group is 11 bits, not the first
1594 checksum = checksum.split("").reverse().join("")
1595 checksum = addSpacesEveryElevenBits(checksum);
1596 checksum = checksum.split("").reverse().join("")
1597 break;
09d63290
IC
1598 }
1599 }
1600 DOM.entropyChecksum.text(checksum);
1601 }
1602
a78f4e28
IC
1603 function updateCsv() {
1604 var tableCsv = "path,address,public key,private key\n";
1605 var rows = DOM.addresses.find("tr");
1606 for (var i=0; i<rows.length; i++) {
1607 var row = $(rows[i]);
1608 var cells = row.find("td");
1609 for (var j=0; j<cells.length; j++) {
1610 var cell = $(cells[j]);
1611 if (!cell.children().hasClass("invisible")) {
1612 tableCsv = tableCsv + cell.text();
1613 }
1614 if (j != cells.length - 1) {
1615 tableCsv = tableCsv + ",";
1616 }
1617 }
1618 tableCsv = tableCsv + "\n";
1619 }
1620 DOM.csv.val(tableCsv);
1621 }
74ab4cbe 1622
f8ca25c3
IC
1623 function addSpacesEveryElevenBits(binaryStr) {
1624 return binaryStr.match(/.{1,11}/g).join(" ");
1625 }
1626
7f15cb6e 1627 var networks = [
85f762c9 1628 {
1629 name: "AC - Asiacoin",
85f762c9 1630 onSelect: function() {
1631 network = bitcoinjs.bitcoin.networks.asiacoin;
1632 setHdCoin(51);
1633 },
1634 },
1635 {
1636 name: "ACC - Adcoin",
85f762c9 1637 onSelect: function() {
1638 network = bitcoinjs.bitcoin.networks.adcoin;
1639 setHdCoin(161);
1640 },
1641 },
1642 {
1643 name: "AUR - Auroracoin",
85f762c9 1644 onSelect: function() {
1645 network = bitcoinjs.bitcoin.networks.auroracoin;
1646 setHdCoin(85);
1647 },
1648 },
cfc0c4d7 1649 {
1650 name: "AXE - Axe",
cfc0c4d7 1651 onSelect: function() {
1652 network = bitcoinjs.bitcoin.networks.axe;
7d9b5f68 1653 setHdCoin(4242);
cfc0c4d7 1654 },
1655 },
85f762c9 1656 {
1657 name: "BCA - Bitcoin Atom",
85f762c9 1658 onSelect: function() {
1659 network = bitcoinjs.bitcoin.networks.atom;
1660 setHdCoin(185);
1661 },
1662 },
52d698e4 1663 {
2eab7c32 1664 name: "BCH - Bitcoin Cash",
52d698e4 1665 onSelect: function() {
e0f91e20 1666 DOM.bitcoinCashAddressTypeContainer.removeClass("hidden");
2eab7c32 1667 setHdCoin(145);
52d698e4 1668 },
1669 },
daab55dc 1670 {
2eab7c32 1671 name: "BEET - Beetlecoin",
daab55dc 1672 onSelect: function() {
2eab7c32
IC
1673 network = bitcoinjs.bitcoin.networks.beetlecoin;
1674 setHdCoin(800);
daab55dc
IC
1675 },
1676 },
85f762c9 1677 {
1678 name: "BELA - Belacoin",
85f762c9 1679 onSelect: function() {
1680 network = bitcoinjs.bitcoin.networks.belacoin;
1681 setHdCoin(73);
1682 },
1683 },
892ce76f
IC
1684 {
1685 name: "BLK - BlackCoin",
892ce76f
IC
1686 onSelect: function() {
1687 network = bitcoinjs.bitcoin.networks.blackcoin;
1688 setHdCoin(10);
1689 },
1690 },
85f762c9 1691 {
1692 name: "BRIT - Britcoin",
85f762c9 1693 onSelect: function() {
1694 network = bitcoinjs.bitcoin.networks.britcoin;
1695 setHdCoin(70);
1696 },
1697 },
1698 {
1699 name: "BSD - Bitsend",
85f762c9 1700 onSelect: function() {
1701 network = bitcoinjs.bitcoin.networks.bitsend;
1702 setHdCoin(91);
1703 },
1704 },
1705 {
1706 name: "BTA - Bata",
85f762c9 1707 onSelect: function() {
1708 network = bitcoinjs.bitcoin.networks.bata;
1709 setHdCoin(89);
1710 },
1711 },
7f15cb6e 1712 {
534481b6 1713 name: "BTC - Bitcoin",
7a995731 1714 onSelect: function() {
a0091a40 1715 network = bitcoinjs.bitcoin.networks.bitcoin;
6c08f364 1716 setHdCoin(0);
7a995731
IC
1717 },
1718 },
7f15cb6e 1719 {
534481b6 1720 name: "BTC - Bitcoin Testnet",
7a995731 1721 onSelect: function() {
a0091a40 1722 network = bitcoinjs.bitcoin.networks.testnet;
6c08f364 1723 setHdCoin(1);
7a995731
IC
1724 },
1725 },
1e2cc748 1726 {
1727 name: "BTCP - Bitcoin Private",
1e2cc748 1728 onSelect: function() {
1729 network = bitcoinjs.bitcoin.networks.bitcoinprivate;
1730 setHdCoin(183);
1731 },
1732 },
1733 {
1734 name: "BTCZ - Bitcoinz",
1e2cc748 1735 onSelect: function() {
1736 network = bitcoinjs.bitcoin.networks.bitcoinz;
1737 setHdCoin(177);
1738 },
1739 },
39608073
RS
1740 {
1741 name: "BTG - Bitcoin Gold",
39608073
RS
1742 onSelect: function() {
1743 network = bitcoinjs.bitcoin.networks.bgold;
88ae1301 1744 setHdCoin(156);
39608073
RS
1745 },
1746 },
85f762c9 1747 {
1748 name: "BTX - Bitcore",
85f762c9 1749 onSelect: function() {
1750 network = bitcoinjs.bitcoin.networks.bitcore;
1751 setHdCoin(160);
1752 },
1753 },
1754 {
1755 name: "CCN - Cannacoin",
85f762c9 1756 onSelect: function() {
1757 network = bitcoinjs.bitcoin.networks.cannacoin;
1758 setHdCoin(19);
1759 },
1760 },
1761 {
1762 name: "CDN - Canadaecoin",
85f762c9 1763 onSelect: function() {
1764 network = bitcoinjs.bitcoin.networks.canadaecoin;
1765 setHdCoin(34);
1766 },
1767 },
7f15cb6e 1768 {
534481b6 1769 name: "CLAM - Clams",
7a995731 1770 onSelect: function() {
a0091a40 1771 network = bitcoinjs.bitcoin.networks.clam;
6c08f364 1772 setHdCoin(23);
7a995731
IC
1773 },
1774 },
85f762c9 1775 {
1776 name: "CLUB - Clubcoin",
85f762c9 1777 onSelect: function() {
1778 network = bitcoinjs.bitcoin.networks.clubcoin;
1779 setHdCoin(79);
1780 },
1781 },
1782 {
1783 name: "CMP - Compcoin",
85f762c9 1784 onSelect: function() {
1785 network = bitcoinjs.bitcoin.networks.compcoin;
1786 setHdCoin(71);
1787 },
1788 },
1789 {
1790 name: "CRAVE - Crave",
85f762c9 1791 onSelect: function() {
1792 network = bitcoinjs.bitcoin.networks.crave;
1793 setHdCoin(186);
1794 },
1795 },
0921f370 1796 {
1797 name: "CRW - Crown",
1798 onSelect: function() {
6c08f364
IC
1799 network = bitcoinjs.bitcoin.networks.crown;
1800 setHdCoin(72);
0921f370 1801 },
1802 },
7f15cb6e 1803 {
534481b6 1804 name: "DASH - Dash",
e3a9508c 1805 onSelect: function() {
a0091a40 1806 network = bitcoinjs.bitcoin.networks.dash;
6c08f364 1807 setHdCoin(5);
e3a9508c
IC
1808 },
1809 },
c0386f3b 1810 {
534481b6 1811 name: "DASH - Dash Testnet",
c0386f3b 1812 onSelect: function() {
a0091a40 1813 network = bitcoinjs.bitcoin.networks.dashtn;
6c08f364 1814 setHdCoin(1);
c0386f3b
KR
1815 },
1816 },
85f762c9 1817 {
1818 name: "DFC - Defcoin",
85f762c9 1819 onSelect: function() {
1820 network = bitcoinjs.bitcoin.networks.defcoin;
1821 setHdCoin(1337);
1822 },
1823 },
1824 {
1825 name: "DGB - Digibyte",
85f762c9 1826 onSelect: function() {
1827 network = bitcoinjs.bitcoin.networks.digibyte;
1828 setHdCoin(20);
1829 },
1830 },
1831 {
1832 name: "DGC - Digitalcoin",
85f762c9 1833 onSelect: function() {
1834 network = bitcoinjs.bitcoin.networks.digitalcoin;
1835 setHdCoin(18);
1836 },
1837 },
1838 {
1839 name: "DMD - Diamond",
85f762c9 1840 onSelect: function() {
1841 network = bitcoinjs.bitcoin.networks.diamond;
1842 setHdCoin(152);
1843 },
1844 },
40209fd8 1845 {
1846 name: "DNR - Denarius",
40209fd8 1847 onSelect: function() {
1848 network = bitcoinjs.bitcoin.networks.denarius;
50289881 1849 setHdCoin(116);
40209fd8 1850 },
1851 },
e3a9508c 1852 {
534481b6 1853 name: "DOGE - Dogecoin",
1854 onSelect: function() {
6c08f364
IC
1855 network = bitcoinjs.bitcoin.networks.dogecoin;
1856 setHdCoin(3);
534481b6 1857 },
1858 },
85f762c9 1859 {
1860 name: "ECN - Ecoin",
85f762c9 1861 onSelect: function() {
1862 network = bitcoinjs.bitcoin.networks.ecoin;
1863 setHdCoin(115);
1864 },
1865 },
1866 {
1867 name: "EDRC - Edrcoin",
85f762c9 1868 onSelect: function() {
1869 network = bitcoinjs.bitcoin.networks.edrcoin;
1870 setHdCoin(56);
1871 },
1872 },
1873 {
1874 name: "EFL - Egulden",
85f762c9 1875 onSelect: function() {
1876 network = bitcoinjs.bitcoin.networks.egulden;
1877 setHdCoin(78);
1878 },
1879 },
1880 {
1881 name: "EMC2 - Einsteinium",
85f762c9 1882 onSelect: function() {
1883 network = bitcoinjs.bitcoin.networks.einsteinium;
1884 setHdCoin(41);
1885 },
1886 },
1887 {
1888 name: "ERC - Europecoin",
85f762c9 1889 onSelect: function() {
1890 network = bitcoinjs.bitcoin.networks.europecoin;
1891 setHdCoin(151);
1892 },
1893 },
534481b6 1894 {
1895 name: "ETH - Ethereum",
e3a9508c 1896 onSelect: function() {
a0091a40 1897 network = bitcoinjs.bitcoin.networks.bitcoin;
6c08f364 1898 setHdCoin(60);
e3a9508c
IC
1899 },
1900 },
85f762c9 1901 {
1902 name: "EXCL - Exclusivecoin",
85f762c9 1903 onSelect: function() {
1904 network = bitcoinjs.bitcoin.networks.exclusivecoin;
1905 setHdCoin(190);
1906 },
1907 },
6e679905 1908 {
1909 name: "FJC - Fujicoin",
6e679905 1910 onSelect: function() {
1911 network = bitcoinjs.bitcoin.networks.fujicoin;
1912 setHdCoin(75);
1913 },
1914 },
85f762c9 1915 {
1916 name: "FLASH - Flashcoin",
85f762c9 1917 onSelect: function() {
1918 network = bitcoinjs.bitcoin.networks.flashcoin;
1919 setHdCoin(120);
1920 },
1921 },
1922 {
1923 name: "FRST - Firstcoin",
85f762c9 1924 onSelect: function() {
1925 network = bitcoinjs.bitcoin.networks.firstcoin;
1926 setHdCoin(167);
1927 },
1928 },
1929 {
1930 name: "FTC - Feathercoin",
85f762c9 1931 onSelect: function() {
1932 network = bitcoinjs.bitcoin.networks.feathercoin;
1933 setHdCoin(8);
1934 },
1935 },
f88fab20 1936 {
534481b6 1937 name: "GAME - GameCredits",
f88fab20 1938 onSelect: function() {
a0091a40 1939 network = bitcoinjs.bitcoin.networks.game;
6c08f364 1940 setHdCoin(101);
f88fab20 1941 },
1942 },
85f762c9 1943 {
1944 name: "GBX - Gobyte",
85f762c9 1945 onSelect: function() {
1946 network = bitcoinjs.bitcoin.networks.gobyte;
1947 setHdCoin(176);
1948 },
1949 },
1950 {
1951 name: "GCR - GCRCoin",
85f762c9 1952 onSelect: function() {
1953 network = bitcoinjs.bitcoin.networks.gcr;
1954 setHdCoin(79);
1955 },
1956 },
1957 {
1958 name: "GRC - Gridcoin",
85f762c9 1959 onSelect: function() {
1960 network = bitcoinjs.bitcoin.networks.gridcoin;
1961 setHdCoin(84);
1962 },
1963 },
1964 {
1965 name: "HNC - Helleniccoin",
85f762c9 1966 onSelect: function() {
1967 network = bitcoinjs.bitcoin.networks.helleniccoin;
1968 setHdCoin(168);
1969 },
1970 },
1971 {
1972 name: "INSN - Insane",
85f762c9 1973 onSelect: function() {
1974 network = bitcoinjs.bitcoin.networks.insane;
1975 setHdCoin(68);
1976 },
1977 },
1978 {
1979 name: "IOP - Iop",
85f762c9 1980 onSelect: function() {
1981 network = bitcoinjs.bitcoin.networks.iop;
1982 setHdCoin(66);
1983 },
1984 },
1985 {
1986 name: "IXC - Ixcoin",
85f762c9 1987 onSelect: function() {
1988 network = bitcoinjs.bitcoin.networks.ixcoin;
1989 setHdCoin(86);
1990 },
1991 },
a3baa26e 1992 {
534481b6 1993 name: "JBS - Jumbucks",
a3baa26e 1994 onSelect: function() {
a0091a40 1995 network = bitcoinjs.bitcoin.networks.jumbucks;
6c08f364 1996 setHdCoin(26);
a3baa26e
IC
1997 },
1998 },
aab3645f 1999 {
2000 name: "KMD - Komodo",
2001 bip49available: false,
2002 onSelect: function() {
2003 network = bitcoinjs.bitcoin.networks.komodo;
2004 setHdCoin(141);
2005 },
2006 },
0a5d28a7 2007 {
2008 name: "KOBO - Kobocoin",
2009 bip49available: false,
2010 onSelect: function() {
2011 network = bitcoinjs.bitcoin.networks.kobocoin;
2012 setHdCoin(196);
2013 },
2014 },
85f762c9 2015 {
2016 name: "LBC - Library Credits",
85f762c9 2017 onSelect: function() {
2018 network = bitcoinjs.bitcoin.networks.lbry;
2019 setHdCoin(140);
2020 },
2021 },
2022 {
2023 name: "LCC - Litecoincash",
85f762c9 2024 onSelect: function() {
2025 network = bitcoinjs.bitcoin.networks.litecoincash;
2026 setHdCoin(192);
2027 },
2028 },
2029 {
2030 name: "LDCN - Landcoin",
85f762c9 2031 onSelect: function() {
2032 network = bitcoinjs.bitcoin.networks.landcoin;
2033 setHdCoin(63);
2034 },
2035 },
2036 {
2037 name: "LINX - Linx",
85f762c9 2038 onSelect: function() {
2039 network = bitcoinjs.bitcoin.networks.linx;
2040 setHdCoin(114);
2041 },
2042 },
a3baa26e 2043 {
534481b6 2044 name: "LTC - Litecoin",
a3baa26e 2045 onSelect: function() {
a0091a40 2046 network = bitcoinjs.bitcoin.networks.litecoin;
6c08f364 2047 setHdCoin(2);
3abab9b0 2048 DOM.litecoinLtubContainer.removeClass("hidden");
a3baa26e
IC
2049 },
2050 },
85f762c9 2051 {
2052 name: "LYNX - Lynx",
85f762c9 2053 onSelect: function() {
2054 network = bitcoinjs.bitcoin.networks.lynx;
2055 setHdCoin(191);
2056 },
2057 },
56ad9601
JS
2058 {
2059 name: "MAZA - Maza",
56ad9601
JS
2060 onSelect: function() {
2061 network = bitcoinjs.bitcoin.networks.maza;
2062 setHdCoin(13);
2063 },
2064 },
85f762c9 2065 {
2066 name: "MNX - Minexcoin",
85f762c9 2067 onSelect: function() {
2068 network = bitcoinjs.bitcoin.networks.minexcoin;
2069 setHdCoin(182);
2070 },
2071 },
f487fea9
IC
2072 {
2073 name: "MONA - Monacoin",
f487fea9
IC
2074 onSelect: function() {
2075 network = bitcoinjs.bitcoin.networks.monacoin,
2076 setHdCoin(22);
2077 },
2078 },
85f762c9 2079 {
2080 name: "NAV - Navcoin",
85f762c9 2081 onSelect: function() {
2082 network = bitcoinjs.bitcoin.networks.navcoin;
2083 setHdCoin(130);
2084 },
2085 },
db37d639
IC
2086 {
2087 name: "NEBL - Neblio",
db37d639
IC
2088 onSelect: function() {
2089 network = bitcoinjs.bitcoin.networks.neblio;
2090 setHdCoin(146);
2091 },
2092 },
85f762c9 2093 {
2094 name: "NEOS - Neoscoin",
85f762c9 2095 onSelect: function() {
2096 network = bitcoinjs.bitcoin.networks.neoscoin;
2097 setHdCoin(25);
2098 },
2099 },
2100 {
2101 name: "NLG - Gulden",
85f762c9 2102 onSelect: function() {
2103 network = bitcoinjs.bitcoin.networks.gulden;
2104 setHdCoin(87);
2105 },
2106 },
a3baa26e 2107 {
534481b6 2108 name: "NMC - Namecoin",
a3baa26e 2109 onSelect: function() {
a0091a40 2110 network = bitcoinjs.bitcoin.networks.namecoin;
6c08f364 2111 setHdCoin(7);
a3baa26e
IC
2112 },
2113 },
1e2cc748 2114 {
2115 name: "NRG - Energi",
1e2cc748 2116 onSelect: function() {
2117 network = bitcoinjs.bitcoin.networks.energi;
2118 setHdCoin(204);
2119 },
2120 },
85f762c9 2121 {
2122 name: "NRO - Neurocoin",
85f762c9 2123 onSelect: function() {
2124 network = bitcoinjs.bitcoin.networks.neurocoin;
2125 setHdCoin(110);
2126 },
2127 },
2128 {
2129 name: "NSR - Nushares",
85f762c9 2130 onSelect: function() {
2131 network = bitcoinjs.bitcoin.networks.nushares;
2132 setHdCoin(11);
2133 },
2134 },
2135 {
2136 name: "NYC - Newyorkc",
85f762c9 2137 onSelect: function() {
2138 network = bitcoinjs.bitcoin.networks.newyorkc;
2139 setHdCoin(179);
2140 },
2141 },
2142 {
2143 name: "NVC - Novacoin",
85f762c9 2144 onSelect: function() {
2145 network = bitcoinjs.bitcoin.networks.novacoin;
2146 setHdCoin(50);
2147 },
2148 },
2149 {
2150 name: "OK - Okcash",
85f762c9 2151 onSelect: function() {
2152 network = bitcoinjs.bitcoin.networks.okcash;
2153 setHdCoin(69);
2154 },
2155 },
2156 {
2157 name: "OMNI - Omnicore",
85f762c9 2158 onSelect: function() {
2159 network = bitcoinjs.bitcoin.networks.omnicore;
2160 setHdCoin(200);
2161 },
2162 },
66419cf3 2163 {
2164 name: "ONX - Onixcoin",
66419cf3 2165 onSelect: function() {
2166 network = bitcoinjs.bitcoin.networks.onixcoin;
d00c7199 2167 setHdCoin(174);
66419cf3 2168 },
2169 },
85f762c9 2170 {
2171 name: "PINK - Pinkcoin",
85f762c9 2172 onSelect: function() {
2173 network = bitcoinjs.bitcoin.networks.pinkcoin;
2174 setHdCoin(117);
2175 },
2176 },
c0df0189 2177 {
2178 name: "PIVX - PIVX",
c0df0189 2179 onSelect: function() {
2180 network = bitcoinjs.bitcoin.networks.pivx;
2181 setHdCoin(119);
2182 },
2183 },
2184 {
2185 name: "PIVX - PIVX Testnet",
c0df0189 2186 onSelect: function() {
2187 network = bitcoinjs.bitcoin.networks.pivxtestnet;
2188 setHdCoin(1);
2189 },
2190 },
85f762c9 2191 {
2192 name: "POSW - POSWcoin",
85f762c9 2193 onSelect: function() {
2194 network = bitcoinjs.bitcoin.networks.poswcoin;
2195 setHdCoin(47);
2196 },
2197 },
2198 {
2199 name: "POT - Potcoin",
85f762c9 2200 onSelect: function() {
2201 network = bitcoinjs.bitcoin.networks.potcoin;
2202 setHdCoin(81);
2203 },
2204 },
5c434a8a 2205 {
534481b6 2206 name: "PPC - Peercoin",
5c434a8a 2207 onSelect: function() {
a0091a40 2208 network = bitcoinjs.bitcoin.networks.peercoin;
6c08f364 2209 setHdCoin(6);
5c434a8a
CM
2210 },
2211 },
85f762c9 2212 {
2213 name: "PSB - Pesobit",
85f762c9 2214 onSelect: function() {
2215 network = bitcoinjs.bitcoin.networks.pesobit;
2216 setHdCoin(62);
2217 },
2218 },
2219 {
2220 name: "PUT - Putincoin",
85f762c9 2221 onSelect: function() {
2222 network = bitcoinjs.bitcoin.networks.putincoin;
2223 setHdCoin(122);
2224 },
2225 },
2226 {
2227 name: "RBY - Rubycoin",
85f762c9 2228 onSelect: function() {
2229 network = bitcoinjs.bitcoin.networks.rubycoin;
2230 setHdCoin(16);
2231 },
2232 },
2233 {
2234 name: "RDD - Reddcoin",
85f762c9 2235 onSelect: function() {
6db7516d 2236 network = bitcoinjs.bitcoin.networks.reddcoin;
85f762c9 2237 setHdCoin(4);
2238 },
2239 },
2240 {
2241 name: "RVR - RevolutionVR",
85f762c9 2242 onSelect: function() {
2243 network = bitcoinjs.bitcoin.networks.revolutionvr;
2244 setHdCoin(129);
2245 },
2246 },
64a7d2aa 2247 {
534481b6 2248 name: "SDC - ShadowCash",
82f91834 2249 onSelect: function() {
a0091a40 2250 network = bitcoinjs.bitcoin.networks.shadow;
6c08f364 2251 setHdCoin(35);
82f91834
DG
2252 },
2253 },
07ac4350 2254 {
534481b6 2255 name: "SDC - ShadowCash Testnet",
07ac4350 2256 onSelect: function() {
a0091a40 2257 network = bitcoinjs.bitcoin.networks.shadowtn;
6c08f364 2258 setHdCoin(1);
07ac4350 2259 },
2260 },
7a5a87a0 2261 {
534481b6 2262 name: "SLM - Slimcoin",
7a5a87a0 2263 onSelect: function() {
a0091a40 2264 network = bitcoinjs.bitcoin.networks.slimcoin;
6c08f364 2265 setHdCoin(63);
7a5a87a0
GH
2266 },
2267 },
2268 {
534481b6 2269 name: "SLM - Slimcoin Testnet",
7a5a87a0 2270 onSelect: function() {
a0091a40 2271 network = bitcoinjs.bitcoin.networks.slimcointn;
6c08f364 2272 setHdCoin(111);
7a5a87a0
GH
2273 },
2274 },
85f762c9 2275 {
2276 name: "SLR - Solarcoin",
85f762c9 2277 onSelect: function() {
2278 network = bitcoinjs.bitcoin.networks.solarcoin;
2279 setHdCoin(58);
2280 },
2281 },
2282 {
2283 name: "SMLY - Smileycoin",
85f762c9 2284 onSelect: function() {
2285 network = bitcoinjs.bitcoin.networks.smileycoin;
2286 setHdCoin(59);
2287 },
2288 },
2289 {
2290 name: "STRAT - Stratis",
85f762c9 2291 onSelect: function() {
2292 network = bitcoinjs.bitcoin.networks.stratis;
2293 setHdCoin(105);
2294 },
2295 },
2296 {
2297 name: "SYS - Syscoin",
85f762c9 2298 onSelect: function() {
2299 network = bitcoinjs.bitcoin.networks.syscoin;
2300 setHdCoin(57);
2301 },
2302 },
2303 {
2304 name: "THC - Hempcoin",
85f762c9 2305 onSelect: function() {
2306 network = bitcoinjs.bitcoin.networks.hempcoin;
2307 setHdCoin(113);
2308 },
2309 },
2310 {
2311 name: "TOA - Toa",
85f762c9 2312 onSelect: function() {
2313 network = bitcoinjs.bitcoin.networks.toa;
2314 setHdCoin(159);
2315 },
2316 },
2317 {
2318 name: "USC - Ultimatesecurecash",
85f762c9 2319 onSelect: function() {
2320 network = bitcoinjs.bitcoin.networks.ultimatesecurecash;
2321 setHdCoin(112);
2322 },
2323 },
8dd28f2c 2324 {
2325 name: "USNBT - NuBits",
8dd28f2c 2326 onSelect: function() {
2327 network = bitcoinjs.bitcoin.networks.nubits;
2328 setHdCoin(12);
2329 },
2330 },
85f762c9 2331 {
2332 name: "UNO - Unobtanium",
85f762c9 2333 onSelect: function() {
2334 network = bitcoinjs.bitcoin.networks.unobtanium;
2335 setHdCoin(92);
2336 },
2337 },
2338 {
2339 name: "VASH - Vpncoin",
85f762c9 2340 onSelect: function() {
2341 network = bitcoinjs.bitcoin.networks.vpncoin;
2342 setHdCoin(33);
2343 },
2344 },
07ac4350 2345 {
534481b6 2346 name: "VIA - Viacoin",
07ac4350 2347 onSelect: function() {
a0091a40 2348 network = bitcoinjs.bitcoin.networks.viacoin;
6c08f364 2349 setHdCoin(14);
07ac4350 2350 },
2351 },
0edac945 2352 {
534481b6 2353 name: "VIA - Viacoin Testnet",
0edac945 2354 onSelect: function() {
a0091a40 2355 network = bitcoinjs.bitcoin.networks.viacointestnet;
6c08f364 2356 setHdCoin(1);
0edac945
IC
2357 },
2358 },
85f762c9 2359 {
2360 name: "VIVO - Vivo",
85f762c9 2361 onSelect: function() {
2362 network = bitcoinjs.bitcoin.networks.vivo;
2363 setHdCoin(166);
2364 },
2365 },
2366 {
2367 name: "VTC - Vertcoin",
85f762c9 2368 onSelect: function() {
2369 network = bitcoinjs.bitcoin.networks.vertcoin;
2370 setHdCoin(28);
2371 },
2372 },
2373 {
2374 name: "WC - Wincoin",
85f762c9 2375 onSelect: function() {
2376 network = bitcoinjs.bitcoin.networks.wincoin;
2377 setHdCoin(181);
2378 },
2379 },
2380 {
2381 name: "XBC - Bitcoinplus",
85f762c9 2382 onSelect: function() {
2383 network = bitcoinjs.bitcoin.networks.bitcoinplus;
2384 setHdCoin(65);
2385 },
2386 },
534481b6 2387 {
7ebdf61c 2388 name: "XMY - Myriadcoin",
534481b6 2389 onSelect: function() {
7ebdf61c
IC
2390 network = bitcoinjs.bitcoin.networks.myriadcoin;
2391 setHdCoin(90);
534481b6 2392 },
adedbf91 2393 },
2394 {
7ebdf61c 2395 name: "XRP - Ripple",
adedbf91 2396 onSelect: function() {
7ebdf61c
IC
2397 network = bitcoinjs.bitcoin.networks.bitcoin;
2398 setHdCoin(144);
adedbf91 2399 },
e1d0cf4f 2400 },
85f762c9 2401 {
2402 name: "XVC - Vcash",
85f762c9 2403 onSelect: function() {
2404 network = bitcoinjs.bitcoin.networks.vcash;
2405 setHdCoin(127);
2406 },
2407 },
2408 {
2409 name: "XVG - Verge",
85f762c9 2410 onSelect: function() {
2411 network = bitcoinjs.bitcoin.networks.verge;
2412 setHdCoin(77);
2413 },
2414 },
2415 {
2416 name: "XWC - Whitecoin",
85f762c9 2417 onSelect: function() {
2418 network = bitcoinjs.bitcoin.networks.whitecoin;
2419 setHdCoin(155);
2420 },
2421 },
2422 {
2423 name: "XZC - Zcoin",
85f762c9 2424 onSelect: function() {
2425 network = bitcoinjs.bitcoin.networks.zcoin;
2426 setHdCoin(136);
2427 },
2428 },
1e2cc748 2429 {
2430 name: "ZCL - Zclassic",
1e2cc748 2431 onSelect: function() {
2432 network = bitcoinjs.bitcoin.networks.zclassic;
2433 setHdCoin(147);
2434 },
2435 },
0702ecd3 2436 {
2437 name: "ZEC - Zcash",
0702ecd3 2438 onSelect: function() {
2439 network = bitcoinjs.bitcoin.networks.zcash;
2440 setHdCoin(133);
2441 },
2442 },
24355c46 2443 {
2444 name: "XUEZ - Xuez",
24355c46 2445 onSelect: function() {
2446 network = bitcoinjs.bitcoin.networks.xuez;
2447 setHdCoin(225);
2448 },
2449 },
1e2cc748 2450 {
2451 name: "ZEN - Zencash",
1e2cc748 2452 onSelect: function() {
2453 network = bitcoinjs.bitcoin.networks.zencash;
2454 setHdCoin(121);
2455 },
2456 },
7f15cb6e 2457 ]
6ee4fb7d 2458
b4fd763c
AG
2459 var clients = [
2460 {
2461 name: "Bitcoin Core",
2462 onSelect: function() {
2463 DOM.bip32path.val("m/0'/0'");
2464 DOM.hardenedAddresses.prop('checked', true);
2465 },
2466 },
2467 {
2468 name: "blockchain.info",
2469 onSelect: function() {
2470 DOM.bip32path.val("m/44'/0'/0'");
2471 DOM.hardenedAddresses.prop('checked', false);
2472 },
2473 },
2474 {
2475 name: "MultiBit HD",
2476 onSelect: function() {
2477 DOM.bip32path.val("m/0'/0");
2478 DOM.hardenedAddresses.prop('checked', false);
2479 },
2480 }
2481 ]
7a995731 2482
ebd8d4e8
IC
2483 init();
2484
2485})();