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(function() {
238 var entropy
= mnemonic
.toRawEntropyHex(DOM
.phrase
.val());
239 if (entropy
!== null) {
240 DOM
.entropyMnemonicLength
.val("raw");
241 DOM
.entropy
.val(entropy
);
246 function phraseChanged() {
248 setMnemonicLanguage();
249 // Get the mnemonic phrase
250 var phrase
= DOM
.phrase
.val();
251 var errorText
= findPhraseErrors(phrase
);
253 showValidationError(errorText
);
256 // Calculate and display
257 var passphrase
= DOM
.passphrase
.val();
258 calcBip32RootKeyFromSeed(phrase
, passphrase
);
259 calcForDerivationPath();
260 // Show the word indexes
264 function tabChanged() {
266 adjustNetworkForSegwit();
267 var phrase
= DOM
.phrase
.val();
269 // Calculate and display for mnemonic
270 var errorText
= findPhraseErrors(phrase
);
272 showValidationError(errorText
);
275 // Calculate and display
276 var passphrase
= DOM
.passphrase
.val();
277 calcBip32RootKeyFromSeed(phrase
, passphrase
);
280 // Calculate and display for root key
281 var rootKeyBase58
= DOM
.rootKey
.val();
282 var errorText
= validateRootKey(rootKeyBase58
);
284 showValidationError(errorText
);
287 // Calculate and display
288 calcBip32RootKeyFromBase58(rootKeyBase58
);
290 calcForDerivationPath();
293 function delayedEntropyChanged() {
294 hideValidationError();
296 if (entropyChangeTimeoutEvent
!= null) {
297 clearTimeout(entropyChangeTimeoutEvent
);
299 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
302 function entropyChanged() {
303 // If blank entropy, clear mnemonic, addresses, errors
304 if (DOM
.entropy
.val().trim().length
== 0) {
306 clearEntropyFeedback();
308 DOM
.phraseSplit
.val("");
309 showValidationError("Blank entropy");
312 // Get the current phrase to detect changes
313 var phrase
= DOM
.phrase
.val();
314 // Set the phrase from the entropy
315 setMnemonicFromEntropy();
316 // Recalc addresses if the phrase has changed
317 var newPhrase
= DOM
.phrase
.val();
318 if (newPhrase
!= phrase
) {
319 if (newPhrase
.length
== 0) {
331 function delayedRootKeyChanged() {
332 // Warn if there is an existing mnemonic or passphrase.
333 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
334 if (!confirm("This will clear existing mnemonic and passphrase")) {
335 DOM
.rootKey
.val(bip32RootKey
);
339 hideValidationError();
341 // Clear existing mnemonic and passphrase
343 DOM
.phraseSplit
.val("");
344 DOM
.passphrase
.val("");
346 if (rootKeyChangedTimeoutEvent
!= null) {
347 clearTimeout(rootKeyChangedTimeoutEvent
);
349 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
352 function rootKeyChanged() {
354 hideValidationError();
355 var rootKeyBase58
= DOM
.rootKey
.val();
356 var errorText
= validateRootKey(rootKeyBase58
);
358 showValidationError(errorText
);
361 // Calculate and display
362 calcBip32RootKeyFromBase58(rootKeyBase58
);
363 calcForDerivationPath();
366 function litecoinUseLtubChanged() {
367 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
368 if (litecoinUseLtub
) {
369 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
372 network
= bitcoinjs
.bitcoin
.networks
.litecoinXprv
;
377 function calcForDerivationPath() {
379 clearAddressesList();
381 // Don't show segwit if it's selected but network doesn't support it
382 if (segwitSelected() && !networkHasSegwit()) {
383 showSegwitUnavailable();
387 showSegwitAvailable();
388 // Get the derivation path
389 var derivationPath
= getDerivationPath();
390 var errorText
= findDerivationPathErrors(derivationPath
);
392 showValidationError(errorText
);
395 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
396 if (bip44TabSelected()) {
399 else if (bip49TabSelected()) {
402 else if (bip84TabSelected()) {
408 function generateClicked() {
409 if (isUsingOwnEntropy()) {
414 setTimeout(function() {
415 setMnemonicLanguage();
416 var phrase
= generateRandomPhrase();
424 function languageChanged() {
425 setTimeout(function() {
426 setMnemonicLanguage();
427 if (DOM
.phrase
.val().length
> 0) {
428 var newPhrase
= convertPhraseToNewLanguage();
429 DOM
.phrase
.val(newPhrase
);
430 writeSplitPhrase(newPhrase
);
434 DOM
.generate
.trigger("click");
439 function bitcoinCashAddressTypeChange() {
443 function toggleIndexes() {
444 showIndex
= !showIndex
;
445 $("td.index span").toggleClass("invisible");
448 function toggleAddresses() {
449 showAddress
= !showAddress
;
450 $("td.address span").toggleClass("invisible");
453 function togglePublicKeys() {
454 showPubKey
= !showPubKey
;
455 $("td.pubkey span").toggleClass("invisible");
458 function togglePrivateKeys() {
459 showPrivKey
= !showPrivKey
;
460 $("td.privkey span").toggleClass("invisible");
463 function privacyScreenToggled() {
464 // private-data contains elements added to DOM at runtime
465 // so catch all by adding visual privacy class to the root of the DOM
466 if (DOM
.privacyScreenToggle
.prop("checked")) {
467 $("body").addClass("visual-privacy");
470 $("body").removeClass("visual-privacy");
476 function generateRandomPhrase() {
477 if (!hasStrongRandom()) {
478 var errorText
= "This browser does not support strong randomness";
479 showValidationError(errorText
);
482 // get the amount of entropy to use
483 var numWords
= parseInt(DOM
.generatedStrength
.val());
484 var strength
= numWords
/ 3 * 32;
485 var buffer
= new Uint8Array(strength
/ 8);
486 // create secure entropy
487 var data
= crypto
.getRandomValues(buffer
);
489 var words
= mnemonic
.toMnemonic(data
);
490 DOM
.phrase
.val(words
);
491 writeSplitPhrase(words
);
493 var entropyHex
= uint8ArrayToHex(data
);
494 DOM
.entropy
.val(entropyHex
);
495 // ensure entropy fields are consistent with what is being displayed
496 DOM
.entropyMnemonicLength
.val("raw");
500 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
501 seed
= mnemonic
.toSeed(phrase
, passphrase
);
502 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
504 bip32RootKey
= groestlcoinjs
.HDNode
.fromSeedHex(seed
, network
);
508 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
510 calcBip32RootKeyFromBase58GRS(rootKeyBase58
);
513 // try parsing with various segwit network params since this extended
514 // key may be from any one of them.
515 if (networkHasSegwit()) {
517 if ("baseNetwork" in n
) {
518 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
520 // try parsing using base network params
522 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
526 // try parsing using p2wpkh params
529 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
534 // try parsing using p2wpkh-in-p2sh network params
535 if ("p2wpkhInP2sh" in n
) {
537 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
543 // try the network params as currently specified
544 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
547 function calcBip32RootKeyFromBase58GRS(rootKeyBase58
) {
548 // try parsing with various segwit network params since this extended
549 // key may be from any one of them.
550 if (networkHasSegwit()) {
552 if ("baseNetwork" in n
) {
553 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
555 // try parsing using base network params
557 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
561 // try parsing using p2wpkh params
564 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
569 // try parsing using p2wpkh-in-p2sh network params
570 if ("p2wpkhInP2sh" in n
) {
572 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
578 // try the network params as currently specified
579 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
582 function calcBip32ExtendedKey(path
) {
583 // Check there's a root key to derive from
587 var extendedKey
= bip32RootKey
;
588 // Derive the key from the path
589 var pathBits
= path
.split("/");
590 for (var i
=0; i
<pathBits
.length
; i
++) {
591 var bit
= pathBits
[i
];
592 var index
= parseInt(bit
);
596 var hardened
= bit
[bit
.length
-1] == "'";
597 var isPriv
= !(extendedKey
.isNeutered());
598 var invalidDerivationPath
= hardened
&& !isPriv
;
599 if (invalidDerivationPath
) {
603 extendedKey
= extendedKey
.deriveHardened(index
);
606 extendedKey
= extendedKey
.derive(index
);
612 function showValidationError(errorText
) {
618 function hideValidationError() {
624 function findPhraseErrors(phrase
) {
625 // Preprocess the words
626 phrase
= mnemonic
.normalizeString(phrase
);
627 var words
= phraseToWordArray(phrase
);
628 // Detect blank phrase
629 if (words
.length
== 0) {
630 return "Blank mnemonic";
633 for (var i
=0; i
<words
.length
; i
++) {
635 var language
= getLanguage();
636 if (WORDLISTS
[language
].indexOf(word
) == -1) {
637 console
.log("Finding closest match to " + word
);
638 var nearestWord
= findNearestWord(word
);
639 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
642 // Check the words are valid
643 var properPhrase
= wordArrayToPhrase(words
);
644 var isValid
= mnemonic
.check(properPhrase
);
646 return "Invalid mnemonic";
651 function validateRootKey(rootKeyBase58
) {
653 return validateRootKeyGRS(rootKeyBase58
);
655 // try various segwit network params since this extended key may be from
657 if (networkHasSegwit()) {
659 if ("baseNetwork" in n
) {
660 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
662 // try parsing using base network params
664 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
668 // try parsing using p2wpkh params
671 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
676 // try parsing using p2wpkh-in-p2sh network params
677 if ("p2wpkhInP2sh" in n
) {
679 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
685 // try the network params as currently specified
687 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
690 return "Invalid root key";
695 function validateRootKeyGRS(rootKeyBase58
) {
696 // try various segwit network params since this extended key may be from
698 if (networkHasSegwit()) {
700 if ("baseNetwork" in n
) {
701 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
703 // try parsing using base network params
705 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
709 // try parsing using p2wpkh params
712 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
717 // try parsing using p2wpkh-in-p2sh network params
718 if ("p2wpkhInP2sh" in n
) {
720 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
726 // try the network params as currently specified
728 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
731 return "Invalid root key";
736 function getDerivationPath() {
737 if (bip44TabSelected()) {
738 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
739 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
740 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
741 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
743 path
+= purpose
+ "'/";
745 path
+= account
+ "'/";
747 DOM
.bip44path
.val(path
);
748 var derivationPath
= DOM
.bip44path
.val();
749 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
750 return derivationPath
;
752 else if (bip49TabSelected()) {
753 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
754 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
755 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
756 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
758 path
+= purpose
+ "'/";
760 path
+= account
+ "'/";
762 DOM
.bip49path
.val(path
);
763 var derivationPath
= DOM
.bip49path
.val();
764 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
765 return derivationPath
;
767 else if (bip84TabSelected()) {
768 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
769 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
770 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
771 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
773 path
+= purpose
+ "'/";
775 path
+= account
+ "'/";
777 DOM
.bip84path
.val(path
);
778 var derivationPath
= DOM
.bip84path
.val();
779 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
780 return derivationPath
;
782 else if (bip32TabSelected()) {
783 var derivationPath
= DOM
.bip32path
.val();
784 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
785 return derivationPath
;
787 else if (bip141TabSelected()) {
788 var derivationPath
= DOM
.bip141path
.val();
789 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
790 return derivationPath
;
793 console
.log("Unknown derivation path");
797 function findDerivationPathErrors(path
) {
798 // TODO is not perfect but is better than nothing
800 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
802 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
803 var maxDepth
= 255; // TODO verify this!!
804 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
805 if (path
[0] != "m") {
806 return "First character must be 'm'";
808 if (path
.length
> 1) {
809 if (path
[1] != "/") {
810 return "Separator must be '/'";
812 var indexes
= path
.split("/");
813 if (indexes
.length
> maxDepth
) {
814 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
816 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
817 var index
= indexes
[depth
];
818 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
819 if (invalidChars
.length
> 0) {
820 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
822 var indexValue
= parseInt(index
.replace("'", ""));
824 return "Invalid number at depth " + depth
;
826 if (indexValue
> maxIndexValue
) {
827 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
831 // Check root key exists or else derivation path is useless!
833 return "No root key";
835 // Check no hardened derivation path when using xpub keys
836 var hardenedPath
= path
.indexOf("'") > -1;
837 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
838 var hardened
= hardenedPath
|| hardenedAddresses
;
839 var isXpubkey
= bip32RootKey
.isNeutered();
840 if (hardened
&& isXpubkey
) {
841 return "Hardened derivation path is invalid with xpub key";
847 return networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin" || networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin Testnet";
850 function displayBip44Info() {
851 // Get the derivation path for the account
852 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
853 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
854 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
856 path
+= purpose
+ "'/";
858 path
+= account
+ "'/";
859 // Calculate the account extended keys
860 var accountExtendedKey
= calcBip32ExtendedKey(path
);
861 var accountXprv
= accountExtendedKey
.toBase58();
862 var accountXpub
= accountExtendedKey
.neutered().toBase58();
863 // Display the extended keys
864 DOM
.bip44accountXprv
.val(accountXprv
);
865 DOM
.bip44accountXpub
.val(accountXpub
);
868 function displayBip49Info() {
869 // Get the derivation path for the account
870 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
871 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
872 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
874 path
+= purpose
+ "'/";
876 path
+= account
+ "'/";
877 // Calculate the account extended keys
878 var accountExtendedKey
= calcBip32ExtendedKey(path
);
879 var accountXprv
= accountExtendedKey
.toBase58();
880 var accountXpub
= accountExtendedKey
.neutered().toBase58();
881 // Display the extended keys
882 DOM
.bip49accountXprv
.val(accountXprv
);
883 DOM
.bip49accountXpub
.val(accountXpub
);
886 function displayBip84Info() {
887 // Get the derivation path for the account
888 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
889 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
890 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
892 path
+= purpose
+ "'/";
894 path
+= account
+ "'/";
895 // Calculate the account extended keys
896 var accountExtendedKey
= calcBip32ExtendedKey(path
);
897 var accountXprv
= accountExtendedKey
.toBase58();
898 var accountXpub
= accountExtendedKey
.neutered().toBase58();
899 // Display the extended keys
900 DOM
.bip84accountXprv
.val(accountXprv
);
901 DOM
.bip84accountXpub
.val(accountXpub
);
904 function displayBip32Info() {
907 var rootKey
= bip32RootKey
.toBase58();
908 DOM
.rootKey
.val(rootKey
);
909 var xprvkeyB58
= "NA";
910 if (!bip32ExtendedKey
.isNeutered()) {
911 xprvkeyB58
= bip32ExtendedKey
.toBase58();
913 var extendedPrivKey
= xprvkeyB58
;
914 DOM
.extendedPrivKey
.val(extendedPrivKey
);
915 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
916 DOM
.extendedPubKey
.val(extendedPubKey
);
917 // Display the addresses and privkeys
918 clearAddressesList();
919 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
920 displayAddresses(0, initialAddressCount
);
923 function displayAddresses(start
, total
) {
924 generationProcesses
.push(new (function() {
928 this.stop = function() {
929 for (var i
=0; i
<rows
.length
; i
++) {
930 rows
[i
].shouldGenerate
= false;
935 for (var i
=0; i
<total
; i
++) {
936 var index
= i
+ start
;
937 var isLast
= i
== total
- 1;
938 rows
.push(new TableRow(index
, isLast
));
944 function segwitSelected() {
945 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
948 function p2wpkhSelected() {
949 return bip84TabSelected() ||
950 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
953 function p2wpkhInP2shSelected() {
954 return bip49TabSelected() ||
955 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
958 function TableRow(index
, isLast
) {
961 this.shouldGenerate
= true;
962 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
963 var useBip38
= DOM
.useBip38
.prop("checked");
964 var bip38password
= DOM
.bip38Password
.val();
965 var isSegwit
= segwitSelected();
966 var segwitAvailable
= networkHasSegwit();
967 var isP2wpkh
= p2wpkhSelected();
968 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
974 function calculateValues() {
975 setTimeout(function() {
976 if (!self
.shouldGenerate
) {
979 // derive HDkey for this row of the table
981 if (useHardenedAddresses
) {
982 key
= bip32ExtendedKey
.deriveHardened(index
);
985 key
= bip32ExtendedKey
.derive(index
);
987 // bip38 requires uncompressed keys
988 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
989 var keyPair
= key
.keyPair
;
990 var useUncompressed
= useBip38
;
991 if (useUncompressed
) {
992 keyPair
= new bitcoinjs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
994 keyPair
= new groestlcoinjs
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
998 var address
= keyPair
.getAddress().toString();
1000 var hasPrivkey
= !key
.isNeutered();
1003 privkey
= keyPair
.toWIF();
1004 // BIP38 encode private key if required
1007 privkey
= groestlcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1008 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1009 }, null, networks
[DOM
.network
.val()].name
.includes("Testnet"));
1011 privkey
= bitcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1012 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1017 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
1018 var indexText
= getDerivationPath() + "/" + index
;
1019 if (useHardenedAddresses
) {
1020 indexText
= indexText
+ "'";
1022 // Ethereum values are different
1023 if ((networks
[DOM
.network
.val()].name
== "ETH - Ethereum")
1024 || (networks
[DOM
.network
.val()].name
== "ETC - Ethereum Classic")
1025 || (networks
[DOM
.network
.val()].name
== "PIRL - Pirl")
1026 || (networks
[DOM
.network
.val()].name
== "MIX - MIX")
1027 || (networks
[DOM
.network
.val()].name
== "MUSIC - Musicoin")
1028 || (networks
[DOM
.network
.val()].name
== "POA - Poa")
1029 || (networks
[DOM
.network
.val()].name
== "EXP - Expanse")
1030 || (networks
[DOM
.network
.val()].name
== "CLO - Callisto")
1031 || (networks
[DOM
.network
.val()].name
== "DXN - DEXON")
1032 || (networks
[DOM
.network
.val()].name
== "ELLA - Ellaism")
1033 || (networks
[DOM
.network
.val()].name
== "ESN - Ethersocial Network")
1034 || (networks
[DOM
.network
.val()].name
== "VET - VeChain")
1036 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1037 privkey
= privKeyBuffer
.toString('hex');
1038 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
1039 var hexAddress
= addressBuffer
.toString('hex');
1040 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
1041 address
= ethUtil
.addHexPrefix(checksumAddress
);
1042 privkey
= ethUtil
.addHexPrefix(privkey
);
1043 pubkey
= ethUtil
.addHexPrefix(pubkey
);
1046 // Stellar is different
1047 if (networks
[DOM
.network
.val()].name
== "XLM - Stellar") {
1048 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
1049 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
1051 path
+= purpose
+ "'/";
1052 path
+= coin
+ "'/" + index
+ "'";
1053 var keypair
= stellarUtil
.getKeypair(path
, seed
);
1055 privkey
= keypair
.secret();
1056 pubkey
= address
= keypair
.publicKey();
1058 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
1059 var NasAccount
= require("nebulas-account");
1060 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1061 var nebulasAccount
= new NasAccount();
1062 nebulasAccount
.setPrivateKey(privKeyBuffer
);
1063 address
= nebulasAccount
.getAddressString();
1064 privkey
= nebulasAccount
.getPrivateKeyString();
1065 pubkey
= nebulasAccount
.getPublicKeyString();
1067 // Ripple values are different
1068 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
1069 privkey
= convertRipplePriv(privkey
);
1070 address
= convertRippleAdrr(address
);
1072 // CasinoCoin values are different
1073 if (networks
[DOM
.network
.val()].name
== "CSC - CasinoCoin") {
1074 privkey
= convertCasinoCoinPriv(privkey
);
1075 address
= convertCasinoCoinAdrr(address
);
1077 // Bitcoin Cash address format may vary
1078 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
1079 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1080 if (bchAddrType
== "cashaddr") {
1081 address
= bchaddr
.toCashAddress(address
);
1083 else if (bchAddrType
== "bitpay") {
1084 address
= bchaddr
.toBitpayAddress(address
);
1087 // Bitcoin Cash address format may vary
1088 if (networks
[DOM
.network
.val()].name
== "SLP - Simple Ledger Protocol") {
1089 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1090 if (bchAddrType
== "cashaddr") {
1091 address
= bchaddr
.toSlpAddress(address
);
1094 // Segwit addresses are different
1096 if (!segwitAvailable
) {
1100 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1101 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1102 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1104 else if (isP2wpkhInP2sh
) {
1105 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1106 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1107 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
1108 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
1109 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1113 if ((networks
[DOM
.network
.val()].name
== "CRW - Crown")) {
1114 address
= bitcoinjs
.bitcoin
.networks
.crown
.toNewAddress(address
);
1117 if (networks
[DOM
.network
.val()].name
== "EOS - EOSIO") {
1119 pubkey
= eosUtil
.bufferToPublic(keyPair
.getPublicKeyBuffer());
1120 privkey
= eosUtil
.bufferToPrivate(keyPair
.d
.toBuffer(32));
1123 //Groestlcoin Addresses are different
1127 if (!segwitAvailable
) {
1131 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1133 else if (isP2wpkhInP2sh
) {
1134 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1137 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1140 addAddressToList(indexText
, address
, pubkey
, privkey
);
1152 function showMore() {
1153 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
1154 if (isNaN(rowsToAdd
)) {
1156 DOM
.rowsToAdd
.val("20");
1158 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
1160 start
= lastIndexInTable() + 1;
1163 var newStart
= start
+ rowsToAdd
;
1164 DOM
.moreRowsStartIndex
.val(newStart
);
1166 if (rowsToAdd
> 200) {
1167 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1168 msg
+= "Do you want to continue?";
1169 if (!confirm(msg
)) {
1173 displayAddresses(start
, rowsToAdd
);
1176 function clearDisplay() {
1177 clearAddressesList();
1179 hideValidationError();
1182 function clearAddressesList() {
1183 DOM
.addresses
.empty();
1188 function stopGenerating() {
1189 while (generationProcesses
.length
> 0) {
1190 var generation
= generationProcesses
.shift();
1195 function clearKeys() {
1200 function clearRootKey() {
1201 DOM
.rootKey
.val("");
1204 function clearDerivedKeys() {
1205 DOM
.extendedPrivKey
.val("");
1206 DOM
.extendedPubKey
.val("");
1207 DOM
.bip44accountXprv
.val("");
1208 DOM
.bip44accountXpub
.val("");
1211 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1212 var row
= $(addressRowTemplate
.html());
1214 var indexCell
= row
.find(".index span");
1215 var addressCell
= row
.find(".address span");
1216 var pubkeyCell
= row
.find(".pubkey span");
1217 var privkeyCell
= row
.find(".privkey span");
1219 indexCell
.text(indexText
);
1220 addressCell
.text(address
);
1221 pubkeyCell
.text(pubkey
);
1222 privkeyCell
.text(privkey
);
1225 indexCell
.addClass("invisible");
1228 addressCell
.addClass("invisible");
1231 pubkeyCell
.addClass("invisible");
1234 privkeyCell
.addClass("invisible");
1236 DOM
.addresses
.append(row
);
1237 var rowShowQrEls
= row
.find("[data-show-qr]");
1238 setQrEvents(rowShowQrEls
);
1241 function hasStrongRandom() {
1242 return 'crypto' in window
&& window
['crypto'] !== null;
1245 function disableForms() {
1246 $("form").on("submit", function(e
) {
1251 function parseIntNoNaN(val
, defaultVal
) {
1252 var v
= parseInt(val
);
1259 function showPending() {
1261 .text("Calculating...")
1265 function findNearestWord(word
) {
1266 var language
= getLanguage();
1267 var words
= WORDLISTS
[language
];
1268 var minDistance
= 99;
1269 var closestWord
= words
[0];
1270 for (var i
=0; i
<words
.length
; i
++) {
1271 var comparedTo
= words
[i
];
1272 if (comparedTo
.indexOf(word
) == 0) {
1275 var distance
= Levenshtein
.get(word
, comparedTo
);
1276 if (distance
< minDistance
) {
1277 closestWord
= comparedTo
;
1278 minDistance
= distance
;
1284 function hidePending() {
1290 function populateNetworkSelect() {
1291 for (var i
=0; i
<networks
.length
; i
++) {
1292 var network
= networks
[i
];
1293 var option
= $("<option>");
1294 option
.attr("value", i
);
1295 option
.text(network
.name
);
1296 if (network
.name
== "BTC - Bitcoin") {
1297 option
.prop("selected", true);
1299 DOM
.phraseNetwork
.append(option
);
1303 function populateClientSelect() {
1304 for (var i
=0; i
<clients
.length
; i
++) {
1305 var client
= clients
[i
];
1306 var option
= $("<option>");
1307 option
.attr("value", i
);
1308 option
.text(client
.name
);
1309 DOM
.bip32Client
.append(option
);
1313 function getLanguage() {
1314 var defaultLanguage
= "english";
1315 // Try to get from existing phrase
1316 var language
= getLanguageFromPhrase();
1317 // Try to get from url if not from phrase
1318 if (language
.length
== 0) {
1319 language
= getLanguageFromUrl();
1321 // Default to English if no other option
1322 if (language
.length
== 0) {
1323 language
= defaultLanguage
;
1328 function getLanguageFromPhrase(phrase
) {
1329 // Check if how many words from existing phrase match a language.
1332 phrase
= DOM
.phrase
.val();
1334 if (phrase
.length
> 0) {
1335 var words
= phraseToWordArray(phrase
);
1336 var languageMatches
= {};
1337 for (l
in WORDLISTS
) {
1338 // Track how many words match in this language
1339 languageMatches
[l
] = 0;
1340 for (var i
=0; i
<words
.length
; i
++) {
1341 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1342 if (wordInLanguage
) {
1343 languageMatches
[l
]++;
1346 // Find languages with most word matches.
1347 // This is made difficult due to commonalities between Chinese
1348 // simplified vs traditional.
1349 var mostMatches
= 0;
1350 var mostMatchedLanguages
= [];
1351 for (var l
in languageMatches
) {
1352 var numMatches
= languageMatches
[l
];
1353 if (numMatches
> mostMatches
) {
1354 mostMatches
= numMatches
;
1355 mostMatchedLanguages
= [l
];
1357 else if (numMatches
== mostMatches
) {
1358 mostMatchedLanguages
.push(l
);
1362 if (mostMatchedLanguages
.length
> 0) {
1363 // Use first language and warn if multiple detected
1364 language
= mostMatchedLanguages
[0];
1365 if (mostMatchedLanguages
.length
> 1) {
1366 console
.warn("Multiple possible languages");
1367 console
.warn(mostMatchedLanguages
);
1374 function getLanguageFromUrl() {
1375 for (var language
in WORDLISTS
) {
1376 if (window
.location
.hash
.indexOf(language
) > -1) {
1383 function setMnemonicLanguage() {
1384 var language
= getLanguage();
1385 // Load the bip39 mnemonic generator for this language if required
1386 if (!(language
in mnemonics
)) {
1387 mnemonics
[language
] = new Mnemonic(language
);
1389 mnemonic
= mnemonics
[language
];
1392 function convertPhraseToNewLanguage() {
1393 var oldLanguage
= getLanguageFromPhrase();
1394 var newLanguage
= getLanguageFromUrl();
1395 var oldPhrase
= DOM
.phrase
.val();
1396 var oldWords
= phraseToWordArray(oldPhrase
);
1398 for (var i
=0; i
<oldWords
.length
; i
++) {
1399 var oldWord
= oldWords
[i
];
1400 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1401 var newWord
= WORDLISTS
[newLanguage
][index
];
1402 newWords
.push(newWord
);
1404 newPhrase
= wordArrayToPhrase(newWords
);
1408 // TODO look at jsbip39 - mnemonic.splitWords
1409 function phraseToWordArray(phrase
) {
1410 var words
= phrase
.split(/\s/g);
1412 for (var i
=0; i
<words
.length
; i
++) {
1413 var word
= words
[i
];
1414 if (word
.length
> 0) {
1415 noBlanks
.push(word
);
1421 // TODO look at jsbip39 - mnemonic.joinWords
1422 function wordArrayToPhrase(words
) {
1423 var phrase
= words
.join(" ");
1424 var language
= getLanguageFromPhrase(phrase
);
1425 if (language
== "japanese") {
1426 phrase
= words
.join("\u3000");
1431 function writeSplitPhrase(phrase
) {
1432 var wordCount
= phrase
.split(/\s/g).length
; //get number of words in phrase
1433 var left
=[]; //initialize array of indexs
1434 for (var i
=0;i
<wordCount
;i
++) left
.push(i
); //add all indexs to array
1435 var group
=[[],[],[]], //make array for 3 groups
1436 groupI
=-1; //initialize group index
1437 var seed
= Math
.abs(sjcl
.hash
.sha256
.hash(phrase
)[0])% 2147483647; //start seed at sudo random value based on hash of words
1438 while (left
.length
>0) { //while indexs left
1439 groupI
=(groupI
+1)%3; //get next group to insert index into
1440 seed
= seed
* 16807 % 2147483647; //change random value.(simple predicatable random number generator works well for this use)
1441 var selected
=Math
.floor(left
.length
*(seed
- 1) / 2147483646); //get index in left we will use for this group
1442 group
[groupI
].push(left
[selected
]); //add index to group
1443 left
.splice(selected
,1); //remove selected index
1445 var cards
=[phrase
.split(/\s/g),phrase
.split(/\s/g),phrase
.split(/\s/g)];//make array of cards
1446 for (var i
=0;i
<3;i
++) { //go through each card
1447 for (var ii
=0;ii
<wordCount
/3;ii
++) cards
[i
][group
[i
][ii
]]='XXXX'; //erase words listed in the group
1448 cards
[i
]='Card '+(i
+1)+': '+wordArrayToPhrase(cards
[i
]); //combine words on card back to string
1450 DOM
.splitPhrase
.val(cards
.join("\r\n")); //make words visible
1453 function isUsingOwnEntropy() {
1454 return DOM
.useEntropy
.prop("checked");
1457 function setMnemonicFromEntropy() {
1458 clearEntropyFeedback();
1459 // Get entropy value
1460 var entropyStr
= DOM
.entropy
.val();
1461 // Work out minimum base for entropy
1462 var entropy
= Entropy
.fromString(entropyStr
);
1463 if (entropy
.binaryStr
.length
== 0) {
1466 // Show entropy details
1467 showEntropyFeedback(entropy
);
1468 // Use entropy hash if not using raw entropy
1469 var bits
= entropy
.binaryStr
;
1470 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1471 if (mnemonicLength
!= "raw") {
1472 // Get bits by hashing entropy with SHA256
1473 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1474 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1475 bits
= BigInteger
.parse(hex
, 16).toString(2);
1476 while (bits
.length
% 256 != 0) {
1479 // Truncate hash to suit number of words
1480 mnemonicLength
= parseInt(mnemonicLength
);
1481 var numberOfBits
= 32 * mnemonicLength
/ 3;
1482 bits
= bits
.substring(0, numberOfBits
);
1483 // show warning for weak entropy override
1484 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1485 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1488 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1492 // hide warning for weak entropy override
1493 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1495 // Discard trailing entropy
1496 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1497 var start
= bits
.length
- bitsToUse
;
1498 var binaryStr
= bits
.substring(start
);
1499 // Convert entropy string to numeric array
1500 var entropyArr
= [];
1501 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1502 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1503 var entropyByte
= parseInt(byteAsBits
, 2);
1504 entropyArr
.push(entropyByte
)
1506 // Convert entropy array to mnemonic
1507 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1508 // Set the mnemonic in the UI
1509 DOM
.phrase
.val(phrase
);
1510 writeSplitPhrase(phrase
);
1511 // Show the word indexes
1513 // Show the checksum
1517 function clearEntropyFeedback() {
1518 DOM
.entropyCrackTime
.text("...");
1519 DOM
.entropyType
.text("");
1520 DOM
.entropyWordCount
.text("0");
1521 DOM
.entropyEventCount
.text("0");
1522 DOM
.entropyBitsPerEvent
.text("0");
1523 DOM
.entropyBits
.text("0");
1524 DOM
.entropyFiltered
.html(" ");
1525 DOM
.entropyBinary
.html(" ");
1528 function showEntropyFeedback(entropy
) {
1529 var numberOfBits
= entropy
.binaryStr
.length
;
1530 var timeToCrack
= "unknown";
1532 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1533 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1534 if (z
.feedback
.warning
!= "") {
1535 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1539 console
.log("Error detecting entropy strength with zxcvbn:");
1542 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1543 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1544 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1545 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1546 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1547 DOM
.entropyType
.text(entropyTypeStr
);
1548 DOM
.entropyCrackTime
.text(timeToCrack
);
1549 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1550 DOM
.entropyBits
.text(numberOfBits
);
1551 DOM
.entropyWordCount
.text(wordCount
);
1552 DOM
.entropyBinary
.text(spacedBinaryStr
);
1553 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1554 // detect and warn of filtering
1555 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1556 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1557 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1559 DOM
.entropyFilterWarning
.removeClass('hidden');
1562 DOM
.entropyFilterWarning
.addClass('hidden');
1566 function getEntropyTypeStr(entropy
) {
1567 var typeStr
= entropy
.base
.str
;
1568 // Add some detail if these are cards
1569 if (entropy
.base
.asInt
== 52) {
1570 var cardDetail
= []; // array of message strings
1571 // Detect duplicates
1573 var dupeTracker
= {};
1574 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1575 var card
= entropy
.base
.parts
[i
];
1576 var cardUpper
= card
.toUpperCase();
1577 if (cardUpper
in dupeTracker
) {
1580 dupeTracker
[cardUpper
] = true;
1582 if (dupes
.length
> 0) {
1583 var dupeWord
= "duplicates";
1584 if (dupes
.length
== 1) {
1585 dupeWord
= "duplicate";
1587 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1588 if (dupes
.length
> 3) {
1591 cardDetail
.push(msg
);
1594 var uniqueCards
= [];
1595 for (var uniqueCard
in dupeTracker
) {
1596 uniqueCards
.push(uniqueCard
);
1598 if (uniqueCards
.length
== 52) {
1599 cardDetail
.unshift("full deck");
1601 // Detect missing cards
1602 var values
= "A23456789TJQK";
1604 var missingCards
= [];
1605 for (var i
=0; i
<suits
.length
; i
++) {
1606 for (var j
=0; j
<values
.length
; j
++) {
1607 var card
= values
[j
] + suits
[i
];
1608 if (!(card
in dupeTracker
)) {
1609 missingCards
.push(card
);
1613 // Display missing cards if six or less, ie clearly going for full deck
1614 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1615 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1616 if (missingCards
.length
> 3) {
1619 cardDetail
.push(msg
);
1621 // Add card details to typeStr
1622 if (cardDetail
.length
> 0) {
1623 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1629 function setQrEvents(els
) {
1630 els
.on("mouseenter", createQr
);
1631 els
.on("mouseleave", destroyQr
);
1632 els
.on("click", toggleQr
);
1635 function createQr(e
) {
1636 var content
= e
.target
.textContent
|| e
.target
.value
;
1644 DOM
.qrImage
.append(qrEl
);
1646 DOM
.qrHider
.addClass("hidden");
1649 DOM
.qrHider
.removeClass("hidden");
1651 DOM
.qrContainer
.removeClass("hidden");
1655 function destroyQr() {
1656 DOM
.qrImage
.text("");
1657 DOM
.qrContainer
.addClass("hidden");
1660 function toggleQr() {
1662 DOM
.qrHider
.toggleClass("hidden");
1663 DOM
.qrHint
.toggleClass("hidden");
1666 function bip44TabSelected() {
1667 return DOM
.bip44tab
.hasClass("active");
1670 function bip32TabSelected() {
1671 return DOM
.bip32tab
.hasClass("active");
1674 function networkHasSegwit() {
1676 if ("baseNetwork" in network
) {
1677 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1679 // check if only p2wpkh params are required
1680 if (p2wpkhSelected()) {
1681 return "p2wpkh" in n
;
1683 // check if only p2wpkh-in-p2sh params are required
1684 else if (p2wpkhInP2shSelected()) {
1685 return "p2wpkhInP2sh" in n
;
1687 // require both if it's unclear which params are required
1688 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1691 function bip49TabSelected() {
1692 return DOM
.bip49tab
.hasClass("active");
1695 function bip84TabSelected() {
1696 return DOM
.bip84tab
.hasClass("active");
1699 function bip141TabSelected() {
1700 return DOM
.bip141tab
.hasClass("active");
1703 function setHdCoin(coinValue
) {
1704 DOM
.bip44coin
.val(coinValue
);
1705 DOM
.bip49coin
.val(coinValue
);
1706 DOM
.bip84coin
.val(coinValue
);
1709 function showSegwitAvailable() {
1710 DOM
.bip49unavailable
.addClass("hidden");
1711 DOM
.bip49available
.removeClass("hidden");
1712 DOM
.bip84unavailable
.addClass("hidden");
1713 DOM
.bip84available
.removeClass("hidden");
1714 DOM
.bip141unavailable
.addClass("hidden");
1715 DOM
.bip141available
.removeClass("hidden");
1718 function showSegwitUnavailable() {
1719 DOM
.bip49available
.addClass("hidden");
1720 DOM
.bip49unavailable
.removeClass("hidden");
1721 DOM
.bip84available
.addClass("hidden");
1722 DOM
.bip84unavailable
.removeClass("hidden");
1723 DOM
.bip141available
.addClass("hidden");
1724 DOM
.bip141unavailable
.removeClass("hidden");
1727 function adjustNetworkForSegwit() {
1728 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1729 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1731 // See https://github.com/iancoleman/bip39/issues/125
1732 var segwitNetworks
= null;
1733 // if a segwit network is alread selected, need to use base network to
1734 // look up new parameters
1735 if ("baseNetwork" in network
) {
1736 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1738 // choose the right segwit params
1739 if (p2wpkhSelected() && "p2wpkh" in network
) {
1740 network
= network
.p2wpkh
;
1742 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1743 network
= network
.p2wpkhInP2sh
;
1747 function lastIndexInTable() {
1748 var pathText
= DOM
.addresses
.find(".index").last().text();
1749 var pathBits
= pathText
.split("/");
1750 var lastBit
= pathBits
[pathBits
.length
-1];
1751 var lastBitClean
= lastBit
.replace("'", "");
1752 return parseInt(lastBitClean
);
1755 function uint8ArrayToHex(a
) {
1757 for (var i
=0; i
<a
.length
; i
++) {
1758 var h
= a
[i
].toString(16);
1759 while (h
.length
< 2) {
1767 function showWordIndexes() {
1768 var phrase
= DOM
.phrase
.val();
1769 var words
= phraseToWordArray(phrase
);
1770 var wordIndexes
= [];
1771 var language
= getLanguage();
1772 for (var i
=0; i
<words
.length
; i
++) {
1773 var word
= words
[i
];
1774 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1775 wordIndexes
.push(wordIndex
);
1777 var wordIndexesStr
= wordIndexes
.join(", ");
1778 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1781 function showChecksum() {
1782 var phrase
= DOM
.phrase
.val();
1783 var words
= phraseToWordArray(phrase
);
1784 var checksumBitlength
= words
.length
/ 3;
1787 var language
= getLanguage();
1788 for (var i
=words
.length
-1; i
>=0; i
--) {
1789 var word
= words
[i
];
1790 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1791 var wordBinary
= wordIndex
.toString(2);
1792 while (wordBinary
.length
< 11) {
1793 wordBinary
= "0" + wordBinary
;
1795 var binaryStr
= wordBinary
+ binaryStr
;
1796 if (binaryStr
.length
>= checksumBitlength
) {
1797 var start
= binaryStr
.length
- checksumBitlength
;
1798 var end
= binaryStr
.length
;
1799 checksum
= binaryStr
.substring(start
, end
);
1800 // add spaces so the last group is 11 bits, not the first
1801 checksum
= checksum
.split("").reverse().join("")
1802 checksum
= addSpacesEveryElevenBits(checksum
);
1803 checksum
= checksum
.split("").reverse().join("")
1807 DOM
.entropyChecksum
.text(checksum
);
1810 function updateCsv() {
1811 var tableCsv
= "path,address,public key,private key\n";
1812 var rows
= DOM
.addresses
.find("tr");
1813 for (var i
=0; i
<rows
.length
; i
++) {
1814 var row
= $(rows
[i
]);
1815 var cells
= row
.find("td");
1816 for (var j
=0; j
<cells
.length
; j
++) {
1817 var cell
= $(cells
[j
]);
1818 if (!cell
.children().hasClass("invisible")) {
1819 tableCsv
= tableCsv
+ cell
.text();
1821 if (j
!= cells
.length
- 1) {
1822 tableCsv
= tableCsv
+ ",";
1825 tableCsv
= tableCsv
+ "\n";
1827 DOM
.csv
.val(tableCsv
);
1830 function addSpacesEveryElevenBits(binaryStr
) {
1831 return binaryStr
.match(/.{1,11}/g).join(" ");
1836 name: "AC - Asiacoin",
1837 onSelect: function() {
1838 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1843 name: "ACC - Adcoin",
1844 onSelect: function() {
1845 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1850 name: "ARYA - Aryacoin",
1851 onSelect: function() {
1852 network
= bitcoinjs
.bitcoin
.networks
.aryacoin
;
1857 name: "AUR - Auroracoin",
1858 onSelect: function() {
1859 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1865 onSelect: function() {
1866 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1871 name: "ANON - ANON",
1872 onSelect: function() {
1873 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1878 name: "BOLI - Bolivarcoin",
1879 onSelect: function() {
1880 network
= bitcoinjs
.bitcoin
.networks
.bolivarcoin
;
1885 name: "BCA - Bitcoin Atom",
1886 onSelect: function() {
1887 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1892 name: "BCH - Bitcoin Cash",
1893 onSelect: function() {
1894 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1899 name: "BEET - Beetlecoin",
1900 onSelect: function() {
1901 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1906 name: "BELA - Belacoin",
1907 onSelect: function() {
1908 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1913 name: "BLK - BlackCoin",
1914 onSelect: function() {
1915 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1920 name: "BND - Blocknode",
1921 onSelect: function() {
1922 network
= bitcoinjs
.bitcoin
.networks
.blocknode
;
1927 name: "tBND - Blocknode Testnet",
1928 onSelect: function() {
1929 network
= bitcoinjs
.bitcoin
.networks
.blocknode_testnet
;
1934 name: "BRIT - Britcoin",
1935 onSelect: function() {
1936 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
1941 name: "BSD - Bitsend",
1942 onSelect: function() {
1943 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
1948 name: "BST - BlockStamp",
1949 onSelect: function() {
1950 network
= bitcoinjs
.bitcoin
.networks
.blockstamp
;
1956 onSelect: function() {
1957 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1962 name: "BTC - Bitcoin",
1963 onSelect: function() {
1964 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1969 name: "BTC - Bitcoin Testnet",
1970 onSelect: function() {
1971 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1976 name: "BITG - Bitcoin Green",
1977 onSelect: function() {
1978 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1983 name: "BTCP - Bitcoin Private",
1984 onSelect: function() {
1985 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
1990 name: "BSV - BitcoinSV",
1991 onSelect: function() {
1992 network
= bitcoinjs
.bitcoin
.networks
.bitcoinsv
;
1997 name: "BTCZ - Bitcoinz",
1998 onSelect: function() {
1999 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
2004 name: "BTDX - BitCloud",
2005 onSelect: function() {
2006 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
2011 name: "BTG - Bitcoin Gold",
2012 onSelect: function() {
2013 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
2018 name: "BTX - Bitcore",
2019 onSelect: function() {
2020 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
2025 name: "CCN - Cannacoin",
2026 onSelect: function() {
2027 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2032 name: "CESC - Cryptoescudo",
2033 onSelect: function() {
2034 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2039 name: "CDN - Canadaecoin",
2040 onSelect: function() {
2041 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
2046 name: "CLAM - Clams",
2047 onSelect: function() {
2048 network
= bitcoinjs
.bitcoin
.networks
.clam
;
2053 name: "CLO - Callisto",
2054 segwitAvailable: false,
2055 onSelect: function() {
2056 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2061 name: "CLUB - Clubcoin",
2062 onSelect: function() {
2063 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
2068 name: "CMP - Compcoin",
2069 onSelect: function() {
2070 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
2075 name: "CPU - CPUchain",
2076 onSelect: function() {
2077 network
= bitcoinjs
.bitcoin
.networks
.cpuchain
;
2082 name: "CRAVE - Crave",
2083 onSelect: function() {
2084 network
= bitcoinjs
.bitcoin
.networks
.crave
;
2089 name: "CRW - Crown (Legacy)",
2090 onSelect: function() {
2091 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2096 name: "CRW - Crown",
2097 onSelect: function() {
2098 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2103 name: "CSC - CasinoCoin",
2104 onSelect: function() {
2105 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2110 name: "DASH - Dash",
2111 onSelect: function() {
2112 network
= bitcoinjs
.bitcoin
.networks
.dash
;
2117 name: "DASH - Dash Testnet",
2118 onSelect: function() {
2119 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
2124 name: "DFC - Defcoin",
2125 onSelect: function() {
2126 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
2131 name: "DGB - Digibyte",
2132 onSelect: function() {
2133 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
2138 name: "DGC - Digitalcoin",
2139 onSelect: function() {
2140 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
2145 name: "DMD - Diamond",
2146 onSelect: function() {
2147 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
2152 name: "DNR - Denarius",
2153 onSelect: function() {
2154 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
2159 name: "DOGE - Dogecoin",
2160 onSelect: function() {
2161 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
2166 name: "DOGEt - Dogecoin Testnet",
2167 onSelect: function() {
2168 network
= bitcoinjs
.bitcoin
.networks
.dogecointestnet
;
2173 name: "DXN - DEXON",
2174 onSelect: function() {
2175 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2180 name: "ECN - Ecoin",
2181 onSelect: function() {
2182 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
2187 name: "EDRC - Edrcoin",
2188 onSelect: function() {
2189 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
2194 name: "EFL - Egulden",
2195 onSelect: function() {
2196 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
2201 name: "ELLA - Ellaism",
2202 segwitAvailable: false,
2203 onSelect: function() {
2204 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2209 name: "EMC2 - Einsteinium",
2210 onSelect: function() {
2211 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
2216 name: "ERC - Europecoin",
2217 onSelect: function() {
2218 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
2223 name: "EOS - EOSIO",
2224 onSelect: function() {
2225 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2230 name: "ESN - Ethersocial Network",
2231 segwitAvailable: false,
2232 onSelect: function() {
2233 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2238 name: "ETC - Ethereum Classic",
2239 segwitAvailable: false,
2240 onSelect: function() {
2241 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2246 name: "ETH - Ethereum",
2247 onSelect: function() {
2248 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2253 name: "EXCL - Exclusivecoin",
2254 onSelect: function() {
2255 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
2260 name: "EXCC - ExchangeCoin",
2261 onSelect: function() {
2262 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
2267 name: "EXP - Expanse",
2268 segwitAvailable: false,
2269 onSelect: function() {
2270 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2276 onSelect: function() {
2277 network
= bitcoinjs
.bitcoin
.networks
.fix
;
2282 name: "FIX - FIX Testnet",
2283 onSelect: function() {
2284 network
= bitcoinjs
.bitcoin
.networks
.fixtestnet
;
2289 name: "FJC - Fujicoin",
2290 onSelect: function() {
2291 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2296 name: "FLASH - Flashcoin",
2297 onSelect: function() {
2298 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2303 name: "FRST - Firstcoin",
2304 onSelect: function() {
2305 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2310 name: "FTC - Feathercoin",
2311 onSelect: function() {
2312 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2317 name: "GAME - GameCredits",
2318 onSelect: function() {
2319 network
= bitcoinjs
.bitcoin
.networks
.game
;
2324 name: "GBX - Gobyte",
2325 onSelect: function() {
2326 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2331 name: "GCR - GCRCoin",
2332 onSelect: function() {
2333 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2338 name: "GRC - Gridcoin",
2339 onSelect: function() {
2340 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2345 name: "GRS - Groestlcoin",
2346 onSelect: function() {
2347 network
= bitcoinjs
.bitcoin
.networks
.groestlcoin
;
2352 name: "GRS - Groestlcoin Testnet",
2353 onSelect: function() {
2354 network
= bitcoinjs
.bitcoin
.networks
.groestlcointestnet
;
2359 name: "HNC - Helleniccoin",
2360 onSelect: function() {
2361 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2366 name: "HUSH - Hush (Legacy)",
2367 onSelect: function() {
2368 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2373 name: "HUSH - Hush3",
2374 onSelect: function() {
2375 network
= bitcoinjs
.bitcoin
.networks
.hush3
;
2380 name: "INSN - Insane",
2381 onSelect: function() {
2382 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2388 onSelect: function() {
2389 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2394 name: "IXC - Ixcoin",
2395 onSelect: function() {
2396 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2401 name: "JBS - Jumbucks",
2402 onSelect: function() {
2403 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2408 name: "KMD - Komodo",
2409 bip49available: false,
2410 onSelect: function() {
2411 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2416 name: "KOBO - Kobocoin",
2417 bip49available: false,
2418 onSelect: function() {
2419 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2424 name: "LBC - Library Credits",
2425 onSelect: function() {
2426 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2431 name: "LCC - Litecoincash",
2432 onSelect: function() {
2433 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2438 name: "LDCN - Landcoin",
2439 onSelect: function() {
2440 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2445 name: "LINX - Linx",
2446 onSelect: function() {
2447 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2452 name: "LKR - Lkrcoin",
2453 segwitAvailable: false,
2454 onSelect: function() {
2455 network
= bitcoinjs
.bitcoin
.networks
.lkrcoin
;
2460 name: "LTC - Litecoin",
2461 onSelect: function() {
2462 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2464 DOM
.litecoinLtubContainer
.removeClass("hidden");
2468 name: "LTCt - Litecoin Testnet",
2469 onSelect: function() {
2470 network
= bitcoinjs
.bitcoin
.networks
.litecointestnet
;
2472 DOM
.litecoinLtubContainer
.removeClass("hidden");
2476 name: "LTZ - LitecoinZ",
2477 onSelect: function() {
2478 network
= bitcoinjs
.bitcoin
.networks
.litecoinz
;
2483 name: "LYNX - Lynx",
2484 onSelect: function() {
2485 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2490 name: "MAZA - Maza",
2491 onSelect: function() {
2492 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2497 name: "MEC - Megacoin",
2498 onSelect: function() {
2499 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2505 segwitAvailable: false,
2506 onSelect: function() {
2507 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2512 name: "MNX - Minexcoin",
2513 onSelect: function() {
2514 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2519 name: "MONA - Monacoin",
2520 onSelect: function() {
2521 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2526 name: "MONK - Monkey Project",
2527 onSelect: function() {
2528 network
= bitcoinjs
.bitcoin
.networks
.monkeyproject
,
2533 name: "MUSIC - Musicoin",
2534 segwitAvailable: false,
2535 onSelect: function() {
2536 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2541 name: "NAV - Navcoin",
2542 onSelect: function() {
2543 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2548 name: "NAS - Nebulas",
2549 onSelect: function() {
2550 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2555 name: "NEBL - Neblio",
2556 onSelect: function() {
2557 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2562 name: "NEOS - Neoscoin",
2563 onSelect: function() {
2564 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2569 name: "NIX - NIX Platform",
2570 onSelect: function() {
2571 network
= bitcoinjs
.bitcoin
.networks
.nix
;
2576 name: "NLG - Gulden",
2577 onSelect: function() {
2578 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2583 name: "NMC - Namecoin",
2584 onSelect: function() {
2585 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2590 name: "NRG - Energi",
2591 onSelect: function() {
2592 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2597 name: "NRO - Neurocoin",
2598 onSelect: function() {
2599 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2604 name: "NSR - Nushares",
2605 onSelect: function() {
2606 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2611 name: "NYC - Newyorkc",
2612 onSelect: function() {
2613 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2618 name: "NVC - Novacoin",
2619 onSelect: function() {
2620 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2625 name: "OK - Okcash",
2626 onSelect: function() {
2627 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2632 name: "OMNI - Omnicore",
2633 onSelect: function() {
2634 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2639 name: "ONION - DeepOnion",
2640 onSelect: function() {
2641 network
= bitcoinjs
.bitcoin
.networks
.deeponion
;
2646 name: "ONX - Onixcoin",
2647 onSelect: function() {
2648 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2653 name: "PHR - Phore",
2654 onSelect: function() {
2655 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2660 name: "PINK - Pinkcoin",
2661 onSelect: function() {
2662 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2667 name: "PIRL - Pirl",
2668 segwitAvailable: false,
2669 onSelect: function() {
2670 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2675 name: "PIVX - PIVX",
2676 onSelect: function() {
2677 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2682 name: "PIVX - PIVX Testnet",
2683 onSelect: function() {
2684 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2690 segwitAvailable: false,
2691 onSelect: function() {
2692 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2697 name: "POSW - POSWcoin",
2698 onSelect: function() {
2699 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2704 name: "POT - Potcoin",
2705 onSelect: function() {
2706 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2711 name: "PPC - Peercoin",
2712 onSelect: function() {
2713 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2718 name: "PRJ - ProjectCoin",
2719 onSelect: function() {
2720 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2725 name: "PSB - Pesobit",
2726 onSelect: function() {
2727 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2732 name: "PUT - Putincoin",
2733 onSelect: function() {
2734 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2739 name: "RPD - Rapids",
2740 onSelect: function() {
2741 network
= bitcoinjs
.bitcoin
.networks
.rapids
;
2746 name: "RVN - Ravencoin",
2747 onSelect: function() {
2748 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2753 name: "RBY - Rubycoin",
2754 onSelect: function() {
2755 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2760 name: "RDD - Reddcoin",
2761 onSelect: function() {
2762 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2767 name: "RVR - RevolutionVR",
2768 onSelect: function() {
2769 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2774 name: "SAFE - Safecoin",
2775 onSelect: function() {
2776 network
= bitcoinjs
.bitcoin
.networks
.safecoin
;
2781 name: "SLS - Salus",
2782 onSelect: function() {
2783 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2788 name: "SDC - ShadowCash",
2789 onSelect: function() {
2790 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2795 name: "SDC - ShadowCash Testnet",
2796 onSelect: function() {
2797 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2802 name: "SLM - Slimcoin",
2803 onSelect: function() {
2804 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2809 name: "SLM - Slimcoin Testnet",
2810 onSelect: function() {
2811 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2816 name: "SLP - Simple Ledger Protocol",
2817 onSelect: function() {
2818 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2823 name: "SLR - Solarcoin",
2824 onSelect: function() {
2825 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2830 name: "SMLY - Smileycoin",
2831 onSelect: function() {
2832 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2837 name: "STASH - Stash",
2838 onSelect: function() {
2839 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2844 name: "STASH - Stash Testnet",
2845 onSelect: function() {
2846 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2851 name: "STRAT - Stratis",
2852 onSelect: function() {
2853 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2858 name: "TSTRAT - Stratis Testnet",
2859 onSelect: function() {
2860 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2865 name: "SYS - Syscoin",
2866 onSelect: function() {
2867 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2872 name: "THC - Hempcoin",
2873 onSelect: function() {
2874 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2880 onSelect: function() {
2881 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2886 name: "TWINS - TWINS",
2887 onSelect: function() {
2888 network
= bitcoinjs
.bitcoin
.networks
.twins
;
2893 name: "TWINS - TWINS Testnet",
2894 onSelect: function() {
2895 network
= bitcoinjs
.bitcoin
.networks
.twinstestnet
;
2900 name: "USC - Ultimatesecurecash",
2901 onSelect: function() {
2902 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2907 name: "USNBT - NuBits",
2908 onSelect: function() {
2909 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2914 name: "UNO - Unobtanium",
2915 onSelect: function() {
2916 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2921 name: "VASH - Vpncoin",
2922 onSelect: function() {
2923 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2928 name: "VET - VeChain",
2929 onSelect: function() {
2930 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2935 name: "VIA - Viacoin",
2936 onSelect: function() {
2937 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2942 name: "VIA - Viacoin Testnet",
2943 onSelect: function() {
2944 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2949 name: "VIVO - Vivo",
2950 onSelect: function() {
2951 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2956 name: "VTC - Vertcoin",
2957 onSelect: function() {
2958 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2963 name: "WGR - Wagerr",
2964 onSelect: function() {
2965 network
= bitcoinjs
.bitcoin
.networks
.wagerr
;
2970 name: "WC - Wincoin",
2971 onSelect: function() {
2972 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2977 name: "XAX - Artax",
2978 onSelect: function() {
2979 network
= bitcoinjs
.bitcoin
.networks
.artax
;
2984 name: "XBC - Bitcoinplus",
2985 onSelect: function() {
2986 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
2991 name: "XLM - Stellar",
2992 onSelect: function() {
2993 network
= stellarUtil
.dummyNetwork
;
2998 name: "XMY - Myriadcoin",
2999 onSelect: function() {
3000 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
3005 name: "XRP - Ripple",
3006 onSelect: function() {
3007 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
3012 name: "XVC - Vcash",
3013 onSelect: function() {
3014 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
3019 name: "XVG - Verge",
3020 onSelect: function() {
3021 network
= bitcoinjs
.bitcoin
.networks
.verge
;
3026 name: "XUEZ - Xuez",
3027 segwitAvailable: false,
3028 onSelect: function() {
3029 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
3034 name: "XWC - Whitecoin",
3035 onSelect: function() {
3036 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
3041 name: "XZC - Zcoin",
3042 onSelect: function() {
3043 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
3048 name: "ZCL - Zclassic",
3049 onSelect: function() {
3050 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
3055 name: "ZEC - Zcash",
3056 onSelect: function() {
3057 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
3062 name: "ZEN - Horizen",
3063 onSelect: function() {
3064 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
3072 name: "Bitcoin Core",
3073 onSelect: function() {
3074 DOM
.bip32path
.val("m/0'/0'");
3075 DOM
.hardenedAddresses
.prop('checked', true);
3079 name: "blockchain.info",
3080 onSelect: function() {
3081 DOM
.bip32path
.val("m/44'/0'/0'");
3082 DOM
.hardenedAddresses
.prop('checked', false);
3086 name: "MultiBit HD",
3087 onSelect: function() {
3088 DOM
.bip32path
.val("m/0'/0");
3089 DOM
.hardenedAddresses
.prop('checked', false);
3093 name: "Coinomi, Ledger",
3094 onSelect: function() {
3095 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
3096 DOM
.hardenedAddresses
.prop('checked', false);