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
.phraseSplitWarn
= $(".phraseSplitWarn");
49 DOM
.passphrase
= $(".passphrase");
50 DOM
.generateContainer
= $(".generate-container");
51 DOM
.generate
= $(".generate");
52 DOM
.seed
= $(".seed");
53 DOM
.rootKey
= $(".root-key");
54 DOM
.litecoinLtubContainer
= $(".litecoin-ltub-container");
55 DOM
.litecoinUseLtub
= $(".litecoin-use-ltub");
56 DOM
.extendedPrivKey
= $(".extended-priv-key");
57 DOM
.extendedPubKey
= $(".extended-pub-key");
58 DOM
.bip32tab
= $("#bip32-tab");
59 DOM
.bip44tab
= $("#bip44-tab");
60 DOM
.bip49tab
= $("#bip49-tab");
61 DOM
.bip84tab
= $("#bip84-tab");
62 DOM
.bip141tab
= $("#bip141-tab");
63 DOM
.bip32panel
= $("#bip32");
64 DOM
.bip44panel
= $("#bip44");
65 DOM
.bip49panel
= $("#bip49");
66 DOM
.bip32path
= $("#bip32-path");
67 DOM
.bip44path
= $("#bip44-path");
68 DOM
.bip44purpose
= $("#bip44 .purpose");
69 DOM
.bip44coin
= $("#bip44 .coin");
70 DOM
.bip44account
= $("#bip44 .account");
71 DOM
.bip44accountXprv
= $("#bip44 .account-xprv");
72 DOM
.bip44accountXpub
= $("#bip44 .account-xpub");
73 DOM
.bip44change
= $("#bip44 .change");
74 DOM
.bip49unavailable
= $("#bip49 .unavailable");
75 DOM
.bip49available
= $("#bip49 .available");
76 DOM
.bip49path
= $("#bip49-path");
77 DOM
.bip49purpose
= $("#bip49 .purpose");
78 DOM
.bip49coin
= $("#bip49 .coin");
79 DOM
.bip49account
= $("#bip49 .account");
80 DOM
.bip49accountXprv
= $("#bip49 .account-xprv");
81 DOM
.bip49accountXpub
= $("#bip49 .account-xpub");
82 DOM
.bip49change
= $("#bip49 .change");
83 DOM
.bip84unavailable
= $("#bip84 .unavailable");
84 DOM
.bip84available
= $("#bip84 .available");
85 DOM
.bip84path
= $("#bip84-path");
86 DOM
.bip84purpose
= $("#bip84 .purpose");
87 DOM
.bip84coin
= $("#bip84 .coin");
88 DOM
.bip84account
= $("#bip84 .account");
89 DOM
.bip84accountXprv
= $("#bip84 .account-xprv");
90 DOM
.bip84accountXpub
= $("#bip84 .account-xpub");
91 DOM
.bip84change
= $("#bip84 .change");
92 DOM
.bip141unavailable
= $("#bip141 .unavailable");
93 DOM
.bip141available
= $("#bip141 .available");
94 DOM
.bip141path
= $("#bip141-path");
95 DOM
.bip141semantics
= $(".bip141-semantics");
96 DOM
.generatedStrength
= $(".generate-container .strength");
97 DOM
.generatedStrengthWarning
= $(".generate-container .warning");
98 DOM
.hardenedAddresses
= $(".hardened-addresses");
99 DOM
.bitcoinCashAddressTypeContainer
= $(".bch-addr-type-container");
100 DOM
.bitcoinCashAddressType
= $("[name=bch-addr-type]")
101 DOM
.useBip38
= $(".use-bip38");
102 DOM
.bip38Password
= $(".bip38-password");
103 DOM
.addresses
= $(".addresses");
104 DOM
.csvTab
= $("#csv-tab a");
106 DOM
.rowsToAdd
= $(".rows-to-add");
107 DOM
.more
= $(".more");
108 DOM
.moreRowsStartIndex
= $(".more-rows-start-index");
109 DOM
.feedback
= $(".feedback");
110 DOM
.tab
= $(".derivation-type a");
111 DOM
.indexToggle
= $(".index-toggle");
112 DOM
.addressToggle
= $(".address-toggle");
113 DOM
.publicKeyToggle
= $(".public-key-toggle");
114 DOM
.privateKeyToggle
= $(".private-key-toggle");
115 DOM
.languages
= $(".languages a");
116 DOM
.qrContainer
= $(".qr-container");
117 DOM
.qrHider
= DOM
.qrContainer
.find(".qr-hider");
118 DOM
.qrImage
= DOM
.qrContainer
.find(".qr-image");
119 DOM
.qrHint
= DOM
.qrContainer
.find(".qr-hint");
120 DOM
.showQrEls
= $("[data-show-qr]");
124 DOM
.privacyScreenToggle
.on("change", privacyScreenToggled
);
125 DOM
.generatedStrength
.on("change", generatedStrengthChanged
);
126 DOM
.network
.on("change", networkChanged
);
127 DOM
.bip32Client
.on("change", bip32ClientChanged
);
128 DOM
.useEntropy
.on("change", setEntropyVisibility
);
129 DOM
.entropy
.on("input", delayedEntropyChanged
);
130 DOM
.entropyMnemonicLength
.on("change", entropyChanged
);
131 DOM
.phrase
.on("input", delayedPhraseChanged
);
132 DOM
.passphrase
.on("input", delayedPhraseChanged
);
133 DOM
.generate
.on("click", generateClicked
);
134 DOM
.more
.on("click", showMore
);
135 DOM
.rootKey
.on("input", delayedRootKeyChanged
);
136 DOM
.litecoinUseLtub
.on("change", litecoinUseLtubChanged
);
137 DOM
.bip32path
.on("input", calcForDerivationPath
);
138 DOM
.bip44account
.on("input", calcForDerivationPath
);
139 DOM
.bip44change
.on("input", calcForDerivationPath
);
140 DOM
.bip49account
.on("input", calcForDerivationPath
);
141 DOM
.bip49change
.on("input", calcForDerivationPath
);
142 DOM
.bip84account
.on("input", calcForDerivationPath
);
143 DOM
.bip84change
.on("input", calcForDerivationPath
);
144 DOM
.bip141path
.on("input", calcForDerivationPath
);
145 DOM
.bip141semantics
.on("change", tabChanged
);
146 DOM
.tab
.on("shown.bs.tab", tabChanged
);
147 DOM
.hardenedAddresses
.on("change", calcForDerivationPath
);
148 DOM
.useBip38
.on("change", calcForDerivationPath
);
149 DOM
.bip38Password
.on("change", calcForDerivationPath
);
150 DOM
.indexToggle
.on("click", toggleIndexes
);
151 DOM
.addressToggle
.on("click", toggleAddresses
);
152 DOM
.publicKeyToggle
.on("click", togglePublicKeys
);
153 DOM
.privateKeyToggle
.on("click", togglePrivateKeys
);
154 DOM
.csvTab
.on("click", updateCsv
);
155 DOM
.languages
.on("click", languageChanged
);
156 DOM
.bitcoinCashAddressType
.on("change", bitcoinCashAddressTypeChange
);
157 setQrEvents(DOM
.showQrEls
);
160 hideValidationError();
161 populateNetworkSelect();
162 populateClientSelect();
167 function generatedStrengthChanged() {
168 var strength
= parseInt(DOM
.generatedStrength
.val());
170 DOM
.generatedStrengthWarning
.removeClass("hidden");
173 DOM
.generatedStrengthWarning
.addClass("hidden");
177 function networkChanged(e
) {
179 clearAddressesList();
180 DOM
.litecoinLtubContainer
.addClass("hidden");
181 DOM
.bitcoinCashAddressTypeContainer
.addClass("hidden");
182 var networkIndex
= e
.target
.value
;
183 var network
= networks
[networkIndex
];
185 adjustNetworkForSegwit();
194 function bip32ClientChanged(e
) {
195 var clientIndex
= DOM
.bip32Client
.val();
196 if (clientIndex
== "custom") {
197 DOM
.bip32path
.prop("readonly", false);
200 DOM
.bip32path
.prop("readonly", true);
201 clients
[clientIndex
].onSelect();
211 function setEntropyVisibility() {
212 if (isUsingOwnEntropy()) {
213 DOM
.entropyContainer
.removeClass("hidden");
214 DOM
.generateContainer
.addClass("hidden");
215 DOM
.phrase
.prop("readonly", true);
220 DOM
.entropyContainer
.addClass("hidden");
221 DOM
.generateContainer
.removeClass("hidden");
222 DOM
.phrase
.prop("readonly", false);
227 function delayedPhraseChanged() {
228 hideValidationError();
231 bip32ExtendedKey
= null;
232 clearAddressesList();
234 if (phraseChangeTimeoutEvent
!= null) {
235 clearTimeout(phraseChangeTimeoutEvent
);
237 phraseChangeTimeoutEvent
= setTimeout(function() {
239 var entropy
= mnemonic
.toRawEntropyHex(DOM
.phrase
.val());
240 if (entropy
!== null) {
241 DOM
.entropyMnemonicLength
.val("raw");
242 DOM
.entropy
.val(entropy
);
247 function phraseChanged() {
249 setMnemonicLanguage();
250 // Get the mnemonic phrase
251 var phrase
= DOM
.phrase
.val();
252 var errorText
= findPhraseErrors(phrase
);
254 showValidationError(errorText
);
257 // Calculate and display
258 var passphrase
= DOM
.passphrase
.val();
259 calcBip32RootKeyFromSeed(phrase
, passphrase
);
260 calcForDerivationPath();
261 // Show the word indexes
265 function tabChanged() {
267 adjustNetworkForSegwit();
268 var phrase
= DOM
.phrase
.val();
270 // Calculate and display for mnemonic
271 var errorText
= findPhraseErrors(phrase
);
273 showValidationError(errorText
);
276 // Calculate and display
277 var passphrase
= DOM
.passphrase
.val();
278 calcBip32RootKeyFromSeed(phrase
, passphrase
);
281 // Calculate and display for root key
282 var rootKeyBase58
= DOM
.rootKey
.val();
283 var errorText
= validateRootKey(rootKeyBase58
);
285 showValidationError(errorText
);
288 // Calculate and display
289 calcBip32RootKeyFromBase58(rootKeyBase58
);
291 calcForDerivationPath();
294 function delayedEntropyChanged() {
295 hideValidationError();
297 if (entropyChangeTimeoutEvent
!= null) {
298 clearTimeout(entropyChangeTimeoutEvent
);
300 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
303 function entropyChanged() {
304 // If blank entropy, clear mnemonic, addresses, errors
305 if (DOM
.entropy
.val().trim().length
== 0) {
307 clearEntropyFeedback();
309 DOM
.phraseSplit
.val("");
310 showValidationError("Blank entropy");
313 // Get the current phrase to detect changes
314 var phrase
= DOM
.phrase
.val();
315 // Set the phrase from the entropy
316 setMnemonicFromEntropy();
317 // Recalc addresses if the phrase has changed
318 var newPhrase
= DOM
.phrase
.val();
319 if (newPhrase
!= phrase
) {
320 if (newPhrase
.length
== 0) {
332 function delayedRootKeyChanged() {
333 // Warn if there is an existing mnemonic or passphrase.
334 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
335 if (!confirm("This will clear existing mnemonic and passphrase")) {
336 DOM
.rootKey
.val(bip32RootKey
);
340 hideValidationError();
342 // Clear existing mnemonic and passphrase
344 DOM
.phraseSplit
.val("");
345 DOM
.passphrase
.val("");
347 if (rootKeyChangedTimeoutEvent
!= null) {
348 clearTimeout(rootKeyChangedTimeoutEvent
);
350 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
353 function rootKeyChanged() {
355 hideValidationError();
356 var rootKeyBase58
= DOM
.rootKey
.val();
357 var errorText
= validateRootKey(rootKeyBase58
);
359 showValidationError(errorText
);
362 // Calculate and display
363 calcBip32RootKeyFromBase58(rootKeyBase58
);
364 calcForDerivationPath();
367 function litecoinUseLtubChanged() {
368 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
369 if (litecoinUseLtub
) {
370 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
373 network
= bitcoinjs
.bitcoin
.networks
.litecoinXprv
;
378 function calcForDerivationPath() {
380 clearAddressesList();
382 // Don't show segwit if it's selected but network doesn't support it
383 if (segwitSelected() && !networkHasSegwit()) {
384 showSegwitUnavailable();
388 showSegwitAvailable();
389 // Get the derivation path
390 var derivationPath
= getDerivationPath();
391 var errorText
= findDerivationPathErrors(derivationPath
);
393 showValidationError(errorText
);
396 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
397 if (bip44TabSelected()) {
400 else if (bip49TabSelected()) {
403 else if (bip84TabSelected()) {
409 function generateClicked() {
410 if (isUsingOwnEntropy()) {
415 setTimeout(function() {
416 setMnemonicLanguage();
417 var phrase
= generateRandomPhrase();
425 function languageChanged() {
426 setTimeout(function() {
427 setMnemonicLanguage();
428 if (DOM
.phrase
.val().length
> 0) {
429 var newPhrase
= convertPhraseToNewLanguage();
430 DOM
.phrase
.val(newPhrase
);
431 writeSplitPhrase(newPhrase
);
435 DOM
.generate
.trigger("click");
440 function bitcoinCashAddressTypeChange() {
444 function toggleIndexes() {
445 showIndex
= !showIndex
;
446 $("td.index span").toggleClass("invisible");
449 function toggleAddresses() {
450 showAddress
= !showAddress
;
451 $("td.address span").toggleClass("invisible");
454 function togglePublicKeys() {
455 showPubKey
= !showPubKey
;
456 $("td.pubkey span").toggleClass("invisible");
459 function togglePrivateKeys() {
460 showPrivKey
= !showPrivKey
;
461 $("td.privkey span").toggleClass("invisible");
464 function privacyScreenToggled() {
465 // private-data contains elements added to DOM at runtime
466 // so catch all by adding visual privacy class to the root of the DOM
467 if (DOM
.privacyScreenToggle
.prop("checked")) {
468 $("body").addClass("visual-privacy");
471 $("body").removeClass("visual-privacy");
477 function generateRandomPhrase() {
478 if (!hasStrongRandom()) {
479 var errorText
= "This browser does not support strong randomness";
480 showValidationError(errorText
);
483 // get the amount of entropy to use
484 var numWords
= parseInt(DOM
.generatedStrength
.val());
485 var strength
= numWords
/ 3 * 32;
486 var buffer
= new Uint8Array(strength
/ 8);
487 // create secure entropy
488 var data
= crypto
.getRandomValues(buffer
);
490 var words
= mnemonic
.toMnemonic(data
);
491 DOM
.phrase
.val(words
);
492 writeSplitPhrase(words
);
494 var entropyHex
= uint8ArrayToHex(data
);
495 DOM
.entropy
.val(entropyHex
);
496 // ensure entropy fields are consistent with what is being displayed
497 DOM
.entropyMnemonicLength
.val("raw");
501 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
502 seed
= mnemonic
.toSeed(phrase
, passphrase
);
503 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
505 bip32RootKey
= groestlcoinjs
.HDNode
.fromSeedHex(seed
, network
);
509 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
511 calcBip32RootKeyFromBase58GRS(rootKeyBase58
);
514 // try parsing with various segwit network params since this extended
515 // key may be from any one of them.
516 if (networkHasSegwit()) {
518 if ("baseNetwork" in n
) {
519 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
521 // try parsing using base network params
523 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
527 // try parsing using p2wpkh params
530 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
535 // try parsing using p2wpkh-in-p2sh network params
536 if ("p2wpkhInP2sh" in n
) {
538 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
544 // try the network params as currently specified
545 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
548 function calcBip32RootKeyFromBase58GRS(rootKeyBase58
) {
549 // try parsing with various segwit network params since this extended
550 // key may be from any one of them.
551 if (networkHasSegwit()) {
553 if ("baseNetwork" in n
) {
554 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
556 // try parsing using base network params
558 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
562 // try parsing using p2wpkh params
565 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
570 // try parsing using p2wpkh-in-p2sh network params
571 if ("p2wpkhInP2sh" in n
) {
573 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
579 // try the network params as currently specified
580 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
583 function calcBip32ExtendedKey(path
) {
584 // Check there's a root key to derive from
588 var extendedKey
= bip32RootKey
;
589 // Derive the key from the path
590 var pathBits
= path
.split("/");
591 for (var i
=0; i
<pathBits
.length
; i
++) {
592 var bit
= pathBits
[i
];
593 var index
= parseInt(bit
);
597 var hardened
= bit
[bit
.length
-1] == "'";
598 var isPriv
= !(extendedKey
.isNeutered());
599 var invalidDerivationPath
= hardened
&& !isPriv
;
600 if (invalidDerivationPath
) {
604 extendedKey
= extendedKey
.deriveHardened(index
);
607 extendedKey
= extendedKey
.derive(index
);
613 function showValidationError(errorText
) {
619 function hideValidationError() {
625 function findPhraseErrors(phrase
) {
626 // Preprocess the words
627 phrase
= mnemonic
.normalizeString(phrase
);
628 var words
= phraseToWordArray(phrase
);
629 // Detect blank phrase
630 if (words
.length
== 0) {
631 return "Blank mnemonic";
634 for (var i
=0; i
<words
.length
; i
++) {
636 var language
= getLanguage();
637 if (WORDLISTS
[language
].indexOf(word
) == -1) {
638 console
.log("Finding closest match to " + word
);
639 var nearestWord
= findNearestWord(word
);
640 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
643 // Check the words are valid
644 var properPhrase
= wordArrayToPhrase(words
);
645 var isValid
= mnemonic
.check(properPhrase
);
647 return "Invalid mnemonic";
652 function validateRootKey(rootKeyBase58
) {
654 return validateRootKeyGRS(rootKeyBase58
);
656 // try various segwit network params since this extended key may be from
658 if (networkHasSegwit()) {
660 if ("baseNetwork" in n
) {
661 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
663 // try parsing using base network params
665 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
669 // try parsing using p2wpkh params
672 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
677 // try parsing using p2wpkh-in-p2sh network params
678 if ("p2wpkhInP2sh" in n
) {
680 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
686 // try the network params as currently specified
688 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
691 return "Invalid root key";
696 function validateRootKeyGRS(rootKeyBase58
) {
697 // try various segwit network params since this extended key may be from
699 if (networkHasSegwit()) {
701 if ("baseNetwork" in n
) {
702 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
704 // try parsing using base network params
706 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
710 // try parsing using p2wpkh params
713 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
718 // try parsing using p2wpkh-in-p2sh network params
719 if ("p2wpkhInP2sh" in n
) {
721 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
727 // try the network params as currently specified
729 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
732 return "Invalid root key";
737 function getDerivationPath() {
738 if (bip44TabSelected()) {
739 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
740 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
741 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
742 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
744 path
+= purpose
+ "'/";
746 path
+= account
+ "'/";
748 DOM
.bip44path
.val(path
);
749 var derivationPath
= DOM
.bip44path
.val();
750 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
751 return derivationPath
;
753 else if (bip49TabSelected()) {
754 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
755 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
756 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
757 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
759 path
+= purpose
+ "'/";
761 path
+= account
+ "'/";
763 DOM
.bip49path
.val(path
);
764 var derivationPath
= DOM
.bip49path
.val();
765 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
766 return derivationPath
;
768 else if (bip84TabSelected()) {
769 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
770 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
771 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
772 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
774 path
+= purpose
+ "'/";
776 path
+= account
+ "'/";
778 DOM
.bip84path
.val(path
);
779 var derivationPath
= DOM
.bip84path
.val();
780 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
781 return derivationPath
;
783 else if (bip32TabSelected()) {
784 var derivationPath
= DOM
.bip32path
.val();
785 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
786 return derivationPath
;
788 else if (bip141TabSelected()) {
789 var derivationPath
= DOM
.bip141path
.val();
790 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
791 return derivationPath
;
794 console
.log("Unknown derivation path");
798 function findDerivationPathErrors(path
) {
799 // TODO is not perfect but is better than nothing
801 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
803 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
804 var maxDepth
= 255; // TODO verify this!!
805 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
806 if (path
[0] != "m") {
807 return "First character must be 'm'";
809 if (path
.length
> 1) {
810 if (path
[1] != "/") {
811 return "Separator must be '/'";
813 var indexes
= path
.split("/");
814 if (indexes
.length
> maxDepth
) {
815 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
817 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
818 var index
= indexes
[depth
];
819 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
820 if (invalidChars
.length
> 0) {
821 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
823 var indexValue
= parseInt(index
.replace("'", ""));
825 return "Invalid number at depth " + depth
;
827 if (indexValue
> maxIndexValue
) {
828 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
832 // Check root key exists or else derivation path is useless!
834 return "No root key";
836 // Check no hardened derivation path when using xpub keys
837 var hardenedPath
= path
.indexOf("'") > -1;
838 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
839 var hardened
= hardenedPath
|| hardenedAddresses
;
840 var isXpubkey
= bip32RootKey
.isNeutered();
841 if (hardened
&& isXpubkey
) {
842 return "Hardened derivation path is invalid with xpub key";
848 return networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin" || networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin Testnet";
851 function displayBip44Info() {
852 // Get the derivation path for the account
853 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
854 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
855 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
857 path
+= purpose
+ "'/";
859 path
+= account
+ "'/";
860 // Calculate the account extended keys
861 var accountExtendedKey
= calcBip32ExtendedKey(path
);
862 var accountXprv
= accountExtendedKey
.toBase58();
863 var accountXpub
= accountExtendedKey
.neutered().toBase58();
864 // Display the extended keys
865 DOM
.bip44accountXprv
.val(accountXprv
);
866 DOM
.bip44accountXpub
.val(accountXpub
);
869 function displayBip49Info() {
870 // Get the derivation path for the account
871 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
872 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
873 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
875 path
+= purpose
+ "'/";
877 path
+= account
+ "'/";
878 // Calculate the account extended keys
879 var accountExtendedKey
= calcBip32ExtendedKey(path
);
880 var accountXprv
= accountExtendedKey
.toBase58();
881 var accountXpub
= accountExtendedKey
.neutered().toBase58();
882 // Display the extended keys
883 DOM
.bip49accountXprv
.val(accountXprv
);
884 DOM
.bip49accountXpub
.val(accountXpub
);
887 function displayBip84Info() {
888 // Get the derivation path for the account
889 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
890 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
891 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
893 path
+= purpose
+ "'/";
895 path
+= account
+ "'/";
896 // Calculate the account extended keys
897 var accountExtendedKey
= calcBip32ExtendedKey(path
);
898 var accountXprv
= accountExtendedKey
.toBase58();
899 var accountXpub
= accountExtendedKey
.neutered().toBase58();
900 // Display the extended keys
901 DOM
.bip84accountXprv
.val(accountXprv
);
902 DOM
.bip84accountXpub
.val(accountXpub
);
905 function displayBip32Info() {
908 var rootKey
= bip32RootKey
.toBase58();
909 DOM
.rootKey
.val(rootKey
);
910 var xprvkeyB58
= "NA";
911 if (!bip32ExtendedKey
.isNeutered()) {
912 xprvkeyB58
= bip32ExtendedKey
.toBase58();
914 var extendedPrivKey
= xprvkeyB58
;
915 DOM
.extendedPrivKey
.val(extendedPrivKey
);
916 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
917 DOM
.extendedPubKey
.val(extendedPubKey
);
918 // Display the addresses and privkeys
919 clearAddressesList();
920 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
921 displayAddresses(0, initialAddressCount
);
924 function displayAddresses(start
, total
) {
925 generationProcesses
.push(new (function() {
929 this.stop = function() {
930 for (var i
=0; i
<rows
.length
; i
++) {
931 rows
[i
].shouldGenerate
= false;
936 for (var i
=0; i
<total
; i
++) {
937 var index
= i
+ start
;
938 var isLast
= i
== total
- 1;
939 rows
.push(new TableRow(index
, isLast
));
945 function segwitSelected() {
946 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
949 function p2wpkhSelected() {
950 return bip84TabSelected() ||
951 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
954 function p2wpkhInP2shSelected() {
955 return bip49TabSelected() ||
956 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
959 function TableRow(index
, isLast
) {
962 this.shouldGenerate
= true;
963 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
964 var useBip38
= DOM
.useBip38
.prop("checked");
965 var bip38password
= DOM
.bip38Password
.val();
966 var isSegwit
= segwitSelected();
967 var segwitAvailable
= networkHasSegwit();
968 var isP2wpkh
= p2wpkhSelected();
969 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
975 function calculateValues() {
976 setTimeout(function() {
977 if (!self
.shouldGenerate
) {
980 // derive HDkey for this row of the table
982 if (useHardenedAddresses
) {
983 key
= bip32ExtendedKey
.deriveHardened(index
);
986 key
= bip32ExtendedKey
.derive(index
);
988 // bip38 requires uncompressed keys
989 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
990 var keyPair
= key
.keyPair
;
991 var useUncompressed
= useBip38
;
992 if (useUncompressed
) {
993 keyPair
= new bitcoinjs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
995 keyPair
= new groestlcoinjs
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
999 var address
= keyPair
.getAddress().toString();
1001 var hasPrivkey
= !key
.isNeutered();
1004 privkey
= keyPair
.toWIF();
1005 // BIP38 encode private key if required
1008 privkey
= groestlcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1009 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1010 }, null, networks
[DOM
.network
.val()].name
.includes("Testnet"));
1012 privkey
= bitcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1013 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1018 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
1019 var indexText
= getDerivationPath() + "/" + index
;
1020 if (useHardenedAddresses
) {
1021 indexText
= indexText
+ "'";
1023 // Ethereum values are different
1024 if ((networks
[DOM
.network
.val()].name
== "ETH - Ethereum")
1025 || (networks
[DOM
.network
.val()].name
== "ETC - Ethereum Classic")
1026 || (networks
[DOM
.network
.val()].name
== "PIRL - Pirl")
1027 || (networks
[DOM
.network
.val()].name
== "MIX - MIX")
1028 || (networks
[DOM
.network
.val()].name
== "MUSIC - Musicoin")
1029 || (networks
[DOM
.network
.val()].name
== "POA - Poa")
1030 || (networks
[DOM
.network
.val()].name
== "EXP - Expanse")
1031 || (networks
[DOM
.network
.val()].name
== "CLO - Callisto")
1032 || (networks
[DOM
.network
.val()].name
== "DXN - DEXON")
1033 || (networks
[DOM
.network
.val()].name
== "ELLA - Ellaism")
1034 || (networks
[DOM
.network
.val()].name
== "ESN - Ethersocial Network")
1035 || (networks
[DOM
.network
.val()].name
== "VET - VeChain")
1037 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1038 privkey
= privKeyBuffer
.toString('hex');
1039 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
1040 var hexAddress
= addressBuffer
.toString('hex');
1041 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
1042 address
= ethUtil
.addHexPrefix(checksumAddress
);
1043 privkey
= ethUtil
.addHexPrefix(privkey
);
1044 pubkey
= ethUtil
.addHexPrefix(pubkey
);
1047 // Stellar is different
1048 if (networks
[DOM
.network
.val()].name
== "XLM - Stellar") {
1049 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
1050 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
1052 path
+= purpose
+ "'/";
1053 path
+= coin
+ "'/" + index
+ "'";
1054 var keypair
= stellarUtil
.getKeypair(path
, seed
);
1056 privkey
= keypair
.secret();
1057 pubkey
= address
= keypair
.publicKey();
1059 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
1060 var NasAccount
= require("nebulas-account");
1061 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1062 var nebulasAccount
= new NasAccount();
1063 nebulasAccount
.setPrivateKey(privKeyBuffer
);
1064 address
= nebulasAccount
.getAddressString();
1065 privkey
= nebulasAccount
.getPrivateKeyString();
1066 pubkey
= nebulasAccount
.getPublicKeyString();
1068 // Ripple values are different
1069 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
1070 privkey
= convertRipplePriv(privkey
);
1071 address
= convertRippleAdrr(address
);
1073 // CasinoCoin values are different
1074 if (networks
[DOM
.network
.val()].name
== "CSC - CasinoCoin") {
1075 privkey
= convertCasinoCoinPriv(privkey
);
1076 address
= convertCasinoCoinAdrr(address
);
1078 // Bitcoin Cash address format may vary
1079 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
1080 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1081 if (bchAddrType
== "cashaddr") {
1082 address
= bchaddr
.toCashAddress(address
);
1084 else if (bchAddrType
== "bitpay") {
1085 address
= bchaddr
.toBitpayAddress(address
);
1088 // Bitcoin Cash address format may vary
1089 if (networks
[DOM
.network
.val()].name
== "SLP - Simple Ledger Protocol") {
1090 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1091 if (bchAddrType
== "cashaddr") {
1092 address
= bchaddr
.toSlpAddress(address
);
1095 // Segwit addresses are different
1097 if (!segwitAvailable
) {
1101 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1102 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1103 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1105 else if (isP2wpkhInP2sh
) {
1106 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1107 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1108 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
1109 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
1110 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1114 if ((networks
[DOM
.network
.val()].name
== "CRW - Crown")) {
1115 address
= bitcoinjs
.bitcoin
.networks
.crown
.toNewAddress(address
);
1118 if (networks
[DOM
.network
.val()].name
== "EOS - EOSIO") {
1120 pubkey
= eosUtil
.bufferToPublic(keyPair
.getPublicKeyBuffer());
1121 privkey
= eosUtil
.bufferToPrivate(keyPair
.d
.toBuffer(32));
1124 //Groestlcoin Addresses are different
1128 if (!segwitAvailable
) {
1132 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1134 else if (isP2wpkhInP2sh
) {
1135 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1138 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1141 addAddressToList(indexText
, address
, pubkey
, privkey
);
1153 function showMore() {
1154 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
1155 if (isNaN(rowsToAdd
)) {
1157 DOM
.rowsToAdd
.val("20");
1159 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
1161 start
= lastIndexInTable() + 1;
1164 var newStart
= start
+ rowsToAdd
;
1165 DOM
.moreRowsStartIndex
.val(newStart
);
1167 if (rowsToAdd
> 200) {
1168 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1169 msg
+= "Do you want to continue?";
1170 if (!confirm(msg
)) {
1174 displayAddresses(start
, rowsToAdd
);
1177 function clearDisplay() {
1178 clearAddressesList();
1180 hideValidationError();
1183 function clearAddressesList() {
1184 DOM
.addresses
.empty();
1189 function stopGenerating() {
1190 while (generationProcesses
.length
> 0) {
1191 var generation
= generationProcesses
.shift();
1196 function clearKeys() {
1201 function clearRootKey() {
1202 DOM
.rootKey
.val("");
1205 function clearDerivedKeys() {
1206 DOM
.extendedPrivKey
.val("");
1207 DOM
.extendedPubKey
.val("");
1208 DOM
.bip44accountXprv
.val("");
1209 DOM
.bip44accountXpub
.val("");
1212 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1213 var row
= $(addressRowTemplate
.html());
1215 var indexCell
= row
.find(".index span");
1216 var addressCell
= row
.find(".address span");
1217 var pubkeyCell
= row
.find(".pubkey span");
1218 var privkeyCell
= row
.find(".privkey span");
1220 indexCell
.text(indexText
);
1221 addressCell
.text(address
);
1222 pubkeyCell
.text(pubkey
);
1223 privkeyCell
.text(privkey
);
1226 indexCell
.addClass("invisible");
1229 addressCell
.addClass("invisible");
1232 pubkeyCell
.addClass("invisible");
1235 privkeyCell
.addClass("invisible");
1237 DOM
.addresses
.append(row
);
1238 var rowShowQrEls
= row
.find("[data-show-qr]");
1239 setQrEvents(rowShowQrEls
);
1242 function hasStrongRandom() {
1243 return 'crypto' in window
&& window
['crypto'] !== null;
1246 function disableForms() {
1247 $("form").on("submit", function(e
) {
1252 function parseIntNoNaN(val
, defaultVal
) {
1253 var v
= parseInt(val
);
1260 function showPending() {
1262 .text("Calculating...")
1266 function findNearestWord(word
) {
1267 var language
= getLanguage();
1268 var words
= WORDLISTS
[language
];
1269 var minDistance
= 99;
1270 var closestWord
= words
[0];
1271 for (var i
=0; i
<words
.length
; i
++) {
1272 var comparedTo
= words
[i
];
1273 if (comparedTo
.indexOf(word
) == 0) {
1276 var distance
= Levenshtein
.get(word
, comparedTo
);
1277 if (distance
< minDistance
) {
1278 closestWord
= comparedTo
;
1279 minDistance
= distance
;
1285 function hidePending() {
1291 function populateNetworkSelect() {
1292 for (var i
=0; i
<networks
.length
; i
++) {
1293 var network
= networks
[i
];
1294 var option
= $("<option>");
1295 option
.attr("value", i
);
1296 option
.text(network
.name
);
1297 if (network
.name
== "BTC - Bitcoin") {
1298 option
.prop("selected", true);
1300 DOM
.phraseNetwork
.append(option
);
1304 function populateClientSelect() {
1305 for (var i
=0; i
<clients
.length
; i
++) {
1306 var client
= clients
[i
];
1307 var option
= $("<option>");
1308 option
.attr("value", i
);
1309 option
.text(client
.name
);
1310 DOM
.bip32Client
.append(option
);
1314 function getLanguage() {
1315 var defaultLanguage
= "english";
1316 // Try to get from existing phrase
1317 var language
= getLanguageFromPhrase();
1318 // Try to get from url if not from phrase
1319 if (language
.length
== 0) {
1320 language
= getLanguageFromUrl();
1322 // Default to English if no other option
1323 if (language
.length
== 0) {
1324 language
= defaultLanguage
;
1329 function getLanguageFromPhrase(phrase
) {
1330 // Check if how many words from existing phrase match a language.
1333 phrase
= DOM
.phrase
.val();
1335 if (phrase
.length
> 0) {
1336 var words
= phraseToWordArray(phrase
);
1337 var languageMatches
= {};
1338 for (l
in WORDLISTS
) {
1339 // Track how many words match in this language
1340 languageMatches
[l
] = 0;
1341 for (var i
=0; i
<words
.length
; i
++) {
1342 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1343 if (wordInLanguage
) {
1344 languageMatches
[l
]++;
1347 // Find languages with most word matches.
1348 // This is made difficult due to commonalities between Chinese
1349 // simplified vs traditional.
1350 var mostMatches
= 0;
1351 var mostMatchedLanguages
= [];
1352 for (var l
in languageMatches
) {
1353 var numMatches
= languageMatches
[l
];
1354 if (numMatches
> mostMatches
) {
1355 mostMatches
= numMatches
;
1356 mostMatchedLanguages
= [l
];
1358 else if (numMatches
== mostMatches
) {
1359 mostMatchedLanguages
.push(l
);
1363 if (mostMatchedLanguages
.length
> 0) {
1364 // Use first language and warn if multiple detected
1365 language
= mostMatchedLanguages
[0];
1366 if (mostMatchedLanguages
.length
> 1) {
1367 console
.warn("Multiple possible languages");
1368 console
.warn(mostMatchedLanguages
);
1375 function getLanguageFromUrl() {
1376 for (var language
in WORDLISTS
) {
1377 if (window
.location
.hash
.indexOf(language
) > -1) {
1384 function setMnemonicLanguage() {
1385 var language
= getLanguage();
1386 // Load the bip39 mnemonic generator for this language if required
1387 if (!(language
in mnemonics
)) {
1388 mnemonics
[language
] = new Mnemonic(language
);
1390 mnemonic
= mnemonics
[language
];
1393 function convertPhraseToNewLanguage() {
1394 var oldLanguage
= getLanguageFromPhrase();
1395 var newLanguage
= getLanguageFromUrl();
1396 var oldPhrase
= DOM
.phrase
.val();
1397 var oldWords
= phraseToWordArray(oldPhrase
);
1399 for (var i
=0; i
<oldWords
.length
; i
++) {
1400 var oldWord
= oldWords
[i
];
1401 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1402 var newWord
= WORDLISTS
[newLanguage
][index
];
1403 newWords
.push(newWord
);
1405 newPhrase
= wordArrayToPhrase(newWords
);
1409 // TODO look at jsbip39 - mnemonic.splitWords
1410 function phraseToWordArray(phrase
) {
1411 var words
= phrase
.split(/\s/g);
1413 for (var i
=0; i
<words
.length
; i
++) {
1414 var word
= words
[i
];
1415 if (word
.length
> 0) {
1416 noBlanks
.push(word
);
1422 // TODO look at jsbip39 - mnemonic.joinWords
1423 function wordArrayToPhrase(words
) {
1424 var phrase
= words
.join(" ");
1425 var language
= getLanguageFromPhrase(phrase
);
1426 if (language
== "japanese") {
1427 phrase
= words
.join("\u3000");
1432 function writeSplitPhrase(phrase
) {
1433 var wordCount
= phrase
.split(/\s/g).length
; //get number of words in phrase
1434 var left
=[]; //initialize array of indexs
1435 for (var i
=0;i
<wordCount
;i
++) left
.push(i
); //add all indexs to array
1436 var group
=[[],[],[]], //make array for 3 groups
1437 groupI
=-1; //initialize group index
1438 var seed
= Math
.abs(sjcl
.hash
.sha256
.hash(phrase
)[0])% 2147483647; //start seed at sudo random value based on hash of words
1439 while (left
.length
>0) { //while indexs left
1440 groupI
=(groupI
+1)%3; //get next group to insert index into
1441 seed
= seed
* 16807 % 2147483647; //change random value.(simple predicatable random number generator works well for this use)
1442 var selected
=Math
.floor(left
.length
*(seed
- 1) / 2147483646); //get index in left we will use for this group
1443 group
[groupI
].push(left
[selected
]); //add index to group
1444 left
.splice(selected
,1); //remove selected index
1446 var cards
=[phrase
.split(/\s/g),phrase
.split(/\s/g),phrase
.split(/\s/g)];//make array of cards
1447 for (var i
=0;i
<3;i
++) { //go through each card
1448 for (var ii
=0;ii
<wordCount
/3;ii
++) cards
[i
][group
[i
][ii
]]='XXXX'; //erase words listed in the group
1449 cards
[i
]='Card '+(i
+1)+': '+wordArrayToPhrase(cards
[i
]); //combine words on card back to string
1451 DOM
.splitPhrase
.val(cards
.join("\r\n")); //make words visible
1452 var triesPerSecond
=10000000000; //assumed number of tries per second
1453 var hackTime
=Math
.pow(2,wordCount
*10/3)/triesPerSecond
; //get number of bits of unknown data per card
1455 hackTime
="<1 second";
1456 } else if (hackTime
<86400) {
1457 hackTime
=Math
.floor(hackTime
)+" seconds";
1458 } else if(hackTime
<31557600) {
1459 hackTime
=Math
.floor(hackTime
/86400)+" days";
1461 hackTime
=Math
.floor(hackTime
/31557600)+" years";
1463 DOM
.phraseSplitWarn
.html("Time to hack with only one card: "+hackTime
);
1466 function isUsingOwnEntropy() {
1467 return DOM
.useEntropy
.prop("checked");
1470 function setMnemonicFromEntropy() {
1471 clearEntropyFeedback();
1472 // Get entropy value
1473 var entropyStr
= DOM
.entropy
.val();
1474 // Work out minimum base for entropy
1475 var entropy
= Entropy
.fromString(entropyStr
);
1476 if (entropy
.binaryStr
.length
== 0) {
1479 // Show entropy details
1480 showEntropyFeedback(entropy
);
1481 // Use entropy hash if not using raw entropy
1482 var bits
= entropy
.binaryStr
;
1483 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1484 if (mnemonicLength
!= "raw") {
1485 // Get bits by hashing entropy with SHA256
1486 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1487 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1488 bits
= BigInteger
.parse(hex
, 16).toString(2);
1489 while (bits
.length
% 256 != 0) {
1492 // Truncate hash to suit number of words
1493 mnemonicLength
= parseInt(mnemonicLength
);
1494 var numberOfBits
= 32 * mnemonicLength
/ 3;
1495 bits
= bits
.substring(0, numberOfBits
);
1496 // show warning for weak entropy override
1497 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1498 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1501 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1505 // hide warning for weak entropy override
1506 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1508 // Discard trailing entropy
1509 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1510 var start
= bits
.length
- bitsToUse
;
1511 var binaryStr
= bits
.substring(start
);
1512 // Convert entropy string to numeric array
1513 var entropyArr
= [];
1514 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1515 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1516 var entropyByte
= parseInt(byteAsBits
, 2);
1517 entropyArr
.push(entropyByte
)
1519 // Convert entropy array to mnemonic
1520 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1521 // Set the mnemonic in the UI
1522 DOM
.phrase
.val(phrase
);
1523 writeSplitPhrase(phrase
);
1524 // Show the word indexes
1526 // Show the checksum
1530 function clearEntropyFeedback() {
1531 DOM
.entropyCrackTime
.text("...");
1532 DOM
.entropyType
.text("");
1533 DOM
.entropyWordCount
.text("0");
1534 DOM
.entropyEventCount
.text("0");
1535 DOM
.entropyBitsPerEvent
.text("0");
1536 DOM
.entropyBits
.text("0");
1537 DOM
.entropyFiltered
.html(" ");
1538 DOM
.entropyBinary
.html(" ");
1541 function showEntropyFeedback(entropy
) {
1542 var numberOfBits
= entropy
.binaryStr
.length
;
1543 var timeToCrack
= "unknown";
1545 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1546 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1547 if (z
.feedback
.warning
!= "") {
1548 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1552 console
.log("Error detecting entropy strength with zxcvbn:");
1555 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1556 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1557 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1558 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1559 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1560 DOM
.entropyType
.text(entropyTypeStr
);
1561 DOM
.entropyCrackTime
.text(timeToCrack
);
1562 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1563 DOM
.entropyBits
.text(numberOfBits
);
1564 DOM
.entropyWordCount
.text(wordCount
);
1565 DOM
.entropyBinary
.text(spacedBinaryStr
);
1566 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1567 // detect and warn of filtering
1568 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1569 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1570 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1572 DOM
.entropyFilterWarning
.removeClass('hidden');
1575 DOM
.entropyFilterWarning
.addClass('hidden');
1579 function getEntropyTypeStr(entropy
) {
1580 var typeStr
= entropy
.base
.str
;
1581 // Add some detail if these are cards
1582 if (entropy
.base
.asInt
== 52) {
1583 var cardDetail
= []; // array of message strings
1584 // Detect duplicates
1586 var dupeTracker
= {};
1587 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1588 var card
= entropy
.base
.parts
[i
];
1589 var cardUpper
= card
.toUpperCase();
1590 if (cardUpper
in dupeTracker
) {
1593 dupeTracker
[cardUpper
] = true;
1595 if (dupes
.length
> 0) {
1596 var dupeWord
= "duplicates";
1597 if (dupes
.length
== 1) {
1598 dupeWord
= "duplicate";
1600 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1601 if (dupes
.length
> 3) {
1604 cardDetail
.push(msg
);
1607 var uniqueCards
= [];
1608 for (var uniqueCard
in dupeTracker
) {
1609 uniqueCards
.push(uniqueCard
);
1611 if (uniqueCards
.length
== 52) {
1612 cardDetail
.unshift("full deck");
1614 // Detect missing cards
1615 var values
= "A23456789TJQK";
1617 var missingCards
= [];
1618 for (var i
=0; i
<suits
.length
; i
++) {
1619 for (var j
=0; j
<values
.length
; j
++) {
1620 var card
= values
[j
] + suits
[i
];
1621 if (!(card
in dupeTracker
)) {
1622 missingCards
.push(card
);
1626 // Display missing cards if six or less, ie clearly going for full deck
1627 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1628 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1629 if (missingCards
.length
> 3) {
1632 cardDetail
.push(msg
);
1634 // Add card details to typeStr
1635 if (cardDetail
.length
> 0) {
1636 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1642 function setQrEvents(els
) {
1643 els
.on("mouseenter", createQr
);
1644 els
.on("mouseleave", destroyQr
);
1645 els
.on("click", toggleQr
);
1648 function createQr(e
) {
1649 var content
= e
.target
.textContent
|| e
.target
.value
;
1657 DOM
.qrImage
.append(qrEl
);
1659 DOM
.qrHider
.addClass("hidden");
1662 DOM
.qrHider
.removeClass("hidden");
1664 DOM
.qrContainer
.removeClass("hidden");
1668 function destroyQr() {
1669 DOM
.qrImage
.text("");
1670 DOM
.qrContainer
.addClass("hidden");
1673 function toggleQr() {
1675 DOM
.qrHider
.toggleClass("hidden");
1676 DOM
.qrHint
.toggleClass("hidden");
1679 function bip44TabSelected() {
1680 return DOM
.bip44tab
.hasClass("active");
1683 function bip32TabSelected() {
1684 return DOM
.bip32tab
.hasClass("active");
1687 function networkHasSegwit() {
1689 if ("baseNetwork" in network
) {
1690 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1692 // check if only p2wpkh params are required
1693 if (p2wpkhSelected()) {
1694 return "p2wpkh" in n
;
1696 // check if only p2wpkh-in-p2sh params are required
1697 else if (p2wpkhInP2shSelected()) {
1698 return "p2wpkhInP2sh" in n
;
1700 // require both if it's unclear which params are required
1701 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1704 function bip49TabSelected() {
1705 return DOM
.bip49tab
.hasClass("active");
1708 function bip84TabSelected() {
1709 return DOM
.bip84tab
.hasClass("active");
1712 function bip141TabSelected() {
1713 return DOM
.bip141tab
.hasClass("active");
1716 function setHdCoin(coinValue
) {
1717 DOM
.bip44coin
.val(coinValue
);
1718 DOM
.bip49coin
.val(coinValue
);
1719 DOM
.bip84coin
.val(coinValue
);
1722 function showSegwitAvailable() {
1723 DOM
.bip49unavailable
.addClass("hidden");
1724 DOM
.bip49available
.removeClass("hidden");
1725 DOM
.bip84unavailable
.addClass("hidden");
1726 DOM
.bip84available
.removeClass("hidden");
1727 DOM
.bip141unavailable
.addClass("hidden");
1728 DOM
.bip141available
.removeClass("hidden");
1731 function showSegwitUnavailable() {
1732 DOM
.bip49available
.addClass("hidden");
1733 DOM
.bip49unavailable
.removeClass("hidden");
1734 DOM
.bip84available
.addClass("hidden");
1735 DOM
.bip84unavailable
.removeClass("hidden");
1736 DOM
.bip141available
.addClass("hidden");
1737 DOM
.bip141unavailable
.removeClass("hidden");
1740 function adjustNetworkForSegwit() {
1741 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1742 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1744 // See https://github.com/iancoleman/bip39/issues/125
1745 var segwitNetworks
= null;
1746 // if a segwit network is alread selected, need to use base network to
1747 // look up new parameters
1748 if ("baseNetwork" in network
) {
1749 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1751 // choose the right segwit params
1752 if (p2wpkhSelected() && "p2wpkh" in network
) {
1753 network
= network
.p2wpkh
;
1755 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1756 network
= network
.p2wpkhInP2sh
;
1760 function lastIndexInTable() {
1761 var pathText
= DOM
.addresses
.find(".index").last().text();
1762 var pathBits
= pathText
.split("/");
1763 var lastBit
= pathBits
[pathBits
.length
-1];
1764 var lastBitClean
= lastBit
.replace("'", "");
1765 return parseInt(lastBitClean
);
1768 function uint8ArrayToHex(a
) {
1770 for (var i
=0; i
<a
.length
; i
++) {
1771 var h
= a
[i
].toString(16);
1772 while (h
.length
< 2) {
1780 function showWordIndexes() {
1781 var phrase
= DOM
.phrase
.val();
1782 var words
= phraseToWordArray(phrase
);
1783 var wordIndexes
= [];
1784 var language
= getLanguage();
1785 for (var i
=0; i
<words
.length
; i
++) {
1786 var word
= words
[i
];
1787 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1788 wordIndexes
.push(wordIndex
);
1790 var wordIndexesStr
= wordIndexes
.join(", ");
1791 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1794 function showChecksum() {
1795 var phrase
= DOM
.phrase
.val();
1796 var words
= phraseToWordArray(phrase
);
1797 var checksumBitlength
= words
.length
/ 3;
1800 var language
= getLanguage();
1801 for (var i
=words
.length
-1; i
>=0; i
--) {
1802 var word
= words
[i
];
1803 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1804 var wordBinary
= wordIndex
.toString(2);
1805 while (wordBinary
.length
< 11) {
1806 wordBinary
= "0" + wordBinary
;
1808 var binaryStr
= wordBinary
+ binaryStr
;
1809 if (binaryStr
.length
>= checksumBitlength
) {
1810 var start
= binaryStr
.length
- checksumBitlength
;
1811 var end
= binaryStr
.length
;
1812 checksum
= binaryStr
.substring(start
, end
);
1813 // add spaces so the last group is 11 bits, not the first
1814 checksum
= checksum
.split("").reverse().join("")
1815 checksum
= addSpacesEveryElevenBits(checksum
);
1816 checksum
= checksum
.split("").reverse().join("")
1820 DOM
.entropyChecksum
.text(checksum
);
1823 function updateCsv() {
1824 var tableCsv
= "path,address,public key,private key\n";
1825 var rows
= DOM
.addresses
.find("tr");
1826 for (var i
=0; i
<rows
.length
; i
++) {
1827 var row
= $(rows
[i
]);
1828 var cells
= row
.find("td");
1829 for (var j
=0; j
<cells
.length
; j
++) {
1830 var cell
= $(cells
[j
]);
1831 if (!cell
.children().hasClass("invisible")) {
1832 tableCsv
= tableCsv
+ cell
.text();
1834 if (j
!= cells
.length
- 1) {
1835 tableCsv
= tableCsv
+ ",";
1838 tableCsv
= tableCsv
+ "\n";
1840 DOM
.csv
.val(tableCsv
);
1843 function addSpacesEveryElevenBits(binaryStr
) {
1844 return binaryStr
.match(/.{1,11}/g).join(" ");
1849 name: "AC - Asiacoin",
1850 onSelect: function() {
1851 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1856 name: "ACC - Adcoin",
1857 onSelect: function() {
1858 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1863 name: "ARYA - Aryacoin",
1864 onSelect: function() {
1865 network
= bitcoinjs
.bitcoin
.networks
.aryacoin
;
1870 name: "AUR - Auroracoin",
1871 onSelect: function() {
1872 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1878 onSelect: function() {
1879 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1884 name: "ANON - ANON",
1885 onSelect: function() {
1886 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1891 name: "BOLI - Bolivarcoin",
1892 onSelect: function() {
1893 network
= bitcoinjs
.bitcoin
.networks
.bolivarcoin
;
1898 name: "BCA - Bitcoin Atom",
1899 onSelect: function() {
1900 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1905 name: "BCH - Bitcoin Cash",
1906 onSelect: function() {
1907 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1912 name: "BEET - Beetlecoin",
1913 onSelect: function() {
1914 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1919 name: "BELA - Belacoin",
1920 onSelect: function() {
1921 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1926 name: "BLK - BlackCoin",
1927 onSelect: function() {
1928 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1933 name: "BND - Blocknode",
1934 onSelect: function() {
1935 network
= bitcoinjs
.bitcoin
.networks
.blocknode
;
1940 name: "tBND - Blocknode Testnet",
1941 onSelect: function() {
1942 network
= bitcoinjs
.bitcoin
.networks
.blocknode_testnet
;
1947 name: "BRIT - Britcoin",
1948 onSelect: function() {
1949 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
1954 name: "BSD - Bitsend",
1955 onSelect: function() {
1956 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
1961 name: "BST - BlockStamp",
1962 onSelect: function() {
1963 network
= bitcoinjs
.bitcoin
.networks
.blockstamp
;
1969 onSelect: function() {
1970 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1975 name: "BTC - Bitcoin",
1976 onSelect: function() {
1977 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1982 name: "BTC - Bitcoin Testnet",
1983 onSelect: function() {
1984 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1989 name: "BITG - Bitcoin Green",
1990 onSelect: function() {
1991 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1996 name: "BTCP - Bitcoin Private",
1997 onSelect: function() {
1998 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
2003 name: "BSV - BitcoinSV",
2004 onSelect: function() {
2005 network
= bitcoinjs
.bitcoin
.networks
.bitcoinsv
;
2010 name: "BTCZ - Bitcoinz",
2011 onSelect: function() {
2012 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
2017 name: "BTDX - BitCloud",
2018 onSelect: function() {
2019 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
2024 name: "BTG - Bitcoin Gold",
2025 onSelect: function() {
2026 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
2031 name: "BTX - Bitcore",
2032 onSelect: function() {
2033 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
2038 name: "CCN - Cannacoin",
2039 onSelect: function() {
2040 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2045 name: "CESC - Cryptoescudo",
2046 onSelect: function() {
2047 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2052 name: "CDN - Canadaecoin",
2053 onSelect: function() {
2054 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
2059 name: "CLAM - Clams",
2060 onSelect: function() {
2061 network
= bitcoinjs
.bitcoin
.networks
.clam
;
2066 name: "CLO - Callisto",
2067 segwitAvailable: false,
2068 onSelect: function() {
2069 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2074 name: "CLUB - Clubcoin",
2075 onSelect: function() {
2076 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
2081 name: "CMP - Compcoin",
2082 onSelect: function() {
2083 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
2088 name: "CPU - CPUchain",
2089 onSelect: function() {
2090 network
= bitcoinjs
.bitcoin
.networks
.cpuchain
;
2095 name: "CRAVE - Crave",
2096 onSelect: function() {
2097 network
= bitcoinjs
.bitcoin
.networks
.crave
;
2102 name: "CRW - Crown (Legacy)",
2103 onSelect: function() {
2104 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2109 name: "CRW - Crown",
2110 onSelect: function() {
2111 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2116 name: "CSC - CasinoCoin",
2117 onSelect: function() {
2118 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2123 name: "DASH - Dash",
2124 onSelect: function() {
2125 network
= bitcoinjs
.bitcoin
.networks
.dash
;
2130 name: "DASH - Dash Testnet",
2131 onSelect: function() {
2132 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
2137 name: "DFC - Defcoin",
2138 onSelect: function() {
2139 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
2144 name: "DGB - Digibyte",
2145 onSelect: function() {
2146 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
2151 name: "DGC - Digitalcoin",
2152 onSelect: function() {
2153 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
2158 name: "DMD - Diamond",
2159 onSelect: function() {
2160 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
2165 name: "DNR - Denarius",
2166 onSelect: function() {
2167 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
2172 name: "DOGE - Dogecoin",
2173 onSelect: function() {
2174 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
2179 name: "DOGEt - Dogecoin Testnet",
2180 onSelect: function() {
2181 network
= bitcoinjs
.bitcoin
.networks
.dogecointestnet
;
2186 name: "DXN - DEXON",
2187 onSelect: function() {
2188 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2193 name: "ECN - Ecoin",
2194 onSelect: function() {
2195 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
2200 name: "EDRC - Edrcoin",
2201 onSelect: function() {
2202 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
2207 name: "EFL - Egulden",
2208 onSelect: function() {
2209 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
2214 name: "ELLA - Ellaism",
2215 segwitAvailable: false,
2216 onSelect: function() {
2217 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2222 name: "EMC2 - Einsteinium",
2223 onSelect: function() {
2224 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
2229 name: "ERC - Europecoin",
2230 onSelect: function() {
2231 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
2236 name: "EOS - EOSIO",
2237 onSelect: function() {
2238 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2243 name: "ESN - Ethersocial Network",
2244 segwitAvailable: false,
2245 onSelect: function() {
2246 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2251 name: "ETC - Ethereum Classic",
2252 segwitAvailable: false,
2253 onSelect: function() {
2254 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2259 name: "ETH - Ethereum",
2260 onSelect: function() {
2261 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2266 name: "EXCL - Exclusivecoin",
2267 onSelect: function() {
2268 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
2273 name: "EXCC - ExchangeCoin",
2274 onSelect: function() {
2275 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
2280 name: "EXP - Expanse",
2281 segwitAvailable: false,
2282 onSelect: function() {
2283 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2289 onSelect: function() {
2290 network
= bitcoinjs
.bitcoin
.networks
.fix
;
2295 name: "FIX - FIX Testnet",
2296 onSelect: function() {
2297 network
= bitcoinjs
.bitcoin
.networks
.fixtestnet
;
2302 name: "FJC - Fujicoin",
2303 onSelect: function() {
2304 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2309 name: "FLASH - Flashcoin",
2310 onSelect: function() {
2311 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2316 name: "FRST - Firstcoin",
2317 onSelect: function() {
2318 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2323 name: "FTC - Feathercoin",
2324 onSelect: function() {
2325 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2330 name: "GAME - GameCredits",
2331 onSelect: function() {
2332 network
= bitcoinjs
.bitcoin
.networks
.game
;
2337 name: "GBX - Gobyte",
2338 onSelect: function() {
2339 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2344 name: "GCR - GCRCoin",
2345 onSelect: function() {
2346 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2351 name: "GRC - Gridcoin",
2352 onSelect: function() {
2353 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2358 name: "GRS - Groestlcoin",
2359 onSelect: function() {
2360 network
= bitcoinjs
.bitcoin
.networks
.groestlcoin
;
2365 name: "GRS - Groestlcoin Testnet",
2366 onSelect: function() {
2367 network
= bitcoinjs
.bitcoin
.networks
.groestlcointestnet
;
2372 name: "HNC - Helleniccoin",
2373 onSelect: function() {
2374 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2379 name: "HUSH - Hush (Legacy)",
2380 onSelect: function() {
2381 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2386 name: "HUSH - Hush3",
2387 onSelect: function() {
2388 network
= bitcoinjs
.bitcoin
.networks
.hush3
;
2393 name: "INSN - Insane",
2394 onSelect: function() {
2395 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2401 onSelect: function() {
2402 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2407 name: "IXC - Ixcoin",
2408 onSelect: function() {
2409 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2414 name: "JBS - Jumbucks",
2415 onSelect: function() {
2416 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2421 name: "KMD - Komodo",
2422 bip49available: false,
2423 onSelect: function() {
2424 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2429 name: "KOBO - Kobocoin",
2430 bip49available: false,
2431 onSelect: function() {
2432 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2437 name: "LBC - Library Credits",
2438 onSelect: function() {
2439 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2444 name: "LCC - Litecoincash",
2445 onSelect: function() {
2446 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2451 name: "LDCN - Landcoin",
2452 onSelect: function() {
2453 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2458 name: "LINX - Linx",
2459 onSelect: function() {
2460 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2465 name: "LKR - Lkrcoin",
2466 segwitAvailable: false,
2467 onSelect: function() {
2468 network
= bitcoinjs
.bitcoin
.networks
.lkrcoin
;
2473 name: "LTC - Litecoin",
2474 onSelect: function() {
2475 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2477 DOM
.litecoinLtubContainer
.removeClass("hidden");
2481 name: "LTCt - Litecoin Testnet",
2482 onSelect: function() {
2483 network
= bitcoinjs
.bitcoin
.networks
.litecointestnet
;
2485 DOM
.litecoinLtubContainer
.removeClass("hidden");
2489 name: "LTZ - LitecoinZ",
2490 onSelect: function() {
2491 network
= bitcoinjs
.bitcoin
.networks
.litecoinz
;
2496 name: "LYNX - Lynx",
2497 onSelect: function() {
2498 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2503 name: "MAZA - Maza",
2504 onSelect: function() {
2505 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2510 name: "MEC - Megacoin",
2511 onSelect: function() {
2512 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2518 segwitAvailable: false,
2519 onSelect: function() {
2520 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2525 name: "MNX - Minexcoin",
2526 onSelect: function() {
2527 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2532 name: "MONA - Monacoin",
2533 onSelect: function() {
2534 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2539 name: "MONK - Monkey Project",
2540 onSelect: function() {
2541 network
= bitcoinjs
.bitcoin
.networks
.monkeyproject
,
2546 name: "MUSIC - Musicoin",
2547 segwitAvailable: false,
2548 onSelect: function() {
2549 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2554 name: "NAV - Navcoin",
2555 onSelect: function() {
2556 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2561 name: "NAS - Nebulas",
2562 onSelect: function() {
2563 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2568 name: "NEBL - Neblio",
2569 onSelect: function() {
2570 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2575 name: "NEOS - Neoscoin",
2576 onSelect: function() {
2577 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2582 name: "NIX - NIX Platform",
2583 onSelect: function() {
2584 network
= bitcoinjs
.bitcoin
.networks
.nix
;
2589 name: "NLG - Gulden",
2590 onSelect: function() {
2591 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2596 name: "NMC - Namecoin",
2597 onSelect: function() {
2598 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2603 name: "NRG - Energi",
2604 onSelect: function() {
2605 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2610 name: "NRO - Neurocoin",
2611 onSelect: function() {
2612 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2617 name: "NSR - Nushares",
2618 onSelect: function() {
2619 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2624 name: "NYC - Newyorkc",
2625 onSelect: function() {
2626 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2631 name: "NVC - Novacoin",
2632 onSelect: function() {
2633 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2638 name: "OK - Okcash",
2639 onSelect: function() {
2640 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2645 name: "OMNI - Omnicore",
2646 onSelect: function() {
2647 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2652 name: "ONION - DeepOnion",
2653 onSelect: function() {
2654 network
= bitcoinjs
.bitcoin
.networks
.deeponion
;
2659 name: "ONX - Onixcoin",
2660 onSelect: function() {
2661 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2666 name: "PHR - Phore",
2667 onSelect: function() {
2668 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2673 name: "PINK - Pinkcoin",
2674 onSelect: function() {
2675 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2680 name: "PIRL - Pirl",
2681 segwitAvailable: false,
2682 onSelect: function() {
2683 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2688 name: "PIVX - PIVX",
2689 onSelect: function() {
2690 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2695 name: "PIVX - PIVX Testnet",
2696 onSelect: function() {
2697 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2703 segwitAvailable: false,
2704 onSelect: function() {
2705 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2710 name: "POSW - POSWcoin",
2711 onSelect: function() {
2712 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2717 name: "POT - Potcoin",
2718 onSelect: function() {
2719 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2724 name: "PPC - Peercoin",
2725 onSelect: function() {
2726 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2731 name: "PRJ - ProjectCoin",
2732 onSelect: function() {
2733 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2738 name: "PSB - Pesobit",
2739 onSelect: function() {
2740 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2745 name: "PUT - Putincoin",
2746 onSelect: function() {
2747 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2752 name: "RPD - Rapids",
2753 onSelect: function() {
2754 network
= bitcoinjs
.bitcoin
.networks
.rapids
;
2759 name: "RVN - Ravencoin",
2760 onSelect: function() {
2761 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2766 name: "RBY - Rubycoin",
2767 onSelect: function() {
2768 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2773 name: "RDD - Reddcoin",
2774 onSelect: function() {
2775 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2780 name: "RVR - RevolutionVR",
2781 onSelect: function() {
2782 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2787 name: "SAFE - Safecoin",
2788 onSelect: function() {
2789 network
= bitcoinjs
.bitcoin
.networks
.safecoin
;
2794 name: "SLS - Salus",
2795 onSelect: function() {
2796 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2801 name: "SDC - ShadowCash",
2802 onSelect: function() {
2803 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2808 name: "SDC - ShadowCash Testnet",
2809 onSelect: function() {
2810 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2815 name: "SLM - Slimcoin",
2816 onSelect: function() {
2817 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2822 name: "SLM - Slimcoin Testnet",
2823 onSelect: function() {
2824 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2829 name: "SLP - Simple Ledger Protocol",
2830 onSelect: function() {
2831 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2836 name: "SLR - Solarcoin",
2837 onSelect: function() {
2838 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2843 name: "SMLY - Smileycoin",
2844 onSelect: function() {
2845 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2850 name: "STASH - Stash",
2851 onSelect: function() {
2852 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2857 name: "STASH - Stash Testnet",
2858 onSelect: function() {
2859 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2864 name: "STRAT - Stratis",
2865 onSelect: function() {
2866 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2871 name: "TSTRAT - Stratis Testnet",
2872 onSelect: function() {
2873 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2878 name: "SYS - Syscoin",
2879 onSelect: function() {
2880 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2885 name: "THC - Hempcoin",
2886 onSelect: function() {
2887 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2893 onSelect: function() {
2894 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2899 name: "TWINS - TWINS",
2900 onSelect: function() {
2901 network
= bitcoinjs
.bitcoin
.networks
.twins
;
2906 name: "TWINS - TWINS Testnet",
2907 onSelect: function() {
2908 network
= bitcoinjs
.bitcoin
.networks
.twinstestnet
;
2913 name: "USC - Ultimatesecurecash",
2914 onSelect: function() {
2915 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2920 name: "USNBT - NuBits",
2921 onSelect: function() {
2922 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2927 name: "UNO - Unobtanium",
2928 onSelect: function() {
2929 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2934 name: "VASH - Vpncoin",
2935 onSelect: function() {
2936 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2941 name: "VET - VeChain",
2942 onSelect: function() {
2943 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2948 name: "VIA - Viacoin",
2949 onSelect: function() {
2950 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2955 name: "VIA - Viacoin Testnet",
2956 onSelect: function() {
2957 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2962 name: "VIVO - Vivo",
2963 onSelect: function() {
2964 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2969 name: "VTC - Vertcoin",
2970 onSelect: function() {
2971 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2976 name: "WGR - Wagerr",
2977 onSelect: function() {
2978 network
= bitcoinjs
.bitcoin
.networks
.wagerr
;
2983 name: "WC - Wincoin",
2984 onSelect: function() {
2985 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2990 name: "XAX - Artax",
2991 onSelect: function() {
2992 network
= bitcoinjs
.bitcoin
.networks
.artax
;
2997 name: "XBC - Bitcoinplus",
2998 onSelect: function() {
2999 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
3004 name: "XLM - Stellar",
3005 onSelect: function() {
3006 network
= stellarUtil
.dummyNetwork
;
3011 name: "XMY - Myriadcoin",
3012 onSelect: function() {
3013 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
3018 name: "XRP - Ripple",
3019 onSelect: function() {
3020 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
3025 name: "XVC - Vcash",
3026 onSelect: function() {
3027 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
3032 name: "XVG - Verge",
3033 onSelect: function() {
3034 network
= bitcoinjs
.bitcoin
.networks
.verge
;
3039 name: "XUEZ - Xuez",
3040 segwitAvailable: false,
3041 onSelect: function() {
3042 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
3047 name: "XWC - Whitecoin",
3048 onSelect: function() {
3049 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
3054 name: "XZC - Zcoin",
3055 onSelect: function() {
3056 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
3061 name: "ZCL - Zclassic",
3062 onSelect: function() {
3063 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
3068 name: "ZEC - Zcash",
3069 onSelect: function() {
3070 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
3075 name: "ZEN - Horizen",
3076 onSelect: function() {
3077 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
3085 name: "Bitcoin Core",
3086 onSelect: function() {
3087 DOM
.bip32path
.val("m/0'/0'");
3088 DOM
.hardenedAddresses
.prop('checked', true);
3092 name: "blockchain.info",
3093 onSelect: function() {
3094 DOM
.bip32path
.val("m/44'/0'/0'");
3095 DOM
.hardenedAddresses
.prop('checked', false);
3099 name: "MultiBit HD",
3100 onSelect: function() {
3101 DOM
.bip32path
.val("m/0'/0");
3102 DOM
.hardenedAddresses
.prop('checked', false);
3106 name: "Coinomi, Ledger",
3107 onSelect: function() {
3108 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
3109 DOM
.hardenedAddresses
.prop('checked', false);