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
.passphrase
= $(".passphrase");
48 DOM
.generateContainer
= $(".generate-container");
49 DOM
.generate
= $(".generate");
50 DOM
.seed
= $(".seed");
51 DOM
.rootKey
= $(".root-key");
52 DOM
.litecoinLtubContainer
= $(".litecoin-ltub-container");
53 DOM
.litecoinUseLtub
= $(".litecoin-use-ltub");
54 DOM
.extendedPrivKey
= $(".extended-priv-key");
55 DOM
.extendedPubKey
= $(".extended-pub-key");
56 DOM
.bip32tab
= $("#bip32-tab");
57 DOM
.bip44tab
= $("#bip44-tab");
58 DOM
.bip49tab
= $("#bip49-tab");
59 DOM
.bip84tab
= $("#bip84-tab");
60 DOM
.bip141tab
= $("#bip141-tab");
61 DOM
.bip32panel
= $("#bip32");
62 DOM
.bip44panel
= $("#bip44");
63 DOM
.bip49panel
= $("#bip49");
64 DOM
.bip32path
= $("#bip32-path");
65 DOM
.bip44path
= $("#bip44-path");
66 DOM
.bip44purpose
= $("#bip44 .purpose");
67 DOM
.bip44coin
= $("#bip44 .coin");
68 DOM
.bip44account
= $("#bip44 .account");
69 DOM
.bip44accountXprv
= $("#bip44 .account-xprv");
70 DOM
.bip44accountXpub
= $("#bip44 .account-xpub");
71 DOM
.bip44change
= $("#bip44 .change");
72 DOM
.bip49unavailable
= $("#bip49 .unavailable");
73 DOM
.bip49available
= $("#bip49 .available");
74 DOM
.bip49path
= $("#bip49-path");
75 DOM
.bip49purpose
= $("#bip49 .purpose");
76 DOM
.bip49coin
= $("#bip49 .coin");
77 DOM
.bip49account
= $("#bip49 .account");
78 DOM
.bip49accountXprv
= $("#bip49 .account-xprv");
79 DOM
.bip49accountXpub
= $("#bip49 .account-xpub");
80 DOM
.bip49change
= $("#bip49 .change");
81 DOM
.bip84unavailable
= $("#bip84 .unavailable");
82 DOM
.bip84available
= $("#bip84 .available");
83 DOM
.bip84path
= $("#bip84-path");
84 DOM
.bip84purpose
= $("#bip84 .purpose");
85 DOM
.bip84coin
= $("#bip84 .coin");
86 DOM
.bip84account
= $("#bip84 .account");
87 DOM
.bip84accountXprv
= $("#bip84 .account-xprv");
88 DOM
.bip84accountXpub
= $("#bip84 .account-xpub");
89 DOM
.bip84change
= $("#bip84 .change");
90 DOM
.bip141unavailable
= $("#bip141 .unavailable");
91 DOM
.bip141available
= $("#bip141 .available");
92 DOM
.bip141path
= $("#bip141-path");
93 DOM
.bip141semantics
= $(".bip141-semantics");
94 DOM
.generatedStrength
= $(".generate-container .strength");
95 DOM
.generatedStrengthWarning
= $(".generate-container .warning");
96 DOM
.hardenedAddresses
= $(".hardened-addresses");
97 DOM
.bitcoinCashAddressTypeContainer
= $(".bch-addr-type-container");
98 DOM
.bitcoinCashAddressType
= $("[name=bch-addr-type]")
99 DOM
.useBip38
= $(".use-bip38");
100 DOM
.bip38Password
= $(".bip38-password");
101 DOM
.addresses
= $(".addresses");
102 DOM
.csvTab
= $("#csv-tab a");
104 DOM
.rowsToAdd
= $(".rows-to-add");
105 DOM
.more
= $(".more");
106 DOM
.moreRowsStartIndex
= $(".more-rows-start-index");
107 DOM
.feedback
= $(".feedback");
108 DOM
.tab
= $(".derivation-type a");
109 DOM
.indexToggle
= $(".index-toggle");
110 DOM
.addressToggle
= $(".address-toggle");
111 DOM
.publicKeyToggle
= $(".public-key-toggle");
112 DOM
.privateKeyToggle
= $(".private-key-toggle");
113 DOM
.languages
= $(".languages a");
114 DOM
.qrContainer
= $(".qr-container");
115 DOM
.qrHider
= DOM
.qrContainer
.find(".qr-hider");
116 DOM
.qrImage
= DOM
.qrContainer
.find(".qr-image");
117 DOM
.qrHint
= DOM
.qrContainer
.find(".qr-hint");
118 DOM
.showQrEls
= $("[data-show-qr]");
122 DOM
.privacyScreenToggle
.on("change", privacyScreenToggled
);
123 DOM
.generatedStrength
.on("change", generatedStrengthChanged
);
124 DOM
.network
.on("change", networkChanged
);
125 DOM
.bip32Client
.on("change", bip32ClientChanged
);
126 DOM
.useEntropy
.on("change", setEntropyVisibility
);
127 DOM
.entropy
.on("input", delayedEntropyChanged
);
128 DOM
.entropyMnemonicLength
.on("change", entropyChanged
);
129 DOM
.phrase
.on("input", delayedPhraseChanged
);
130 DOM
.passphrase
.on("input", delayedPhraseChanged
);
131 DOM
.generate
.on("click", generateClicked
);
132 DOM
.more
.on("click", showMore
);
133 DOM
.rootKey
.on("input", delayedRootKeyChanged
);
134 DOM
.litecoinUseLtub
.on("change", litecoinUseLtubChanged
);
135 DOM
.bip32path
.on("input", calcForDerivationPath
);
136 DOM
.bip44account
.on("input", calcForDerivationPath
);
137 DOM
.bip44change
.on("input", calcForDerivationPath
);
138 DOM
.bip49account
.on("input", calcForDerivationPath
);
139 DOM
.bip49change
.on("input", calcForDerivationPath
);
140 DOM
.bip84account
.on("input", calcForDerivationPath
);
141 DOM
.bip84change
.on("input", calcForDerivationPath
);
142 DOM
.bip141path
.on("input", calcForDerivationPath
);
143 DOM
.bip141semantics
.on("change", tabChanged
);
144 DOM
.tab
.on("shown.bs.tab", tabChanged
);
145 DOM
.hardenedAddresses
.on("change", calcForDerivationPath
);
146 DOM
.useBip38
.on("change", calcForDerivationPath
);
147 DOM
.bip38Password
.on("change", calcForDerivationPath
);
148 DOM
.indexToggle
.on("click", toggleIndexes
);
149 DOM
.addressToggle
.on("click", toggleAddresses
);
150 DOM
.publicKeyToggle
.on("click", togglePublicKeys
);
151 DOM
.privateKeyToggle
.on("click", togglePrivateKeys
);
152 DOM
.csvTab
.on("click", updateCsv
);
153 DOM
.languages
.on("click", languageChanged
);
154 DOM
.bitcoinCashAddressType
.on("change", bitcoinCashAddressTypeChange
);
155 setQrEvents(DOM
.showQrEls
);
158 hideValidationError();
159 populateNetworkSelect();
160 populateClientSelect();
165 function generatedStrengthChanged() {
166 var strength
= parseInt(DOM
.generatedStrength
.val());
168 DOM
.generatedStrengthWarning
.removeClass("hidden");
171 DOM
.generatedStrengthWarning
.addClass("hidden");
175 function networkChanged(e
) {
177 clearAddressesList();
178 DOM
.litecoinLtubContainer
.addClass("hidden");
179 DOM
.bitcoinCashAddressTypeContainer
.addClass("hidden");
180 var networkIndex
= e
.target
.value
;
181 var network
= networks
[networkIndex
];
183 adjustNetworkForSegwit();
192 function bip32ClientChanged(e
) {
193 var clientIndex
= DOM
.bip32Client
.val();
194 if (clientIndex
== "custom") {
195 DOM
.bip32path
.prop("readonly", false);
198 DOM
.bip32path
.prop("readonly", true);
199 clients
[clientIndex
].onSelect();
209 function setEntropyVisibility() {
210 if (isUsingOwnEntropy()) {
211 DOM
.entropyContainer
.removeClass("hidden");
212 DOM
.generateContainer
.addClass("hidden");
213 DOM
.phrase
.prop("readonly", true);
218 DOM
.entropyContainer
.addClass("hidden");
219 DOM
.generateContainer
.removeClass("hidden");
220 DOM
.phrase
.prop("readonly", false);
225 function delayedPhraseChanged() {
226 hideValidationError();
229 bip32ExtendedKey
= null;
230 clearAddressesList();
232 if (phraseChangeTimeoutEvent
!= null) {
233 clearTimeout(phraseChangeTimeoutEvent
);
235 phraseChangeTimeoutEvent
= setTimeout(phraseChanged
, 400);
238 function phraseChanged() {
240 setMnemonicLanguage();
241 // Get the mnemonic phrase
242 var phrase
= DOM
.phrase
.val();
243 var errorText
= findPhraseErrors(phrase
);
245 showValidationError(errorText
);
248 // Calculate and display
249 var passphrase
= DOM
.passphrase
.val();
250 calcBip32RootKeyFromSeed(phrase
, passphrase
);
251 calcForDerivationPath();
252 // Show the word indexes
256 function tabChanged() {
258 adjustNetworkForSegwit();
259 var phrase
= DOM
.phrase
.val();
261 // Calculate and display for mnemonic
262 var errorText
= findPhraseErrors(phrase
);
264 showValidationError(errorText
);
267 // Calculate and display
268 var passphrase
= DOM
.passphrase
.val();
269 calcBip32RootKeyFromSeed(phrase
, passphrase
);
272 // Calculate and display for root key
273 var rootKeyBase58
= DOM
.rootKey
.val();
274 var errorText
= validateRootKey(rootKeyBase58
);
276 showValidationError(errorText
);
279 // Calculate and display
280 calcBip32RootKeyFromBase58(rootKeyBase58
);
282 calcForDerivationPath();
285 function delayedEntropyChanged() {
286 hideValidationError();
288 if (entropyChangeTimeoutEvent
!= null) {
289 clearTimeout(entropyChangeTimeoutEvent
);
291 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
294 function entropyChanged() {
295 // If blank entropy, clear mnemonic, addresses, errors
296 if (DOM
.entropy
.val().trim().length
== 0) {
298 clearEntropyFeedback();
300 showValidationError("Blank entropy");
303 // Get the current phrase to detect changes
304 var phrase
= DOM
.phrase
.val();
305 // Set the phrase from the entropy
306 setMnemonicFromEntropy();
307 // Recalc addresses if the phrase has changed
308 var newPhrase
= DOM
.phrase
.val();
309 if (newPhrase
!= phrase
) {
310 if (newPhrase
.length
== 0) {
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
);
330 hideValidationError();
332 // Clear existing mnemonic and passphrase
334 DOM
.passphrase
.val("");
336 if (rootKeyChangedTimeoutEvent
!= null) {
337 clearTimeout(rootKeyChangedTimeoutEvent
);
339 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
342 function rootKeyChanged() {
344 hideValidationError();
345 var rootKeyBase58
= DOM
.rootKey
.val();
346 var errorText
= validateRootKey(rootKeyBase58
);
348 showValidationError(errorText
);
351 // Calculate and display
352 calcBip32RootKeyFromBase58(rootKeyBase58
);
353 calcForDerivationPath();
356 function litecoinUseLtubChanged() {
357 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
358 if (litecoinUseLtub
) {
359 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
362 network
= bitcoinjs
.bitcoin
.networks
.litecoinXprv
;
367 function calcForDerivationPath() {
369 clearAddressesList();
371 // Don't show segwit if it's selected but network doesn't support it
372 if (segwitSelected() && !networkHasSegwit()) {
373 showSegwitUnavailable();
377 showSegwitAvailable();
378 // Get the derivation path
379 var derivationPath
= getDerivationPath();
380 var errorText
= findDerivationPathErrors(derivationPath
);
382 showValidationError(errorText
);
385 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
386 if (bip44TabSelected()) {
389 else if (bip49TabSelected()) {
392 else if (bip84TabSelected()) {
398 function generateClicked() {
399 if (isUsingOwnEntropy()) {
404 setTimeout(function() {
405 setMnemonicLanguage();
406 var phrase
= generateRandomPhrase();
414 function languageChanged() {
415 setTimeout(function() {
416 setMnemonicLanguage();
417 if (DOM
.phrase
.val().length
> 0) {
418 var newPhrase
= convertPhraseToNewLanguage();
419 DOM
.phrase
.val(newPhrase
);
423 DOM
.generate
.trigger("click");
428 function bitcoinCashAddressTypeChange() {
432 function toggleIndexes() {
433 showIndex
= !showIndex
;
434 $("td.index span").toggleClass("invisible");
437 function toggleAddresses() {
438 showAddress
= !showAddress
;
439 $("td.address span").toggleClass("invisible");
442 function togglePublicKeys() {
443 showPubKey
= !showPubKey
;
444 $("td.pubkey span").toggleClass("invisible");
447 function togglePrivateKeys() {
448 showPrivKey
= !showPrivKey
;
449 $("td.privkey span").toggleClass("invisible");
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");
459 $("body").removeClass("visual-privacy");
465 function generateRandomPhrase() {
466 if (!hasStrongRandom()) {
467 var errorText
= "This browser does not support strong randomness";
468 showValidationError(errorText
);
471 // get the amount of entropy to use
472 var numWords
= parseInt(DOM
.generatedStrength
.val());
473 var strength
= numWords
/ 3 * 32;
474 var buffer
= new Uint8Array(strength
/ 8);
475 // create secure entropy
476 var data
= crypto
.getRandomValues(buffer
);
478 var words
= mnemonic
.toMnemonic(data
);
479 DOM
.phrase
.val(words
);
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");
488 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
489 seed
= mnemonic
.toSeed(phrase
, passphrase
);
490 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
493 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
494 // try parsing with various segwit network params since this extended
495 // key may be from any one of them.
496 if (networkHasSegwit()) {
498 if ("baseNetwork" in n
) {
499 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
501 // try parsing using base network params
503 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
507 // try parsing using p2wpkh params
510 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
515 // try parsing using p2wpkh-in-p2sh network params
516 if ("p2wpkhInP2sh" in n
) {
518 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
524 // try the network params as currently specified
525 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
528 function calcBip32ExtendedKey(path
) {
529 // Check there's a root key to derive from
533 var extendedKey
= bip32RootKey
;
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
);
542 var hardened
= bit
[bit
.length
-1] == "'";
543 var isPriv
= !(extendedKey
.isNeutered());
544 var invalidDerivationPath
= hardened
&& !isPriv
;
545 if (invalidDerivationPath
) {
549 extendedKey
= extendedKey
.deriveHardened(index
);
552 extendedKey
= extendedKey
.derive(index
);
558 function showValidationError(errorText
) {
564 function hideValidationError() {
570 function findPhraseErrors(phrase
) {
571 // Preprocess the words
572 phrase
= mnemonic
.normalizeString(phrase
);
573 var words
= phraseToWordArray(phrase
);
574 // Detect blank phrase
575 if (words
.length
== 0) {
576 return "Blank mnemonic";
579 for (var i
=0; i
<words
.length
; i
++) {
581 var language
= getLanguage();
582 if (WORDLISTS
[language
].indexOf(word
) == -1) {
583 console
.log("Finding closest match to " + word
);
584 var nearestWord
= findNearestWord(word
);
585 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
588 // Check the words are valid
589 var properPhrase
= wordArrayToPhrase(words
);
590 var isValid
= mnemonic
.check(properPhrase
);
592 return "Invalid mnemonic";
597 function validateRootKey(rootKeyBase58
) {
598 // try various segwit network params since this extended key may be from
600 if (networkHasSegwit()) {
602 if ("baseNetwork" in n
) {
603 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
605 // try parsing using base network params
607 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
611 // try parsing using p2wpkh params
614 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
619 // try parsing using p2wpkh-in-p2sh network params
620 if ("p2wpkhInP2sh" in n
) {
622 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
628 // try the network params as currently specified
630 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
633 return "Invalid root key";
638 function getDerivationPath() {
639 if (bip44TabSelected()) {
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);
645 path
+= purpose
+ "'/";
647 path
+= account
+ "'/";
649 DOM
.bip44path
.val(path
);
650 var derivationPath
= DOM
.bip44path
.val();
651 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
652 return derivationPath
;
654 else if (bip49TabSelected()) {
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);
660 path
+= purpose
+ "'/";
662 path
+= account
+ "'/";
664 DOM
.bip49path
.val(path
);
665 var derivationPath
= DOM
.bip49path
.val();
666 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
667 return derivationPath
;
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);
675 path
+= purpose
+ "'/";
677 path
+= account
+ "'/";
679 DOM
.bip84path
.val(path
);
680 var derivationPath
= DOM
.bip84path
.val();
681 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
682 return derivationPath
;
684 else if (bip32TabSelected()) {
685 var derivationPath
= DOM
.bip32path
.val();
686 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
687 return derivationPath
;
689 else if (bip141TabSelected()) {
690 var derivationPath
= DOM
.bip141path
.val();
691 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
692 return derivationPath
;
695 console
.log("Unknown derivation path");
699 function findDerivationPathErrors(path
) {
700 // TODO is not perfect but is better than nothing
702 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
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'";
710 if (path
.length
> 1) {
711 if (path
[1] != "/") {
712 return "Separator must be '/'";
714 var indexes
= path
.split("/");
715 if (indexes
.length
> maxDepth
) {
716 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
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
;
724 var indexValue
= parseInt(index
.replace("'", ""));
726 return "Invalid number at depth " + depth
;
728 if (indexValue
> maxIndexValue
) {
729 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
733 // Check root key exists or else derivation path is useless!
735 return "No root key";
737 // Check no hardened derivation path when using xpub keys
738 var hardenedPath
= path
.indexOf("'") > -1;
739 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
740 var hardened
= hardenedPath
|| hardenedAddresses
;
741 var isXpubkey
= bip32RootKey
.isNeutered();
742 if (hardened
&& isXpubkey
) {
743 return "Hardened derivation path is invalid with xpub key";
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);
754 path
+= purpose
+ "'/";
756 path
+= account
+ "'/";
757 // Calculate the account extended keys
758 var accountExtendedKey
= calcBip32ExtendedKey(path
);
759 var accountXprv
= accountExtendedKey
.toBase58();
760 var accountXpub
= accountExtendedKey
.neutered().toBase58();
761 // Display the extended keys
762 DOM
.bip44accountXprv
.val(accountXprv
);
763 DOM
.bip44accountXpub
.val(accountXpub
);
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);
772 path
+= purpose
+ "'/";
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
);
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);
790 path
+= purpose
+ "'/";
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
);
802 function displayBip32Info() {
805 var rootKey
= bip32RootKey
.toBase58();
806 DOM
.rootKey
.val(rootKey
);
807 var xprvkeyB58
= "NA";
808 if (!bip32ExtendedKey
.isNeutered()) {
809 xprvkeyB58
= bip32ExtendedKey
.toBase58();
811 var extendedPrivKey
= xprvkeyB58
;
812 DOM
.extendedPrivKey
.val(extendedPrivKey
);
813 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
814 DOM
.extendedPubKey
.val(extendedPubKey
);
815 // Display the addresses and privkeys
816 clearAddressesList();
817 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
818 displayAddresses(0, initialAddressCount
);
821 function displayAddresses(start
, total
) {
822 generationProcesses
.push(new (function() {
826 this.stop = function() {
827 for (var i
=0; i
<rows
.length
; i
++) {
828 rows
[i
].shouldGenerate
= false;
833 for (var i
=0; i
<total
; i
++) {
834 var index
= i
+ start
;
835 var isLast
= i
== total
- 1;
836 rows
.push(new TableRow(index
, isLast
));
842 function segwitSelected() {
843 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
846 function p2wpkhSelected() {
847 return bip84TabSelected() ||
848 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
851 function p2wpkhInP2shSelected() {
852 return bip49TabSelected() ||
853 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
856 function TableRow(index
, isLast
) {
859 this.shouldGenerate
= true;
860 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
861 var useBip38
= DOM
.useBip38
.prop("checked");
862 var bip38password
= DOM
.bip38Password
.val();
863 var isSegwit
= segwitSelected();
864 var segwitAvailable
= networkHasSegwit();
865 var isP2wpkh
= p2wpkhSelected();
866 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
872 function calculateValues() {
873 setTimeout(function() {
874 if (!self
.shouldGenerate
) {
877 // derive HDkey for this row of the table
879 if (useHardenedAddresses
) {
880 key
= bip32ExtendedKey
.deriveHardened(index
);
883 key
= bip32ExtendedKey
.derive(index
);
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
) {
890 keyPair
= new bitcoinjs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
893 var address
= keyPair
.getAddress().toString();
895 var hasPrivkey
= !key
.isNeutered();
898 privkey
= keyPair
.toWIF();
899 // BIP38 encode private key if required
901 privkey
= bitcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
902 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
907 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
908 var indexText
= getDerivationPath() + "/" + index
;
909 if (useHardenedAddresses
) {
910 indexText
= indexText
+ "'";
912 // Ethereum values are different
913 if ((networks
[DOM
.network
.val()].name
== "ETH - Ethereum")
914 || (networks
[DOM
.network
.val()].name
== "ETC - Ethereum Classic")
915 || (networks
[DOM
.network
.val()].name
== "PIRL - Pirl")
916 || (networks
[DOM
.network
.val()].name
== "MIX - MIX")
917 || (networks
[DOM
.network
.val()].name
== "MUSIC - Musicoin")
918 || (networks
[DOM
.network
.val()].name
== "POA - Poa")
919 || (networks
[DOM
.network
.val()].name
== "EXP - Expanse")
920 || (networks
[DOM
.network
.val()].name
== "CLO - Callisto")
921 || (networks
[DOM
.network
.val()].name
== "DXN - DEXON")) {
922 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
923 privkey
= privKeyBuffer
.toString('hex');
924 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
925 var hexAddress
= addressBuffer
.toString('hex');
926 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
927 address
= ethUtil
.addHexPrefix(checksumAddress
);
928 privkey
= ethUtil
.addHexPrefix(privkey
);
929 pubkey
= ethUtil
.addHexPrefix(pubkey
);
931 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
932 var NasAccount
= require("nebulas").Account
;
933 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
934 // privkey = privKeyBuffer.toString('hex');
935 console
.log(privkey
);
936 var nasAccount
= NasAccount
.NewAccount(privKeyBuffer
);
937 // var addressBuffer = ethUtil.privateToAddress(privKeyBuffer);
938 // var hexAddress = addressBuffer.toString('hex');
939 // var checksumAddress = ethUtil.toChecksumAddress(hexAddress);
940 address
= nasAccount
.getAddressString();
941 privkey
= nasAccount
.getPrivateKeyString();
942 pubkey
= nasAccount
.getPublicKeyString();
944 // Ripple values are different
945 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
946 privkey
= convertRipplePriv(privkey
);
947 address
= convertRippleAdrr(address
);
949 // Bitcoin Cash address format may vary
950 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
951 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
952 if (bchAddrType
== "cashaddr") {
953 address
= bchaddr
.toCashAddress(address
);
955 else if (bchAddrType
== "bitpay") {
956 address
= bchaddr
.toBitpayAddress(address
);
959 // Segwit addresses are different
961 if (!segwitAvailable
) {
965 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
966 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
967 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
969 else if (isP2wpkhInP2sh
) {
970 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
971 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
972 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
973 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
974 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
977 addAddressToList(indexText
, address
, pubkey
, privkey
);
989 function showMore() {
990 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
991 if (isNaN(rowsToAdd
)) {
993 DOM
.rowsToAdd
.val("20");
995 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
997 start
= lastIndexInTable() + 1;
1000 var newStart
= start
+ rowsToAdd
;
1001 DOM
.moreRowsStartIndex
.val(newStart
);
1003 if (rowsToAdd
> 200) {
1004 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1005 msg
+= "Do you want to continue?";
1006 if (!confirm(msg
)) {
1010 displayAddresses(start
, rowsToAdd
);
1013 function clearDisplay() {
1014 clearAddressesList();
1016 hideValidationError();
1019 function clearAddressesList() {
1020 DOM
.addresses
.empty();
1025 function stopGenerating() {
1026 while (generationProcesses
.length
> 0) {
1027 var generation
= generationProcesses
.shift();
1032 function clearKeys() {
1037 function clearRootKey() {
1038 DOM
.rootKey
.val("");
1041 function clearDerivedKeys() {
1042 DOM
.extendedPrivKey
.val("");
1043 DOM
.extendedPubKey
.val("");
1044 DOM
.bip44accountXprv
.val("");
1045 DOM
.bip44accountXpub
.val("");
1048 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1049 var row
= $(addressRowTemplate
.html());
1051 var indexCell
= row
.find(".index span");
1052 var addressCell
= row
.find(".address span");
1053 var pubkeyCell
= row
.find(".pubkey span");
1054 var privkeyCell
= row
.find(".privkey span");
1056 indexCell
.text(indexText
);
1057 addressCell
.text(address
);
1058 pubkeyCell
.text(pubkey
);
1059 privkeyCell
.text(privkey
);
1062 indexCell
.addClass("invisible");
1065 addressCell
.addClass("invisible");
1068 pubkeyCell
.addClass("invisible");
1071 privkeyCell
.addClass("invisible");
1073 DOM
.addresses
.append(row
);
1074 var rowShowQrEls
= row
.find("[data-show-qr]");
1075 setQrEvents(rowShowQrEls
);
1078 function hasStrongRandom() {
1079 return 'crypto' in window
&& window
['crypto'] !== null;
1082 function disableForms() {
1083 $("form").on("submit", function(e
) {
1088 function parseIntNoNaN(val
, defaultVal
) {
1089 var v
= parseInt(val
);
1096 function showPending() {
1098 .text("Calculating...")
1102 function findNearestWord(word
) {
1103 var language
= getLanguage();
1104 var words
= WORDLISTS
[language
];
1105 var minDistance
= 99;
1106 var closestWord
= words
[0];
1107 for (var i
=0; i
<words
.length
; i
++) {
1108 var comparedTo
= words
[i
];
1109 if (comparedTo
.indexOf(word
) == 0) {
1112 var distance
= Levenshtein
.get(word
, comparedTo
);
1113 if (distance
< minDistance
) {
1114 closestWord
= comparedTo
;
1115 minDistance
= distance
;
1121 function hidePending() {
1127 function populateNetworkSelect() {
1128 for (var i
=0; i
<networks
.length
; i
++) {
1129 var network
= networks
[i
];
1130 var option
= $("<option>");
1131 option
.attr("value", i
);
1132 option
.text(network
.name
);
1133 if (network
.name
== "BTC - Bitcoin") {
1134 option
.prop("selected", true);
1136 DOM
.phraseNetwork
.append(option
);
1140 function populateClientSelect() {
1141 for (var i
=0; i
<clients
.length
; i
++) {
1142 var client
= clients
[i
];
1143 var option
= $("<option>");
1144 option
.attr("value", i
);
1145 option
.text(client
.name
);
1146 DOM
.bip32Client
.append(option
);
1150 function getLanguage() {
1151 var defaultLanguage
= "english";
1152 // Try to get from existing phrase
1153 var language
= getLanguageFromPhrase();
1154 // Try to get from url if not from phrase
1155 if (language
.length
== 0) {
1156 language
= getLanguageFromUrl();
1158 // Default to English if no other option
1159 if (language
.length
== 0) {
1160 language
= defaultLanguage
;
1165 function getLanguageFromPhrase(phrase
) {
1166 // Check if how many words from existing phrase match a language.
1169 phrase
= DOM
.phrase
.val();
1171 if (phrase
.length
> 0) {
1172 var words
= phraseToWordArray(phrase
);
1173 var languageMatches
= {};
1174 for (l
in WORDLISTS
) {
1175 // Track how many words match in this language
1176 languageMatches
[l
] = 0;
1177 for (var i
=0; i
<words
.length
; i
++) {
1178 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1179 if (wordInLanguage
) {
1180 languageMatches
[l
]++;
1183 // Find languages with most word matches.
1184 // This is made difficult due to commonalities between Chinese
1185 // simplified vs traditional.
1186 var mostMatches
= 0;
1187 var mostMatchedLanguages
= [];
1188 for (var l
in languageMatches
) {
1189 var numMatches
= languageMatches
[l
];
1190 if (numMatches
> mostMatches
) {
1191 mostMatches
= numMatches
;
1192 mostMatchedLanguages
= [l
];
1194 else if (numMatches
== mostMatches
) {
1195 mostMatchedLanguages
.push(l
);
1199 if (mostMatchedLanguages
.length
> 0) {
1200 // Use first language and warn if multiple detected
1201 language
= mostMatchedLanguages
[0];
1202 if (mostMatchedLanguages
.length
> 1) {
1203 console
.warn("Multiple possible languages");
1204 console
.warn(mostMatchedLanguages
);
1211 function getLanguageFromUrl() {
1212 for (var language
in WORDLISTS
) {
1213 if (window
.location
.hash
.indexOf(language
) > -1) {
1220 function setMnemonicLanguage() {
1221 var language
= getLanguage();
1222 // Load the bip39 mnemonic generator for this language if required
1223 if (!(language
in mnemonics
)) {
1224 mnemonics
[language
] = new Mnemonic(language
);
1226 mnemonic
= mnemonics
[language
];
1229 function convertPhraseToNewLanguage() {
1230 var oldLanguage
= getLanguageFromPhrase();
1231 var newLanguage
= getLanguageFromUrl();
1232 var oldPhrase
= DOM
.phrase
.val();
1233 var oldWords
= phraseToWordArray(oldPhrase
);
1235 for (var i
=0; i
<oldWords
.length
; i
++) {
1236 var oldWord
= oldWords
[i
];
1237 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1238 var newWord
= WORDLISTS
[newLanguage
][index
];
1239 newWords
.push(newWord
);
1241 newPhrase
= wordArrayToPhrase(newWords
);
1245 // TODO look at jsbip39 - mnemonic.splitWords
1246 function phraseToWordArray(phrase
) {
1247 var words
= phrase
.split(/\s/g);
1249 for (var i
=0; i
<words
.length
; i
++) {
1250 var word
= words
[i
];
1251 if (word
.length
> 0) {
1252 noBlanks
.push(word
);
1258 // TODO look at jsbip39 - mnemonic.joinWords
1259 function wordArrayToPhrase(words
) {
1260 var phrase
= words
.join(" ");
1261 var language
= getLanguageFromPhrase(phrase
);
1262 if (language
== "japanese") {
1263 phrase
= words
.join("\u3000");
1268 function isUsingOwnEntropy() {
1269 return DOM
.useEntropy
.prop("checked");
1272 function setMnemonicFromEntropy() {
1273 clearEntropyFeedback();
1274 // Get entropy value
1275 var entropyStr
= DOM
.entropy
.val();
1276 // Work out minimum base for entropy
1277 var entropy
= Entropy
.fromString(entropyStr
);
1278 if (entropy
.binaryStr
.length
== 0) {
1281 // Show entropy details
1282 showEntropyFeedback(entropy
);
1283 // Use entropy hash if not using raw entropy
1284 var bits
= entropy
.binaryStr
;
1285 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1286 if (mnemonicLength
!= "raw") {
1287 // Get bits by hashing entropy with SHA256
1288 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1289 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1290 bits
= BigInteger
.parse(hex
, 16).toString(2);
1291 while (bits
.length
% 256 != 0) {
1294 // Truncate hash to suit number of words
1295 mnemonicLength
= parseInt(mnemonicLength
);
1296 var numberOfBits
= 32 * mnemonicLength
/ 3;
1297 bits
= bits
.substring(0, numberOfBits
);
1298 // show warning for weak entropy override
1299 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1300 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1303 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1307 // hide warning for weak entropy override
1308 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1310 // Discard trailing entropy
1311 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1312 var start
= bits
.length
- bitsToUse
;
1313 var binaryStr
= bits
.substring(start
);
1314 // Convert entropy string to numeric array
1315 var entropyArr
= [];
1316 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1317 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1318 var entropyByte
= parseInt(byteAsBits
, 2);
1319 entropyArr
.push(entropyByte
)
1321 // Convert entropy array to mnemonic
1322 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1323 // Set the mnemonic in the UI
1324 DOM
.phrase
.val(phrase
);
1325 // Show the word indexes
1327 // Show the checksum
1331 function clearEntropyFeedback() {
1332 DOM
.entropyCrackTime
.text("...");
1333 DOM
.entropyType
.text("");
1334 DOM
.entropyWordCount
.text("0");
1335 DOM
.entropyEventCount
.text("0");
1336 DOM
.entropyBitsPerEvent
.text("0");
1337 DOM
.entropyBits
.text("0");
1338 DOM
.entropyFiltered
.html(" ");
1339 DOM
.entropyBinary
.html(" ");
1342 function showEntropyFeedback(entropy
) {
1343 var numberOfBits
= entropy
.binaryStr
.length
;
1344 var timeToCrack
= "unknown";
1346 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1347 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1348 if (z
.feedback
.warning
!= "") {
1349 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1353 console
.log("Error detecting entropy strength with zxcvbn:");
1356 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1357 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1358 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1359 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1360 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1361 DOM
.entropyType
.text(entropyTypeStr
);
1362 DOM
.entropyCrackTime
.text(timeToCrack
);
1363 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1364 DOM
.entropyBits
.text(numberOfBits
);
1365 DOM
.entropyWordCount
.text(wordCount
);
1366 DOM
.entropyBinary
.text(spacedBinaryStr
);
1367 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1368 // detect and warn of filtering
1369 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1370 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1371 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1373 DOM
.entropyFilterWarning
.removeClass('hidden');
1376 DOM
.entropyFilterWarning
.addClass('hidden');
1380 function getEntropyTypeStr(entropy
) {
1381 var typeStr
= entropy
.base
.str
;
1382 // Add some detail if these are cards
1383 if (entropy
.base
.asInt
== 52) {
1384 var cardDetail
= []; // array of message strings
1385 // Detect duplicates
1387 var dupeTracker
= {};
1388 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1389 var card
= entropy
.base
.parts
[i
];
1390 var cardUpper
= card
.toUpperCase();
1391 if (cardUpper
in dupeTracker
) {
1394 dupeTracker
[cardUpper
] = true;
1396 if (dupes
.length
> 0) {
1397 var dupeWord
= "duplicates";
1398 if (dupes
.length
== 1) {
1399 dupeWord
= "duplicate";
1401 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1402 if (dupes
.length
> 3) {
1405 cardDetail
.push(msg
);
1408 var uniqueCards
= [];
1409 for (var uniqueCard
in dupeTracker
) {
1410 uniqueCards
.push(uniqueCard
);
1412 if (uniqueCards
.length
== 52) {
1413 cardDetail
.unshift("full deck");
1415 // Detect missing cards
1416 var values
= "A23456789TJQK";
1418 var missingCards
= [];
1419 for (var i
=0; i
<suits
.length
; i
++) {
1420 for (var j
=0; j
<values
.length
; j
++) {
1421 var card
= values
[j
] + suits
[i
];
1422 if (!(card
in dupeTracker
)) {
1423 missingCards
.push(card
);
1427 // Display missing cards if six or less, ie clearly going for full deck
1428 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1429 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1430 if (missingCards
.length
> 3) {
1433 cardDetail
.push(msg
);
1435 // Add card details to typeStr
1436 if (cardDetail
.length
> 0) {
1437 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1443 function setQrEvents(els
) {
1444 els
.on("mouseenter", createQr
);
1445 els
.on("mouseleave", destroyQr
);
1446 els
.on("click", toggleQr
);
1449 function createQr(e
) {
1450 var content
= e
.target
.textContent
|| e
.target
.value
;
1458 DOM
.qrImage
.append(qrEl
);
1460 DOM
.qrHider
.addClass("hidden");
1463 DOM
.qrHider
.removeClass("hidden");
1465 DOM
.qrContainer
.removeClass("hidden");
1469 function destroyQr() {
1470 DOM
.qrImage
.text("");
1471 DOM
.qrContainer
.addClass("hidden");
1474 function toggleQr() {
1476 DOM
.qrHider
.toggleClass("hidden");
1477 DOM
.qrHint
.toggleClass("hidden");
1480 function bip44TabSelected() {
1481 return DOM
.bip44tab
.hasClass("active");
1484 function bip32TabSelected() {
1485 return DOM
.bip32tab
.hasClass("active");
1488 function networkHasSegwit() {
1490 if ("baseNetwork" in network
) {
1491 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1493 // check if only p2wpkh params are required
1494 if (p2wpkhSelected()) {
1495 return "p2wpkh" in n
;
1497 // check if only p2wpkh-in-p2sh params are required
1498 else if (p2wpkhInP2shSelected()) {
1499 return "p2wpkhInP2sh" in n
;
1501 // require both if it's unclear which params are required
1502 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1505 function bip49TabSelected() {
1506 return DOM
.bip49tab
.hasClass("active");
1509 function bip84TabSelected() {
1510 return DOM
.bip84tab
.hasClass("active");
1513 function bip141TabSelected() {
1514 return DOM
.bip141tab
.hasClass("active");
1517 function setHdCoin(coinValue
) {
1518 DOM
.bip44coin
.val(coinValue
);
1519 DOM
.bip49coin
.val(coinValue
);
1520 DOM
.bip84coin
.val(coinValue
);
1523 function showSegwitAvailable() {
1524 DOM
.bip49unavailable
.addClass("hidden");
1525 DOM
.bip49available
.removeClass("hidden");
1526 DOM
.bip84unavailable
.addClass("hidden");
1527 DOM
.bip84available
.removeClass("hidden");
1528 DOM
.bip141unavailable
.addClass("hidden");
1529 DOM
.bip141available
.removeClass("hidden");
1532 function showSegwitUnavailable() {
1533 DOM
.bip49available
.addClass("hidden");
1534 DOM
.bip49unavailable
.removeClass("hidden");
1535 DOM
.bip84available
.addClass("hidden");
1536 DOM
.bip84unavailable
.removeClass("hidden");
1537 DOM
.bip141available
.addClass("hidden");
1538 DOM
.bip141unavailable
.removeClass("hidden");
1541 function adjustNetworkForSegwit() {
1542 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1543 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1545 // See https://github.com/iancoleman/bip39/issues/125
1546 var segwitNetworks
= null;
1547 // if a segwit network is alread selected, need to use base network to
1548 // look up new parameters
1549 if ("baseNetwork" in network
) {
1550 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1552 // choose the right segwit params
1553 if (p2wpkhSelected() && "p2wpkh" in network
) {
1554 network
= network
.p2wpkh
;
1556 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1557 network
= network
.p2wpkhInP2sh
;
1561 function lastIndexInTable() {
1562 var pathText
= DOM
.addresses
.find(".index").last().text();
1563 var pathBits
= pathText
.split("/");
1564 var lastBit
= pathBits
[pathBits
.length
-1];
1565 var lastBitClean
= lastBit
.replace("'", "");
1566 return parseInt(lastBitClean
);
1569 function uint8ArrayToHex(a
) {
1571 for (var i
=0; i
<a
.length
; i
++) {
1572 var h
= a
[i
].toString(16);
1573 while (h
.length
< 2) {
1581 function showWordIndexes() {
1582 var phrase
= DOM
.phrase
.val();
1583 var words
= phraseToWordArray(phrase
);
1584 var wordIndexes
= [];
1585 var language
= getLanguage();
1586 for (var i
=0; i
<words
.length
; i
++) {
1587 var word
= words
[i
];
1588 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1589 wordIndexes
.push(wordIndex
);
1591 var wordIndexesStr
= wordIndexes
.join(", ");
1592 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1595 function showChecksum() {
1596 var phrase
= DOM
.phrase
.val();
1597 var words
= phraseToWordArray(phrase
);
1598 var checksumBitlength
= words
.length
/ 3;
1601 var language
= getLanguage();
1602 for (var i
=words
.length
-1; i
>=0; i
--) {
1603 var word
= words
[i
];
1604 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1605 var wordBinary
= wordIndex
.toString(2);
1606 while (wordBinary
.length
< 11) {
1607 wordBinary
= "0" + wordBinary
;
1609 var binaryStr
= wordBinary
+ binaryStr
;
1610 if (binaryStr
.length
>= checksumBitlength
) {
1611 var start
= binaryStr
.length
- checksumBitlength
;
1612 var end
= binaryStr
.length
;
1613 checksum
= binaryStr
.substring(start
, end
);
1614 // add spaces so the last group is 11 bits, not the first
1615 checksum
= checksum
.split("").reverse().join("")
1616 checksum
= addSpacesEveryElevenBits(checksum
);
1617 checksum
= checksum
.split("").reverse().join("")
1621 DOM
.entropyChecksum
.text(checksum
);
1624 function updateCsv() {
1625 var tableCsv
= "path,address,public key,private key\n";
1626 var rows
= DOM
.addresses
.find("tr");
1627 for (var i
=0; i
<rows
.length
; i
++) {
1628 var row
= $(rows
[i
]);
1629 var cells
= row
.find("td");
1630 for (var j
=0; j
<cells
.length
; j
++) {
1631 var cell
= $(cells
[j
]);
1632 if (!cell
.children().hasClass("invisible")) {
1633 tableCsv
= tableCsv
+ cell
.text();
1635 if (j
!= cells
.length
- 1) {
1636 tableCsv
= tableCsv
+ ",";
1639 tableCsv
= tableCsv
+ "\n";
1641 DOM
.csv
.val(tableCsv
);
1644 function addSpacesEveryElevenBits(binaryStr
) {
1645 return binaryStr
.match(/.{1,11}/g).join(" ");
1650 name: "AC - Asiacoin",
1651 onSelect: function() {
1652 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1657 name: "ACC - Adcoin",
1658 onSelect: function() {
1659 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1664 name: "AUR - Auroracoin",
1665 onSelect: function() {
1666 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1672 onSelect: function() {
1673 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1678 name: "ANON - ANON",
1679 onSelect: function() {
1680 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1685 name: "BCA - Bitcoin Atom",
1686 onSelect: function() {
1687 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1692 name: "BCH - Bitcoin Cash",
1693 onSelect: function() {
1694 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1699 name: "BEET - Beetlecoin",
1700 onSelect: function() {
1701 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1706 name: "BELA - Belacoin",
1707 onSelect: function() {
1708 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1713 name: "BLK - BlackCoin",
1714 onSelect: function() {
1715 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1720 name: "BND - Blocknode",
1721 onSelect: function() {
1722 network
= bitcoinjs
.bitcoin
.networks
.blocknode
;
1727 name: "tBND - Blocknode Testnet",
1728 onSelect: function() {
1729 network
= bitcoinjs
.bitcoin
.networks
.blocknode_testnet
;
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
;
1748 name: "BST - BlockStamp",
1749 onSelect: function() {
1750 network
= bitcoinjs
.bitcoin
.networks
.blockstamp
;
1756 onSelect: function() {
1757 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1762 name: "BTC - Bitcoin",
1763 onSelect: function() {
1764 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1769 name: "BTC - Bitcoin Testnet",
1770 onSelect: function() {
1771 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1776 name: "BITG - Bitcoin Green",
1777 onSelect: function() {
1778 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1783 name: "BTCP - Bitcoin Private",
1784 onSelect: function() {
1785 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
1790 name: "BTCZ - Bitcoinz",
1791 onSelect: function() {
1792 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
1797 name: "BTDX - BitCloud",
1798 onSelect: function() {
1799 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
1804 name: "BTG - Bitcoin Gold",
1805 onSelect: function() {
1806 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
1811 name: "BTX - Bitcore",
1812 onSelect: function() {
1813 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
1818 name: "CCN - Cannacoin",
1819 onSelect: function() {
1820 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1825 name: "CESC - Cryptoescudo",
1826 onSelect: function() {
1827 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1832 name: "CDN - Canadaecoin",
1833 onSelect: function() {
1834 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
1839 name: "CLAM - Clams",
1840 onSelect: function() {
1841 network
= bitcoinjs
.bitcoin
.networks
.clam
;
1846 name: "CLO - Callisto",
1847 segwitAvailable: false,
1848 onSelect: function() {
1849 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1854 name: "CLUB - Clubcoin",
1855 onSelect: function() {
1856 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
1861 name: "CMP - Compcoin",
1862 onSelect: function() {
1863 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
1868 name: "CRAVE - Crave",
1869 onSelect: function() {
1870 network
= bitcoinjs
.bitcoin
.networks
.crave
;
1875 name: "CRW - Crown",
1876 onSelect: function() {
1877 network
= bitcoinjs
.bitcoin
.networks
.crown
;
1882 name: "DASH - Dash",
1883 onSelect: function() {
1884 network
= bitcoinjs
.bitcoin
.networks
.dash
;
1889 name: "DASH - Dash Testnet",
1890 onSelect: function() {
1891 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
1896 name: "DFC - Defcoin",
1897 onSelect: function() {
1898 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
1903 name: "DGB - Digibyte",
1904 onSelect: function() {
1905 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
1910 name: "DGC - Digitalcoin",
1911 onSelect: function() {
1912 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
1917 name: "DMD - Diamond",
1918 onSelect: function() {
1919 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
1924 name: "DNR - Denarius",
1925 onSelect: function() {
1926 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
1931 name: "DOGE - Dogecoin",
1932 onSelect: function() {
1933 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
1938 name: "DXN - DEXON",
1939 onSelect: function() {
1940 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1945 name: "ECN - Ecoin",
1946 onSelect: function() {
1947 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
1952 name: "EDRC - Edrcoin",
1953 onSelect: function() {
1954 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
1959 name: "EFL - Egulden",
1960 onSelect: function() {
1961 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
1966 name: "EMC2 - Einsteinium",
1967 onSelect: function() {
1968 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
1973 name: "ERC - Europecoin",
1974 onSelect: function() {
1975 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
1980 name: "ETC - Ethereum Classic",
1981 segwitAvailable: false,
1982 onSelect: function() {
1983 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1988 name: "ETH - Ethereum",
1989 onSelect: function() {
1990 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1995 name: "EXCL - Exclusivecoin",
1996 onSelect: function() {
1997 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
2002 name: "EXCC - ExchangeCoin",
2003 onSelect: function() {
2004 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
2009 name: "EXP - Expanse",
2010 segwitAvailable: false,
2011 onSelect: function() {
2012 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2017 name: "FJC - Fujicoin",
2018 onSelect: function() {
2019 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2024 name: "FLASH - Flashcoin",
2025 onSelect: function() {
2026 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2031 name: "FRST - Firstcoin",
2032 onSelect: function() {
2033 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2038 name: "FTC - Feathercoin",
2039 onSelect: function() {
2040 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2045 name: "GAME - GameCredits",
2046 onSelect: function() {
2047 network
= bitcoinjs
.bitcoin
.networks
.game
;
2052 name: "GBX - Gobyte",
2053 onSelect: function() {
2054 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2059 name: "GCR - GCRCoin",
2060 onSelect: function() {
2061 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2066 name: "GRC - Gridcoin",
2067 onSelect: function() {
2068 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2073 name: "HNC - Helleniccoin",
2074 onSelect: function() {
2075 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2080 name: "HUSH - Hush",
2081 onSelect: function() {
2082 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2087 name: "INSN - Insane",
2088 onSelect: function() {
2089 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2095 onSelect: function() {
2096 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2101 name: "IXC - Ixcoin",
2102 onSelect: function() {
2103 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2108 name: "JBS - Jumbucks",
2109 onSelect: function() {
2110 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2115 name: "KMD - Komodo",
2116 bip49available: false,
2117 onSelect: function() {
2118 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2123 name: "KOBO - Kobocoin",
2124 bip49available: false,
2125 onSelect: function() {
2126 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2131 name: "LBC - Library Credits",
2132 onSelect: function() {
2133 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2138 name: "LCC - Litecoincash",
2139 onSelect: function() {
2140 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2145 name: "LDCN - Landcoin",
2146 onSelect: function() {
2147 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2152 name: "LINX - Linx",
2153 onSelect: function() {
2154 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2159 name: "LKR - Lkrcoin",
2160 segwitAvailable: false,
2161 onSelect: function() {
2162 network
= bitcoinjs
.bitcoin
.networks
.lkrcoin
;
2167 name: "LTC - Litecoin",
2168 onSelect: function() {
2169 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2171 DOM
.litecoinLtubContainer
.removeClass("hidden");
2175 name: "LTZ - LitecoinZ",
2176 onSelect: function() {
2177 network
= bitcoinjs
.bitcoin
.networks
.litecoinz
;
2182 name: "LYNX - Lynx",
2183 onSelect: function() {
2184 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2189 name: "MAZA - Maza",
2190 onSelect: function() {
2191 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2196 name: "MEC - Megacoin",
2197 onSelect: function() {
2198 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2204 segwitAvailable: false,
2205 onSelect: function() {
2206 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2211 name: "MNX - Minexcoin",
2212 onSelect: function() {
2213 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2218 name: "MONA - Monacoin",
2219 onSelect: function() {
2220 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2225 name: "MUSIC - Musicoin",
2226 segwitAvailable: false,
2227 onSelect: function() {
2228 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2233 name: "NAV - Navcoin",
2234 onSelect: function() {
2235 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2240 name: "NAS - Nebulas",
2241 onSelect: function() {
2242 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2247 name: "NEBL - Neblio",
2248 onSelect: function() {
2249 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2254 name: "NEOS - Neoscoin",
2255 onSelect: function() {
2256 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2261 name: "NIX - NIX Platform",
2262 onSelect: function() {
2263 network
= bitcoinjs
.bitcoin
.networks
.nix
;
2268 name: "NLG - Gulden",
2269 onSelect: function() {
2270 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2275 name: "NMC - Namecoin",
2276 onSelect: function() {
2277 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2282 name: "NRG - Energi",
2283 onSelect: function() {
2284 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2289 name: "NRO - Neurocoin",
2290 onSelect: function() {
2291 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2296 name: "NSR - Nushares",
2297 onSelect: function() {
2298 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2303 name: "NYC - Newyorkc",
2304 onSelect: function() {
2305 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2310 name: "NVC - Novacoin",
2311 onSelect: function() {
2312 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2317 name: "OK - Okcash",
2318 onSelect: function() {
2319 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2324 name: "OMNI - Omnicore",
2325 onSelect: function() {
2326 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2331 name: "ONX - Onixcoin",
2332 onSelect: function() {
2333 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2338 name: "PHR - Phore",
2339 onSelect: function() {
2340 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2345 name: "PINK - Pinkcoin",
2346 onSelect: function() {
2347 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2352 name: "PIRL - Pirl",
2353 segwitAvailable: false,
2354 onSelect: function() {
2355 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2360 name: "PIVX - PIVX",
2361 onSelect: function() {
2362 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2367 name: "PIVX - PIVX Testnet",
2368 onSelect: function() {
2369 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2375 segwitAvailable: false,
2376 onSelect: function() {
2377 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2382 name: "POSW - POSWcoin",
2383 onSelect: function() {
2384 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2389 name: "POT - Potcoin",
2390 onSelect: function() {
2391 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2396 name: "PPC - Peercoin",
2397 onSelect: function() {
2398 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2403 name: "PRJ - ProjectCoin",
2404 onSelect: function() {
2405 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2410 name: "PSB - Pesobit",
2411 onSelect: function() {
2412 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2417 name: "PUT - Putincoin",
2418 onSelect: function() {
2419 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2424 name: "RVN - Ravencoin",
2425 onSelect: function() {
2426 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2431 name: "RBY - Rubycoin",
2432 onSelect: function() {
2433 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2438 name: "RDD - Reddcoin",
2439 onSelect: function() {
2440 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2445 name: "RVR - RevolutionVR",
2446 onSelect: function() {
2447 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2452 name: "SAFE - Safecoin",
2453 onSelect: function() {
2454 network
= bitcoinjs
.bitcoin
.networks
.safecoin
;
2459 name: "SLS - Salus",
2460 onSelect: function() {
2461 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2466 name: "SDC - ShadowCash",
2467 onSelect: function() {
2468 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2473 name: "SDC - ShadowCash Testnet",
2474 onSelect: function() {
2475 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2480 name: "SLM - Slimcoin",
2481 onSelect: function() {
2482 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2487 name: "SLM - Slimcoin Testnet",
2488 onSelect: function() {
2489 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2494 name: "SLR - Solarcoin",
2495 onSelect: function() {
2496 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2501 name: "SMLY - Smileycoin",
2502 onSelect: function() {
2503 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2508 name: "STASH - Stash",
2509 onSelect: function() {
2510 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2515 name: "STASH - Stash Testnet",
2516 onSelect: function() {
2517 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2522 name: "STRAT - Stratis",
2523 onSelect: function() {
2524 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2529 name: "TSTRAT - Stratis Testnet",
2530 onSelect: function() {
2531 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2536 name: "SYS - Syscoin",
2537 onSelect: function() {
2538 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2543 name: "THC - Hempcoin",
2544 onSelect: function() {
2545 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2551 onSelect: function() {
2552 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2557 name: "USC - Ultimatesecurecash",
2558 onSelect: function() {
2559 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2564 name: "USNBT - NuBits",
2565 onSelect: function() {
2566 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2571 name: "UNO - Unobtanium",
2572 onSelect: function() {
2573 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2578 name: "VASH - Vpncoin",
2579 onSelect: function() {
2580 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2585 name: "VIA - Viacoin",
2586 onSelect: function() {
2587 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2592 name: "VIA - Viacoin Testnet",
2593 onSelect: function() {
2594 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2599 name: "VIVO - Vivo",
2600 onSelect: function() {
2601 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2606 name: "VTC - Vertcoin",
2607 onSelect: function() {
2608 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2613 name: "WC - Wincoin",
2614 onSelect: function() {
2615 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2620 name: "XAX - Artax",
2621 onSelect: function() {
2622 network
= bitcoinjs
.bitcoin
.networks
.artax
;
2627 name: "XBC - Bitcoinplus",
2628 onSelect: function() {
2629 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
2634 name: "XMY - Myriadcoin",
2635 onSelect: function() {
2636 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
2641 name: "XRP - Ripple",
2642 onSelect: function() {
2643 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2648 name: "XVC - Vcash",
2649 onSelect: function() {
2650 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
2655 name: "XVG - Verge",
2656 onSelect: function() {
2657 network
= bitcoinjs
.bitcoin
.networks
.verge
;
2662 name: "XUEZ - Xuez",
2663 segwitAvailable: false,
2664 onSelect: function() {
2665 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
2670 name: "XWC - Whitecoin",
2671 onSelect: function() {
2672 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
2677 name: "XZC - Zcoin",
2678 onSelect: function() {
2679 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
2684 name: "ZCL - Zclassic",
2685 onSelect: function() {
2686 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
2691 name: "ZEC - Zcash",
2692 onSelect: function() {
2693 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
2698 name: "ZEN - Zencash",
2699 onSelect: function() {
2700 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
2708 name: "Bitcoin Core",
2709 onSelect: function() {
2710 DOM
.bip32path
.val("m/0'/0'");
2711 DOM
.hardenedAddresses
.prop('checked', true);
2715 name: "blockchain.info",
2716 onSelect: function() {
2717 DOM
.bip32path
.val("m/44'/0'/0'");
2718 DOM
.hardenedAddresses
.prop('checked', false);
2722 name: "MultiBit HD",
2723 onSelect: function() {
2724 DOM
.bip32path
.val("m/0'/0");
2725 DOM
.hardenedAddresses
.prop('checked', false);
2729 name: "Coinomi, Ledger",
2730 onSelect: function() {
2731 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
2732 DOM
.hardenedAddresses
.prop('checked', false);