3 // mnemonics is populated as required by getLanguage
4 var mnemonics
= { "english": new Mnemonic("english") };
5 var mnemonic
= mnemonics
["english"];
7 var bip32RootKey
= null;
8 var bip32ExtendedKey
= null;
9 var network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
10 var addressRowTemplate
= $("#address-row-template");
13 var showAddress
= true;
14 var showPubKey
= true;
15 var showPrivKey
= true;
17 var litecoinUseLtub
= true;
19 var entropyChangeTimeoutEvent
= null;
20 var phraseChangeTimeoutEvent
= null;
21 var rootKeyChangedTimeoutEvent
= null;
23 var generationProcesses
= [];
26 DOM
.privacyScreenToggle
= $(".privacy-screen-toggle");
27 DOM
.network
= $(".network");
28 DOM
.bip32Client
= $("#bip32-client");
29 DOM
.phraseNetwork
= $("#network-phrase");
30 DOM
.useEntropy
= $(".use-entropy");
31 DOM
.entropyContainer
= $(".entropy-container");
32 DOM
.entropy
= $(".entropy");
33 DOM
.entropyFiltered
= DOM
.entropyContainer
.find(".filtered");
34 DOM
.entropyType
= DOM
.entropyContainer
.find(".type");
35 DOM
.entropyCrackTime
= DOM
.entropyContainer
.find(".crack-time");
36 DOM
.entropyEventCount
= DOM
.entropyContainer
.find(".event-count");
37 DOM
.entropyBits
= DOM
.entropyContainer
.find(".bits");
38 DOM
.entropyBitsPerEvent
= DOM
.entropyContainer
.find(".bits-per-event");
39 DOM
.entropyWordCount
= DOM
.entropyContainer
.find(".word-count");
40 DOM
.entropyBinary
= DOM
.entropyContainer
.find(".binary");
41 DOM
.entropyWordIndexes
= DOM
.entropyContainer
.find(".word-indexes");
42 DOM
.entropyChecksum
= DOM
.entropyContainer
.find(".checksum");
43 DOM
.entropyMnemonicLength
= DOM
.entropyContainer
.find(".mnemonic-length");
44 DOM
.entropyWeakEntropyOverrideWarning
= DOM
.entropyContainer
.find(".weak-entropy-override-warning");
45 DOM
.entropyFilterWarning
= DOM
.entropyContainer
.find(".filter-warning");
46 DOM
.phrase
= $(".phrase");
47 DOM
.splitPhrase
= $(".phraseSplit");
48 DOM
.passphrase
= $(".passphrase");
49 DOM
.generateContainer
= $(".generate-container");
50 DOM
.generate
= $(".generate");
51 DOM
.seed
= $(".seed");
52 DOM
.rootKey
= $(".root-key");
53 DOM
.litecoinLtubContainer
= $(".litecoin-ltub-container");
54 DOM
.litecoinUseLtub
= $(".litecoin-use-ltub");
55 DOM
.extendedPrivKey
= $(".extended-priv-key");
56 DOM
.extendedPubKey
= $(".extended-pub-key");
57 DOM
.bip32tab
= $("#bip32-tab");
58 DOM
.bip44tab
= $("#bip44-tab");
59 DOM
.bip49tab
= $("#bip49-tab");
60 DOM
.bip84tab
= $("#bip84-tab");
61 DOM
.bip141tab
= $("#bip141-tab");
62 DOM
.bip32panel
= $("#bip32");
63 DOM
.bip44panel
= $("#bip44");
64 DOM
.bip49panel
= $("#bip49");
65 DOM
.bip32path
= $("#bip32-path");
66 DOM
.bip44path
= $("#bip44-path");
67 DOM
.bip44purpose
= $("#bip44 .purpose");
68 DOM
.bip44coin
= $("#bip44 .coin");
69 DOM
.bip44account
= $("#bip44 .account");
70 DOM
.bip44accountXprv
= $("#bip44 .account-xprv");
71 DOM
.bip44accountXpub
= $("#bip44 .account-xpub");
72 DOM
.bip44change
= $("#bip44 .change");
73 DOM
.bip49unavailable
= $("#bip49 .unavailable");
74 DOM
.bip49available
= $("#bip49 .available");
75 DOM
.bip49path
= $("#bip49-path");
76 DOM
.bip49purpose
= $("#bip49 .purpose");
77 DOM
.bip49coin
= $("#bip49 .coin");
78 DOM
.bip49account
= $("#bip49 .account");
79 DOM
.bip49accountXprv
= $("#bip49 .account-xprv");
80 DOM
.bip49accountXpub
= $("#bip49 .account-xpub");
81 DOM
.bip49change
= $("#bip49 .change");
82 DOM
.bip84unavailable
= $("#bip84 .unavailable");
83 DOM
.bip84available
= $("#bip84 .available");
84 DOM
.bip84path
= $("#bip84-path");
85 DOM
.bip84purpose
= $("#bip84 .purpose");
86 DOM
.bip84coin
= $("#bip84 .coin");
87 DOM
.bip84account
= $("#bip84 .account");
88 DOM
.bip84accountXprv
= $("#bip84 .account-xprv");
89 DOM
.bip84accountXpub
= $("#bip84 .account-xpub");
90 DOM
.bip84change
= $("#bip84 .change");
91 DOM
.bip141unavailable
= $("#bip141 .unavailable");
92 DOM
.bip141available
= $("#bip141 .available");
93 DOM
.bip141path
= $("#bip141-path");
94 DOM
.bip141semantics
= $(".bip141-semantics");
95 DOM
.generatedStrength
= $(".generate-container .strength");
96 DOM
.generatedStrengthWarning
= $(".generate-container .warning");
97 DOM
.hardenedAddresses
= $(".hardened-addresses");
98 DOM
.bitcoinCashAddressTypeContainer
= $(".bch-addr-type-container");
99 DOM
.bitcoinCashAddressType
= $("[name=bch-addr-type]")
100 DOM
.useBip38
= $(".use-bip38");
101 DOM
.bip38Password
= $(".bip38-password");
102 DOM
.addresses
= $(".addresses");
103 DOM
.csvTab
= $("#csv-tab a");
105 DOM
.rowsToAdd
= $(".rows-to-add");
106 DOM
.more
= $(".more");
107 DOM
.moreRowsStartIndex
= $(".more-rows-start-index");
108 DOM
.feedback
= $(".feedback");
109 DOM
.tab
= $(".derivation-type a");
110 DOM
.indexToggle
= $(".index-toggle");
111 DOM
.addressToggle
= $(".address-toggle");
112 DOM
.publicKeyToggle
= $(".public-key-toggle");
113 DOM
.privateKeyToggle
= $(".private-key-toggle");
114 DOM
.languages
= $(".languages a");
115 DOM
.qrContainer
= $(".qr-container");
116 DOM
.qrHider
= DOM
.qrContainer
.find(".qr-hider");
117 DOM
.qrImage
= DOM
.qrContainer
.find(".qr-image");
118 DOM
.qrHint
= DOM
.qrContainer
.find(".qr-hint");
119 DOM
.showQrEls
= $("[data-show-qr]");
123 DOM
.privacyScreenToggle
.on("change", privacyScreenToggled
);
124 DOM
.generatedStrength
.on("change", generatedStrengthChanged
);
125 DOM
.network
.on("change", networkChanged
);
126 DOM
.bip32Client
.on("change", bip32ClientChanged
);
127 DOM
.useEntropy
.on("change", setEntropyVisibility
);
128 DOM
.entropy
.on("input", delayedEntropyChanged
);
129 DOM
.entropyMnemonicLength
.on("change", entropyChanged
);
130 DOM
.phrase
.on("input", delayedPhraseChanged
);
131 DOM
.passphrase
.on("input", delayedPhraseChanged
);
132 DOM
.generate
.on("click", generateClicked
);
133 DOM
.more
.on("click", showMore
);
134 DOM
.rootKey
.on("input", delayedRootKeyChanged
);
135 DOM
.litecoinUseLtub
.on("change", litecoinUseLtubChanged
);
136 DOM
.bip32path
.on("input", calcForDerivationPath
);
137 DOM
.bip44account
.on("input", calcForDerivationPath
);
138 DOM
.bip44change
.on("input", calcForDerivationPath
);
139 DOM
.bip49account
.on("input", calcForDerivationPath
);
140 DOM
.bip49change
.on("input", calcForDerivationPath
);
141 DOM
.bip84account
.on("input", calcForDerivationPath
);
142 DOM
.bip84change
.on("input", calcForDerivationPath
);
143 DOM
.bip141path
.on("input", calcForDerivationPath
);
144 DOM
.bip141semantics
.on("change", tabChanged
);
145 DOM
.tab
.on("shown.bs.tab", tabChanged
);
146 DOM
.hardenedAddresses
.on("change", calcForDerivationPath
);
147 DOM
.useBip38
.on("change", calcForDerivationPath
);
148 DOM
.bip38Password
.on("change", calcForDerivationPath
);
149 DOM
.indexToggle
.on("click", toggleIndexes
);
150 DOM
.addressToggle
.on("click", toggleAddresses
);
151 DOM
.publicKeyToggle
.on("click", togglePublicKeys
);
152 DOM
.privateKeyToggle
.on("click", togglePrivateKeys
);
153 DOM
.csvTab
.on("click", updateCsv
);
154 DOM
.languages
.on("click", languageChanged
);
155 DOM
.bitcoinCashAddressType
.on("change", bitcoinCashAddressTypeChange
);
156 setQrEvents(DOM
.showQrEls
);
159 hideValidationError();
160 populateNetworkSelect();
161 populateClientSelect();
166 function generatedStrengthChanged() {
167 var strength
= parseInt(DOM
.generatedStrength
.val());
169 DOM
.generatedStrengthWarning
.removeClass("hidden");
172 DOM
.generatedStrengthWarning
.addClass("hidden");
176 function networkChanged(e
) {
178 clearAddressesList();
179 DOM
.litecoinLtubContainer
.addClass("hidden");
180 DOM
.bitcoinCashAddressTypeContainer
.addClass("hidden");
181 var networkIndex
= e
.target
.value
;
182 var network
= networks
[networkIndex
];
184 adjustNetworkForSegwit();
193 function bip32ClientChanged(e
) {
194 var clientIndex
= DOM
.bip32Client
.val();
195 if (clientIndex
== "custom") {
196 DOM
.bip32path
.prop("readonly", false);
199 DOM
.bip32path
.prop("readonly", true);
200 clients
[clientIndex
].onSelect();
210 function setEntropyVisibility() {
211 if (isUsingOwnEntropy()) {
212 DOM
.entropyContainer
.removeClass("hidden");
213 DOM
.generateContainer
.addClass("hidden");
214 DOM
.phrase
.prop("readonly", true);
219 DOM
.entropyContainer
.addClass("hidden");
220 DOM
.generateContainer
.removeClass("hidden");
221 DOM
.phrase
.prop("readonly", false);
226 function delayedPhraseChanged() {
227 hideValidationError();
230 bip32ExtendedKey
= null;
231 clearAddressesList();
233 if (phraseChangeTimeoutEvent
!= null) {
234 clearTimeout(phraseChangeTimeoutEvent
);
236 phraseChangeTimeoutEvent
= setTimeout(phraseChanged
, 400);
239 function phraseChanged() {
241 setMnemonicLanguage();
242 // Get the mnemonic phrase
243 var phrase
= DOM
.phrase
.val();
244 var errorText
= findPhraseErrors(phrase
);
246 showValidationError(errorText
);
249 // Calculate and display
250 var passphrase
= DOM
.passphrase
.val();
251 calcBip32RootKeyFromSeed(phrase
, passphrase
);
252 calcForDerivationPath();
253 // Show the word indexes
257 function tabChanged() {
259 adjustNetworkForSegwit();
260 var phrase
= DOM
.phrase
.val();
262 // Calculate and display for mnemonic
263 var errorText
= findPhraseErrors(phrase
);
265 showValidationError(errorText
);
268 // Calculate and display
269 var passphrase
= DOM
.passphrase
.val();
270 calcBip32RootKeyFromSeed(phrase
, passphrase
);
273 // Calculate and display for root key
274 var rootKeyBase58
= DOM
.rootKey
.val();
275 var errorText
= validateRootKey(rootKeyBase58
);
277 showValidationError(errorText
);
280 // Calculate and display
281 calcBip32RootKeyFromBase58(rootKeyBase58
);
283 calcForDerivationPath();
286 function delayedEntropyChanged() {
287 hideValidationError();
289 if (entropyChangeTimeoutEvent
!= null) {
290 clearTimeout(entropyChangeTimeoutEvent
);
292 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
295 function entropyChanged() {
296 // If blank entropy, clear mnemonic, addresses, errors
297 if (DOM
.entropy
.val().trim().length
== 0) {
299 clearEntropyFeedback();
301 DOM
.phraseSplit
.val("");
302 showValidationError("Blank entropy");
305 // Get the current phrase to detect changes
306 var phrase
= DOM
.phrase
.val();
307 // Set the phrase from the entropy
308 setMnemonicFromEntropy();
309 // Recalc addresses if the phrase has changed
310 var newPhrase
= DOM
.phrase
.val();
311 if (newPhrase
!= phrase
) {
312 if (newPhrase
.length
== 0) {
324 function delayedRootKeyChanged() {
325 // Warn if there is an existing mnemonic or passphrase.
326 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
327 if (!confirm("This will clear existing mnemonic and passphrase")) {
328 DOM
.rootKey
.val(bip32RootKey
);
332 hideValidationError();
334 // Clear existing mnemonic and passphrase
336 DOM
.phraseSplit
.val("");
337 DOM
.passphrase
.val("");
339 if (rootKeyChangedTimeoutEvent
!= null) {
340 clearTimeout(rootKeyChangedTimeoutEvent
);
342 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
345 function rootKeyChanged() {
347 hideValidationError();
348 var rootKeyBase58
= DOM
.rootKey
.val();
349 var errorText
= validateRootKey(rootKeyBase58
);
351 showValidationError(errorText
);
354 // Calculate and display
355 calcBip32RootKeyFromBase58(rootKeyBase58
);
356 calcForDerivationPath();
359 function litecoinUseLtubChanged() {
360 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
361 if (litecoinUseLtub
) {
362 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
365 network
= bitcoinjs
.bitcoin
.networks
.litecoinXprv
;
370 function calcForDerivationPath() {
372 clearAddressesList();
374 // Don't show segwit if it's selected but network doesn't support it
375 if (segwitSelected() && !networkHasSegwit()) {
376 showSegwitUnavailable();
380 showSegwitAvailable();
381 // Get the derivation path
382 var derivationPath
= getDerivationPath();
383 var errorText
= findDerivationPathErrors(derivationPath
);
385 showValidationError(errorText
);
388 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
389 if (bip44TabSelected()) {
392 else if (bip49TabSelected()) {
395 else if (bip84TabSelected()) {
401 function generateClicked() {
402 if (isUsingOwnEntropy()) {
407 setTimeout(function() {
408 setMnemonicLanguage();
409 var phrase
= generateRandomPhrase();
417 function languageChanged() {
418 setTimeout(function() {
419 setMnemonicLanguage();
420 if (DOM
.phrase
.val().length
> 0) {
421 var newPhrase
= convertPhraseToNewLanguage();
422 DOM
.phrase
.val(newPhrase
);
423 writeSplitPhrase(newPhrase
);
427 DOM
.generate
.trigger("click");
432 function bitcoinCashAddressTypeChange() {
436 function toggleIndexes() {
437 showIndex
= !showIndex
;
438 $("td.index span").toggleClass("invisible");
441 function toggleAddresses() {
442 showAddress
= !showAddress
;
443 $("td.address span").toggleClass("invisible");
446 function togglePublicKeys() {
447 showPubKey
= !showPubKey
;
448 $("td.pubkey span").toggleClass("invisible");
451 function togglePrivateKeys() {
452 showPrivKey
= !showPrivKey
;
453 $("td.privkey span").toggleClass("invisible");
456 function privacyScreenToggled() {
457 // private-data contains elements added to DOM at runtime
458 // so catch all by adding visual privacy class to the root of the DOM
459 if (DOM
.privacyScreenToggle
.prop("checked")) {
460 $("body").addClass("visual-privacy");
463 $("body").removeClass("visual-privacy");
469 function generateRandomPhrase() {
470 if (!hasStrongRandom()) {
471 var errorText
= "This browser does not support strong randomness";
472 showValidationError(errorText
);
475 // get the amount of entropy to use
476 var numWords
= parseInt(DOM
.generatedStrength
.val());
477 var strength
= numWords
/ 3 * 32;
478 var buffer
= new Uint8Array(strength
/ 8);
479 // create secure entropy
480 var data
= crypto
.getRandomValues(buffer
);
482 var words
= mnemonic
.toMnemonic(data
);
483 DOM
.phrase
.val(words
);
484 writeSplitPhrase(words
);
486 var entropyHex
= uint8ArrayToHex(data
);
487 DOM
.entropy
.val(entropyHex
);
488 // ensure entropy fields are consistent with what is being displayed
489 DOM
.entropyMnemonicLength
.val("raw");
493 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
494 seed
= mnemonic
.toSeed(phrase
, passphrase
);
495 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
498 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
499 // try parsing with various segwit network params since this extended
500 // key may be from any one of them.
501 if (networkHasSegwit()) {
503 if ("baseNetwork" in n
) {
504 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
506 // try parsing using base network params
508 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
512 // try parsing using p2wpkh params
515 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
520 // try parsing using p2wpkh-in-p2sh network params
521 if ("p2wpkhInP2sh" in n
) {
523 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
529 // try the network params as currently specified
530 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
533 function calcBip32ExtendedKey(path
) {
534 // Check there's a root key to derive from
538 var extendedKey
= bip32RootKey
;
539 // Derive the key from the path
540 var pathBits
= path
.split("/");
541 for (var i
=0; i
<pathBits
.length
; i
++) {
542 var bit
= pathBits
[i
];
543 var index
= parseInt(bit
);
547 var hardened
= bit
[bit
.length
-1] == "'";
548 var isPriv
= !(extendedKey
.isNeutered());
549 var invalidDerivationPath
= hardened
&& !isPriv
;
550 if (invalidDerivationPath
) {
554 extendedKey
= extendedKey
.deriveHardened(index
);
557 extendedKey
= extendedKey
.derive(index
);
563 function showValidationError(errorText
) {
569 function hideValidationError() {
575 function findPhraseErrors(phrase
) {
576 // Preprocess the words
577 phrase
= mnemonic
.normalizeString(phrase
);
578 var words
= phraseToWordArray(phrase
);
579 // Detect blank phrase
580 if (words
.length
== 0) {
581 return "Blank mnemonic";
584 for (var i
=0; i
<words
.length
; i
++) {
586 var language
= getLanguage();
587 if (WORDLISTS
[language
].indexOf(word
) == -1) {
588 console
.log("Finding closest match to " + word
);
589 var nearestWord
= findNearestWord(word
);
590 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
593 // Check the words are valid
594 var properPhrase
= wordArrayToPhrase(words
);
595 var isValid
= mnemonic
.check(properPhrase
);
597 return "Invalid mnemonic";
602 function validateRootKey(rootKeyBase58
) {
603 // try various segwit network params since this extended key may be from
605 if (networkHasSegwit()) {
607 if ("baseNetwork" in n
) {
608 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
610 // try parsing using base network params
612 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
616 // try parsing using p2wpkh params
619 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
624 // try parsing using p2wpkh-in-p2sh network params
625 if ("p2wpkhInP2sh" in n
) {
627 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
633 // try the network params as currently specified
635 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
638 return "Invalid root key";
643 function getDerivationPath() {
644 if (bip44TabSelected()) {
645 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
646 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
647 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
648 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
650 path
+= purpose
+ "'/";
652 path
+= account
+ "'/";
654 DOM
.bip44path
.val(path
);
655 var derivationPath
= DOM
.bip44path
.val();
656 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
657 return derivationPath
;
659 else if (bip49TabSelected()) {
660 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
661 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
662 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
663 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
665 path
+= purpose
+ "'/";
667 path
+= account
+ "'/";
669 DOM
.bip49path
.val(path
);
670 var derivationPath
= DOM
.bip49path
.val();
671 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
672 return derivationPath
;
674 else if (bip84TabSelected()) {
675 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
676 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
677 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
678 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
680 path
+= purpose
+ "'/";
682 path
+= account
+ "'/";
684 DOM
.bip84path
.val(path
);
685 var derivationPath
= DOM
.bip84path
.val();
686 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
687 return derivationPath
;
689 else if (bip32TabSelected()) {
690 var derivationPath
= DOM
.bip32path
.val();
691 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
692 return derivationPath
;
694 else if (bip141TabSelected()) {
695 var derivationPath
= DOM
.bip141path
.val();
696 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
697 return derivationPath
;
700 console
.log("Unknown derivation path");
704 function findDerivationPathErrors(path
) {
705 // TODO is not perfect but is better than nothing
707 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
709 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
710 var maxDepth
= 255; // TODO verify this!!
711 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
712 if (path
[0] != "m") {
713 return "First character must be 'm'";
715 if (path
.length
> 1) {
716 if (path
[1] != "/") {
717 return "Separator must be '/'";
719 var indexes
= path
.split("/");
720 if (indexes
.length
> maxDepth
) {
721 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
723 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
724 var index
= indexes
[depth
];
725 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
726 if (invalidChars
.length
> 0) {
727 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
729 var indexValue
= parseInt(index
.replace("'", ""));
731 return "Invalid number at depth " + depth
;
733 if (indexValue
> maxIndexValue
) {
734 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
738 // Check root key exists or else derivation path is useless!
740 return "No root key";
742 // Check no hardened derivation path when using xpub keys
743 var hardenedPath
= path
.indexOf("'") > -1;
744 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
745 var hardened
= hardenedPath
|| hardenedAddresses
;
746 var isXpubkey
= bip32RootKey
.isNeutered();
747 if (hardened
&& isXpubkey
) {
748 return "Hardened derivation path is invalid with xpub key";
753 function displayBip44Info() {
754 // Get the derivation path for the account
755 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
756 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
757 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
759 path
+= purpose
+ "'/";
761 path
+= account
+ "'/";
762 // Calculate the account extended keys
763 var accountExtendedKey
= calcBip32ExtendedKey(path
);
764 var accountXprv
= accountExtendedKey
.toBase58();
765 var accountXpub
= accountExtendedKey
.neutered().toBase58();
766 // Display the extended keys
767 DOM
.bip44accountXprv
.val(accountXprv
);
768 DOM
.bip44accountXpub
.val(accountXpub
);
771 function displayBip49Info() {
772 // Get the derivation path for the account
773 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
774 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
775 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
777 path
+= purpose
+ "'/";
779 path
+= account
+ "'/";
780 // Calculate the account extended keys
781 var accountExtendedKey
= calcBip32ExtendedKey(path
);
782 var accountXprv
= accountExtendedKey
.toBase58();
783 var accountXpub
= accountExtendedKey
.neutered().toBase58();
784 // Display the extended keys
785 DOM
.bip49accountXprv
.val(accountXprv
);
786 DOM
.bip49accountXpub
.val(accountXpub
);
789 function displayBip84Info() {
790 // Get the derivation path for the account
791 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
792 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
793 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
795 path
+= purpose
+ "'/";
797 path
+= account
+ "'/";
798 // Calculate the account extended keys
799 var accountExtendedKey
= calcBip32ExtendedKey(path
);
800 var accountXprv
= accountExtendedKey
.toBase58();
801 var accountXpub
= accountExtendedKey
.neutered().toBase58();
802 // Display the extended keys
803 DOM
.bip84accountXprv
.val(accountXprv
);
804 DOM
.bip84accountXpub
.val(accountXpub
);
807 function displayBip32Info() {
810 var rootKey
= bip32RootKey
.toBase58();
811 DOM
.rootKey
.val(rootKey
);
812 var xprvkeyB58
= "NA";
813 if (!bip32ExtendedKey
.isNeutered()) {
814 xprvkeyB58
= bip32ExtendedKey
.toBase58();
816 var extendedPrivKey
= xprvkeyB58
;
817 DOM
.extendedPrivKey
.val(extendedPrivKey
);
818 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
819 DOM
.extendedPubKey
.val(extendedPubKey
);
820 // Display the addresses and privkeys
821 clearAddressesList();
822 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
823 displayAddresses(0, initialAddressCount
);
826 function displayAddresses(start
, total
) {
827 generationProcesses
.push(new (function() {
831 this.stop = function() {
832 for (var i
=0; i
<rows
.length
; i
++) {
833 rows
[i
].shouldGenerate
= false;
838 for (var i
=0; i
<total
; i
++) {
839 var index
= i
+ start
;
840 var isLast
= i
== total
- 1;
841 rows
.push(new TableRow(index
, isLast
));
847 function segwitSelected() {
848 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
851 function p2wpkhSelected() {
852 return bip84TabSelected() ||
853 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
856 function p2wpkhInP2shSelected() {
857 return bip49TabSelected() ||
858 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
861 function TableRow(index
, isLast
) {
864 this.shouldGenerate
= true;
865 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
866 var useBip38
= DOM
.useBip38
.prop("checked");
867 var bip38password
= DOM
.bip38Password
.val();
868 var isSegwit
= segwitSelected();
869 var segwitAvailable
= networkHasSegwit();
870 var isP2wpkh
= p2wpkhSelected();
871 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
877 function calculateValues() {
878 setTimeout(function() {
879 if (!self
.shouldGenerate
) {
882 // derive HDkey for this row of the table
884 if (useHardenedAddresses
) {
885 key
= bip32ExtendedKey
.deriveHardened(index
);
888 key
= bip32ExtendedKey
.derive(index
);
890 // bip38 requires uncompressed keys
891 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
892 var keyPair
= key
.keyPair
;
893 var useUncompressed
= useBip38
;
894 if (useUncompressed
) {
895 keyPair
= new bitcoinjs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
898 var address
= keyPair
.getAddress().toString();
900 var hasPrivkey
= !key
.isNeutered();
903 privkey
= keyPair
.toWIF();
904 // BIP38 encode private key if required
906 privkey
= bitcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
907 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
912 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
913 var indexText
= getDerivationPath() + "/" + index
;
914 if (useHardenedAddresses
) {
915 indexText
= indexText
+ "'";
917 // Ethereum values are different
918 if ((networks
[DOM
.network
.val()].name
== "ETH - Ethereum")
919 || (networks
[DOM
.network
.val()].name
== "ETC - Ethereum Classic")
920 || (networks
[DOM
.network
.val()].name
== "PIRL - Pirl")
921 || (networks
[DOM
.network
.val()].name
== "MIX - MIX")
922 || (networks
[DOM
.network
.val()].name
== "MUSIC - Musicoin")
923 || (networks
[DOM
.network
.val()].name
== "POA - Poa")
924 || (networks
[DOM
.network
.val()].name
== "EXP - Expanse")
925 || (networks
[DOM
.network
.val()].name
== "CLO - Callisto")) {
926 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
927 privkey
= privKeyBuffer
.toString('hex');
928 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
929 var hexAddress
= addressBuffer
.toString('hex');
930 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
931 address
= ethUtil
.addHexPrefix(checksumAddress
);
932 privkey
= ethUtil
.addHexPrefix(privkey
);
933 pubkey
= ethUtil
.addHexPrefix(pubkey
);
935 // Ripple values are different
936 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
937 privkey
= convertRipplePriv(privkey
);
938 address
= convertRippleAdrr(address
);
940 // Bitcoin Cash address format may vary
941 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
942 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
943 if (bchAddrType
== "cashaddr") {
944 address
= bchaddr
.toCashAddress(address
);
946 else if (bchAddrType
== "bitpay") {
947 address
= bchaddr
.toBitpayAddress(address
);
950 // Segwit addresses are different
952 if (!segwitAvailable
) {
956 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
957 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
958 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
960 else if (isP2wpkhInP2sh
) {
961 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
962 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
963 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
964 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
965 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
968 addAddressToList(indexText
, address
, pubkey
, privkey
);
980 function showMore() {
981 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
982 if (isNaN(rowsToAdd
)) {
984 DOM
.rowsToAdd
.val("20");
986 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
988 start
= lastIndexInTable() + 1;
991 var newStart
= start
+ rowsToAdd
;
992 DOM
.moreRowsStartIndex
.val(newStart
);
994 if (rowsToAdd
> 200) {
995 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
996 msg
+= "Do you want to continue?";
1001 displayAddresses(start
, rowsToAdd
);
1004 function clearDisplay() {
1005 clearAddressesList();
1007 hideValidationError();
1010 function clearAddressesList() {
1011 DOM
.addresses
.empty();
1016 function stopGenerating() {
1017 while (generationProcesses
.length
> 0) {
1018 var generation
= generationProcesses
.shift();
1023 function clearKeys() {
1028 function clearRootKey() {
1029 DOM
.rootKey
.val("");
1032 function clearDerivedKeys() {
1033 DOM
.extendedPrivKey
.val("");
1034 DOM
.extendedPubKey
.val("");
1035 DOM
.bip44accountXprv
.val("");
1036 DOM
.bip44accountXpub
.val("");
1039 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1040 var row
= $(addressRowTemplate
.html());
1042 var indexCell
= row
.find(".index span");
1043 var addressCell
= row
.find(".address span");
1044 var pubkeyCell
= row
.find(".pubkey span");
1045 var privkeyCell
= row
.find(".privkey span");
1047 indexCell
.text(indexText
);
1048 addressCell
.text(address
);
1049 pubkeyCell
.text(pubkey
);
1050 privkeyCell
.text(privkey
);
1053 indexCell
.addClass("invisible");
1056 addressCell
.addClass("invisible");
1059 pubkeyCell
.addClass("invisible");
1062 privkeyCell
.addClass("invisible");
1064 DOM
.addresses
.append(row
);
1065 var rowShowQrEls
= row
.find("[data-show-qr]");
1066 setQrEvents(rowShowQrEls
);
1069 function hasStrongRandom() {
1070 return 'crypto' in window
&& window
['crypto'] !== null;
1073 function disableForms() {
1074 $("form").on("submit", function(e
) {
1079 function parseIntNoNaN(val
, defaultVal
) {
1080 var v
= parseInt(val
);
1087 function showPending() {
1089 .text("Calculating...")
1093 function findNearestWord(word
) {
1094 var language
= getLanguage();
1095 var words
= WORDLISTS
[language
];
1096 var minDistance
= 99;
1097 var closestWord
= words
[0];
1098 for (var i
=0; i
<words
.length
; i
++) {
1099 var comparedTo
= words
[i
];
1100 if (comparedTo
.indexOf(word
) == 0) {
1103 var distance
= Levenshtein
.get(word
, comparedTo
);
1104 if (distance
< minDistance
) {
1105 closestWord
= comparedTo
;
1106 minDistance
= distance
;
1112 function hidePending() {
1118 function populateNetworkSelect() {
1119 for (var i
=0; i
<networks
.length
; i
++) {
1120 var network
= networks
[i
];
1121 var option
= $("<option>");
1122 option
.attr("value", i
);
1123 option
.text(network
.name
);
1124 if (network
.name
== "BTC - Bitcoin") {
1125 option
.prop("selected", true);
1127 DOM
.phraseNetwork
.append(option
);
1131 function populateClientSelect() {
1132 for (var i
=0; i
<clients
.length
; i
++) {
1133 var client
= clients
[i
];
1134 var option
= $("<option>");
1135 option
.attr("value", i
);
1136 option
.text(client
.name
);
1137 DOM
.bip32Client
.append(option
);
1141 function getLanguage() {
1142 var defaultLanguage
= "english";
1143 // Try to get from existing phrase
1144 var language
= getLanguageFromPhrase();
1145 // Try to get from url if not from phrase
1146 if (language
.length
== 0) {
1147 language
= getLanguageFromUrl();
1149 // Default to English if no other option
1150 if (language
.length
== 0) {
1151 language
= defaultLanguage
;
1156 function getLanguageFromPhrase(phrase
) {
1157 // Check if how many words from existing phrase match a language.
1160 phrase
= DOM
.phrase
.val();
1162 if (phrase
.length
> 0) {
1163 var words
= phraseToWordArray(phrase
);
1164 var languageMatches
= {};
1165 for (l
in WORDLISTS
) {
1166 // Track how many words match in this language
1167 languageMatches
[l
] = 0;
1168 for (var i
=0; i
<words
.length
; i
++) {
1169 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1170 if (wordInLanguage
) {
1171 languageMatches
[l
]++;
1174 // Find languages with most word matches.
1175 // This is made difficult due to commonalities between Chinese
1176 // simplified vs traditional.
1177 var mostMatches
= 0;
1178 var mostMatchedLanguages
= [];
1179 for (var l
in languageMatches
) {
1180 var numMatches
= languageMatches
[l
];
1181 if (numMatches
> mostMatches
) {
1182 mostMatches
= numMatches
;
1183 mostMatchedLanguages
= [l
];
1185 else if (numMatches
== mostMatches
) {
1186 mostMatchedLanguages
.push(l
);
1190 if (mostMatchedLanguages
.length
> 0) {
1191 // Use first language and warn if multiple detected
1192 language
= mostMatchedLanguages
[0];
1193 if (mostMatchedLanguages
.length
> 1) {
1194 console
.warn("Multiple possible languages");
1195 console
.warn(mostMatchedLanguages
);
1202 function getLanguageFromUrl() {
1203 for (var language
in WORDLISTS
) {
1204 if (window
.location
.hash
.indexOf(language
) > -1) {
1211 function setMnemonicLanguage() {
1212 var language
= getLanguage();
1213 // Load the bip39 mnemonic generator for this language if required
1214 if (!(language
in mnemonics
)) {
1215 mnemonics
[language
] = new Mnemonic(language
);
1217 mnemonic
= mnemonics
[language
];
1220 function convertPhraseToNewLanguage() {
1221 var oldLanguage
= getLanguageFromPhrase();
1222 var newLanguage
= getLanguageFromUrl();
1223 var oldPhrase
= DOM
.phrase
.val();
1224 var oldWords
= phraseToWordArray(oldPhrase
);
1226 for (var i
=0; i
<oldWords
.length
; i
++) {
1227 var oldWord
= oldWords
[i
];
1228 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1229 var newWord
= WORDLISTS
[newLanguage
][index
];
1230 newWords
.push(newWord
);
1232 newPhrase
= wordArrayToPhrase(newWords
);
1236 // TODO look at jsbip39 - mnemonic.splitWords
1237 function phraseToWordArray(phrase
) {
1238 var words
= phrase
.split(/\s/g);
1240 for (var i
=0; i
<words
.length
; i
++) {
1241 var word
= words
[i
];
1242 if (word
.length
> 0) {
1243 noBlanks
.push(word
);
1249 // TODO look at jsbip39 - mnemonic.joinWords
1250 function wordArrayToPhrase(words
) {
1251 var phrase
= words
.join(" ");
1252 var language
= getLanguageFromPhrase(phrase
);
1253 if (language
== "japanese") {
1254 phrase
= words
.join("\u3000");
1259 function writeSplitPhrase(phrase
) {
1260 var wordCount
= phrase
.split(/\s/g).length
; //get number of words in phrase
1261 var left
=[]; //initialize array of indexs
1262 for (var i
=0;i
<wordCount
;i
++) left
.push(i
); //add all indexs to array
1263 var group
=[[],[],[]], //make array for 3 groups
1264 groupI
=-1; //initialize group index
1265 var seed
= Math
.abs(sjcl
.hash
.sha256
.hash(phrase
)[0])% 2147483647; //start seed at sudo random value based on hash of words
1266 while (left
.length
>0) { //while indexs left
1267 groupI
=(groupI
+1)%3; //get next group to insert index into
1268 seed
= seed
* 16807 % 2147483647; //change random value.(simple predicatable random number generator works well for this use)
1269 var selected
=Math
.floor(left
.length
*(seed
- 1) / 2147483646); //get index in left we will use for this group
1270 group
[groupI
].push(left
[selected
]); //add index to group
1271 left
.splice(selected
,1); //remove selected index
1273 var cards
=[phrase
.split(/\s/g),phrase
.split(/\s/g),phrase
.split(/\s/g)];//make array of cards
1274 for (var i
=0;i
<3;i
++) { //go through each card
1275 for (var ii
=0;ii
<wordCount
/3;ii
++) cards
[i
][group
[i
][ii
]]='XXXX'; //erase words listed in the group
1276 cards
[i
]='Card '+(i
+1)+': '+wordArrayToPhrase(cards
[i
]); //combine words on card back to string
1278 DOM
.splitPhrase
.val(cards
.join("\r\n")); //make words visible
1281 function isUsingOwnEntropy() {
1282 return DOM
.useEntropy
.prop("checked");
1285 function setMnemonicFromEntropy() {
1286 clearEntropyFeedback();
1287 // Get entropy value
1288 var entropyStr
= DOM
.entropy
.val();
1289 // Work out minimum base for entropy
1290 var entropy
= Entropy
.fromString(entropyStr
);
1291 if (entropy
.binaryStr
.length
== 0) {
1294 // Show entropy details
1295 showEntropyFeedback(entropy
);
1296 // Use entropy hash if not using raw entropy
1297 var bits
= entropy
.binaryStr
;
1298 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1299 if (mnemonicLength
!= "raw") {
1300 // Get bits by hashing entropy with SHA256
1301 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1302 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1303 bits
= BigInteger
.parse(hex
, 16).toString(2);
1304 while (bits
.length
% 256 != 0) {
1307 // Truncate hash to suit number of words
1308 mnemonicLength
= parseInt(mnemonicLength
);
1309 var numberOfBits
= 32 * mnemonicLength
/ 3;
1310 bits
= bits
.substring(0, numberOfBits
);
1311 // show warning for weak entropy override
1312 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1313 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1316 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1320 // hide warning for weak entropy override
1321 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1323 // Discard trailing entropy
1324 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1325 var start
= bits
.length
- bitsToUse
;
1326 var binaryStr
= bits
.substring(start
);
1327 // Convert entropy string to numeric array
1328 var entropyArr
= [];
1329 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1330 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1331 var entropyByte
= parseInt(byteAsBits
, 2);
1332 entropyArr
.push(entropyByte
)
1334 // Convert entropy array to mnemonic
1335 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1336 // Set the mnemonic in the UI
1337 DOM
.phrase
.val(phrase
);
1338 writeSplitPhrase(phrase
);
1339 // Show the word indexes
1341 // Show the checksum
1345 function clearEntropyFeedback() {
1346 DOM
.entropyCrackTime
.text("...");
1347 DOM
.entropyType
.text("");
1348 DOM
.entropyWordCount
.text("0");
1349 DOM
.entropyEventCount
.text("0");
1350 DOM
.entropyBitsPerEvent
.text("0");
1351 DOM
.entropyBits
.text("0");
1352 DOM
.entropyFiltered
.html(" ");
1353 DOM
.entropyBinary
.html(" ");
1356 function showEntropyFeedback(entropy
) {
1357 var numberOfBits
= entropy
.binaryStr
.length
;
1358 var timeToCrack
= "unknown";
1360 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1361 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1362 if (z
.feedback
.warning
!= "") {
1363 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1367 console
.log("Error detecting entropy strength with zxcvbn:");
1370 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1371 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1372 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1373 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1374 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1375 DOM
.entropyType
.text(entropyTypeStr
);
1376 DOM
.entropyCrackTime
.text(timeToCrack
);
1377 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1378 DOM
.entropyBits
.text(numberOfBits
);
1379 DOM
.entropyWordCount
.text(wordCount
);
1380 DOM
.entropyBinary
.text(spacedBinaryStr
);
1381 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1382 // detect and warn of filtering
1383 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1384 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1385 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1387 DOM
.entropyFilterWarning
.removeClass('hidden');
1390 DOM
.entropyFilterWarning
.addClass('hidden');
1394 function getEntropyTypeStr(entropy
) {
1395 var typeStr
= entropy
.base
.str
;
1396 // Add some detail if these are cards
1397 if (entropy
.base
.asInt
== 52) {
1398 var cardDetail
= []; // array of message strings
1399 // Detect duplicates
1401 var dupeTracker
= {};
1402 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1403 var card
= entropy
.base
.parts
[i
];
1404 var cardUpper
= card
.toUpperCase();
1405 if (cardUpper
in dupeTracker
) {
1408 dupeTracker
[cardUpper
] = true;
1410 if (dupes
.length
> 0) {
1411 var dupeWord
= "duplicates";
1412 if (dupes
.length
== 1) {
1413 dupeWord
= "duplicate";
1415 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1416 if (dupes
.length
> 3) {
1419 cardDetail
.push(msg
);
1422 var uniqueCards
= [];
1423 for (var uniqueCard
in dupeTracker
) {
1424 uniqueCards
.push(uniqueCard
);
1426 if (uniqueCards
.length
== 52) {
1427 cardDetail
.unshift("full deck");
1429 // Detect missing cards
1430 var values
= "A23456789TJQK";
1432 var missingCards
= [];
1433 for (var i
=0; i
<suits
.length
; i
++) {
1434 for (var j
=0; j
<values
.length
; j
++) {
1435 var card
= values
[j
] + suits
[i
];
1436 if (!(card
in dupeTracker
)) {
1437 missingCards
.push(card
);
1441 // Display missing cards if six or less, ie clearly going for full deck
1442 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1443 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1444 if (missingCards
.length
> 3) {
1447 cardDetail
.push(msg
);
1449 // Add card details to typeStr
1450 if (cardDetail
.length
> 0) {
1451 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1457 function setQrEvents(els
) {
1458 els
.on("mouseenter", createQr
);
1459 els
.on("mouseleave", destroyQr
);
1460 els
.on("click", toggleQr
);
1463 function createQr(e
) {
1464 var content
= e
.target
.textContent
|| e
.target
.value
;
1472 DOM
.qrImage
.append(qrEl
);
1474 DOM
.qrHider
.addClass("hidden");
1477 DOM
.qrHider
.removeClass("hidden");
1479 DOM
.qrContainer
.removeClass("hidden");
1483 function destroyQr() {
1484 DOM
.qrImage
.text("");
1485 DOM
.qrContainer
.addClass("hidden");
1488 function toggleQr() {
1490 DOM
.qrHider
.toggleClass("hidden");
1491 DOM
.qrHint
.toggleClass("hidden");
1494 function bip44TabSelected() {
1495 return DOM
.bip44tab
.hasClass("active");
1498 function bip32TabSelected() {
1499 return DOM
.bip32tab
.hasClass("active");
1502 function networkHasSegwit() {
1504 if ("baseNetwork" in network
) {
1505 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1507 // check if only p2wpkh params are required
1508 if (p2wpkhSelected()) {
1509 return "p2wpkh" in n
;
1511 // check if only p2wpkh-in-p2sh params are required
1512 else if (p2wpkhInP2shSelected()) {
1513 return "p2wpkhInP2sh" in n
;
1515 // require both if it's unclear which params are required
1516 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1519 function bip49TabSelected() {
1520 return DOM
.bip49tab
.hasClass("active");
1523 function bip84TabSelected() {
1524 return DOM
.bip84tab
.hasClass("active");
1527 function bip141TabSelected() {
1528 return DOM
.bip141tab
.hasClass("active");
1531 function setHdCoin(coinValue
) {
1532 DOM
.bip44coin
.val(coinValue
);
1533 DOM
.bip49coin
.val(coinValue
);
1534 DOM
.bip84coin
.val(coinValue
);
1537 function showSegwitAvailable() {
1538 DOM
.bip49unavailable
.addClass("hidden");
1539 DOM
.bip49available
.removeClass("hidden");
1540 DOM
.bip84unavailable
.addClass("hidden");
1541 DOM
.bip84available
.removeClass("hidden");
1542 DOM
.bip141unavailable
.addClass("hidden");
1543 DOM
.bip141available
.removeClass("hidden");
1546 function showSegwitUnavailable() {
1547 DOM
.bip49available
.addClass("hidden");
1548 DOM
.bip49unavailable
.removeClass("hidden");
1549 DOM
.bip84available
.addClass("hidden");
1550 DOM
.bip84unavailable
.removeClass("hidden");
1551 DOM
.bip141available
.addClass("hidden");
1552 DOM
.bip141unavailable
.removeClass("hidden");
1555 function adjustNetworkForSegwit() {
1556 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1557 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1559 // See https://github.com/iancoleman/bip39/issues/125
1560 var segwitNetworks
= null;
1561 // if a segwit network is alread selected, need to use base network to
1562 // look up new parameters
1563 if ("baseNetwork" in network
) {
1564 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1566 // choose the right segwit params
1567 if (p2wpkhSelected() && "p2wpkh" in network
) {
1568 network
= network
.p2wpkh
;
1570 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1571 network
= network
.p2wpkhInP2sh
;
1575 function lastIndexInTable() {
1576 var pathText
= DOM
.addresses
.find(".index").last().text();
1577 var pathBits
= pathText
.split("/");
1578 var lastBit
= pathBits
[pathBits
.length
-1];
1579 var lastBitClean
= lastBit
.replace("'", "");
1580 return parseInt(lastBitClean
);
1583 function uint8ArrayToHex(a
) {
1585 for (var i
=0; i
<a
.length
; i
++) {
1586 var h
= a
[i
].toString(16);
1587 while (h
.length
< 2) {
1595 function showWordIndexes() {
1596 var phrase
= DOM
.phrase
.val();
1597 var words
= phraseToWordArray(phrase
);
1598 var wordIndexes
= [];
1599 var language
= getLanguage();
1600 for (var i
=0; i
<words
.length
; i
++) {
1601 var word
= words
[i
];
1602 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1603 wordIndexes
.push(wordIndex
);
1605 var wordIndexesStr
= wordIndexes
.join(", ");
1606 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1609 function showChecksum() {
1610 var phrase
= DOM
.phrase
.val();
1611 var words
= phraseToWordArray(phrase
);
1612 var checksumBitlength
= words
.length
/ 3;
1615 var language
= getLanguage();
1616 for (var i
=words
.length
-1; i
>=0; i
--) {
1617 var word
= words
[i
];
1618 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1619 var wordBinary
= wordIndex
.toString(2);
1620 while (wordBinary
.length
< 11) {
1621 wordBinary
= "0" + wordBinary
;
1623 var binaryStr
= wordBinary
+ binaryStr
;
1624 if (binaryStr
.length
>= checksumBitlength
) {
1625 var start
= binaryStr
.length
- checksumBitlength
;
1626 var end
= binaryStr
.length
;
1627 checksum
= binaryStr
.substring(start
, end
);
1628 // add spaces so the last group is 11 bits, not the first
1629 checksum
= checksum
.split("").reverse().join("")
1630 checksum
= addSpacesEveryElevenBits(checksum
);
1631 checksum
= checksum
.split("").reverse().join("")
1635 DOM
.entropyChecksum
.text(checksum
);
1638 function updateCsv() {
1639 var tableCsv
= "path,address,public key,private key\n";
1640 var rows
= DOM
.addresses
.find("tr");
1641 for (var i
=0; i
<rows
.length
; i
++) {
1642 var row
= $(rows
[i
]);
1643 var cells
= row
.find("td");
1644 for (var j
=0; j
<cells
.length
; j
++) {
1645 var cell
= $(cells
[j
]);
1646 if (!cell
.children().hasClass("invisible")) {
1647 tableCsv
= tableCsv
+ cell
.text();
1649 if (j
!= cells
.length
- 1) {
1650 tableCsv
= tableCsv
+ ",";
1653 tableCsv
= tableCsv
+ "\n";
1655 DOM
.csv
.val(tableCsv
);
1658 function addSpacesEveryElevenBits(binaryStr
) {
1659 return binaryStr
.match(/.{1,11}/g).join(" ");
1664 name: "AC - Asiacoin",
1665 onSelect: function() {
1666 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1671 name: "ACC - Adcoin",
1672 onSelect: function() {
1673 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1678 name: "AUR - Auroracoin",
1679 onSelect: function() {
1680 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1686 onSelect: function() {
1687 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1692 name: "ANON - ANON",
1693 onSelect: function() {
1694 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1699 name: "BCA - Bitcoin Atom",
1700 onSelect: function() {
1701 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1706 name: "BCH - Bitcoin Cash",
1707 onSelect: function() {
1708 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1713 name: "BEET - Beetlecoin",
1714 onSelect: function() {
1715 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1720 name: "BELA - Belacoin",
1721 onSelect: function() {
1722 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1727 name: "BLK - BlackCoin",
1728 onSelect: function() {
1729 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1734 name: "BRIT - Britcoin",
1735 onSelect: function() {
1736 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
1741 name: "BSD - Bitsend",
1742 onSelect: function() {
1743 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
1749 onSelect: function() {
1750 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1755 name: "BTC - Bitcoin",
1756 onSelect: function() {
1757 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1762 name: "BTC - Bitcoin Testnet",
1763 onSelect: function() {
1764 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1769 name: "BITG - Bitcoin Green",
1770 onSelect: function() {
1771 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1776 name: "BTCP - Bitcoin Private",
1777 onSelect: function() {
1778 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
1783 name: "BTCZ - Bitcoinz",
1784 onSelect: function() {
1785 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
1790 name: "BTDX - BitCloud",
1791 onSelect: function() {
1792 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
1797 name: "BTG - Bitcoin Gold",
1798 onSelect: function() {
1799 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
1804 name: "BTX - Bitcore",
1805 onSelect: function() {
1806 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
1811 name: "CCN - Cannacoin",
1812 onSelect: function() {
1813 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1818 name: "CESC - Cryptoescudo",
1819 onSelect: function() {
1820 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1825 name: "CDN - Canadaecoin",
1826 onSelect: function() {
1827 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
1832 name: "CLAM - Clams",
1833 onSelect: function() {
1834 network
= bitcoinjs
.bitcoin
.networks
.clam
;
1839 name: "CLO - Callisto",
1840 segwitAvailable: false,
1841 onSelect: function() {
1842 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1847 name: "CLUB - Clubcoin",
1848 onSelect: function() {
1849 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
1854 name: "CMP - Compcoin",
1855 onSelect: function() {
1856 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
1861 name: "CRAVE - Crave",
1862 onSelect: function() {
1863 network
= bitcoinjs
.bitcoin
.networks
.crave
;
1868 name: "CRW - Crown",
1869 onSelect: function() {
1870 network
= bitcoinjs
.bitcoin
.networks
.crown
;
1875 name: "DASH - Dash",
1876 onSelect: function() {
1877 network
= bitcoinjs
.bitcoin
.networks
.dash
;
1882 name: "DASH - Dash Testnet",
1883 onSelect: function() {
1884 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
1889 name: "DFC - Defcoin",
1890 onSelect: function() {
1891 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
1896 name: "DGB - Digibyte",
1897 onSelect: function() {
1898 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
1903 name: "DGC - Digitalcoin",
1904 onSelect: function() {
1905 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
1910 name: "DMD - Diamond",
1911 onSelect: function() {
1912 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
1917 name: "DNR - Denarius",
1918 onSelect: function() {
1919 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
1924 name: "DOGE - Dogecoin",
1925 onSelect: function() {
1926 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
1931 name: "ECN - Ecoin",
1932 onSelect: function() {
1933 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
1938 name: "EDRC - Edrcoin",
1939 onSelect: function() {
1940 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
1945 name: "EFL - Egulden",
1946 onSelect: function() {
1947 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
1952 name: "EMC2 - Einsteinium",
1953 onSelect: function() {
1954 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
1959 name: "ERC - Europecoin",
1960 onSelect: function() {
1961 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
1966 name: "ETC - Ethereum Classic",
1967 segwitAvailable: false,
1968 onSelect: function() {
1969 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1974 name: "ETH - Ethereum",
1975 onSelect: function() {
1976 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1981 name: "EXCL - Exclusivecoin",
1982 onSelect: function() {
1983 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
1988 name: "EXCC - ExchangeCoin",
1989 onSelect: function() {
1990 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
1995 name: "EXP - Expanse",
1996 segwitAvailable: false,
1997 onSelect: function() {
1998 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2003 name: "FJC - Fujicoin",
2004 onSelect: function() {
2005 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2010 name: "FLASH - Flashcoin",
2011 onSelect: function() {
2012 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2017 name: "FRST - Firstcoin",
2018 onSelect: function() {
2019 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2024 name: "FTC - Feathercoin",
2025 onSelect: function() {
2026 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2031 name: "GAME - GameCredits",
2032 onSelect: function() {
2033 network
= bitcoinjs
.bitcoin
.networks
.game
;
2038 name: "GBX - Gobyte",
2039 onSelect: function() {
2040 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2045 name: "GCR - GCRCoin",
2046 onSelect: function() {
2047 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2052 name: "GRC - Gridcoin",
2053 onSelect: function() {
2054 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2059 name: "HNC - Helleniccoin",
2060 onSelect: function() {
2061 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2066 name: "HUSH - Hush",
2067 onSelect: function() {
2068 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2073 name: "INSN - Insane",
2074 onSelect: function() {
2075 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2081 onSelect: function() {
2082 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2087 name: "IXC - Ixcoin",
2088 onSelect: function() {
2089 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2094 name: "JBS - Jumbucks",
2095 onSelect: function() {
2096 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2101 name: "KMD - Komodo",
2102 bip49available: false,
2103 onSelect: function() {
2104 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2109 name: "KOBO - Kobocoin",
2110 bip49available: false,
2111 onSelect: function() {
2112 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2117 name: "LBC - Library Credits",
2118 onSelect: function() {
2119 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2124 name: "LCC - Litecoincash",
2125 onSelect: function() {
2126 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2131 name: "LDCN - Landcoin",
2132 onSelect: function() {
2133 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2138 name: "LINX - Linx",
2139 onSelect: function() {
2140 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2145 name: "LTC - Litecoin",
2146 onSelect: function() {
2147 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2149 DOM
.litecoinLtubContainer
.removeClass("hidden");
2153 name: "LYNX - Lynx",
2154 onSelect: function() {
2155 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2160 name: "MAZA - Maza",
2161 onSelect: function() {
2162 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2167 name: "MEC - Megacoin",
2168 onSelect: function() {
2169 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2175 segwitAvailable: false,
2176 onSelect: function() {
2177 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2182 name: "MNX - Minexcoin",
2183 onSelect: function() {
2184 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2189 name: "MONA - Monacoin",
2190 onSelect: function() {
2191 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2196 name: "MUSIC - Musicoin",
2197 segwitAvailable: false,
2198 onSelect: function() {
2199 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2204 name: "NAV - Navcoin",
2205 onSelect: function() {
2206 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2211 name: "NEBL - Neblio",
2212 onSelect: function() {
2213 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2218 name: "NEOS - Neoscoin",
2219 onSelect: function() {
2220 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2225 name: "NLG - Gulden",
2226 onSelect: function() {
2227 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2232 name: "NMC - Namecoin",
2233 onSelect: function() {
2234 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2239 name: "NRG - Energi",
2240 onSelect: function() {
2241 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2246 name: "NRO - Neurocoin",
2247 onSelect: function() {
2248 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2253 name: "NSR - Nushares",
2254 onSelect: function() {
2255 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2260 name: "NYC - Newyorkc",
2261 onSelect: function() {
2262 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2267 name: "NVC - Novacoin",
2268 onSelect: function() {
2269 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2274 name: "OK - Okcash",
2275 onSelect: function() {
2276 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2281 name: "OMNI - Omnicore",
2282 onSelect: function() {
2283 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2288 name: "ONX - Onixcoin",
2289 onSelect: function() {
2290 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2295 name: "PHR - Phore",
2296 onSelect: function() {
2297 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2302 name: "PINK - Pinkcoin",
2303 onSelect: function() {
2304 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2309 name: "PIRL - Pirl",
2310 segwitAvailable: false,
2311 onSelect: function() {
2312 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2317 name: "PIVX - PIVX",
2318 onSelect: function() {
2319 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2324 name: "PIVX - PIVX Testnet",
2325 onSelect: function() {
2326 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2332 segwitAvailable: false,
2333 onSelect: function() {
2334 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2339 name: "POSW - POSWcoin",
2340 onSelect: function() {
2341 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2346 name: "POT - Potcoin",
2347 onSelect: function() {
2348 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2353 name: "PPC - Peercoin",
2354 onSelect: function() {
2355 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2360 name: "PRJ - ProjectCoin",
2361 onSelect: function() {
2362 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2367 name: "PSB - Pesobit",
2368 onSelect: function() {
2369 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2374 name: "PUT - Putincoin",
2375 onSelect: function() {
2376 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2381 name: "RVN - Ravencoin",
2382 onSelect: function() {
2383 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2388 name: "RBY - Rubycoin",
2389 onSelect: function() {
2390 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2395 name: "RDD - Reddcoin",
2396 onSelect: function() {
2397 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2402 name: "RVR - RevolutionVR",
2403 onSelect: function() {
2404 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2409 name: "SLS - Salus",
2410 onSelect: function() {
2411 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2416 name: "SDC - ShadowCash",
2417 onSelect: function() {
2418 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2423 name: "SDC - ShadowCash Testnet",
2424 onSelect: function() {
2425 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2430 name: "SLM - Slimcoin",
2431 onSelect: function() {
2432 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2437 name: "SLM - Slimcoin Testnet",
2438 onSelect: function() {
2439 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2444 name: "SLR - Solarcoin",
2445 onSelect: function() {
2446 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2451 name: "SMLY - Smileycoin",
2452 onSelect: function() {
2453 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2458 name: "STASH - Stash",
2459 onSelect: function() {
2460 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2465 name: "STASH - Stash Testnet",
2466 onSelect: function() {
2467 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2472 name: "STRAT - Stratis",
2473 onSelect: function() {
2474 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2479 name: "TSTRAT - Stratis Testnet",
2480 onSelect: function() {
2481 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2486 name: "SYS - Syscoin",
2487 onSelect: function() {
2488 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2493 name: "THC - Hempcoin",
2494 onSelect: function() {
2495 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2501 onSelect: function() {
2502 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2507 name: "USC - Ultimatesecurecash",
2508 onSelect: function() {
2509 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2514 name: "USNBT - NuBits",
2515 onSelect: function() {
2516 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2521 name: "UNO - Unobtanium",
2522 onSelect: function() {
2523 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2528 name: "VASH - Vpncoin",
2529 onSelect: function() {
2530 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2535 name: "VIA - Viacoin",
2536 onSelect: function() {
2537 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2542 name: "VIA - Viacoin Testnet",
2543 onSelect: function() {
2544 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2549 name: "VIVO - Vivo",
2550 onSelect: function() {
2551 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2556 name: "VTC - Vertcoin",
2557 onSelect: function() {
2558 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2563 name: "WC - Wincoin",
2564 onSelect: function() {
2565 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2570 name: "XAX - Artax",
2571 onSelect: function() {
2572 network
= bitcoinjs
.bitcoin
.networks
.artax
;
2577 name: "XBC - Bitcoinplus",
2578 onSelect: function() {
2579 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
2584 name: "XMY - Myriadcoin",
2585 onSelect: function() {
2586 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
2591 name: "XRP - Ripple",
2592 onSelect: function() {
2593 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2598 name: "XVC - Vcash",
2599 onSelect: function() {
2600 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
2605 name: "XVG - Verge",
2606 onSelect: function() {
2607 network
= bitcoinjs
.bitcoin
.networks
.verge
;
2612 name: "XUEZ - Xuez",
2613 segwitAvailable: false,
2614 onSelect: function() {
2615 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
2620 name: "XWC - Whitecoin",
2621 onSelect: function() {
2622 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
2627 name: "XZC - Zcoin",
2628 onSelect: function() {
2629 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
2634 name: "ZCL - Zclassic",
2635 onSelect: function() {
2636 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
2641 name: "ZEC - Zcash",
2642 onSelect: function() {
2643 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
2648 name: "ZEN - Zencash",
2649 onSelect: function() {
2650 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
2658 name: "Bitcoin Core",
2659 onSelect: function() {
2660 DOM
.bip32path
.val("m/0'/0'");
2661 DOM
.hardenedAddresses
.prop('checked', true);
2665 name: "blockchain.info",
2666 onSelect: function() {
2667 DOM
.bip32path
.val("m/44'/0'/0'");
2668 DOM
.hardenedAddresses
.prop('checked', false);
2672 name: "MultiBit HD",
2673 onSelect: function() {
2674 DOM
.bip32path
.val("m/0'/0");
2675 DOM
.hardenedAddresses
.prop('checked', false);
2679 name: "Coinomi, Ledger",
2680 onSelect: function() {
2681 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
2682 DOM
.hardenedAddresses
.prop('checked', false);