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
== "EWT - EnergyWeb")
1027 || (networks
[DOM
.network
.val()].name
== "PIRL - Pirl")
1028 || (networks
[DOM
.network
.val()].name
== "MIX - MIX")
1029 || (networks
[DOM
.network
.val()].name
== "MUSIC - Musicoin")
1030 || (networks
[DOM
.network
.val()].name
== "POA - Poa")
1031 || (networks
[DOM
.network
.val()].name
== "EXP - Expanse")
1032 || (networks
[DOM
.network
.val()].name
== "CLO - Callisto")
1033 || (networks
[DOM
.network
.val()].name
== "DXN - DEXON")
1034 || (networks
[DOM
.network
.val()].name
== "ELLA - Ellaism")
1035 || (networks
[DOM
.network
.val()].name
== "ESN - Ethersocial Network")
1036 || (networks
[DOM
.network
.val()].name
== "VET - VeChain")
1038 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1039 privkey
= privKeyBuffer
.toString('hex');
1040 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
1041 var hexAddress
= addressBuffer
.toString('hex');
1042 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
1043 address
= ethUtil
.addHexPrefix(checksumAddress
);
1044 privkey
= ethUtil
.addHexPrefix(privkey
);
1045 pubkey
= ethUtil
.addHexPrefix(pubkey
);
1048 // Stellar is different
1049 if (networks
[DOM
.network
.val()].name
== "XLM - Stellar") {
1050 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
1051 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
1053 path
+= purpose
+ "'/";
1054 path
+= coin
+ "'/" + index
+ "'";
1055 var keypair
= stellarUtil
.getKeypair(path
, seed
);
1057 privkey
= keypair
.secret();
1058 pubkey
= address
= keypair
.publicKey();
1060 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
1061 var NasAccount
= require("nebulas-account");
1062 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1063 var nebulasAccount
= new NasAccount();
1064 nebulasAccount
.setPrivateKey(privKeyBuffer
);
1065 address
= nebulasAccount
.getAddressString();
1066 privkey
= nebulasAccount
.getPrivateKeyString();
1067 pubkey
= nebulasAccount
.getPublicKeyString();
1069 // Ripple values are different
1070 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
1071 privkey
= convertRipplePriv(privkey
);
1072 address
= convertRippleAdrr(address
);
1074 // CasinoCoin values are different
1075 if (networks
[DOM
.network
.val()].name
== "CSC - CasinoCoin") {
1076 privkey
= convertCasinoCoinPriv(privkey
);
1077 address
= convertCasinoCoinAdrr(address
);
1079 // Bitcoin Cash address format may vary
1080 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
1081 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1082 if (bchAddrType
== "cashaddr") {
1083 address
= bchaddr
.toCashAddress(address
);
1085 else if (bchAddrType
== "bitpay") {
1086 address
= bchaddr
.toBitpayAddress(address
);
1089 // Bitcoin Cash address format may vary
1090 if (networks
[DOM
.network
.val()].name
== "SLP - Simple Ledger Protocol") {
1091 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1092 if (bchAddrType
== "cashaddr") {
1093 address
= bchaddr
.toSlpAddress(address
);
1096 // Segwit addresses are different
1098 if (!segwitAvailable
) {
1102 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1103 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1104 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1106 else if (isP2wpkhInP2sh
) {
1107 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1108 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1109 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
1110 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
1111 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1115 if ((networks
[DOM
.network
.val()].name
== "CRW - Crown")) {
1116 address
= bitcoinjs
.bitcoin
.networks
.crown
.toNewAddress(address
);
1119 if (networks
[DOM
.network
.val()].name
== "EOS - EOSIO") {
1121 pubkey
= eosUtil
.bufferToPublic(keyPair
.getPublicKeyBuffer());
1122 privkey
= eosUtil
.bufferToPrivate(keyPair
.d
.toBuffer(32));
1125 //Groestlcoin Addresses are different
1129 if (!segwitAvailable
) {
1133 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1135 else if (isP2wpkhInP2sh
) {
1136 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1139 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1142 addAddressToList(indexText
, address
, pubkey
, privkey
);
1154 function showMore() {
1155 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
1156 if (isNaN(rowsToAdd
)) {
1158 DOM
.rowsToAdd
.val("20");
1160 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
1162 start
= lastIndexInTable() + 1;
1165 var newStart
= start
+ rowsToAdd
;
1166 DOM
.moreRowsStartIndex
.val(newStart
);
1168 if (rowsToAdd
> 200) {
1169 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1170 msg
+= "Do you want to continue?";
1171 if (!confirm(msg
)) {
1175 displayAddresses(start
, rowsToAdd
);
1178 function clearDisplay() {
1179 clearAddressesList();
1181 hideValidationError();
1184 function clearAddressesList() {
1185 DOM
.addresses
.empty();
1190 function stopGenerating() {
1191 while (generationProcesses
.length
> 0) {
1192 var generation
= generationProcesses
.shift();
1197 function clearKeys() {
1202 function clearRootKey() {
1203 DOM
.rootKey
.val("");
1206 function clearDerivedKeys() {
1207 DOM
.extendedPrivKey
.val("");
1208 DOM
.extendedPubKey
.val("");
1209 DOM
.bip44accountXprv
.val("");
1210 DOM
.bip44accountXpub
.val("");
1213 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1214 var row
= $(addressRowTemplate
.html());
1216 var indexCell
= row
.find(".index span");
1217 var addressCell
= row
.find(".address span");
1218 var pubkeyCell
= row
.find(".pubkey span");
1219 var privkeyCell
= row
.find(".privkey span");
1221 indexCell
.text(indexText
);
1222 addressCell
.text(address
);
1223 pubkeyCell
.text(pubkey
);
1224 privkeyCell
.text(privkey
);
1227 indexCell
.addClass("invisible");
1230 addressCell
.addClass("invisible");
1233 pubkeyCell
.addClass("invisible");
1236 privkeyCell
.addClass("invisible");
1238 DOM
.addresses
.append(row
);
1239 var rowShowQrEls
= row
.find("[data-show-qr]");
1240 setQrEvents(rowShowQrEls
);
1243 function hasStrongRandom() {
1244 return 'crypto' in window
&& window
['crypto'] !== null;
1247 function disableForms() {
1248 $("form").on("submit", function(e
) {
1253 function parseIntNoNaN(val
, defaultVal
) {
1254 var v
= parseInt(val
);
1261 function showPending() {
1263 .text("Calculating...")
1267 function findNearestWord(word
) {
1268 var language
= getLanguage();
1269 var words
= WORDLISTS
[language
];
1270 var minDistance
= 99;
1271 var closestWord
= words
[0];
1272 for (var i
=0; i
<words
.length
; i
++) {
1273 var comparedTo
= words
[i
];
1274 if (comparedTo
.indexOf(word
) == 0) {
1277 var distance
= Levenshtein
.get(word
, comparedTo
);
1278 if (distance
< minDistance
) {
1279 closestWord
= comparedTo
;
1280 minDistance
= distance
;
1286 function hidePending() {
1292 function populateNetworkSelect() {
1293 for (var i
=0; i
<networks
.length
; i
++) {
1294 var network
= networks
[i
];
1295 var option
= $("<option>");
1296 option
.attr("value", i
);
1297 option
.text(network
.name
);
1298 if (network
.name
== "BTC - Bitcoin") {
1299 option
.prop("selected", true);
1301 DOM
.phraseNetwork
.append(option
);
1305 function populateClientSelect() {
1306 for (var i
=0; i
<clients
.length
; i
++) {
1307 var client
= clients
[i
];
1308 var option
= $("<option>");
1309 option
.attr("value", i
);
1310 option
.text(client
.name
);
1311 DOM
.bip32Client
.append(option
);
1315 function getLanguage() {
1316 var defaultLanguage
= "english";
1317 // Try to get from existing phrase
1318 var language
= getLanguageFromPhrase();
1319 // Try to get from url if not from phrase
1320 if (language
.length
== 0) {
1321 language
= getLanguageFromUrl();
1323 // Default to English if no other option
1324 if (language
.length
== 0) {
1325 language
= defaultLanguage
;
1330 function getLanguageFromPhrase(phrase
) {
1331 // Check if how many words from existing phrase match a language.
1334 phrase
= DOM
.phrase
.val();
1336 if (phrase
.length
> 0) {
1337 var words
= phraseToWordArray(phrase
);
1338 var languageMatches
= {};
1339 for (l
in WORDLISTS
) {
1340 // Track how many words match in this language
1341 languageMatches
[l
] = 0;
1342 for (var i
=0; i
<words
.length
; i
++) {
1343 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1344 if (wordInLanguage
) {
1345 languageMatches
[l
]++;
1348 // Find languages with most word matches.
1349 // This is made difficult due to commonalities between Chinese
1350 // simplified vs traditional.
1351 var mostMatches
= 0;
1352 var mostMatchedLanguages
= [];
1353 for (var l
in languageMatches
) {
1354 var numMatches
= languageMatches
[l
];
1355 if (numMatches
> mostMatches
) {
1356 mostMatches
= numMatches
;
1357 mostMatchedLanguages
= [l
];
1359 else if (numMatches
== mostMatches
) {
1360 mostMatchedLanguages
.push(l
);
1364 if (mostMatchedLanguages
.length
> 0) {
1365 // Use first language and warn if multiple detected
1366 language
= mostMatchedLanguages
[0];
1367 if (mostMatchedLanguages
.length
> 1) {
1368 console
.warn("Multiple possible languages");
1369 console
.warn(mostMatchedLanguages
);
1376 function getLanguageFromUrl() {
1377 for (var language
in WORDLISTS
) {
1378 if (window
.location
.hash
.indexOf(language
) > -1) {
1385 function setMnemonicLanguage() {
1386 var language
= getLanguage();
1387 // Load the bip39 mnemonic generator for this language if required
1388 if (!(language
in mnemonics
)) {
1389 mnemonics
[language
] = new Mnemonic(language
);
1391 mnemonic
= mnemonics
[language
];
1394 function convertPhraseToNewLanguage() {
1395 var oldLanguage
= getLanguageFromPhrase();
1396 var newLanguage
= getLanguageFromUrl();
1397 var oldPhrase
= DOM
.phrase
.val();
1398 var oldWords
= phraseToWordArray(oldPhrase
);
1400 for (var i
=0; i
<oldWords
.length
; i
++) {
1401 var oldWord
= oldWords
[i
];
1402 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1403 var newWord
= WORDLISTS
[newLanguage
][index
];
1404 newWords
.push(newWord
);
1406 newPhrase
= wordArrayToPhrase(newWords
);
1410 // TODO look at jsbip39 - mnemonic.splitWords
1411 function phraseToWordArray(phrase
) {
1412 var words
= phrase
.split(/\s/g);
1414 for (var i
=0; i
<words
.length
; i
++) {
1415 var word
= words
[i
];
1416 if (word
.length
> 0) {
1417 noBlanks
.push(word
);
1423 // TODO look at jsbip39 - mnemonic.joinWords
1424 function wordArrayToPhrase(words
) {
1425 var phrase
= words
.join(" ");
1426 var language
= getLanguageFromPhrase(phrase
);
1427 if (language
== "japanese") {
1428 phrase
= words
.join("\u3000");
1433 function writeSplitPhrase(phrase
) {
1434 var wordCount
= phrase
.split(/\s/g).length
; //get number of words in phrase
1435 var left
=[]; //initialize array of indexs
1436 for (var i
=0;i
<wordCount
;i
++) left
.push(i
); //add all indexs to array
1437 var group
=[[],[],[]], //make array for 3 groups
1438 groupI
=-1; //initialize group index
1439 var seed
= Math
.abs(sjcl
.hash
.sha256
.hash(phrase
)[0])% 2147483647; //start seed at sudo random value based on hash of words
1440 while (left
.length
>0) { //while indexs left
1441 groupI
=(groupI
+1)%3; //get next group to insert index into
1442 seed
= seed
* 16807 % 2147483647; //change random value.(simple predicatable random number generator works well for this use)
1443 var selected
=Math
.floor(left
.length
*(seed
- 1) / 2147483646); //get index in left we will use for this group
1444 group
[groupI
].push(left
[selected
]); //add index to group
1445 left
.splice(selected
,1); //remove selected index
1447 var cards
=[phrase
.split(/\s/g),phrase
.split(/\s/g),phrase
.split(/\s/g)];//make array of cards
1448 for (var i
=0;i
<3;i
++) { //go through each card
1449 for (var ii
=0;ii
<wordCount
/3;ii
++) cards
[i
][group
[i
][ii
]]='XXXX'; //erase words listed in the group
1450 cards
[i
]='Card '+(i
+1)+': '+wordArrayToPhrase(cards
[i
]); //combine words on card back to string
1452 DOM
.splitPhrase
.val(cards
.join("\r\n")); //make words visible
1453 var triesPerSecond
=10000000000; //assumed number of tries per second
1454 var hackTime
=Math
.pow(2,wordCount
*10/3)/triesPerSecond
; //get number of bits of unknown data per card
1456 hackTime
="<1 second";
1457 } else if (hackTime
<86400) {
1458 hackTime
=Math
.floor(hackTime
)+" seconds";
1459 } else if(hackTime
<31557600) {
1460 hackTime
=Math
.floor(hackTime
/86400)+" days";
1462 hackTime
=Math
.floor(hackTime
/31557600)+" years";
1464 DOM
.phraseSplitWarn
.html("Time to hack with only one card: "+hackTime
);
1467 function isUsingOwnEntropy() {
1468 return DOM
.useEntropy
.prop("checked");
1471 function setMnemonicFromEntropy() {
1472 clearEntropyFeedback();
1473 // Get entropy value
1474 var entropyStr
= DOM
.entropy
.val();
1475 // Work out minimum base for entropy
1476 var entropy
= Entropy
.fromString(entropyStr
);
1477 if (entropy
.binaryStr
.length
== 0) {
1480 // Show entropy details
1481 showEntropyFeedback(entropy
);
1482 // Use entropy hash if not using raw entropy
1483 var bits
= entropy
.binaryStr
;
1484 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1485 if (mnemonicLength
!= "raw") {
1486 // Get bits by hashing entropy with SHA256
1487 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1488 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1489 bits
= BigInteger
.parse(hex
, 16).toString(2);
1490 while (bits
.length
% 256 != 0) {
1493 // Truncate hash to suit number of words
1494 mnemonicLength
= parseInt(mnemonicLength
);
1495 var numberOfBits
= 32 * mnemonicLength
/ 3;
1496 bits
= bits
.substring(0, numberOfBits
);
1497 // show warning for weak entropy override
1498 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1499 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1502 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1506 // hide warning for weak entropy override
1507 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1509 // Discard trailing entropy
1510 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1511 var start
= bits
.length
- bitsToUse
;
1512 var binaryStr
= bits
.substring(start
);
1513 // Convert entropy string to numeric array
1514 var entropyArr
= [];
1515 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1516 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1517 var entropyByte
= parseInt(byteAsBits
, 2);
1518 entropyArr
.push(entropyByte
)
1520 // Convert entropy array to mnemonic
1521 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1522 // Set the mnemonic in the UI
1523 DOM
.phrase
.val(phrase
);
1524 writeSplitPhrase(phrase
);
1525 // Show the word indexes
1527 // Show the checksum
1531 function clearEntropyFeedback() {
1532 DOM
.entropyCrackTime
.text("...");
1533 DOM
.entropyType
.text("");
1534 DOM
.entropyWordCount
.text("0");
1535 DOM
.entropyEventCount
.text("0");
1536 DOM
.entropyBitsPerEvent
.text("0");
1537 DOM
.entropyBits
.text("0");
1538 DOM
.entropyFiltered
.html(" ");
1539 DOM
.entropyBinary
.html(" ");
1542 function showEntropyFeedback(entropy
) {
1543 var numberOfBits
= entropy
.binaryStr
.length
;
1544 var timeToCrack
= "unknown";
1546 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1547 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1548 if (z
.feedback
.warning
!= "") {
1549 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1553 console
.log("Error detecting entropy strength with zxcvbn:");
1556 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1557 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1558 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1559 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1560 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1561 DOM
.entropyType
.text(entropyTypeStr
);
1562 DOM
.entropyCrackTime
.text(timeToCrack
);
1563 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1564 DOM
.entropyBits
.text(numberOfBits
);
1565 DOM
.entropyWordCount
.text(wordCount
);
1566 DOM
.entropyBinary
.text(spacedBinaryStr
);
1567 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1568 // detect and warn of filtering
1569 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1570 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1571 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1573 DOM
.entropyFilterWarning
.removeClass('hidden');
1576 DOM
.entropyFilterWarning
.addClass('hidden');
1580 function getEntropyTypeStr(entropy
) {
1581 var typeStr
= entropy
.base
.str
;
1582 // Add some detail if these are cards
1583 if (entropy
.base
.asInt
== 52) {
1584 var cardDetail
= []; // array of message strings
1585 // Detect duplicates
1587 var dupeTracker
= {};
1588 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1589 var card
= entropy
.base
.parts
[i
];
1590 var cardUpper
= card
.toUpperCase();
1591 if (cardUpper
in dupeTracker
) {
1594 dupeTracker
[cardUpper
] = true;
1596 if (dupes
.length
> 0) {
1597 var dupeWord
= "duplicates";
1598 if (dupes
.length
== 1) {
1599 dupeWord
= "duplicate";
1601 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1602 if (dupes
.length
> 3) {
1605 cardDetail
.push(msg
);
1608 var uniqueCards
= [];
1609 for (var uniqueCard
in dupeTracker
) {
1610 uniqueCards
.push(uniqueCard
);
1612 if (uniqueCards
.length
== 52) {
1613 cardDetail
.unshift("full deck");
1615 // Detect missing cards
1616 var values
= "A23456789TJQK";
1618 var missingCards
= [];
1619 for (var i
=0; i
<suits
.length
; i
++) {
1620 for (var j
=0; j
<values
.length
; j
++) {
1621 var card
= values
[j
] + suits
[i
];
1622 if (!(card
in dupeTracker
)) {
1623 missingCards
.push(card
);
1627 // Display missing cards if six or less, ie clearly going for full deck
1628 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1629 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1630 if (missingCards
.length
> 3) {
1633 cardDetail
.push(msg
);
1635 // Add card details to typeStr
1636 if (cardDetail
.length
> 0) {
1637 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1643 function setQrEvents(els
) {
1644 els
.on("mouseenter", createQr
);
1645 els
.on("mouseleave", destroyQr
);
1646 els
.on("click", toggleQr
);
1649 function createQr(e
) {
1650 var content
= e
.target
.textContent
|| e
.target
.value
;
1658 DOM
.qrImage
.append(qrEl
);
1660 DOM
.qrHider
.addClass("hidden");
1663 DOM
.qrHider
.removeClass("hidden");
1665 DOM
.qrContainer
.removeClass("hidden");
1669 function destroyQr() {
1670 DOM
.qrImage
.text("");
1671 DOM
.qrContainer
.addClass("hidden");
1674 function toggleQr() {
1676 DOM
.qrHider
.toggleClass("hidden");
1677 DOM
.qrHint
.toggleClass("hidden");
1680 function bip44TabSelected() {
1681 return DOM
.bip44tab
.hasClass("active");
1684 function bip32TabSelected() {
1685 return DOM
.bip32tab
.hasClass("active");
1688 function networkHasSegwit() {
1690 if ("baseNetwork" in network
) {
1691 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1693 // check if only p2wpkh params are required
1694 if (p2wpkhSelected()) {
1695 return "p2wpkh" in n
;
1697 // check if only p2wpkh-in-p2sh params are required
1698 else if (p2wpkhInP2shSelected()) {
1699 return "p2wpkhInP2sh" in n
;
1701 // require both if it's unclear which params are required
1702 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1705 function bip49TabSelected() {
1706 return DOM
.bip49tab
.hasClass("active");
1709 function bip84TabSelected() {
1710 return DOM
.bip84tab
.hasClass("active");
1713 function bip141TabSelected() {
1714 return DOM
.bip141tab
.hasClass("active");
1717 function setHdCoin(coinValue
) {
1718 DOM
.bip44coin
.val(coinValue
);
1719 DOM
.bip49coin
.val(coinValue
);
1720 DOM
.bip84coin
.val(coinValue
);
1723 function showSegwitAvailable() {
1724 DOM
.bip49unavailable
.addClass("hidden");
1725 DOM
.bip49available
.removeClass("hidden");
1726 DOM
.bip84unavailable
.addClass("hidden");
1727 DOM
.bip84available
.removeClass("hidden");
1728 DOM
.bip141unavailable
.addClass("hidden");
1729 DOM
.bip141available
.removeClass("hidden");
1732 function showSegwitUnavailable() {
1733 DOM
.bip49available
.addClass("hidden");
1734 DOM
.bip49unavailable
.removeClass("hidden");
1735 DOM
.bip84available
.addClass("hidden");
1736 DOM
.bip84unavailable
.removeClass("hidden");
1737 DOM
.bip141available
.addClass("hidden");
1738 DOM
.bip141unavailable
.removeClass("hidden");
1741 function adjustNetworkForSegwit() {
1742 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1743 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1745 // See https://github.com/iancoleman/bip39/issues/125
1746 var segwitNetworks
= null;
1747 // if a segwit network is alread selected, need to use base network to
1748 // look up new parameters
1749 if ("baseNetwork" in network
) {
1750 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1752 // choose the right segwit params
1753 if (p2wpkhSelected() && "p2wpkh" in network
) {
1754 network
= network
.p2wpkh
;
1756 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1757 network
= network
.p2wpkhInP2sh
;
1761 function lastIndexInTable() {
1762 var pathText
= DOM
.addresses
.find(".index").last().text();
1763 var pathBits
= pathText
.split("/");
1764 var lastBit
= pathBits
[pathBits
.length
-1];
1765 var lastBitClean
= lastBit
.replace("'", "");
1766 return parseInt(lastBitClean
);
1769 function uint8ArrayToHex(a
) {
1771 for (var i
=0; i
<a
.length
; i
++) {
1772 var h
= a
[i
].toString(16);
1773 while (h
.length
< 2) {
1781 function showWordIndexes() {
1782 var phrase
= DOM
.phrase
.val();
1783 var words
= phraseToWordArray(phrase
);
1784 var wordIndexes
= [];
1785 var language
= getLanguage();
1786 for (var i
=0; i
<words
.length
; i
++) {
1787 var word
= words
[i
];
1788 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1789 wordIndexes
.push(wordIndex
);
1791 var wordIndexesStr
= wordIndexes
.join(", ");
1792 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1795 function showChecksum() {
1796 var phrase
= DOM
.phrase
.val();
1797 var words
= phraseToWordArray(phrase
);
1798 var checksumBitlength
= words
.length
/ 3;
1801 var language
= getLanguage();
1802 for (var i
=words
.length
-1; i
>=0; i
--) {
1803 var word
= words
[i
];
1804 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1805 var wordBinary
= wordIndex
.toString(2);
1806 while (wordBinary
.length
< 11) {
1807 wordBinary
= "0" + wordBinary
;
1809 var binaryStr
= wordBinary
+ binaryStr
;
1810 if (binaryStr
.length
>= checksumBitlength
) {
1811 var start
= binaryStr
.length
- checksumBitlength
;
1812 var end
= binaryStr
.length
;
1813 checksum
= binaryStr
.substring(start
, end
);
1814 // add spaces so the last group is 11 bits, not the first
1815 checksum
= checksum
.split("").reverse().join("")
1816 checksum
= addSpacesEveryElevenBits(checksum
);
1817 checksum
= checksum
.split("").reverse().join("")
1821 DOM
.entropyChecksum
.text(checksum
);
1824 function updateCsv() {
1825 var tableCsv
= "path,address,public key,private key\n";
1826 var rows
= DOM
.addresses
.find("tr");
1827 for (var i
=0; i
<rows
.length
; i
++) {
1828 var row
= $(rows
[i
]);
1829 var cells
= row
.find("td");
1830 for (var j
=0; j
<cells
.length
; j
++) {
1831 var cell
= $(cells
[j
]);
1832 if (!cell
.children().hasClass("invisible")) {
1833 tableCsv
= tableCsv
+ cell
.text();
1835 if (j
!= cells
.length
- 1) {
1836 tableCsv
= tableCsv
+ ",";
1839 tableCsv
= tableCsv
+ "\n";
1841 DOM
.csv
.val(tableCsv
);
1844 function addSpacesEveryElevenBits(binaryStr
) {
1845 return binaryStr
.match(/.{1,11}/g).join(" ");
1850 name: "AC - Asiacoin",
1851 onSelect: function() {
1852 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1857 name: "ACC - Adcoin",
1858 onSelect: function() {
1859 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1864 name: "ARYA - Aryacoin",
1865 onSelect: function() {
1866 network
= bitcoinjs
.bitcoin
.networks
.aryacoin
;
1871 name: "AUR - Auroracoin",
1872 onSelect: function() {
1873 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1879 onSelect: function() {
1880 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1885 name: "ANON - ANON",
1886 onSelect: function() {
1887 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1892 name: "BOLI - Bolivarcoin",
1893 onSelect: function() {
1894 network
= bitcoinjs
.bitcoin
.networks
.bolivarcoin
;
1899 name: "BCA - Bitcoin Atom",
1900 onSelect: function() {
1901 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1906 name: "BCH - Bitcoin Cash",
1907 onSelect: function() {
1908 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1913 name: "BEET - Beetlecoin",
1914 onSelect: function() {
1915 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1920 name: "BELA - Belacoin",
1921 onSelect: function() {
1922 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1927 name: "BLK - BlackCoin",
1928 onSelect: function() {
1929 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1934 name: "BND - Blocknode",
1935 onSelect: function() {
1936 network
= bitcoinjs
.bitcoin
.networks
.blocknode
;
1941 name: "tBND - Blocknode Testnet",
1942 onSelect: function() {
1943 network
= bitcoinjs
.bitcoin
.networks
.blocknode_testnet
;
1948 name: "BRIT - Britcoin",
1949 onSelect: function() {
1950 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
1955 name: "BSD - Bitsend",
1956 onSelect: function() {
1957 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
1962 name: "BST - BlockStamp",
1963 onSelect: function() {
1964 network
= bitcoinjs
.bitcoin
.networks
.blockstamp
;
1970 onSelect: function() {
1971 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1976 name: "BTC - Bitcoin",
1977 onSelect: function() {
1978 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1983 name: "BTC - Bitcoin Testnet",
1984 onSelect: function() {
1985 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1990 name: "BITG - Bitcoin Green",
1991 onSelect: function() {
1992 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1997 name: "BTCP - Bitcoin Private",
1998 onSelect: function() {
1999 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
2004 name: "BSV - BitcoinSV",
2005 onSelect: function() {
2006 network
= bitcoinjs
.bitcoin
.networks
.bitcoinsv
;
2011 name: "BTCZ - Bitcoinz",
2012 onSelect: function() {
2013 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
2018 name: "BTDX - BitCloud",
2019 onSelect: function() {
2020 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
2025 name: "BTG - Bitcoin Gold",
2026 onSelect: function() {
2027 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
2032 name: "BTX - Bitcore",
2033 onSelect: function() {
2034 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
2039 name: "CCN - Cannacoin",
2040 onSelect: function() {
2041 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2046 name: "CESC - Cryptoescudo",
2047 onSelect: function() {
2048 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2053 name: "CDN - Canadaecoin",
2054 onSelect: function() {
2055 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
2060 name: "CLAM - Clams",
2061 onSelect: function() {
2062 network
= bitcoinjs
.bitcoin
.networks
.clam
;
2067 name: "CLO - Callisto",
2068 segwitAvailable: false,
2069 onSelect: function() {
2070 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2075 name: "CLUB - Clubcoin",
2076 onSelect: function() {
2077 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
2082 name: "CMP - Compcoin",
2083 onSelect: function() {
2084 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
2089 name: "CPU - CPUchain",
2090 onSelect: function() {
2091 network
= bitcoinjs
.bitcoin
.networks
.cpuchain
;
2096 name: "CRAVE - Crave",
2097 onSelect: function() {
2098 network
= bitcoinjs
.bitcoin
.networks
.crave
;
2103 name: "CRW - Crown (Legacy)",
2104 onSelect: function() {
2105 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2110 name: "CRW - Crown",
2111 onSelect: function() {
2112 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2117 name: "CSC - CasinoCoin",
2118 onSelect: function() {
2119 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2124 name: "DASH - Dash",
2125 onSelect: function() {
2126 network
= bitcoinjs
.bitcoin
.networks
.dash
;
2131 name: "DASH - Dash Testnet",
2132 onSelect: function() {
2133 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
2138 name: "DFC - Defcoin",
2139 onSelect: function() {
2140 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
2145 name: "DGB - Digibyte",
2146 onSelect: function() {
2147 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
2152 name: "DGC - Digitalcoin",
2153 onSelect: function() {
2154 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
2159 name: "DMD - Diamond",
2160 onSelect: function() {
2161 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
2166 name: "DNR - Denarius",
2167 onSelect: function() {
2168 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
2173 name: "DOGE - Dogecoin",
2174 onSelect: function() {
2175 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
2180 name: "DOGEt - Dogecoin Testnet",
2181 onSelect: function() {
2182 network
= bitcoinjs
.bitcoin
.networks
.dogecointestnet
;
2187 name: "DXN - DEXON",
2188 onSelect: function() {
2189 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2194 name: "ECN - Ecoin",
2195 onSelect: function() {
2196 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
2201 name: "EDRC - Edrcoin",
2202 onSelect: function() {
2203 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
2208 name: "EFL - Egulden",
2209 onSelect: function() {
2210 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
2215 name: "ELLA - Ellaism",
2216 segwitAvailable: false,
2217 onSelect: function() {
2218 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2223 name: "EMC2 - Einsteinium",
2224 onSelect: function() {
2225 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
2230 name: "ERC - Europecoin",
2231 onSelect: function() {
2232 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
2237 name: "EOS - EOSIO",
2238 onSelect: function() {
2239 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2244 name: "ESN - Ethersocial Network",
2245 segwitAvailable: false,
2246 onSelect: function() {
2247 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2252 name: "ETC - Ethereum Classic",
2253 segwitAvailable: false,
2254 onSelect: function() {
2255 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2260 name: "ETH - Ethereum",
2261 onSelect: function() {
2262 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2267 name: "EWT - EnergyWeb",
2268 onSelect: function() {
2269 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2274 name: "EXCL - Exclusivecoin",
2275 onSelect: function() {
2276 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
2281 name: "EXCC - ExchangeCoin",
2282 onSelect: function() {
2283 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
2288 name: "EXP - Expanse",
2289 segwitAvailable: false,
2290 onSelect: function() {
2291 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2297 onSelect: function() {
2298 network
= bitcoinjs
.bitcoin
.networks
.fix
;
2303 name: "FIX - FIX Testnet",
2304 onSelect: function() {
2305 network
= bitcoinjs
.bitcoin
.networks
.fixtestnet
;
2310 name: "FJC - Fujicoin",
2311 onSelect: function() {
2312 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2317 name: "FLASH - Flashcoin",
2318 onSelect: function() {
2319 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2324 name: "FRST - Firstcoin",
2325 onSelect: function() {
2326 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2331 name: "FTC - Feathercoin",
2332 onSelect: function() {
2333 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2338 name: "GAME - GameCredits",
2339 onSelect: function() {
2340 network
= bitcoinjs
.bitcoin
.networks
.game
;
2345 name: "GBX - Gobyte",
2346 onSelect: function() {
2347 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2352 name: "GCR - GCRCoin",
2353 onSelect: function() {
2354 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2359 name: "GRC - Gridcoin",
2360 onSelect: function() {
2361 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2366 name: "GRS - Groestlcoin",
2367 onSelect: function() {
2368 network
= bitcoinjs
.bitcoin
.networks
.groestlcoin
;
2373 name: "GRS - Groestlcoin Testnet",
2374 onSelect: function() {
2375 network
= bitcoinjs
.bitcoin
.networks
.groestlcointestnet
;
2380 name: "HNC - Helleniccoin",
2381 onSelect: function() {
2382 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2387 name: "HUSH - Hush (Legacy)",
2388 onSelect: function() {
2389 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2394 name: "HUSH - Hush3",
2395 onSelect: function() {
2396 network
= bitcoinjs
.bitcoin
.networks
.hush3
;
2401 name: "INSN - Insane",
2402 onSelect: function() {
2403 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2409 onSelect: function() {
2410 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2415 name: "IXC - Ixcoin",
2416 onSelect: function() {
2417 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2422 name: "JBS - Jumbucks",
2423 onSelect: function() {
2424 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2429 name: "KMD - Komodo",
2430 bip49available: false,
2431 onSelect: function() {
2432 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2437 name: "KOBO - Kobocoin",
2438 bip49available: false,
2439 onSelect: function() {
2440 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2445 name: "LBC - Library Credits",
2446 onSelect: function() {
2447 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2452 name: "LCC - Litecoincash",
2453 onSelect: function() {
2454 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2459 name: "LDCN - Landcoin",
2460 onSelect: function() {
2461 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2466 name: "LINX - Linx",
2467 onSelect: function() {
2468 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2473 name: "LKR - Lkrcoin",
2474 segwitAvailable: false,
2475 onSelect: function() {
2476 network
= bitcoinjs
.bitcoin
.networks
.lkrcoin
;
2481 name: "LTC - Litecoin",
2482 onSelect: function() {
2483 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2485 DOM
.litecoinLtubContainer
.removeClass("hidden");
2489 name: "LTCt - Litecoin Testnet",
2490 onSelect: function() {
2491 network
= bitcoinjs
.bitcoin
.networks
.litecointestnet
;
2493 DOM
.litecoinLtubContainer
.removeClass("hidden");
2497 name: "LTZ - LitecoinZ",
2498 onSelect: function() {
2499 network
= bitcoinjs
.bitcoin
.networks
.litecoinz
;
2504 name: "LYNX - Lynx",
2505 onSelect: function() {
2506 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2511 name: "MAZA - Maza",
2512 onSelect: function() {
2513 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2518 name: "MEC - Megacoin",
2519 onSelect: function() {
2520 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2526 segwitAvailable: false,
2527 onSelect: function() {
2528 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2533 name: "MNX - Minexcoin",
2534 onSelect: function() {
2535 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2540 name: "MONA - Monacoin",
2541 onSelect: function() {
2542 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2547 name: "MONK - Monkey Project",
2548 onSelect: function() {
2549 network
= bitcoinjs
.bitcoin
.networks
.monkeyproject
,
2554 name: "MUSIC - Musicoin",
2555 segwitAvailable: false,
2556 onSelect: function() {
2557 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2562 name: "NAV - Navcoin",
2563 onSelect: function() {
2564 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2569 name: "NAS - Nebulas",
2570 onSelect: function() {
2571 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2576 name: "NEBL - Neblio",
2577 onSelect: function() {
2578 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2583 name: "NEOS - Neoscoin",
2584 onSelect: function() {
2585 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2590 name: "NIX - NIX Platform",
2591 onSelect: function() {
2592 network
= bitcoinjs
.bitcoin
.networks
.nix
;
2597 name: "NLG - Gulden",
2598 onSelect: function() {
2599 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2604 name: "NMC - Namecoin",
2605 onSelect: function() {
2606 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2611 name: "NRG - Energi",
2612 onSelect: function() {
2613 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2618 name: "NRO - Neurocoin",
2619 onSelect: function() {
2620 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2625 name: "NSR - Nushares",
2626 onSelect: function() {
2627 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2632 name: "NYC - Newyorkc",
2633 onSelect: function() {
2634 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2639 name: "NVC - Novacoin",
2640 onSelect: function() {
2641 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2646 name: "OK - Okcash",
2647 onSelect: function() {
2648 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2653 name: "OMNI - Omnicore",
2654 onSelect: function() {
2655 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2660 name: "ONION - DeepOnion",
2661 onSelect: function() {
2662 network
= bitcoinjs
.bitcoin
.networks
.deeponion
;
2667 name: "ONX - Onixcoin",
2668 onSelect: function() {
2669 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2674 name: "PHR - Phore",
2675 onSelect: function() {
2676 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2681 name: "PINK - Pinkcoin",
2682 onSelect: function() {
2683 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2688 name: "PIRL - Pirl",
2689 segwitAvailable: false,
2690 onSelect: function() {
2691 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2696 name: "PIVX - PIVX",
2697 onSelect: function() {
2698 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2703 name: "PIVX - PIVX Testnet",
2704 onSelect: function() {
2705 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2711 segwitAvailable: false,
2712 onSelect: function() {
2713 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2718 name: "POSW - POSWcoin",
2719 onSelect: function() {
2720 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2725 name: "POT - Potcoin",
2726 onSelect: function() {
2727 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2732 name: "PPC - Peercoin",
2733 onSelect: function() {
2734 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2739 name: "PRJ - ProjectCoin",
2740 onSelect: function() {
2741 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2746 name: "PSB - Pesobit",
2747 onSelect: function() {
2748 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2753 name: "PUT - Putincoin",
2754 onSelect: function() {
2755 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2760 name: "RPD - Rapids",
2761 onSelect: function() {
2762 network
= bitcoinjs
.bitcoin
.networks
.rapids
;
2767 name: "RVN - Ravencoin",
2768 onSelect: function() {
2769 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2774 name: "RBY - Rubycoin",
2775 onSelect: function() {
2776 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2781 name: "RDD - Reddcoin",
2782 onSelect: function() {
2783 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2788 name: "RVR - RevolutionVR",
2789 onSelect: function() {
2790 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2795 name: "SAFE - Safecoin",
2796 onSelect: function() {
2797 network
= bitcoinjs
.bitcoin
.networks
.safecoin
;
2802 name: "SLS - Salus",
2803 onSelect: function() {
2804 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2809 name: "SDC - ShadowCash",
2810 onSelect: function() {
2811 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2816 name: "SDC - ShadowCash Testnet",
2817 onSelect: function() {
2818 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2823 name: "SLM - Slimcoin",
2824 onSelect: function() {
2825 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2830 name: "SLM - Slimcoin Testnet",
2831 onSelect: function() {
2832 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2837 name: "SLP - Simple Ledger Protocol",
2838 onSelect: function() {
2839 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2844 name: "SLR - Solarcoin",
2845 onSelect: function() {
2846 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2851 name: "SMLY - Smileycoin",
2852 onSelect: function() {
2853 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2858 name: "STASH - Stash",
2859 onSelect: function() {
2860 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2865 name: "STASH - Stash Testnet",
2866 onSelect: function() {
2867 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2872 name: "STRAT - Stratis",
2873 onSelect: function() {
2874 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2879 name: "TSTRAT - Stratis Testnet",
2880 onSelect: function() {
2881 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2886 name: "SYS - Syscoin",
2887 onSelect: function() {
2888 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2893 name: "THC - Hempcoin",
2894 onSelect: function() {
2895 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2901 onSelect: function() {
2902 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2907 name: "TWINS - TWINS",
2908 onSelect: function() {
2909 network
= bitcoinjs
.bitcoin
.networks
.twins
;
2914 name: "TWINS - TWINS Testnet",
2915 onSelect: function() {
2916 network
= bitcoinjs
.bitcoin
.networks
.twinstestnet
;
2921 name: "USC - Ultimatesecurecash",
2922 onSelect: function() {
2923 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2928 name: "USNBT - NuBits",
2929 onSelect: function() {
2930 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2935 name: "UNO - Unobtanium",
2936 onSelect: function() {
2937 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2942 name: "VASH - Vpncoin",
2943 onSelect: function() {
2944 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2949 name: "VET - VeChain",
2950 onSelect: function() {
2951 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2956 name: "VIA - Viacoin",
2957 onSelect: function() {
2958 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2963 name: "VIA - Viacoin Testnet",
2964 onSelect: function() {
2965 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2970 name: "VIVO - Vivo",
2971 onSelect: function() {
2972 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2977 name: "VTC - Vertcoin",
2978 onSelect: function() {
2979 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2984 name: "WGR - Wagerr",
2985 onSelect: function() {
2986 network
= bitcoinjs
.bitcoin
.networks
.wagerr
;
2991 name: "WC - Wincoin",
2992 onSelect: function() {
2993 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2998 name: "XAX - Artax",
2999 onSelect: function() {
3000 network
= bitcoinjs
.bitcoin
.networks
.artax
;
3005 name: "XBC - Bitcoinplus",
3006 onSelect: function() {
3007 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
3012 name: "XLM - Stellar",
3013 onSelect: function() {
3014 network
= stellarUtil
.dummyNetwork
;
3019 name: "XMY - Myriadcoin",
3020 onSelect: function() {
3021 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
3026 name: "XRP - Ripple",
3027 onSelect: function() {
3028 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
3033 name: "XVC - Vcash",
3034 onSelect: function() {
3035 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
3040 name: "XVG - Verge",
3041 onSelect: function() {
3042 network
= bitcoinjs
.bitcoin
.networks
.verge
;
3047 name: "XUEZ - Xuez",
3048 segwitAvailable: false,
3049 onSelect: function() {
3050 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
3055 name: "XWC - Whitecoin",
3056 onSelect: function() {
3057 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
3062 name: "XZC - Zcoin",
3063 onSelect: function() {
3064 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
3069 name: "ZCL - Zclassic",
3070 onSelect: function() {
3071 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
3076 name: "ZEC - Zcash",
3077 onSelect: function() {
3078 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
3083 name: "ZEN - Horizen",
3084 onSelect: function() {
3085 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
3093 name: "Bitcoin Core",
3094 onSelect: function() {
3095 DOM
.bip32path
.val("m/0'/0'");
3096 DOM
.hardenedAddresses
.prop('checked', true);
3100 name: "blockchain.info",
3101 onSelect: function() {
3102 DOM
.bip32path
.val("m/44'/0'/0'");
3103 DOM
.hardenedAddresses
.prop('checked', false);
3107 name: "MultiBit HD",
3108 onSelect: function() {
3109 DOM
.bip32path
.val("m/0'/0");
3110 DOM
.hardenedAddresses
.prop('checked', false);
3114 name: "Coinomi, Ledger",
3115 onSelect: function() {
3116 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
3117 DOM
.hardenedAddresses
.prop('checked', false);