3 // mnemonics is populated as required by getLanguage
4 var mnemonics
= { "english": new Mnemonic("english") };
5 var mnemonic
= mnemonics
["english"];
7 var bip32RootKey
= null;
8 var bip32ExtendedKey
= null;
9 var network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
10 var addressRowTemplate
= $("#address-row-template");
13 var showAddress
= true;
14 var showPubKey
= true;
15 var showPrivKey
= true;
17 var litecoinUseLtub
= true;
19 var entropyChangeTimeoutEvent
= null;
20 var phraseChangeTimeoutEvent
= null;
21 var rootKeyChangedTimeoutEvent
= null;
23 var generationProcesses
= [];
26 DOM
.privacyScreenToggle
= $(".privacy-screen-toggle");
27 DOM
.network
= $(".network");
28 DOM
.bip32Client
= $("#bip32-client");
29 DOM
.phraseNetwork
= $("#network-phrase");
30 DOM
.useEntropy
= $(".use-entropy");
31 DOM
.entropyContainer
= $(".entropy-container");
32 DOM
.entropy
= $(".entropy");
33 DOM
.entropyFiltered
= DOM
.entropyContainer
.find(".filtered");
34 DOM
.entropyType
= DOM
.entropyContainer
.find(".type");
35 DOM
.entropyCrackTime
= DOM
.entropyContainer
.find(".crack-time");
36 DOM
.entropyEventCount
= DOM
.entropyContainer
.find(".event-count");
37 DOM
.entropyBits
= DOM
.entropyContainer
.find(".bits");
38 DOM
.entropyBitsPerEvent
= DOM
.entropyContainer
.find(".bits-per-event");
39 DOM
.entropyWordCount
= DOM
.entropyContainer
.find(".word-count");
40 DOM
.entropyBinary
= DOM
.entropyContainer
.find(".binary");
41 DOM
.entropyWordIndexes
= DOM
.entropyContainer
.find(".word-indexes");
42 DOM
.entropyChecksum
= DOM
.entropyContainer
.find(".checksum");
43 DOM
.entropyMnemonicLength
= DOM
.entropyContainer
.find(".mnemonic-length");
44 DOM
.entropyWeakEntropyOverrideWarning
= DOM
.entropyContainer
.find(".weak-entropy-override-warning");
45 DOM
.entropyFilterWarning
= DOM
.entropyContainer
.find(".filter-warning");
46 DOM
.phrase
= $(".phrase");
47 DOM
.passphrase
= $(".passphrase");
48 DOM
.generateContainer
= $(".generate-container");
49 DOM
.generate
= $(".generate");
50 DOM
.seed
= $(".seed");
51 DOM
.rootKey
= $(".root-key");
52 DOM
.litecoinLtubContainer
= $(".litecoin-ltub-container");
53 DOM
.litecoinUseLtub
= $(".litecoin-use-ltub");
54 DOM
.extendedPrivKey
= $(".extended-priv-key");
55 DOM
.extendedPubKey
= $(".extended-pub-key");
56 DOM
.bip32tab
= $("#bip32-tab");
57 DOM
.bip44tab
= $("#bip44-tab");
58 DOM
.bip49tab
= $("#bip49-tab");
59 DOM
.bip84tab
= $("#bip84-tab");
60 DOM
.bip141tab
= $("#bip141-tab");
61 DOM
.bip32panel
= $("#bip32");
62 DOM
.bip44panel
= $("#bip44");
63 DOM
.bip49panel
= $("#bip49");
64 DOM
.bip32path
= $("#bip32-path");
65 DOM
.bip44path
= $("#bip44-path");
66 DOM
.bip44purpose
= $("#bip44 .purpose");
67 DOM
.bip44coin
= $("#bip44 .coin");
68 DOM
.bip44account
= $("#bip44 .account");
69 DOM
.bip44accountXprv
= $("#bip44 .account-xprv");
70 DOM
.bip44accountXpub
= $("#bip44 .account-xpub");
71 DOM
.bip44change
= $("#bip44 .change");
72 DOM
.bip49unavailable
= $("#bip49 .unavailable");
73 DOM
.bip49available
= $("#bip49 .available");
74 DOM
.bip49path
= $("#bip49-path");
75 DOM
.bip49purpose
= $("#bip49 .purpose");
76 DOM
.bip49coin
= $("#bip49 .coin");
77 DOM
.bip49account
= $("#bip49 .account");
78 DOM
.bip49accountXprv
= $("#bip49 .account-xprv");
79 DOM
.bip49accountXpub
= $("#bip49 .account-xpub");
80 DOM
.bip49change
= $("#bip49 .change");
81 DOM
.bip84unavailable
= $("#bip84 .unavailable");
82 DOM
.bip84available
= $("#bip84 .available");
83 DOM
.bip84path
= $("#bip84-path");
84 DOM
.bip84purpose
= $("#bip84 .purpose");
85 DOM
.bip84coin
= $("#bip84 .coin");
86 DOM
.bip84account
= $("#bip84 .account");
87 DOM
.bip84accountXprv
= $("#bip84 .account-xprv");
88 DOM
.bip84accountXpub
= $("#bip84 .account-xpub");
89 DOM
.bip84change
= $("#bip84 .change");
90 DOM
.bip141unavailable
= $("#bip141 .unavailable");
91 DOM
.bip141available
= $("#bip141 .available");
92 DOM
.bip141path
= $("#bip141-path");
93 DOM
.bip141semantics
= $(".bip141-semantics");
94 DOM
.generatedStrength
= $(".generate-container .strength");
95 DOM
.generatedStrengthWarning
= $(".generate-container .warning");
96 DOM
.hardenedAddresses
= $(".hardened-addresses");
97 DOM
.bitcoinCashAddressTypeContainer
= $(".bch-addr-type-container");
98 DOM
.bitcoinCashAddressType
= $("[name=bch-addr-type]")
99 DOM
.useBip38
= $(".use-bip38");
100 DOM
.bip38Password
= $(".bip38-password");
101 DOM
.addresses
= $(".addresses");
102 DOM
.csvTab
= $("#csv-tab a");
104 DOM
.rowsToAdd
= $(".rows-to-add");
105 DOM
.more
= $(".more");
106 DOM
.moreRowsStartIndex
= $(".more-rows-start-index");
107 DOM
.feedback
= $(".feedback");
108 DOM
.tab
= $(".derivation-type a");
109 DOM
.indexToggle
= $(".index-toggle");
110 DOM
.addressToggle
= $(".address-toggle");
111 DOM
.publicKeyToggle
= $(".public-key-toggle");
112 DOM
.privateKeyToggle
= $(".private-key-toggle");
113 DOM
.languages
= $(".languages a");
114 DOM
.qrContainer
= $(".qr-container");
115 DOM
.qrHider
= DOM
.qrContainer
.find(".qr-hider");
116 DOM
.qrImage
= DOM
.qrContainer
.find(".qr-image");
117 DOM
.qrHint
= DOM
.qrContainer
.find(".qr-hint");
118 DOM
.showQrEls
= $("[data-show-qr]");
122 DOM
.privacyScreenToggle
.on("change", privacyScreenToggled
);
123 DOM
.generatedStrength
.on("change", generatedStrengthChanged
);
124 DOM
.network
.on("change", networkChanged
);
125 DOM
.bip32Client
.on("change", bip32ClientChanged
);
126 DOM
.useEntropy
.on("change", setEntropyVisibility
);
127 DOM
.entropy
.on("input", delayedEntropyChanged
);
128 DOM
.entropyMnemonicLength
.on("change", entropyChanged
);
129 DOM
.phrase
.on("input", delayedPhraseChanged
);
130 DOM
.passphrase
.on("input", delayedPhraseChanged
);
131 DOM
.generate
.on("click", generateClicked
);
132 DOM
.more
.on("click", showMore
);
133 DOM
.rootKey
.on("input", delayedRootKeyChanged
);
134 DOM
.litecoinUseLtub
.on("change", litecoinUseLtubChanged
);
135 DOM
.bip32path
.on("input", calcForDerivationPath
);
136 DOM
.bip44account
.on("input", calcForDerivationPath
);
137 DOM
.bip44change
.on("input", calcForDerivationPath
);
138 DOM
.bip49account
.on("input", calcForDerivationPath
);
139 DOM
.bip49change
.on("input", calcForDerivationPath
);
140 DOM
.bip84account
.on("input", calcForDerivationPath
);
141 DOM
.bip84change
.on("input", calcForDerivationPath
);
142 DOM
.bip141path
.on("input", calcForDerivationPath
);
143 DOM
.bip141semantics
.on("change", tabChanged
);
144 DOM
.tab
.on("shown.bs.tab", tabChanged
);
145 DOM
.hardenedAddresses
.on("change", calcForDerivationPath
);
146 DOM
.useBip38
.on("change", calcForDerivationPath
);
147 DOM
.bip38Password
.on("change", calcForDerivationPath
);
148 DOM
.indexToggle
.on("click", toggleIndexes
);
149 DOM
.addressToggle
.on("click", toggleAddresses
);
150 DOM
.publicKeyToggle
.on("click", togglePublicKeys
);
151 DOM
.privateKeyToggle
.on("click", togglePrivateKeys
);
152 DOM
.csvTab
.on("click", updateCsv
);
153 DOM
.languages
.on("click", languageChanged
);
154 DOM
.bitcoinCashAddressType
.on("change", bitcoinCashAddressTypeChange
);
155 setQrEvents(DOM
.showQrEls
);
158 hideValidationError();
159 populateNetworkSelect();
160 populateClientSelect();
165 function generatedStrengthChanged() {
166 var strength
= parseInt(DOM
.generatedStrength
.val());
168 DOM
.generatedStrengthWarning
.removeClass("hidden");
171 DOM
.generatedStrengthWarning
.addClass("hidden");
175 function networkChanged(e
) {
177 clearAddressesList();
178 DOM
.litecoinLtubContainer
.addClass("hidden");
179 DOM
.bitcoinCashAddressTypeContainer
.addClass("hidden");
180 var networkIndex
= e
.target
.value
;
181 var network
= networks
[networkIndex
];
183 adjustNetworkForSegwit();
192 function bip32ClientChanged(e
) {
193 var clientIndex
= DOM
.bip32Client
.val();
194 if (clientIndex
== "custom") {
195 DOM
.bip32path
.prop("readonly", false);
198 DOM
.bip32path
.prop("readonly", true);
199 clients
[clientIndex
].onSelect();
209 function setEntropyVisibility() {
210 if (isUsingOwnEntropy()) {
211 DOM
.entropyContainer
.removeClass("hidden");
212 DOM
.generateContainer
.addClass("hidden");
213 DOM
.phrase
.prop("readonly", true);
218 DOM
.entropyContainer
.addClass("hidden");
219 DOM
.generateContainer
.removeClass("hidden");
220 DOM
.phrase
.prop("readonly", false);
225 function delayedPhraseChanged() {
226 hideValidationError();
229 bip32ExtendedKey
= null;
230 clearAddressesList();
232 if (phraseChangeTimeoutEvent
!= null) {
233 clearTimeout(phraseChangeTimeoutEvent
);
235 phraseChangeTimeoutEvent
= setTimeout(function() {
237 var entropy
= mnemonic
.toRawEntropyHex(DOM
.phrase
.val());
238 if (entropy
!== null) {
239 DOM
.entropyMnemonicLength
.val("raw");
240 DOM
.entropy
.val(entropy
);
245 function phraseChanged() {
247 setMnemonicLanguage();
248 // Get the mnemonic phrase
249 var phrase
= DOM
.phrase
.val();
250 var errorText
= findPhraseErrors(phrase
);
252 showValidationError(errorText
);
255 // Calculate and display
256 var passphrase
= DOM
.passphrase
.val();
257 calcBip32RootKeyFromSeed(phrase
, passphrase
);
258 calcForDerivationPath();
259 // Show the word indexes
263 function tabChanged() {
265 adjustNetworkForSegwit();
266 var phrase
= DOM
.phrase
.val();
268 // Calculate and display for mnemonic
269 var errorText
= findPhraseErrors(phrase
);
271 showValidationError(errorText
);
274 // Calculate and display
275 var passphrase
= DOM
.passphrase
.val();
276 calcBip32RootKeyFromSeed(phrase
, passphrase
);
279 // Calculate and display for root key
280 var rootKeyBase58
= DOM
.rootKey
.val();
281 var errorText
= validateRootKey(rootKeyBase58
);
283 showValidationError(errorText
);
286 // Calculate and display
287 calcBip32RootKeyFromBase58(rootKeyBase58
);
289 calcForDerivationPath();
292 function delayedEntropyChanged() {
293 hideValidationError();
295 if (entropyChangeTimeoutEvent
!= null) {
296 clearTimeout(entropyChangeTimeoutEvent
);
298 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
301 function entropyChanged() {
302 // If blank entropy, clear mnemonic, addresses, errors
303 if (DOM
.entropy
.val().trim().length
== 0) {
305 clearEntropyFeedback();
307 showValidationError("Blank entropy");
310 // Get the current phrase to detect changes
311 var phrase
= DOM
.phrase
.val();
312 // Set the phrase from the entropy
313 setMnemonicFromEntropy();
314 // Recalc addresses if the phrase has changed
315 var newPhrase
= DOM
.phrase
.val();
316 if (newPhrase
!= phrase
) {
317 if (newPhrase
.length
== 0) {
329 function delayedRootKeyChanged() {
330 // Warn if there is an existing mnemonic or passphrase.
331 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
332 if (!confirm("This will clear existing mnemonic and passphrase")) {
333 DOM
.rootKey
.val(bip32RootKey
);
337 hideValidationError();
339 // Clear existing mnemonic and passphrase
341 DOM
.passphrase
.val("");
343 if (rootKeyChangedTimeoutEvent
!= null) {
344 clearTimeout(rootKeyChangedTimeoutEvent
);
346 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
349 function rootKeyChanged() {
351 hideValidationError();
352 var rootKeyBase58
= DOM
.rootKey
.val();
353 var errorText
= validateRootKey(rootKeyBase58
);
355 showValidationError(errorText
);
358 // Calculate and display
359 calcBip32RootKeyFromBase58(rootKeyBase58
);
360 calcForDerivationPath();
363 function litecoinUseLtubChanged() {
364 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
365 if (litecoinUseLtub
) {
366 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
369 network
= bitcoinjs
.bitcoin
.networks
.litecoinXprv
;
374 function calcForDerivationPath() {
376 clearAddressesList();
378 // Don't show segwit if it's selected but network doesn't support it
379 if (segwitSelected() && !networkHasSegwit()) {
380 showSegwitUnavailable();
384 showSegwitAvailable();
385 // Get the derivation path
386 var derivationPath
= getDerivationPath();
387 var errorText
= findDerivationPathErrors(derivationPath
);
389 showValidationError(errorText
);
392 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
393 if (bip44TabSelected()) {
396 else if (bip49TabSelected()) {
399 else if (bip84TabSelected()) {
405 function generateClicked() {
406 if (isUsingOwnEntropy()) {
411 setTimeout(function() {
412 setMnemonicLanguage();
413 var phrase
= generateRandomPhrase();
421 function languageChanged() {
422 setTimeout(function() {
423 setMnemonicLanguage();
424 if (DOM
.phrase
.val().length
> 0) {
425 var newPhrase
= convertPhraseToNewLanguage();
426 DOM
.phrase
.val(newPhrase
);
430 DOM
.generate
.trigger("click");
435 function bitcoinCashAddressTypeChange() {
439 function toggleIndexes() {
440 showIndex
= !showIndex
;
441 $("td.index span").toggleClass("invisible");
444 function toggleAddresses() {
445 showAddress
= !showAddress
;
446 $("td.address span").toggleClass("invisible");
449 function togglePublicKeys() {
450 showPubKey
= !showPubKey
;
451 $("td.pubkey span").toggleClass("invisible");
454 function togglePrivateKeys() {
455 showPrivKey
= !showPrivKey
;
456 $("td.privkey span").toggleClass("invisible");
459 function privacyScreenToggled() {
460 // private-data contains elements added to DOM at runtime
461 // so catch all by adding visual privacy class to the root of the DOM
462 if (DOM
.privacyScreenToggle
.prop("checked")) {
463 $("body").addClass("visual-privacy");
466 $("body").removeClass("visual-privacy");
472 function generateRandomPhrase() {
473 if (!hasStrongRandom()) {
474 var errorText
= "This browser does not support strong randomness";
475 showValidationError(errorText
);
478 // get the amount of entropy to use
479 var numWords
= parseInt(DOM
.generatedStrength
.val());
480 var strength
= numWords
/ 3 * 32;
481 var buffer
= new Uint8Array(strength
/ 8);
482 // create secure entropy
483 var data
= crypto
.getRandomValues(buffer
);
485 var words
= mnemonic
.toMnemonic(data
);
486 DOM
.phrase
.val(words
);
488 var entropyHex
= uint8ArrayToHex(data
);
489 DOM
.entropy
.val(entropyHex
);
490 // ensure entropy fields are consistent with what is being displayed
491 DOM
.entropyMnemonicLength
.val("raw");
495 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
496 seed
= mnemonic
.toSeed(phrase
, passphrase
);
497 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
499 bip32RootKey
= groestlcoinjs
.HDNode
.fromSeedHex(seed
, network
);
503 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
505 calcBip32RootKeyFromBase58GRS(rootKeyBase58
);
508 // try parsing with various segwit network params since this extended
509 // key may be from any one of them.
510 if (networkHasSegwit()) {
512 if ("baseNetwork" in n
) {
513 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
515 // try parsing using base network params
517 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
521 // try parsing using p2wpkh params
524 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
529 // try parsing using p2wpkh-in-p2sh network params
530 if ("p2wpkhInP2sh" in n
) {
532 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
538 // try the network params as currently specified
539 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
542 function calcBip32RootKeyFromBase58GRS(rootKeyBase58
) {
543 // try parsing with various segwit network params since this extended
544 // key may be from any one of them.
545 if (networkHasSegwit()) {
547 if ("baseNetwork" in n
) {
548 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
550 // try parsing using base network params
552 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
556 // try parsing using p2wpkh params
559 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
564 // try parsing using p2wpkh-in-p2sh network params
565 if ("p2wpkhInP2sh" in n
) {
567 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
573 // try the network params as currently specified
574 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
577 function calcBip32ExtendedKey(path
) {
578 // Check there's a root key to derive from
582 var extendedKey
= bip32RootKey
;
583 // Derive the key from the path
584 var pathBits
= path
.split("/");
585 for (var i
=0; i
<pathBits
.length
; i
++) {
586 var bit
= pathBits
[i
];
587 var index
= parseInt(bit
);
591 var hardened
= bit
[bit
.length
-1] == "'";
592 var isPriv
= !(extendedKey
.isNeutered());
593 var invalidDerivationPath
= hardened
&& !isPriv
;
594 if (invalidDerivationPath
) {
598 extendedKey
= extendedKey
.deriveHardened(index
);
601 extendedKey
= extendedKey
.derive(index
);
607 function showValidationError(errorText
) {
613 function hideValidationError() {
619 function findPhraseErrors(phrase
) {
620 // Preprocess the words
621 phrase
= mnemonic
.normalizeString(phrase
);
622 var words
= phraseToWordArray(phrase
);
623 // Detect blank phrase
624 if (words
.length
== 0) {
625 return "Blank mnemonic";
628 for (var i
=0; i
<words
.length
; i
++) {
630 var language
= getLanguage();
631 if (WORDLISTS
[language
].indexOf(word
) == -1) {
632 console
.log("Finding closest match to " + word
);
633 var nearestWord
= findNearestWord(word
);
634 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
637 // Check the words are valid
638 var properPhrase
= wordArrayToPhrase(words
);
639 var isValid
= mnemonic
.check(properPhrase
);
641 return "Invalid mnemonic";
646 function validateRootKey(rootKeyBase58
) {
648 return validateRootKeyGRS(rootKeyBase58
);
650 // try various segwit network params since this extended key may be from
652 if (networkHasSegwit()) {
654 if ("baseNetwork" in n
) {
655 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
657 // try parsing using base network params
659 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
663 // try parsing using p2wpkh params
666 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
671 // try parsing using p2wpkh-in-p2sh network params
672 if ("p2wpkhInP2sh" in n
) {
674 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
680 // try the network params as currently specified
682 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
685 return "Invalid root key";
690 function validateRootKeyGRS(rootKeyBase58
) {
691 // try various segwit network params since this extended key may be from
693 if (networkHasSegwit()) {
695 if ("baseNetwork" in n
) {
696 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
698 // try parsing using base network params
700 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
704 // try parsing using p2wpkh params
707 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
712 // try parsing using p2wpkh-in-p2sh network params
713 if ("p2wpkhInP2sh" in n
) {
715 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
721 // try the network params as currently specified
723 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
726 return "Invalid root key";
731 function getDerivationPath() {
732 if (bip44TabSelected()) {
733 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
734 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
735 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
736 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
738 path
+= purpose
+ "'/";
740 path
+= account
+ "'/";
742 DOM
.bip44path
.val(path
);
743 var derivationPath
= DOM
.bip44path
.val();
744 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
745 return derivationPath
;
747 else if (bip49TabSelected()) {
748 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
749 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
750 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
751 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
753 path
+= purpose
+ "'/";
755 path
+= account
+ "'/";
757 DOM
.bip49path
.val(path
);
758 var derivationPath
= DOM
.bip49path
.val();
759 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
760 return derivationPath
;
762 else if (bip84TabSelected()) {
763 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
764 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
765 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
766 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
768 path
+= purpose
+ "'/";
770 path
+= account
+ "'/";
772 DOM
.bip84path
.val(path
);
773 var derivationPath
= DOM
.bip84path
.val();
774 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
775 return derivationPath
;
777 else if (bip32TabSelected()) {
778 var derivationPath
= DOM
.bip32path
.val();
779 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
780 return derivationPath
;
782 else if (bip141TabSelected()) {
783 var derivationPath
= DOM
.bip141path
.val();
784 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
785 return derivationPath
;
788 console
.log("Unknown derivation path");
792 function findDerivationPathErrors(path
) {
793 // TODO is not perfect but is better than nothing
795 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
797 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
798 var maxDepth
= 255; // TODO verify this!!
799 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
800 if (path
[0] != "m") {
801 return "First character must be 'm'";
803 if (path
.length
> 1) {
804 if (path
[1] != "/") {
805 return "Separator must be '/'";
807 var indexes
= path
.split("/");
808 if (indexes
.length
> maxDepth
) {
809 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
811 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
812 var index
= indexes
[depth
];
813 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
814 if (invalidChars
.length
> 0) {
815 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
817 var indexValue
= parseInt(index
.replace("'", ""));
819 return "Invalid number at depth " + depth
;
821 if (indexValue
> maxIndexValue
) {
822 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
826 // Check root key exists or else derivation path is useless!
828 return "No root key";
830 // Check no hardened derivation path when using xpub keys
831 var hardenedPath
= path
.indexOf("'") > -1;
832 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
833 var hardened
= hardenedPath
|| hardenedAddresses
;
834 var isXpubkey
= bip32RootKey
.isNeutered();
835 if (hardened
&& isXpubkey
) {
836 return "Hardened derivation path is invalid with xpub key";
842 return networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin" || networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin Testnet";
845 function displayBip44Info() {
846 // Get the derivation path for the account
847 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
848 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
849 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
851 path
+= purpose
+ "'/";
853 path
+= account
+ "'/";
854 // Calculate the account extended keys
855 var accountExtendedKey
= calcBip32ExtendedKey(path
);
856 var accountXprv
= accountExtendedKey
.toBase58();
857 var accountXpub
= accountExtendedKey
.neutered().toBase58();
858 // Display the extended keys
859 DOM
.bip44accountXprv
.val(accountXprv
);
860 DOM
.bip44accountXpub
.val(accountXpub
);
863 function displayBip49Info() {
864 // Get the derivation path for the account
865 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
866 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
867 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
869 path
+= purpose
+ "'/";
871 path
+= account
+ "'/";
872 // Calculate the account extended keys
873 var accountExtendedKey
= calcBip32ExtendedKey(path
);
874 var accountXprv
= accountExtendedKey
.toBase58();
875 var accountXpub
= accountExtendedKey
.neutered().toBase58();
876 // Display the extended keys
877 DOM
.bip49accountXprv
.val(accountXprv
);
878 DOM
.bip49accountXpub
.val(accountXpub
);
881 function displayBip84Info() {
882 // Get the derivation path for the account
883 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
884 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
885 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
887 path
+= purpose
+ "'/";
889 path
+= account
+ "'/";
890 // Calculate the account extended keys
891 var accountExtendedKey
= calcBip32ExtendedKey(path
);
892 var accountXprv
= accountExtendedKey
.toBase58();
893 var accountXpub
= accountExtendedKey
.neutered().toBase58();
894 // Display the extended keys
895 DOM
.bip84accountXprv
.val(accountXprv
);
896 DOM
.bip84accountXpub
.val(accountXpub
);
899 function displayBip32Info() {
902 var rootKey
= bip32RootKey
.toBase58();
903 DOM
.rootKey
.val(rootKey
);
904 var xprvkeyB58
= "NA";
905 if (!bip32ExtendedKey
.isNeutered()) {
906 xprvkeyB58
= bip32ExtendedKey
.toBase58();
908 var extendedPrivKey
= xprvkeyB58
;
909 DOM
.extendedPrivKey
.val(extendedPrivKey
);
910 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
911 DOM
.extendedPubKey
.val(extendedPubKey
);
912 // Display the addresses and privkeys
913 clearAddressesList();
914 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
915 displayAddresses(0, initialAddressCount
);
918 function displayAddresses(start
, total
) {
919 generationProcesses
.push(new (function() {
923 this.stop = function() {
924 for (var i
=0; i
<rows
.length
; i
++) {
925 rows
[i
].shouldGenerate
= false;
930 for (var i
=0; i
<total
; i
++) {
931 var index
= i
+ start
;
932 var isLast
= i
== total
- 1;
933 rows
.push(new TableRow(index
, isLast
));
939 function segwitSelected() {
940 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
943 function p2wpkhSelected() {
944 return bip84TabSelected() ||
945 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
948 function p2wpkhInP2shSelected() {
949 return bip49TabSelected() ||
950 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
953 function TableRow(index
, isLast
) {
956 this.shouldGenerate
= true;
957 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
958 var useBip38
= DOM
.useBip38
.prop("checked");
959 var bip38password
= DOM
.bip38Password
.val();
960 var isSegwit
= segwitSelected();
961 var segwitAvailable
= networkHasSegwit();
962 var isP2wpkh
= p2wpkhSelected();
963 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
969 function calculateValues() {
970 setTimeout(function() {
971 if (!self
.shouldGenerate
) {
974 // derive HDkey for this row of the table
976 if (useHardenedAddresses
) {
977 key
= bip32ExtendedKey
.deriveHardened(index
);
980 key
= bip32ExtendedKey
.derive(index
);
982 // bip38 requires uncompressed keys
983 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
984 var keyPair
= key
.keyPair
;
985 var useUncompressed
= useBip38
;
986 if (useUncompressed
) {
987 keyPair
= new bitcoinjs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
989 keyPair
= new groestlcoinjs
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
993 var address
= keyPair
.getAddress().toString();
995 var hasPrivkey
= !key
.isNeutered();
998 privkey
= keyPair
.toWIF();
999 // BIP38 encode private key if required
1002 privkey
= groestlcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1003 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1004 }, null, networks
[DOM
.network
.val()].name
.includes("Testnet"));
1006 privkey
= bitcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1007 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1012 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
1013 var indexText
= getDerivationPath() + "/" + index
;
1014 if (useHardenedAddresses
) {
1015 indexText
= indexText
+ "'";
1017 // Ethereum values are different
1018 if ((networks
[DOM
.network
.val()].name
== "ETH - Ethereum")
1019 || (networks
[DOM
.network
.val()].name
== "ETC - Ethereum Classic")
1020 || (networks
[DOM
.network
.val()].name
== "PIRL - Pirl")
1021 || (networks
[DOM
.network
.val()].name
== "MIX - MIX")
1022 || (networks
[DOM
.network
.val()].name
== "MUSIC - Musicoin")
1023 || (networks
[DOM
.network
.val()].name
== "POA - Poa")
1024 || (networks
[DOM
.network
.val()].name
== "EXP - Expanse")
1025 || (networks
[DOM
.network
.val()].name
== "CLO - Callisto")
1026 || (networks
[DOM
.network
.val()].name
== "DXN - DEXON")
1027 || (networks
[DOM
.network
.val()].name
== "ELLA - Ellaism")
1028 || (networks
[DOM
.network
.val()].name
== "ESN - Ethersocial Network")
1029 || (networks
[DOM
.network
.val()].name
== "VET - VeChain")
1031 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1032 privkey
= privKeyBuffer
.toString('hex');
1033 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
1034 var hexAddress
= addressBuffer
.toString('hex');
1035 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
1036 address
= ethUtil
.addHexPrefix(checksumAddress
);
1037 privkey
= ethUtil
.addHexPrefix(privkey
);
1038 pubkey
= ethUtil
.addHexPrefix(pubkey
);
1041 // Stellar is different
1042 if (networks
[DOM
.network
.val()].name
== "XLM - Stellar") {
1043 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
1044 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
1046 path
+= purpose
+ "'/";
1047 path
+= coin
+ "'/" + index
+ "'";
1048 var keypair
= stellarUtil
.getKeypair(path
, seed
);
1050 privkey
= keypair
.secret();
1051 pubkey
= address
= keypair
.publicKey();
1053 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
1054 var NasAccount
= require("nebulas-account");
1055 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1056 var nebulasAccount
= new NasAccount();
1057 nebulasAccount
.setPrivateKey(privKeyBuffer
);
1058 address
= nebulasAccount
.getAddressString();
1059 privkey
= nebulasAccount
.getPrivateKeyString();
1060 pubkey
= nebulasAccount
.getPublicKeyString();
1062 // Ripple values are different
1063 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
1064 privkey
= convertRipplePriv(privkey
);
1065 address
= convertRippleAdrr(address
);
1067 // CasinoCoin values are different
1068 if (networks
[DOM
.network
.val()].name
== "CSC - CasinoCoin") {
1069 privkey
= convertCasinoCoinPriv(privkey
);
1070 address
= convertCasinoCoinAdrr(address
);
1072 // Bitcoin Cash address format may vary
1073 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
1074 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1075 if (bchAddrType
== "cashaddr") {
1076 address
= bchaddr
.toCashAddress(address
);
1078 else if (bchAddrType
== "bitpay") {
1079 address
= bchaddr
.toBitpayAddress(address
);
1082 // Bitcoin Cash address format may vary
1083 if (networks
[DOM
.network
.val()].name
== "SLP - Simple Ledger Protocol") {
1084 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1085 if (bchAddrType
== "cashaddr") {
1086 address
= bchaddr
.toSlpAddress(address
);
1089 // Segwit addresses are different
1091 if (!segwitAvailable
) {
1095 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1096 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1097 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1099 else if (isP2wpkhInP2sh
) {
1100 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1101 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1102 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
1103 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
1104 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1108 if ((networks
[DOM
.network
.val()].name
== "CRW - Crown")) {
1109 address
= bitcoinjs
.bitcoin
.networks
.crown
.toNewAddress(address
);
1112 if (networks
[DOM
.network
.val()].name
== "EOS - EOSIO") {
1114 pubkey
= eosUtil
.bufferToPublic(keyPair
.getPublicKeyBuffer());
1115 privkey
= eosUtil
.bufferToPrivate(keyPair
.d
.toBuffer(32));
1118 //Groestlcoin Addresses are different
1122 if (!segwitAvailable
) {
1126 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1128 else if (isP2wpkhInP2sh
) {
1129 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1132 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1135 addAddressToList(indexText
, address
, pubkey
, privkey
);
1147 function showMore() {
1148 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
1149 if (isNaN(rowsToAdd
)) {
1151 DOM
.rowsToAdd
.val("20");
1153 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
1155 start
= lastIndexInTable() + 1;
1158 var newStart
= start
+ rowsToAdd
;
1159 DOM
.moreRowsStartIndex
.val(newStart
);
1161 if (rowsToAdd
> 200) {
1162 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1163 msg
+= "Do you want to continue?";
1164 if (!confirm(msg
)) {
1168 displayAddresses(start
, rowsToAdd
);
1171 function clearDisplay() {
1172 clearAddressesList();
1174 hideValidationError();
1177 function clearAddressesList() {
1178 DOM
.addresses
.empty();
1183 function stopGenerating() {
1184 while (generationProcesses
.length
> 0) {
1185 var generation
= generationProcesses
.shift();
1190 function clearKeys() {
1195 function clearRootKey() {
1196 DOM
.rootKey
.val("");
1199 function clearDerivedKeys() {
1200 DOM
.extendedPrivKey
.val("");
1201 DOM
.extendedPubKey
.val("");
1202 DOM
.bip44accountXprv
.val("");
1203 DOM
.bip44accountXpub
.val("");
1206 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1207 var row
= $(addressRowTemplate
.html());
1209 var indexCell
= row
.find(".index span");
1210 var addressCell
= row
.find(".address span");
1211 var pubkeyCell
= row
.find(".pubkey span");
1212 var privkeyCell
= row
.find(".privkey span");
1214 indexCell
.text(indexText
);
1215 addressCell
.text(address
);
1216 pubkeyCell
.text(pubkey
);
1217 privkeyCell
.text(privkey
);
1220 indexCell
.addClass("invisible");
1223 addressCell
.addClass("invisible");
1226 pubkeyCell
.addClass("invisible");
1229 privkeyCell
.addClass("invisible");
1231 DOM
.addresses
.append(row
);
1232 var rowShowQrEls
= row
.find("[data-show-qr]");
1233 setQrEvents(rowShowQrEls
);
1236 function hasStrongRandom() {
1237 return 'crypto' in window
&& window
['crypto'] !== null;
1240 function disableForms() {
1241 $("form").on("submit", function(e
) {
1246 function parseIntNoNaN(val
, defaultVal
) {
1247 var v
= parseInt(val
);
1254 function showPending() {
1256 .text("Calculating...")
1260 function findNearestWord(word
) {
1261 var language
= getLanguage();
1262 var words
= WORDLISTS
[language
];
1263 var minDistance
= 99;
1264 var closestWord
= words
[0];
1265 for (var i
=0; i
<words
.length
; i
++) {
1266 var comparedTo
= words
[i
];
1267 if (comparedTo
.indexOf(word
) == 0) {
1270 var distance
= Levenshtein
.get(word
, comparedTo
);
1271 if (distance
< minDistance
) {
1272 closestWord
= comparedTo
;
1273 minDistance
= distance
;
1279 function hidePending() {
1285 function populateNetworkSelect() {
1286 for (var i
=0; i
<networks
.length
; i
++) {
1287 var network
= networks
[i
];
1288 var option
= $("<option>");
1289 option
.attr("value", i
);
1290 option
.text(network
.name
);
1291 if (network
.name
== "BTC - Bitcoin") {
1292 option
.prop("selected", true);
1294 DOM
.phraseNetwork
.append(option
);
1298 function populateClientSelect() {
1299 for (var i
=0; i
<clients
.length
; i
++) {
1300 var client
= clients
[i
];
1301 var option
= $("<option>");
1302 option
.attr("value", i
);
1303 option
.text(client
.name
);
1304 DOM
.bip32Client
.append(option
);
1308 function getLanguage() {
1309 var defaultLanguage
= "english";
1310 // Try to get from existing phrase
1311 var language
= getLanguageFromPhrase();
1312 // Try to get from url if not from phrase
1313 if (language
.length
== 0) {
1314 language
= getLanguageFromUrl();
1316 // Default to English if no other option
1317 if (language
.length
== 0) {
1318 language
= defaultLanguage
;
1323 function getLanguageFromPhrase(phrase
) {
1324 // Check if how many words from existing phrase match a language.
1327 phrase
= DOM
.phrase
.val();
1329 if (phrase
.length
> 0) {
1330 var words
= phraseToWordArray(phrase
);
1331 var languageMatches
= {};
1332 for (l
in WORDLISTS
) {
1333 // Track how many words match in this language
1334 languageMatches
[l
] = 0;
1335 for (var i
=0; i
<words
.length
; i
++) {
1336 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1337 if (wordInLanguage
) {
1338 languageMatches
[l
]++;
1341 // Find languages with most word matches.
1342 // This is made difficult due to commonalities between Chinese
1343 // simplified vs traditional.
1344 var mostMatches
= 0;
1345 var mostMatchedLanguages
= [];
1346 for (var l
in languageMatches
) {
1347 var numMatches
= languageMatches
[l
];
1348 if (numMatches
> mostMatches
) {
1349 mostMatches
= numMatches
;
1350 mostMatchedLanguages
= [l
];
1352 else if (numMatches
== mostMatches
) {
1353 mostMatchedLanguages
.push(l
);
1357 if (mostMatchedLanguages
.length
> 0) {
1358 // Use first language and warn if multiple detected
1359 language
= mostMatchedLanguages
[0];
1360 if (mostMatchedLanguages
.length
> 1) {
1361 console
.warn("Multiple possible languages");
1362 console
.warn(mostMatchedLanguages
);
1369 function getLanguageFromUrl() {
1370 for (var language
in WORDLISTS
) {
1371 if (window
.location
.hash
.indexOf(language
) > -1) {
1378 function setMnemonicLanguage() {
1379 var language
= getLanguage();
1380 // Load the bip39 mnemonic generator for this language if required
1381 if (!(language
in mnemonics
)) {
1382 mnemonics
[language
] = new Mnemonic(language
);
1384 mnemonic
= mnemonics
[language
];
1387 function convertPhraseToNewLanguage() {
1388 var oldLanguage
= getLanguageFromPhrase();
1389 var newLanguage
= getLanguageFromUrl();
1390 var oldPhrase
= DOM
.phrase
.val();
1391 var oldWords
= phraseToWordArray(oldPhrase
);
1393 for (var i
=0; i
<oldWords
.length
; i
++) {
1394 var oldWord
= oldWords
[i
];
1395 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1396 var newWord
= WORDLISTS
[newLanguage
][index
];
1397 newWords
.push(newWord
);
1399 newPhrase
= wordArrayToPhrase(newWords
);
1403 // TODO look at jsbip39 - mnemonic.splitWords
1404 function phraseToWordArray(phrase
) {
1405 var words
= phrase
.split(/\s/g);
1407 for (var i
=0; i
<words
.length
; i
++) {
1408 var word
= words
[i
];
1409 if (word
.length
> 0) {
1410 noBlanks
.push(word
);
1416 // TODO look at jsbip39 - mnemonic.joinWords
1417 function wordArrayToPhrase(words
) {
1418 var phrase
= words
.join(" ");
1419 var language
= getLanguageFromPhrase(phrase
);
1420 if (language
== "japanese") {
1421 phrase
= words
.join("\u3000");
1426 function isUsingOwnEntropy() {
1427 return DOM
.useEntropy
.prop("checked");
1430 function setMnemonicFromEntropy() {
1431 clearEntropyFeedback();
1432 // Get entropy value
1433 var entropyStr
= DOM
.entropy
.val();
1434 // Work out minimum base for entropy
1435 var entropy
= Entropy
.fromString(entropyStr
);
1436 if (entropy
.binaryStr
.length
== 0) {
1439 // Show entropy details
1440 showEntropyFeedback(entropy
);
1441 // Use entropy hash if not using raw entropy
1442 var bits
= entropy
.binaryStr
;
1443 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1444 if (mnemonicLength
!= "raw") {
1445 // Get bits by hashing entropy with SHA256
1446 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1447 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1448 bits
= BigInteger
.parse(hex
, 16).toString(2);
1449 while (bits
.length
% 256 != 0) {
1452 // Truncate hash to suit number of words
1453 mnemonicLength
= parseInt(mnemonicLength
);
1454 var numberOfBits
= 32 * mnemonicLength
/ 3;
1455 bits
= bits
.substring(0, numberOfBits
);
1456 // show warning for weak entropy override
1457 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1458 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1461 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1465 // hide warning for weak entropy override
1466 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1468 // Discard trailing entropy
1469 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1470 var start
= bits
.length
- bitsToUse
;
1471 var binaryStr
= bits
.substring(start
);
1472 // Convert entropy string to numeric array
1473 var entropyArr
= [];
1474 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1475 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1476 var entropyByte
= parseInt(byteAsBits
, 2);
1477 entropyArr
.push(entropyByte
)
1479 // Convert entropy array to mnemonic
1480 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1481 // Set the mnemonic in the UI
1482 DOM
.phrase
.val(phrase
);
1483 // Show the word indexes
1485 // Show the checksum
1489 function clearEntropyFeedback() {
1490 DOM
.entropyCrackTime
.text("...");
1491 DOM
.entropyType
.text("");
1492 DOM
.entropyWordCount
.text("0");
1493 DOM
.entropyEventCount
.text("0");
1494 DOM
.entropyBitsPerEvent
.text("0");
1495 DOM
.entropyBits
.text("0");
1496 DOM
.entropyFiltered
.html(" ");
1497 DOM
.entropyBinary
.html(" ");
1500 function showEntropyFeedback(entropy
) {
1501 var numberOfBits
= entropy
.binaryStr
.length
;
1502 var timeToCrack
= "unknown";
1504 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1505 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1506 if (z
.feedback
.warning
!= "") {
1507 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1511 console
.log("Error detecting entropy strength with zxcvbn:");
1514 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1515 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1516 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1517 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1518 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1519 DOM
.entropyType
.text(entropyTypeStr
);
1520 DOM
.entropyCrackTime
.text(timeToCrack
);
1521 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1522 DOM
.entropyBits
.text(numberOfBits
);
1523 DOM
.entropyWordCount
.text(wordCount
);
1524 DOM
.entropyBinary
.text(spacedBinaryStr
);
1525 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1526 // detect and warn of filtering
1527 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1528 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1529 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1531 DOM
.entropyFilterWarning
.removeClass('hidden');
1534 DOM
.entropyFilterWarning
.addClass('hidden');
1538 function getEntropyTypeStr(entropy
) {
1539 var typeStr
= entropy
.base
.str
;
1540 // Add some detail if these are cards
1541 if (entropy
.base
.asInt
== 52) {
1542 var cardDetail
= []; // array of message strings
1543 // Detect duplicates
1545 var dupeTracker
= {};
1546 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1547 var card
= entropy
.base
.parts
[i
];
1548 var cardUpper
= card
.toUpperCase();
1549 if (cardUpper
in dupeTracker
) {
1552 dupeTracker
[cardUpper
] = true;
1554 if (dupes
.length
> 0) {
1555 var dupeWord
= "duplicates";
1556 if (dupes
.length
== 1) {
1557 dupeWord
= "duplicate";
1559 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1560 if (dupes
.length
> 3) {
1563 cardDetail
.push(msg
);
1566 var uniqueCards
= [];
1567 for (var uniqueCard
in dupeTracker
) {
1568 uniqueCards
.push(uniqueCard
);
1570 if (uniqueCards
.length
== 52) {
1571 cardDetail
.unshift("full deck");
1573 // Detect missing cards
1574 var values
= "A23456789TJQK";
1576 var missingCards
= [];
1577 for (var i
=0; i
<suits
.length
; i
++) {
1578 for (var j
=0; j
<values
.length
; j
++) {
1579 var card
= values
[j
] + suits
[i
];
1580 if (!(card
in dupeTracker
)) {
1581 missingCards
.push(card
);
1585 // Display missing cards if six or less, ie clearly going for full deck
1586 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1587 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1588 if (missingCards
.length
> 3) {
1591 cardDetail
.push(msg
);
1593 // Add card details to typeStr
1594 if (cardDetail
.length
> 0) {
1595 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1601 function setQrEvents(els
) {
1602 els
.on("mouseenter", createQr
);
1603 els
.on("mouseleave", destroyQr
);
1604 els
.on("click", toggleQr
);
1607 function createQr(e
) {
1608 var content
= e
.target
.textContent
|| e
.target
.value
;
1616 DOM
.qrImage
.append(qrEl
);
1618 DOM
.qrHider
.addClass("hidden");
1621 DOM
.qrHider
.removeClass("hidden");
1623 DOM
.qrContainer
.removeClass("hidden");
1627 function destroyQr() {
1628 DOM
.qrImage
.text("");
1629 DOM
.qrContainer
.addClass("hidden");
1632 function toggleQr() {
1634 DOM
.qrHider
.toggleClass("hidden");
1635 DOM
.qrHint
.toggleClass("hidden");
1638 function bip44TabSelected() {
1639 return DOM
.bip44tab
.hasClass("active");
1642 function bip32TabSelected() {
1643 return DOM
.bip32tab
.hasClass("active");
1646 function networkHasSegwit() {
1648 if ("baseNetwork" in network
) {
1649 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1651 // check if only p2wpkh params are required
1652 if (p2wpkhSelected()) {
1653 return "p2wpkh" in n
;
1655 // check if only p2wpkh-in-p2sh params are required
1656 else if (p2wpkhInP2shSelected()) {
1657 return "p2wpkhInP2sh" in n
;
1659 // require both if it's unclear which params are required
1660 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1663 function bip49TabSelected() {
1664 return DOM
.bip49tab
.hasClass("active");
1667 function bip84TabSelected() {
1668 return DOM
.bip84tab
.hasClass("active");
1671 function bip141TabSelected() {
1672 return DOM
.bip141tab
.hasClass("active");
1675 function setHdCoin(coinValue
) {
1676 DOM
.bip44coin
.val(coinValue
);
1677 DOM
.bip49coin
.val(coinValue
);
1678 DOM
.bip84coin
.val(coinValue
);
1681 function showSegwitAvailable() {
1682 DOM
.bip49unavailable
.addClass("hidden");
1683 DOM
.bip49available
.removeClass("hidden");
1684 DOM
.bip84unavailable
.addClass("hidden");
1685 DOM
.bip84available
.removeClass("hidden");
1686 DOM
.bip141unavailable
.addClass("hidden");
1687 DOM
.bip141available
.removeClass("hidden");
1690 function showSegwitUnavailable() {
1691 DOM
.bip49available
.addClass("hidden");
1692 DOM
.bip49unavailable
.removeClass("hidden");
1693 DOM
.bip84available
.addClass("hidden");
1694 DOM
.bip84unavailable
.removeClass("hidden");
1695 DOM
.bip141available
.addClass("hidden");
1696 DOM
.bip141unavailable
.removeClass("hidden");
1699 function adjustNetworkForSegwit() {
1700 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1701 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1703 // See https://github.com/iancoleman/bip39/issues/125
1704 var segwitNetworks
= null;
1705 // if a segwit network is alread selected, need to use base network to
1706 // look up new parameters
1707 if ("baseNetwork" in network
) {
1708 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1710 // choose the right segwit params
1711 if (p2wpkhSelected() && "p2wpkh" in network
) {
1712 network
= network
.p2wpkh
;
1714 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1715 network
= network
.p2wpkhInP2sh
;
1719 function lastIndexInTable() {
1720 var pathText
= DOM
.addresses
.find(".index").last().text();
1721 var pathBits
= pathText
.split("/");
1722 var lastBit
= pathBits
[pathBits
.length
-1];
1723 var lastBitClean
= lastBit
.replace("'", "");
1724 return parseInt(lastBitClean
);
1727 function uint8ArrayToHex(a
) {
1729 for (var i
=0; i
<a
.length
; i
++) {
1730 var h
= a
[i
].toString(16);
1731 while (h
.length
< 2) {
1739 function showWordIndexes() {
1740 var phrase
= DOM
.phrase
.val();
1741 var words
= phraseToWordArray(phrase
);
1742 var wordIndexes
= [];
1743 var language
= getLanguage();
1744 for (var i
=0; i
<words
.length
; i
++) {
1745 var word
= words
[i
];
1746 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1747 wordIndexes
.push(wordIndex
);
1749 var wordIndexesStr
= wordIndexes
.join(", ");
1750 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1753 function showChecksum() {
1754 var phrase
= DOM
.phrase
.val();
1755 var words
= phraseToWordArray(phrase
);
1756 var checksumBitlength
= words
.length
/ 3;
1759 var language
= getLanguage();
1760 for (var i
=words
.length
-1; i
>=0; i
--) {
1761 var word
= words
[i
];
1762 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1763 var wordBinary
= wordIndex
.toString(2);
1764 while (wordBinary
.length
< 11) {
1765 wordBinary
= "0" + wordBinary
;
1767 var binaryStr
= wordBinary
+ binaryStr
;
1768 if (binaryStr
.length
>= checksumBitlength
) {
1769 var start
= binaryStr
.length
- checksumBitlength
;
1770 var end
= binaryStr
.length
;
1771 checksum
= binaryStr
.substring(start
, end
);
1772 // add spaces so the last group is 11 bits, not the first
1773 checksum
= checksum
.split("").reverse().join("")
1774 checksum
= addSpacesEveryElevenBits(checksum
);
1775 checksum
= checksum
.split("").reverse().join("")
1779 DOM
.entropyChecksum
.text(checksum
);
1782 function updateCsv() {
1783 var tableCsv
= "path,address,public key,private key\n";
1784 var rows
= DOM
.addresses
.find("tr");
1785 for (var i
=0; i
<rows
.length
; i
++) {
1786 var row
= $(rows
[i
]);
1787 var cells
= row
.find("td");
1788 for (var j
=0; j
<cells
.length
; j
++) {
1789 var cell
= $(cells
[j
]);
1790 if (!cell
.children().hasClass("invisible")) {
1791 tableCsv
= tableCsv
+ cell
.text();
1793 if (j
!= cells
.length
- 1) {
1794 tableCsv
= tableCsv
+ ",";
1797 tableCsv
= tableCsv
+ "\n";
1799 DOM
.csv
.val(tableCsv
);
1802 function addSpacesEveryElevenBits(binaryStr
) {
1803 return binaryStr
.match(/.{1,11}/g).join(" ");
1808 name: "AC - Asiacoin",
1809 onSelect: function() {
1810 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1815 name: "ACC - Adcoin",
1816 onSelect: function() {
1817 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1822 name: "ARYA - Aryacoin",
1823 onSelect: function() {
1824 network
= bitcoinjs
.bitcoin
.networks
.aryacoin
;
1829 name: "AUR - Auroracoin",
1830 onSelect: function() {
1831 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1837 onSelect: function() {
1838 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1843 name: "ANON - ANON",
1844 onSelect: function() {
1845 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1850 name: "BOLI - Bolivarcoin",
1851 onSelect: function() {
1852 network
= bitcoinjs
.bitcoin
.networks
.bolivarcoin
;
1857 name: "BCA - Bitcoin Atom",
1858 onSelect: function() {
1859 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1864 name: "BCH - Bitcoin Cash",
1865 onSelect: function() {
1866 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1871 name: "BEET - Beetlecoin",
1872 onSelect: function() {
1873 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1878 name: "BELA - Belacoin",
1879 onSelect: function() {
1880 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1885 name: "BLK - BlackCoin",
1886 onSelect: function() {
1887 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1892 name: "BND - Blocknode",
1893 onSelect: function() {
1894 network
= bitcoinjs
.bitcoin
.networks
.blocknode
;
1899 name: "tBND - Blocknode Testnet",
1900 onSelect: function() {
1901 network
= bitcoinjs
.bitcoin
.networks
.blocknode_testnet
;
1906 name: "BRIT - Britcoin",
1907 onSelect: function() {
1908 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
1913 name: "BSD - Bitsend",
1914 onSelect: function() {
1915 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
1920 name: "BST - BlockStamp",
1921 onSelect: function() {
1922 network
= bitcoinjs
.bitcoin
.networks
.blockstamp
;
1928 onSelect: function() {
1929 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1934 name: "BTC - Bitcoin",
1935 onSelect: function() {
1936 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1941 name: "BTC - Bitcoin Testnet",
1942 onSelect: function() {
1943 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1948 name: "BITG - Bitcoin Green",
1949 onSelect: function() {
1950 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1955 name: "BTCP - Bitcoin Private",
1956 onSelect: function() {
1957 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
1962 name: "BSV - BitcoinSV",
1963 onSelect: function() {
1964 network
= bitcoinjs
.bitcoin
.networks
.bitcoinsv
;
1969 name: "BTCZ - Bitcoinz",
1970 onSelect: function() {
1971 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
1976 name: "BTDX - BitCloud",
1977 onSelect: function() {
1978 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
1983 name: "BTG - Bitcoin Gold",
1984 onSelect: function() {
1985 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
1990 name: "BTX - Bitcore",
1991 onSelect: function() {
1992 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
1997 name: "CCN - Cannacoin",
1998 onSelect: function() {
1999 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2004 name: "CESC - Cryptoescudo",
2005 onSelect: function() {
2006 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2011 name: "CDN - Canadaecoin",
2012 onSelect: function() {
2013 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
2018 name: "CLAM - Clams",
2019 onSelect: function() {
2020 network
= bitcoinjs
.bitcoin
.networks
.clam
;
2025 name: "CLO - Callisto",
2026 segwitAvailable: false,
2027 onSelect: function() {
2028 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2033 name: "CLUB - Clubcoin",
2034 onSelect: function() {
2035 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
2040 name: "CMP - Compcoin",
2041 onSelect: function() {
2042 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
2047 name: "CPU - CPUchain",
2048 onSelect: function() {
2049 network
= bitcoinjs
.bitcoin
.networks
.cpuchain
;
2054 name: "CRAVE - Crave",
2055 onSelect: function() {
2056 network
= bitcoinjs
.bitcoin
.networks
.crave
;
2061 name: "CRW - Crown (Legacy)",
2062 onSelect: function() {
2063 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2068 name: "CRW - Crown",
2069 onSelect: function() {
2070 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2075 name: "CSC - CasinoCoin",
2076 onSelect: function() {
2077 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2082 name: "DASH - Dash",
2083 onSelect: function() {
2084 network
= bitcoinjs
.bitcoin
.networks
.dash
;
2089 name: "DASH - Dash Testnet",
2090 onSelect: function() {
2091 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
2096 name: "DFC - Defcoin",
2097 onSelect: function() {
2098 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
2103 name: "DGB - Digibyte",
2104 onSelect: function() {
2105 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
2110 name: "DGC - Digitalcoin",
2111 onSelect: function() {
2112 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
2117 name: "DMD - Diamond",
2118 onSelect: function() {
2119 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
2124 name: "DNR - Denarius",
2125 onSelect: function() {
2126 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
2131 name: "DOGE - Dogecoin",
2132 onSelect: function() {
2133 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
2138 name: "DOGEt - Dogecoin Testnet",
2139 onSelect: function() {
2140 network
= bitcoinjs
.bitcoin
.networks
.dogecointestnet
;
2145 name: "DXN - DEXON",
2146 onSelect: function() {
2147 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2152 name: "ECN - Ecoin",
2153 onSelect: function() {
2154 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
2159 name: "EDRC - Edrcoin",
2160 onSelect: function() {
2161 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
2166 name: "EFL - Egulden",
2167 onSelect: function() {
2168 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
2173 name: "ELLA - Ellaism",
2174 segwitAvailable: false,
2175 onSelect: function() {
2176 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2181 name: "EMC2 - Einsteinium",
2182 onSelect: function() {
2183 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
2188 name: "ERC - Europecoin",
2189 onSelect: function() {
2190 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
2195 name: "EOS - EOSIO",
2196 onSelect: function() {
2197 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2202 name: "ESN - Ethersocial Network",
2203 segwitAvailable: false,
2204 onSelect: function() {
2205 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2210 name: "ETC - Ethereum Classic",
2211 segwitAvailable: false,
2212 onSelect: function() {
2213 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2218 name: "ETH - Ethereum",
2219 onSelect: function() {
2220 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2225 name: "EXCL - Exclusivecoin",
2226 onSelect: function() {
2227 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
2232 name: "EXCC - ExchangeCoin",
2233 onSelect: function() {
2234 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
2239 name: "EXP - Expanse",
2240 segwitAvailable: false,
2241 onSelect: function() {
2242 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2248 onSelect: function() {
2249 network
= bitcoinjs
.bitcoin
.networks
.fix
;
2254 name: "FIX - FIX Testnet",
2255 onSelect: function() {
2256 network
= bitcoinjs
.bitcoin
.networks
.fixtestnet
;
2261 name: "FJC - Fujicoin",
2262 onSelect: function() {
2263 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2268 name: "FLASH - Flashcoin",
2269 onSelect: function() {
2270 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2275 name: "FRST - Firstcoin",
2276 onSelect: function() {
2277 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2282 name: "FTC - Feathercoin",
2283 onSelect: function() {
2284 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2289 name: "GAME - GameCredits",
2290 onSelect: function() {
2291 network
= bitcoinjs
.bitcoin
.networks
.game
;
2296 name: "GBX - Gobyte",
2297 onSelect: function() {
2298 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2303 name: "GCR - GCRCoin",
2304 onSelect: function() {
2305 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2310 name: "GRC - Gridcoin",
2311 onSelect: function() {
2312 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2317 name: "GRS - Groestlcoin",
2318 onSelect: function() {
2319 network
= bitcoinjs
.bitcoin
.networks
.groestlcoin
;
2324 name: "GRS - Groestlcoin Testnet",
2325 onSelect: function() {
2326 network
= bitcoinjs
.bitcoin
.networks
.groestlcointestnet
;
2331 name: "HNC - Helleniccoin",
2332 onSelect: function() {
2333 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2338 name: "HUSH - Hush (Legacy)",
2339 onSelect: function() {
2340 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2345 name: "HUSH - Hush3",
2346 onSelect: function() {
2347 network
= bitcoinjs
.bitcoin
.networks
.hush3
;
2352 name: "INSN - Insane",
2353 onSelect: function() {
2354 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2360 onSelect: function() {
2361 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2366 name: "IXC - Ixcoin",
2367 onSelect: function() {
2368 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2373 name: "JBS - Jumbucks",
2374 onSelect: function() {
2375 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2380 name: "KMD - Komodo",
2381 bip49available: false,
2382 onSelect: function() {
2383 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2388 name: "KOBO - Kobocoin",
2389 bip49available: false,
2390 onSelect: function() {
2391 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2396 name: "LBC - Library Credits",
2397 onSelect: function() {
2398 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2403 name: "LCC - Litecoincash",
2404 onSelect: function() {
2405 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2410 name: "LDCN - Landcoin",
2411 onSelect: function() {
2412 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2417 name: "LINX - Linx",
2418 onSelect: function() {
2419 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2424 name: "LKR - Lkrcoin",
2425 segwitAvailable: false,
2426 onSelect: function() {
2427 network
= bitcoinjs
.bitcoin
.networks
.lkrcoin
;
2432 name: "LTC - Litecoin",
2433 onSelect: function() {
2434 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2436 DOM
.litecoinLtubContainer
.removeClass("hidden");
2440 name: "LTCt - Litecoin Testnet",
2441 onSelect: function() {
2442 network
= bitcoinjs
.bitcoin
.networks
.litecointestnet
;
2444 DOM
.litecoinLtubContainer
.removeClass("hidden");
2448 name: "LTZ - LitecoinZ",
2449 onSelect: function() {
2450 network
= bitcoinjs
.bitcoin
.networks
.litecoinz
;
2455 name: "LYNX - Lynx",
2456 onSelect: function() {
2457 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2462 name: "MAZA - Maza",
2463 onSelect: function() {
2464 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2469 name: "MEC - Megacoin",
2470 onSelect: function() {
2471 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2477 segwitAvailable: false,
2478 onSelect: function() {
2479 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2484 name: "MNX - Minexcoin",
2485 onSelect: function() {
2486 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2491 name: "MONA - Monacoin",
2492 onSelect: function() {
2493 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2498 name: "MONK - Monkey Project",
2499 onSelect: function() {
2500 network
= bitcoinjs
.bitcoin
.networks
.monkeyproject
,
2505 name: "MUSIC - Musicoin",
2506 segwitAvailable: false,
2507 onSelect: function() {
2508 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2513 name: "NAV - Navcoin",
2514 onSelect: function() {
2515 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2520 name: "NAS - Nebulas",
2521 onSelect: function() {
2522 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2527 name: "NEBL - Neblio",
2528 onSelect: function() {
2529 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2534 name: "NEOS - Neoscoin",
2535 onSelect: function() {
2536 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2541 name: "NIX - NIX Platform",
2542 onSelect: function() {
2543 network
= bitcoinjs
.bitcoin
.networks
.nix
;
2548 name: "NLG - Gulden",
2549 onSelect: function() {
2550 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2555 name: "NMC - Namecoin",
2556 onSelect: function() {
2557 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2562 name: "NRG - Energi",
2563 onSelect: function() {
2564 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2569 name: "NRO - Neurocoin",
2570 onSelect: function() {
2571 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2576 name: "NSR - Nushares",
2577 onSelect: function() {
2578 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2583 name: "NYC - Newyorkc",
2584 onSelect: function() {
2585 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2590 name: "NVC - Novacoin",
2591 onSelect: function() {
2592 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2597 name: "OK - Okcash",
2598 onSelect: function() {
2599 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2604 name: "OMNI - Omnicore",
2605 onSelect: function() {
2606 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2611 name: "ONION - DeepOnion",
2612 onSelect: function() {
2613 network
= bitcoinjs
.bitcoin
.networks
.deeponion
;
2618 name: "ONX - Onixcoin",
2619 onSelect: function() {
2620 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2625 name: "PHR - Phore",
2626 onSelect: function() {
2627 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2632 name: "PINK - Pinkcoin",
2633 onSelect: function() {
2634 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2639 name: "PIRL - Pirl",
2640 segwitAvailable: false,
2641 onSelect: function() {
2642 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2647 name: "PIVX - PIVX",
2648 onSelect: function() {
2649 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2654 name: "PIVX - PIVX Testnet",
2655 onSelect: function() {
2656 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2662 segwitAvailable: false,
2663 onSelect: function() {
2664 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2669 name: "POSW - POSWcoin",
2670 onSelect: function() {
2671 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2676 name: "POT - Potcoin",
2677 onSelect: function() {
2678 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2683 name: "PPC - Peercoin",
2684 onSelect: function() {
2685 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2690 name: "PRJ - ProjectCoin",
2691 onSelect: function() {
2692 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2697 name: "PSB - Pesobit",
2698 onSelect: function() {
2699 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2704 name: "PUT - Putincoin",
2705 onSelect: function() {
2706 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2711 name: "RPD - Rapids",
2712 onSelect: function() {
2713 network
= bitcoinjs
.bitcoin
.networks
.rapids
;
2718 name: "RVN - Ravencoin",
2719 onSelect: function() {
2720 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2725 name: "RBY - Rubycoin",
2726 onSelect: function() {
2727 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2732 name: "RDD - Reddcoin",
2733 onSelect: function() {
2734 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2739 name: "RVR - RevolutionVR",
2740 onSelect: function() {
2741 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2746 name: "SAFE - Safecoin",
2747 onSelect: function() {
2748 network
= bitcoinjs
.bitcoin
.networks
.safecoin
;
2753 name: "SLS - Salus",
2754 onSelect: function() {
2755 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2760 name: "SDC - ShadowCash",
2761 onSelect: function() {
2762 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2767 name: "SDC - ShadowCash Testnet",
2768 onSelect: function() {
2769 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2774 name: "SLM - Slimcoin",
2775 onSelect: function() {
2776 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2781 name: "SLM - Slimcoin Testnet",
2782 onSelect: function() {
2783 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2788 name: "SLP - Simple Ledger Protocol",
2789 onSelect: function() {
2790 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2795 name: "SLR - Solarcoin",
2796 onSelect: function() {
2797 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2802 name: "SMLY - Smileycoin",
2803 onSelect: function() {
2804 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2809 name: "STASH - Stash",
2810 onSelect: function() {
2811 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2816 name: "STASH - Stash Testnet",
2817 onSelect: function() {
2818 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2823 name: "STRAT - Stratis",
2824 onSelect: function() {
2825 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2830 name: "TSTRAT - Stratis Testnet",
2831 onSelect: function() {
2832 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2837 name: "SYS - Syscoin",
2838 onSelect: function() {
2839 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2844 name: "THC - Hempcoin",
2845 onSelect: function() {
2846 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2852 onSelect: function() {
2853 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2858 name: "TWINS - TWINS",
2859 onSelect: function() {
2860 network
= bitcoinjs
.bitcoin
.networks
.twins
;
2865 name: "TWINS - TWINS Testnet",
2866 onSelect: function() {
2867 network
= bitcoinjs
.bitcoin
.networks
.twinstestnet
;
2872 name: "USC - Ultimatesecurecash",
2873 onSelect: function() {
2874 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2879 name: "USNBT - NuBits",
2880 onSelect: function() {
2881 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2886 name: "UNO - Unobtanium",
2887 onSelect: function() {
2888 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2893 name: "VASH - Vpncoin",
2894 onSelect: function() {
2895 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2900 name: "VET - VeChain",
2901 onSelect: function() {
2902 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2907 name: "VIA - Viacoin",
2908 onSelect: function() {
2909 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2914 name: "VIA - Viacoin Testnet",
2915 onSelect: function() {
2916 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2921 name: "VIVO - Vivo",
2922 onSelect: function() {
2923 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2928 name: "VTC - Vertcoin",
2929 onSelect: function() {
2930 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2935 name: "WGR - Wagerr",
2936 onSelect: function() {
2937 network
= bitcoinjs
.bitcoin
.networks
.wagerr
;
2942 name: "WC - Wincoin",
2943 onSelect: function() {
2944 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2949 name: "XAX - Artax",
2950 onSelect: function() {
2951 network
= bitcoinjs
.bitcoin
.networks
.artax
;
2956 name: "XBC - Bitcoinplus",
2957 onSelect: function() {
2958 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
2963 name: "XLM - Stellar",
2964 onSelect: function() {
2965 network
= stellarUtil
.dummyNetwork
;
2970 name: "XMY - Myriadcoin",
2971 onSelect: function() {
2972 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
2977 name: "XRP - Ripple",
2978 onSelect: function() {
2979 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2984 name: "XVC - Vcash",
2985 onSelect: function() {
2986 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
2991 name: "XVG - Verge",
2992 onSelect: function() {
2993 network
= bitcoinjs
.bitcoin
.networks
.verge
;
2998 name: "XUEZ - Xuez",
2999 segwitAvailable: false,
3000 onSelect: function() {
3001 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
3006 name: "XWC - Whitecoin",
3007 onSelect: function() {
3008 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
3013 name: "XZC - Zcoin",
3014 onSelect: function() {
3015 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
3020 name: "ZCL - Zclassic",
3021 onSelect: function() {
3022 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
3027 name: "ZEC - Zcash",
3028 onSelect: function() {
3029 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
3034 name: "ZEN - Horizen",
3035 onSelect: function() {
3036 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
3044 name: "Bitcoin Core",
3045 onSelect: function() {
3046 DOM
.bip32path
.val("m/0'/0'");
3047 DOM
.hardenedAddresses
.prop('checked', true);
3051 name: "blockchain.info",
3052 onSelect: function() {
3053 DOM
.bip32path
.val("m/44'/0'/0'");
3054 DOM
.hardenedAddresses
.prop('checked', false);
3058 name: "MultiBit HD",
3059 onSelect: function() {
3060 DOM
.bip32path
.val("m/0'/0");
3061 DOM
.hardenedAddresses
.prop('checked', false);
3065 name: "Coinomi, Ledger",
3066 onSelect: function() {
3067 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
3068 DOM
.hardenedAddresses
.prop('checked', false);