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;
18 var isDefaultBip44ChangeValue
= true;
20 var entropyChangeTimeoutEvent
= null;
21 var phraseChangeTimeoutEvent
= null;
22 var rootKeyChangedTimeoutEvent
= null;
24 var generationProcesses
= [];
27 DOM
.privacyScreenToggle
= $(".privacy-screen-toggle");
28 DOM
.network
= $(".network");
29 DOM
.bip32Client
= $("#bip32-client");
30 DOM
.phraseNetwork
= $("#network-phrase");
31 DOM
.useEntropy
= $(".use-entropy");
32 DOM
.entropyContainer
= $(".entropy-container");
33 DOM
.entropy
= $(".entropy");
34 DOM
.entropyFiltered
= DOM
.entropyContainer
.find(".filtered");
35 DOM
.entropyType
= DOM
.entropyContainer
.find(".type");
36 DOM
.entropyCrackTime
= DOM
.entropyContainer
.find(".crack-time");
37 DOM
.entropyEventCount
= DOM
.entropyContainer
.find(".event-count");
38 DOM
.entropyBits
= DOM
.entropyContainer
.find(".bits");
39 DOM
.entropyBitsPerEvent
= DOM
.entropyContainer
.find(".bits-per-event");
40 DOM
.entropyWordCount
= DOM
.entropyContainer
.find(".word-count");
41 DOM
.entropyBinary
= DOM
.entropyContainer
.find(".binary");
42 DOM
.entropyWordIndexes
= DOM
.entropyContainer
.find(".word-indexes");
43 DOM
.entropyChecksum
= DOM
.entropyContainer
.find(".checksum");
44 DOM
.entropyMnemonicLength
= DOM
.entropyContainer
.find(".mnemonic-length");
45 DOM
.entropyWeakEntropyOverrideWarning
= DOM
.entropyContainer
.find(".weak-entropy-override-warning");
46 DOM
.entropyFilterWarning
= DOM
.entropyContainer
.find(".filter-warning");
47 DOM
.phrase
= $(".phrase");
48 DOM
.passphrase
= $(".passphrase");
49 DOM
.generateContainer
= $(".generate-container");
50 DOM
.generate
= $(".generate");
51 DOM
.seed
= $(".seed");
52 DOM
.rootKey
= $(".root-key");
53 DOM
.litecoinLtubContainer
= $(".litecoin-ltub-container");
54 DOM
.litecoinUseLtub
= $(".litecoin-use-ltub");
55 DOM
.extendedPrivKey
= $(".extended-priv-key");
56 DOM
.extendedPubKey
= $(".extended-pub-key");
57 DOM
.bip32tab
= $("#bip32-tab");
58 DOM
.bip44tab
= $("#bip44-tab");
59 DOM
.bip49tab
= $("#bip49-tab");
60 DOM
.bip84tab
= $("#bip84-tab");
61 DOM
.bip141tab
= $("#bip141-tab");
62 DOM
.bip32panel
= $("#bip32");
63 DOM
.bip44panel
= $("#bip44");
64 DOM
.bip49panel
= $("#bip49");
65 DOM
.bip32path
= $("#bip32-path");
66 DOM
.bip44path
= $("#bip44-path");
67 DOM
.bip44purpose
= $("#bip44 .purpose");
68 DOM
.bip44coin
= $("#bip44 .coin");
69 DOM
.bip44account
= $("#bip44 .account");
70 DOM
.bip44accountXprv
= $("#bip44 .account-xprv");
71 DOM
.bip44accountXpub
= $("#bip44 .account-xpub");
72 DOM
.bip44change
= $("#bip44 .change");
73 DOM
.defaultBip44ChangeValue
= $("#bip44 .default-bip44-change-value");
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", modifiedDefaultBip44ChangeValue
);
140 DOM
.bip44change
.on("input", calcForDerivationPath
);
141 DOM
.defaultBip44ChangeValue
.on("click", resetDefaultBip44ChangeValue
);
142 DOM
.bip49account
.on("input", calcForDerivationPath
);
143 DOM
.bip49change
.on("input", calcForDerivationPath
);
144 DOM
.bip84account
.on("input", calcForDerivationPath
);
145 DOM
.bip84change
.on("input", calcForDerivationPath
);
146 DOM
.bip141path
.on("input", calcForDerivationPath
);
147 DOM
.bip141semantics
.on("change", tabChanged
);
148 DOM
.tab
.on("shown.bs.tab", tabChanged
);
149 DOM
.hardenedAddresses
.on("change", calcForDerivationPath
);
150 DOM
.useBip38
.on("change", calcForDerivationPath
);
151 DOM
.bip38Password
.on("change", calcForDerivationPath
);
152 DOM
.indexToggle
.on("click", toggleIndexes
);
153 DOM
.addressToggle
.on("click", toggleAddresses
);
154 DOM
.publicKeyToggle
.on("click", togglePublicKeys
);
155 DOM
.privateKeyToggle
.on("click", togglePrivateKeys
);
156 DOM
.csvTab
.on("click", updateCsv
);
157 DOM
.languages
.on("click", languageChanged
);
158 DOM
.bitcoinCashAddressType
.on("change", bitcoinCashAddressTypeChange
);
159 setQrEvents(DOM
.showQrEls
);
162 hideValidationError();
163 populateNetworkSelect();
164 populateClientSelect();
169 function generatedStrengthChanged() {
170 var strength
= parseInt(DOM
.generatedStrength
.val());
172 DOM
.generatedStrengthWarning
.removeClass("hidden");
175 DOM
.generatedStrengthWarning
.addClass("hidden");
179 function networkChanged(e
) {
181 clearAddressesList();
182 DOM
.litecoinLtubContainer
.addClass("hidden");
183 DOM
.bitcoinCashAddressTypeContainer
.addClass("hidden");
184 var networkIndex
= e
.target
.value
;
185 var network
= networks
[networkIndex
];
187 adjustNetworkForSegwit();
196 function bip32ClientChanged(e
) {
197 var clientIndex
= DOM
.bip32Client
.val();
198 if (clientIndex
== "custom") {
199 DOM
.bip32path
.prop("readonly", false);
202 DOM
.bip32path
.prop("readonly", true);
203 clients
[clientIndex
].onSelect();
213 function setEntropyVisibility() {
214 if (isUsingOwnEntropy()) {
215 DOM
.entropyContainer
.removeClass("hidden");
216 DOM
.generateContainer
.addClass("hidden");
217 DOM
.phrase
.prop("readonly", true);
222 DOM
.entropyContainer
.addClass("hidden");
223 DOM
.generateContainer
.removeClass("hidden");
224 DOM
.phrase
.prop("readonly", false);
229 function delayedPhraseChanged() {
230 hideValidationError();
233 bip32ExtendedKey
= null;
234 clearAddressesList();
236 if (phraseChangeTimeoutEvent
!= null) {
237 clearTimeout(phraseChangeTimeoutEvent
);
239 phraseChangeTimeoutEvent
= setTimeout(phraseChanged
, 400);
242 function phraseChanged() {
244 setMnemonicLanguage();
245 // Get the mnemonic phrase
246 var phrase
= DOM
.phrase
.val();
247 var errorText
= findPhraseErrors(phrase
);
249 showValidationError(errorText
);
252 // Calculate and display
253 var passphrase
= DOM
.passphrase
.val();
254 calcBip32RootKeyFromSeed(phrase
, passphrase
);
255 calcForDerivationPath();
256 // Show the word indexes
260 function tabChanged() {
262 adjustNetworkForSegwit();
263 var phrase
= DOM
.phrase
.val();
265 // Calculate and display for mnemonic
266 var errorText
= findPhraseErrors(phrase
);
268 showValidationError(errorText
);
271 // Calculate and display
272 var passphrase
= DOM
.passphrase
.val();
273 calcBip32RootKeyFromSeed(phrase
, passphrase
);
276 // Calculate and display for root key
277 var rootKeyBase58
= DOM
.rootKey
.val();
278 var errorText
= validateRootKey(rootKeyBase58
);
280 showValidationError(errorText
);
283 // Calculate and display
284 calcBip32RootKeyFromBase58(rootKeyBase58
);
286 calcForDerivationPath();
289 function delayedEntropyChanged() {
290 hideValidationError();
292 if (entropyChangeTimeoutEvent
!= null) {
293 clearTimeout(entropyChangeTimeoutEvent
);
295 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
298 function entropyChanged() {
299 // If blank entropy, clear mnemonic, addresses, errors
300 if (DOM
.entropy
.val().trim().length
== 0) {
302 clearEntropyFeedback();
304 showValidationError("Blank entropy");
307 // Get the current phrase to detect changes
308 var phrase
= DOM
.phrase
.val();
309 // Set the phrase from the entropy
310 setMnemonicFromEntropy();
311 // Recalc addresses if the phrase has changed
312 var newPhrase
= DOM
.phrase
.val();
313 if (newPhrase
!= phrase
) {
314 if (newPhrase
.length
== 0) {
326 function delayedRootKeyChanged() {
327 // Warn if there is an existing mnemonic or passphrase.
328 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
329 if (!confirm("This will clear existing mnemonic and passphrase")) {
330 DOM
.rootKey
.val(bip32RootKey
);
334 hideValidationError();
336 // Clear existing mnemonic and passphrase
338 DOM
.passphrase
.val("");
340 if (rootKeyChangedTimeoutEvent
!= null) {
341 clearTimeout(rootKeyChangedTimeoutEvent
);
343 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
346 function rootKeyChanged() {
348 hideValidationError();
349 var rootKeyBase58
= DOM
.rootKey
.val();
350 var errorText
= validateRootKey(rootKeyBase58
);
352 showValidationError(errorText
);
355 // Calculate and display
356 calcBip32RootKeyFromBase58(rootKeyBase58
);
357 calcForDerivationPath();
360 function litecoinUseLtubChanged() {
361 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
362 if (litecoinUseLtub
) {
363 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
366 network
= bitcoinjs
.bitcoin
.networks
.litecoinXprv
;
371 function calcForDerivationPath() {
373 clearAddressesList();
375 // Don't show segwit if it's selected but network doesn't support it
376 if (segwitSelected() && !networkHasSegwit()) {
377 showSegwitUnavailable();
381 showSegwitAvailable();
382 // Get the derivation path
383 var derivationPath
= getDerivationPath();
384 var errorText
= findDerivationPathErrors(derivationPath
);
386 showValidationError(errorText
);
389 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
390 if (bip44TabSelected()) {
393 else if (bip49TabSelected()) {
396 else if (bip84TabSelected()) {
402 function generateClicked() {
403 if (isUsingOwnEntropy()) {
408 setTimeout(function() {
409 setMnemonicLanguage();
410 var phrase
= generateRandomPhrase();
418 function languageChanged() {
419 setTimeout(function() {
420 setMnemonicLanguage();
421 if (DOM
.phrase
.val().length
> 0) {
422 var newPhrase
= convertPhraseToNewLanguage();
423 DOM
.phrase
.val(newPhrase
);
427 DOM
.generate
.trigger("click");
432 function bitcoinCashAddressTypeChange() {
436 function toggleIndexes() {
437 showIndex
= !showIndex
;
438 $("td.index span").toggleClass("invisible");
441 function toggleAddresses() {
442 showAddress
= !showAddress
;
443 $("td.address span").toggleClass("invisible");
446 function togglePublicKeys() {
447 showPubKey
= !showPubKey
;
448 $("td.pubkey span").toggleClass("invisible");
451 function togglePrivateKeys() {
452 showPrivKey
= !showPrivKey
;
453 $("td.privkey span").toggleClass("invisible");
456 function privacyScreenToggled() {
457 // private-data contains elements added to DOM at runtime
458 // so catch all by adding visual privacy class to the root of the DOM
459 if (DOM
.privacyScreenToggle
.prop("checked")) {
460 $("body").addClass("visual-privacy");
463 $("body").removeClass("visual-privacy");
469 function generateRandomPhrase() {
470 if (!hasStrongRandom()) {
471 var errorText
= "This browser does not support strong randomness";
472 showValidationError(errorText
);
475 // get the amount of entropy to use
476 var numWords
= parseInt(DOM
.generatedStrength
.val());
477 var strength
= numWords
/ 3 * 32;
478 var buffer
= new Uint8Array(strength
/ 8);
479 // create secure entropy
480 var data
= crypto
.getRandomValues(buffer
);
482 var words
= mnemonic
.toMnemonic(data
);
483 DOM
.phrase
.val(words
);
485 var entropyHex
= uint8ArrayToHex(data
);
486 DOM
.entropy
.val(entropyHex
);
487 // ensure entropy fields are consistent with what is being displayed
488 DOM
.entropyMnemonicLength
.val("raw");
492 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
493 seed
= mnemonic
.toSeed(phrase
, passphrase
);
494 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
496 bip32RootKey
= groestlcoinjs
.HDNode
.fromSeedHex(seed
, network
);
500 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
502 calcBip32RootKeyFromBase58GRS(rootKeyBase58
);
505 // try parsing with various segwit network params since this extended
506 // key may be from any one of them.
507 if (networkHasSegwit()) {
509 if ("baseNetwork" in n
) {
510 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
512 // try parsing using base network params
514 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
518 // try parsing using p2wpkh params
521 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
526 // try parsing using p2wpkh-in-p2sh network params
527 if ("p2wpkhInP2sh" in n
) {
529 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
535 // try the network params as currently specified
536 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
539 function calcBip32RootKeyFromBase58GRS(rootKeyBase58
) {
540 // try parsing with various segwit network params since this extended
541 // key may be from any one of them.
542 if (networkHasSegwit()) {
544 if ("baseNetwork" in n
) {
545 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
547 // try parsing using base network params
549 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
553 // try parsing using p2wpkh params
556 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
561 // try parsing using p2wpkh-in-p2sh network params
562 if ("p2wpkhInP2sh" in n
) {
564 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
570 // try the network params as currently specified
571 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
574 function calcBip32ExtendedKey(path
) {
575 // Check there's a root key to derive from
579 var extendedKey
= bip32RootKey
;
580 // Derive the key from the path
581 var pathBits
= path
.split("/");
582 for (var i
=0; i
<pathBits
.length
; i
++) {
583 var bit
= pathBits
[i
];
584 var index
= parseInt(bit
);
588 var hardened
= bit
[bit
.length
-1] == "'";
589 var isPriv
= !(extendedKey
.isNeutered());
590 var invalidDerivationPath
= hardened
&& !isPriv
;
591 if (invalidDerivationPath
) {
595 extendedKey
= extendedKey
.deriveHardened(index
);
598 extendedKey
= extendedKey
.derive(index
);
604 function showValidationError(errorText
) {
610 function hideValidationError() {
616 function findPhraseErrors(phrase
) {
617 // Preprocess the words
618 phrase
= mnemonic
.normalizeString(phrase
);
619 var words
= phraseToWordArray(phrase
);
620 // Detect blank phrase
621 if (words
.length
== 0) {
622 return "Blank mnemonic";
625 for (var i
=0; i
<words
.length
; i
++) {
627 var language
= getLanguage();
628 if (WORDLISTS
[language
].indexOf(word
) == -1) {
629 console
.log("Finding closest match to " + word
);
630 var nearestWord
= findNearestWord(word
);
631 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
634 // Check the words are valid
635 var properPhrase
= wordArrayToPhrase(words
);
636 var isValid
= mnemonic
.check(properPhrase
);
638 return "Invalid mnemonic";
643 function validateRootKey(rootKeyBase58
) {
645 return validateRootKeyGRS(rootKeyBase58
);
647 // try various segwit network params since this extended key may be from
649 if (networkHasSegwit()) {
651 if ("baseNetwork" in n
) {
652 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
654 // try parsing using base network params
656 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
660 // try parsing using p2wpkh params
663 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
668 // try parsing using p2wpkh-in-p2sh network params
669 if ("p2wpkhInP2sh" in n
) {
671 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
677 // try the network params as currently specified
679 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
682 return "Invalid root key";
687 function validateRootKeyGRS(rootKeyBase58
) {
688 // try various segwit network params since this extended key may be from
690 if (networkHasSegwit()) {
692 if ("baseNetwork" in n
) {
693 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
695 // try parsing using base network params
697 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
701 // try parsing using p2wpkh params
704 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
709 // try parsing using p2wpkh-in-p2sh network params
710 if ("p2wpkhInP2sh" in n
) {
712 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
718 // try the network params as currently specified
720 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
723 return "Invalid root key";
728 function getDerivationPath() {
729 if (bip44TabSelected()) {
730 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
731 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
732 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
733 var change
= parseIntNoNaN(DOM
.bip44change
.val(), "");
735 path
+= "/" + purpose
+ "'";
736 path
+= "/" + coin
+ "'";
737 path
+= "/" + account
+ "'";
739 path
+= "/" + change
;
741 DOM
.bip44path
.val(path
);
742 var derivationPath
= DOM
.bip44path
.val();
743 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
744 return derivationPath
;
746 else if (bip49TabSelected()) {
747 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
748 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
749 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
750 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
752 path
+= purpose
+ "'/";
754 path
+= account
+ "'/";
756 DOM
.bip49path
.val(path
);
757 var derivationPath
= DOM
.bip49path
.val();
758 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
759 return derivationPath
;
761 else if (bip84TabSelected()) {
762 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
763 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
764 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
765 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
767 path
+= purpose
+ "'/";
769 path
+= account
+ "'/";
771 DOM
.bip84path
.val(path
);
772 var derivationPath
= DOM
.bip84path
.val();
773 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
774 return derivationPath
;
776 else if (bip32TabSelected()) {
777 var derivationPath
= DOM
.bip32path
.val();
778 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
779 return derivationPath
;
781 else if (bip141TabSelected()) {
782 var derivationPath
= DOM
.bip141path
.val();
783 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
784 return derivationPath
;
787 console
.log("Unknown derivation path");
791 function findDerivationPathErrors(path
) {
792 // TODO is not perfect but is better than nothing
794 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
796 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
797 var maxDepth
= 255; // TODO verify this!!
798 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
799 if (path
[0] != "m") {
800 return "First character must be 'm'";
802 if (path
.length
> 1) {
803 if (path
[1] != "/") {
804 return "Separator must be '/'";
806 var indexes
= path
.split("/");
807 if (indexes
.length
> maxDepth
) {
808 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
810 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
811 var index
= indexes
[depth
];
812 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
813 if (invalidChars
.length
> 0) {
814 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
816 var indexValue
= parseInt(index
.replace("'", ""));
818 return "Invalid number at depth " + depth
;
820 if (indexValue
> maxIndexValue
) {
821 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
825 // Check root key exists or else derivation path is useless!
827 return "No root key";
829 // Check no hardened derivation path when using xpub keys
830 var hardenedPath
= path
.indexOf("'") > -1;
831 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
832 var hardened
= hardenedPath
|| hardenedAddresses
;
833 var isXpubkey
= bip32RootKey
.isNeutered();
834 if (hardened
&& isXpubkey
) {
835 return "Hardened derivation path is invalid with xpub key";
841 return networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin" || networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin Testnet";
844 function displayBip44Info() {
845 // Get the derivation path for the account
846 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
847 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
848 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
850 path
+= purpose
+ "'/";
852 path
+= account
+ "'/";
853 // Calculate the account extended keys
854 var accountExtendedKey
= calcBip32ExtendedKey(path
);
855 var accountXprv
= accountExtendedKey
.toBase58();
856 var accountXpub
= accountExtendedKey
.neutered().toBase58();
857 // Display the extended keys
858 DOM
.bip44accountXprv
.val(accountXprv
);
859 DOM
.bip44accountXpub
.val(accountXpub
);
862 function displayBip49Info() {
863 // Get the derivation path for the account
864 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
865 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
866 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
868 path
+= purpose
+ "'/";
870 path
+= account
+ "'/";
871 // Calculate the account extended keys
872 var accountExtendedKey
= calcBip32ExtendedKey(path
);
873 var accountXprv
= accountExtendedKey
.toBase58();
874 var accountXpub
= accountExtendedKey
.neutered().toBase58();
875 // Display the extended keys
876 DOM
.bip49accountXprv
.val(accountXprv
);
877 DOM
.bip49accountXpub
.val(accountXpub
);
880 function displayBip84Info() {
881 // Get the derivation path for the account
882 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
883 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
884 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
886 path
+= purpose
+ "'/";
888 path
+= account
+ "'/";
889 // Calculate the account extended keys
890 var accountExtendedKey
= calcBip32ExtendedKey(path
);
891 var accountXprv
= accountExtendedKey
.toBase58();
892 var accountXpub
= accountExtendedKey
.neutered().toBase58();
893 // Display the extended keys
894 DOM
.bip84accountXprv
.val(accountXprv
);
895 DOM
.bip84accountXpub
.val(accountXpub
);
898 function displayBip32Info() {
901 var rootKey
= bip32RootKey
.toBase58();
902 DOM
.rootKey
.val(rootKey
);
903 var xprvkeyB58
= "NA";
904 if (!bip32ExtendedKey
.isNeutered()) {
905 xprvkeyB58
= bip32ExtendedKey
.toBase58();
907 var extendedPrivKey
= xprvkeyB58
;
908 DOM
.extendedPrivKey
.val(extendedPrivKey
);
909 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
910 DOM
.extendedPubKey
.val(extendedPubKey
);
911 // Display the addresses and privkeys
912 clearAddressesList();
913 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
914 displayAddresses(0, initialAddressCount
);
917 function displayAddresses(start
, total
) {
918 generationProcesses
.push(new (function() {
922 this.stop = function() {
923 for (var i
=0; i
<rows
.length
; i
++) {
924 rows
[i
].shouldGenerate
= false;
929 for (var i
=0; i
<total
; i
++) {
930 var index
= i
+ start
;
931 var isLast
= i
== total
- 1;
932 rows
.push(new TableRow(index
, isLast
));
938 function segwitSelected() {
939 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
942 function p2wpkhSelected() {
943 return bip84TabSelected() ||
944 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
947 function p2wpkhInP2shSelected() {
948 return bip49TabSelected() ||
949 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
952 function TableRow(index
, isLast
) {
955 this.shouldGenerate
= true;
956 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
957 var useBip38
= DOM
.useBip38
.prop("checked");
958 var bip38password
= DOM
.bip38Password
.val();
959 var isSegwit
= segwitSelected();
960 var segwitAvailable
= networkHasSegwit();
961 var isP2wpkh
= p2wpkhSelected();
962 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
968 function calculateValues() {
969 setTimeout(function() {
970 if (!self
.shouldGenerate
) {
973 // derive HDkey for this row of the table
975 if (useHardenedAddresses
) {
976 key
= bip32ExtendedKey
.deriveHardened(index
);
979 key
= bip32ExtendedKey
.derive(index
);
981 // bip38 requires uncompressed keys
982 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
983 var keyPair
= key
.keyPair
;
984 var useUncompressed
= useBip38
;
985 if (useUncompressed
) {
986 keyPair
= new bitcoinjs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
988 keyPair
= new groestlcoinjs
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
992 var address
= keyPair
.getAddress().toString();
994 var hasPrivkey
= !key
.isNeutered();
997 privkey
= keyPair
.toWIF();
998 // BIP38 encode private key if required
1001 privkey
= groestlcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1002 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1003 }, null, networks
[DOM
.network
.val()].name
.includes("Testnet"));
1005 privkey
= bitcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1006 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1011 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
1012 var indexText
= getDerivationPath() + "/" + index
;
1013 if (useHardenedAddresses
) {
1014 indexText
= indexText
+ "'";
1016 // Ethereum values are different
1017 if (networkIsEthereum()) {
1018 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1019 privkey
= privKeyBuffer
.toString('hex');
1020 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
1021 var hexAddress
= addressBuffer
.toString('hex');
1022 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
1023 address
= ethUtil
.addHexPrefix(checksumAddress
);
1024 privkey
= ethUtil
.addHexPrefix(privkey
);
1025 pubkey
= ethUtil
.addHexPrefix(pubkey
);
1028 // Stellar is different
1029 if (networks
[DOM
.network
.val()].name
== "XLM - Stellar") {
1030 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
1031 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
1033 path
+= purpose
+ "'/";
1034 path
+= coin
+ "'/" + index
+ "'";
1035 var keypair
= stellarUtil
.getKeypair(path
, seed
);
1037 privkey
= keypair
.secret();
1038 pubkey
= address
= keypair
.publicKey();
1040 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
1041 var NasAccount
= require("nebulas-account");
1042 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1043 var nebulasAccount
= new NasAccount();
1044 nebulasAccount
.setPrivateKey(privKeyBuffer
);
1045 address
= nebulasAccount
.getAddressString();
1046 privkey
= nebulasAccount
.getPrivateKeyString();
1047 pubkey
= nebulasAccount
.getPublicKeyString();
1049 // Ripple values are different
1050 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
1051 privkey
= convertRipplePriv(privkey
);
1052 address
= convertRippleAdrr(address
);
1054 // CasinoCoin values are different
1055 if (networks
[DOM
.network
.val()].name
== "CSC - CasinoCoin") {
1056 privkey
= convertCasinoCoinPriv(privkey
);
1057 address
= convertCasinoCoinAdrr(address
);
1059 // Bitcoin Cash address format may vary
1060 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
1061 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1062 if (bchAddrType
== "cashaddr") {
1063 address
= bchaddr
.toCashAddress(address
);
1065 else if (bchAddrType
== "bitpay") {
1066 address
= bchaddr
.toBitpayAddress(address
);
1069 // Bitcoin Cash address format may vary
1070 if (networks
[DOM
.network
.val()].name
== "SLP - Simple Ledger Protocol") {
1071 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1072 if (bchAddrType
== "cashaddr") {
1073 address
= bchaddr
.toSlpAddress(address
);
1076 // Segwit addresses are different
1078 if (!segwitAvailable
) {
1082 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1083 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1084 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1086 else if (isP2wpkhInP2sh
) {
1087 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1088 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1089 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
1090 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
1091 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1095 if ((networks
[DOM
.network
.val()].name
== "CRW - Crown")) {
1096 address
= bitcoinjs
.bitcoin
.networks
.crown
.toNewAddress(address
);
1099 if (networks
[DOM
.network
.val()].name
== "EOS - EOSIO") {
1101 pubkey
= eosUtil
.bufferToPublic(keyPair
.getPublicKeyBuffer());
1102 privkey
= eosUtil
.bufferToPrivate(keyPair
.d
.toBuffer(32));
1105 //Groestlcoin Addresses are different
1109 if (!segwitAvailable
) {
1113 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1115 else if (isP2wpkhInP2sh
) {
1116 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1119 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1122 addAddressToList(indexText
, address
, pubkey
, privkey
);
1134 function showMore() {
1135 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
1136 if (isNaN(rowsToAdd
)) {
1138 DOM
.rowsToAdd
.val("20");
1140 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
1142 start
= lastIndexInTable() + 1;
1145 var newStart
= start
+ rowsToAdd
;
1146 DOM
.moreRowsStartIndex
.val(newStart
);
1148 if (rowsToAdd
> 200) {
1149 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1150 msg
+= "Do you want to continue?";
1151 if (!confirm(msg
)) {
1155 displayAddresses(start
, rowsToAdd
);
1158 function clearDisplay() {
1159 clearAddressesList();
1161 hideValidationError();
1164 function clearAddressesList() {
1165 DOM
.addresses
.empty();
1170 function stopGenerating() {
1171 while (generationProcesses
.length
> 0) {
1172 var generation
= generationProcesses
.shift();
1177 function clearKeys() {
1182 function clearRootKey() {
1183 DOM
.rootKey
.val("");
1186 function clearDerivedKeys() {
1187 DOM
.extendedPrivKey
.val("");
1188 DOM
.extendedPubKey
.val("");
1189 DOM
.bip44accountXprv
.val("");
1190 DOM
.bip44accountXpub
.val("");
1193 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1194 var row
= $(addressRowTemplate
.html());
1196 var indexCell
= row
.find(".index span");
1197 var addressCell
= row
.find(".address span");
1198 var pubkeyCell
= row
.find(".pubkey span");
1199 var privkeyCell
= row
.find(".privkey span");
1201 indexCell
.text(indexText
);
1202 addressCell
.text(address
);
1203 pubkeyCell
.text(pubkey
);
1204 privkeyCell
.text(privkey
);
1207 indexCell
.addClass("invisible");
1210 addressCell
.addClass("invisible");
1213 pubkeyCell
.addClass("invisible");
1216 privkeyCell
.addClass("invisible");
1218 DOM
.addresses
.append(row
);
1219 var rowShowQrEls
= row
.find("[data-show-qr]");
1220 setQrEvents(rowShowQrEls
);
1223 function hasStrongRandom() {
1224 return 'crypto' in window
&& window
['crypto'] !== null;
1227 function disableForms() {
1228 $("form").on("submit", function(e
) {
1233 function parseIntNoNaN(val
, defaultVal
) {
1234 var v
= parseInt(val
);
1241 function showPending() {
1243 .text("Calculating...")
1247 function findNearestWord(word
) {
1248 var language
= getLanguage();
1249 var words
= WORDLISTS
[language
];
1250 var minDistance
= 99;
1251 var closestWord
= words
[0];
1252 for (var i
=0; i
<words
.length
; i
++) {
1253 var comparedTo
= words
[i
];
1254 if (comparedTo
.indexOf(word
) == 0) {
1257 var distance
= Levenshtein
.get(word
, comparedTo
);
1258 if (distance
< minDistance
) {
1259 closestWord
= comparedTo
;
1260 minDistance
= distance
;
1266 function hidePending() {
1272 function populateNetworkSelect() {
1273 for (var i
=0; i
<networks
.length
; i
++) {
1274 var network
= networks
[i
];
1275 var option
= $("<option>");
1276 option
.attr("value", i
);
1277 option
.text(network
.name
);
1278 if (network
.name
== "BTC - Bitcoin") {
1279 option
.prop("selected", true);
1281 DOM
.phraseNetwork
.append(option
);
1285 function populateClientSelect() {
1286 for (var i
=0; i
<clients
.length
; i
++) {
1287 var client
= clients
[i
];
1288 var option
= $("<option>");
1289 option
.attr("value", i
);
1290 option
.text(client
.name
);
1291 DOM
.bip32Client
.append(option
);
1295 function getLanguage() {
1296 var defaultLanguage
= "english";
1297 // Try to get from existing phrase
1298 var language
= getLanguageFromPhrase();
1299 // Try to get from url if not from phrase
1300 if (language
.length
== 0) {
1301 language
= getLanguageFromUrl();
1303 // Default to English if no other option
1304 if (language
.length
== 0) {
1305 language
= defaultLanguage
;
1310 function getLanguageFromPhrase(phrase
) {
1311 // Check if how many words from existing phrase match a language.
1314 phrase
= DOM
.phrase
.val();
1316 if (phrase
.length
> 0) {
1317 var words
= phraseToWordArray(phrase
);
1318 var languageMatches
= {};
1319 for (l
in WORDLISTS
) {
1320 // Track how many words match in this language
1321 languageMatches
[l
] = 0;
1322 for (var i
=0; i
<words
.length
; i
++) {
1323 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1324 if (wordInLanguage
) {
1325 languageMatches
[l
]++;
1328 // Find languages with most word matches.
1329 // This is made difficult due to commonalities between Chinese
1330 // simplified vs traditional.
1331 var mostMatches
= 0;
1332 var mostMatchedLanguages
= [];
1333 for (var l
in languageMatches
) {
1334 var numMatches
= languageMatches
[l
];
1335 if (numMatches
> mostMatches
) {
1336 mostMatches
= numMatches
;
1337 mostMatchedLanguages
= [l
];
1339 else if (numMatches
== mostMatches
) {
1340 mostMatchedLanguages
.push(l
);
1344 if (mostMatchedLanguages
.length
> 0) {
1345 // Use first language and warn if multiple detected
1346 language
= mostMatchedLanguages
[0];
1347 if (mostMatchedLanguages
.length
> 1) {
1348 console
.warn("Multiple possible languages");
1349 console
.warn(mostMatchedLanguages
);
1356 function getLanguageFromUrl() {
1357 for (var language
in WORDLISTS
) {
1358 if (window
.location
.hash
.indexOf(language
) > -1) {
1365 function setMnemonicLanguage() {
1366 var language
= getLanguage();
1367 // Load the bip39 mnemonic generator for this language if required
1368 if (!(language
in mnemonics
)) {
1369 mnemonics
[language
] = new Mnemonic(language
);
1371 mnemonic
= mnemonics
[language
];
1374 function convertPhraseToNewLanguage() {
1375 var oldLanguage
= getLanguageFromPhrase();
1376 var newLanguage
= getLanguageFromUrl();
1377 var oldPhrase
= DOM
.phrase
.val();
1378 var oldWords
= phraseToWordArray(oldPhrase
);
1380 for (var i
=0; i
<oldWords
.length
; i
++) {
1381 var oldWord
= oldWords
[i
];
1382 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1383 var newWord
= WORDLISTS
[newLanguage
][index
];
1384 newWords
.push(newWord
);
1386 newPhrase
= wordArrayToPhrase(newWords
);
1390 // TODO look at jsbip39 - mnemonic.splitWords
1391 function phraseToWordArray(phrase
) {
1392 var words
= phrase
.split(/\s/g);
1394 for (var i
=0; i
<words
.length
; i
++) {
1395 var word
= words
[i
];
1396 if (word
.length
> 0) {
1397 noBlanks
.push(word
);
1403 // TODO look at jsbip39 - mnemonic.joinWords
1404 function wordArrayToPhrase(words
) {
1405 var phrase
= words
.join(" ");
1406 var language
= getLanguageFromPhrase(phrase
);
1407 if (language
== "japanese") {
1408 phrase
= words
.join("\u3000");
1413 function isUsingOwnEntropy() {
1414 return DOM
.useEntropy
.prop("checked");
1417 function setMnemonicFromEntropy() {
1418 clearEntropyFeedback();
1419 // Get entropy value
1420 var entropyStr
= DOM
.entropy
.val();
1421 // Work out minimum base for entropy
1422 var entropy
= Entropy
.fromString(entropyStr
);
1423 if (entropy
.binaryStr
.length
== 0) {
1426 // Show entropy details
1427 showEntropyFeedback(entropy
);
1428 // Use entropy hash if not using raw entropy
1429 var bits
= entropy
.binaryStr
;
1430 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1431 if (mnemonicLength
!= "raw") {
1432 // Get bits by hashing entropy with SHA256
1433 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1434 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1435 bits
= BigInteger
.parse(hex
, 16).toString(2);
1436 while (bits
.length
% 256 != 0) {
1439 // Truncate hash to suit number of words
1440 mnemonicLength
= parseInt(mnemonicLength
);
1441 var numberOfBits
= 32 * mnemonicLength
/ 3;
1442 bits
= bits
.substring(0, numberOfBits
);
1443 // show warning for weak entropy override
1444 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1445 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1448 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1452 // hide warning for weak entropy override
1453 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1455 // Discard trailing entropy
1456 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1457 var start
= bits
.length
- bitsToUse
;
1458 var binaryStr
= bits
.substring(start
);
1459 // Convert entropy string to numeric array
1460 var entropyArr
= [];
1461 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1462 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1463 var entropyByte
= parseInt(byteAsBits
, 2);
1464 entropyArr
.push(entropyByte
)
1466 // Convert entropy array to mnemonic
1467 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1468 // Set the mnemonic in the UI
1469 DOM
.phrase
.val(phrase
);
1470 // Show the word indexes
1472 // Show the checksum
1476 function clearEntropyFeedback() {
1477 DOM
.entropyCrackTime
.text("...");
1478 DOM
.entropyType
.text("");
1479 DOM
.entropyWordCount
.text("0");
1480 DOM
.entropyEventCount
.text("0");
1481 DOM
.entropyBitsPerEvent
.text("0");
1482 DOM
.entropyBits
.text("0");
1483 DOM
.entropyFiltered
.html(" ");
1484 DOM
.entropyBinary
.html(" ");
1487 function showEntropyFeedback(entropy
) {
1488 var numberOfBits
= entropy
.binaryStr
.length
;
1489 var timeToCrack
= "unknown";
1491 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1492 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1493 if (z
.feedback
.warning
!= "") {
1494 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1498 console
.log("Error detecting entropy strength with zxcvbn:");
1501 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1502 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1503 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1504 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1505 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1506 DOM
.entropyType
.text(entropyTypeStr
);
1507 DOM
.entropyCrackTime
.text(timeToCrack
);
1508 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1509 DOM
.entropyBits
.text(numberOfBits
);
1510 DOM
.entropyWordCount
.text(wordCount
);
1511 DOM
.entropyBinary
.text(spacedBinaryStr
);
1512 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1513 // detect and warn of filtering
1514 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1515 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1516 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1518 DOM
.entropyFilterWarning
.removeClass('hidden');
1521 DOM
.entropyFilterWarning
.addClass('hidden');
1525 function getEntropyTypeStr(entropy
) {
1526 var typeStr
= entropy
.base
.str
;
1527 // Add some detail if these are cards
1528 if (entropy
.base
.asInt
== 52) {
1529 var cardDetail
= []; // array of message strings
1530 // Detect duplicates
1532 var dupeTracker
= {};
1533 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1534 var card
= entropy
.base
.parts
[i
];
1535 var cardUpper
= card
.toUpperCase();
1536 if (cardUpper
in dupeTracker
) {
1539 dupeTracker
[cardUpper
] = true;
1541 if (dupes
.length
> 0) {
1542 var dupeWord
= "duplicates";
1543 if (dupes
.length
== 1) {
1544 dupeWord
= "duplicate";
1546 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1547 if (dupes
.length
> 3) {
1550 cardDetail
.push(msg
);
1553 var uniqueCards
= [];
1554 for (var uniqueCard
in dupeTracker
) {
1555 uniqueCards
.push(uniqueCard
);
1557 if (uniqueCards
.length
== 52) {
1558 cardDetail
.unshift("full deck");
1560 // Detect missing cards
1561 var values
= "A23456789TJQK";
1563 var missingCards
= [];
1564 for (var i
=0; i
<suits
.length
; i
++) {
1565 for (var j
=0; j
<values
.length
; j
++) {
1566 var card
= values
[j
] + suits
[i
];
1567 if (!(card
in dupeTracker
)) {
1568 missingCards
.push(card
);
1572 // Display missing cards if six or less, ie clearly going for full deck
1573 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1574 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1575 if (missingCards
.length
> 3) {
1578 cardDetail
.push(msg
);
1580 // Add card details to typeStr
1581 if (cardDetail
.length
> 0) {
1582 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1588 function setQrEvents(els
) {
1589 els
.on("mouseenter", createQr
);
1590 els
.on("mouseleave", destroyQr
);
1591 els
.on("click", toggleQr
);
1594 function createQr(e
) {
1595 var content
= e
.target
.textContent
|| e
.target
.value
;
1603 DOM
.qrImage
.append(qrEl
);
1605 DOM
.qrHider
.addClass("hidden");
1608 DOM
.qrHider
.removeClass("hidden");
1610 DOM
.qrContainer
.removeClass("hidden");
1614 function destroyQr() {
1615 DOM
.qrImage
.text("");
1616 DOM
.qrContainer
.addClass("hidden");
1619 function toggleQr() {
1621 DOM
.qrHider
.toggleClass("hidden");
1622 DOM
.qrHint
.toggleClass("hidden");
1625 function bip44TabSelected() {
1626 return DOM
.bip44tab
.hasClass("active");
1629 function bip32TabSelected() {
1630 return DOM
.bip32tab
.hasClass("active");
1633 function networkIsEthereum() {
1634 var name
= networks
[DOM
.network
.val()].name
;
1635 return (name
== "ETH - Ethereum")
1636 || (name
== "ETC - Ethereum Classic")
1637 || (name
== "PIRL - Pirl")
1638 || (name
== "MIX - MIX")
1639 || (name
== "MUSIC - Musicoin")
1640 || (name
== "POA - Poa")
1641 || (name
== "EXP - Expanse")
1642 || (name
== "CLO - Callisto")
1643 || (name
== "DXN - DEXON")
1644 || (name
== "ELLA - Ellaism")
1645 || (name
== "ESN - Ethersocial Network")
1646 || (name
== "VET - VeChain")
1649 function networkHasSegwit() {
1651 if ("baseNetwork" in network
) {
1652 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1654 // check if only p2wpkh params are required
1655 if (p2wpkhSelected()) {
1656 return "p2wpkh" in n
;
1658 // check if only p2wpkh-in-p2sh params are required
1659 else if (p2wpkhInP2shSelected()) {
1660 return "p2wpkhInP2sh" in n
;
1662 // require both if it's unclear which params are required
1663 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1666 function bip49TabSelected() {
1667 return DOM
.bip49tab
.hasClass("active");
1670 function bip84TabSelected() {
1671 return DOM
.bip84tab
.hasClass("active");
1674 function bip141TabSelected() {
1675 return DOM
.bip141tab
.hasClass("active");
1678 function setBip44ChangeValue() {
1679 if (isDefaultBip44ChangeValue
) {
1680 if (networkIsEthereum()) {
1681 DOM
.bip44change
.val("");
1683 DOM
.bip44change
.val(0);
1688 function modifiedDefaultBip44ChangeValue() {
1689 isDefaultBip44ChangeValue
= false;
1692 function resetDefaultBip44ChangeValue() {
1693 isDefaultBip44ChangeValue
= true;
1694 setBip44ChangeValue();
1697 function setHdCoin(coinValue
) {
1698 DOM
.bip44coin
.val(coinValue
);
1699 DOM
.bip49coin
.val(coinValue
);
1700 DOM
.bip84coin
.val(coinValue
);
1701 setBip44ChangeValue();
1704 function showSegwitAvailable() {
1705 DOM
.bip49unavailable
.addClass("hidden");
1706 DOM
.bip49available
.removeClass("hidden");
1707 DOM
.bip84unavailable
.addClass("hidden");
1708 DOM
.bip84available
.removeClass("hidden");
1709 DOM
.bip141unavailable
.addClass("hidden");
1710 DOM
.bip141available
.removeClass("hidden");
1713 function showSegwitUnavailable() {
1714 DOM
.bip49available
.addClass("hidden");
1715 DOM
.bip49unavailable
.removeClass("hidden");
1716 DOM
.bip84available
.addClass("hidden");
1717 DOM
.bip84unavailable
.removeClass("hidden");
1718 DOM
.bip141available
.addClass("hidden");
1719 DOM
.bip141unavailable
.removeClass("hidden");
1722 function adjustNetworkForSegwit() {
1723 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1724 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1726 // See https://github.com/iancoleman/bip39/issues/125
1727 var segwitNetworks
= null;
1728 // if a segwit network is alread selected, need to use base network to
1729 // look up new parameters
1730 if ("baseNetwork" in network
) {
1731 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1733 // choose the right segwit params
1734 if (p2wpkhSelected() && "p2wpkh" in network
) {
1735 network
= network
.p2wpkh
;
1737 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1738 network
= network
.p2wpkhInP2sh
;
1742 function lastIndexInTable() {
1743 var pathText
= DOM
.addresses
.find(".index").last().text();
1744 var pathBits
= pathText
.split("/");
1745 var lastBit
= pathBits
[pathBits
.length
-1];
1746 var lastBitClean
= lastBit
.replace("'", "");
1747 return parseInt(lastBitClean
);
1750 function uint8ArrayToHex(a
) {
1752 for (var i
=0; i
<a
.length
; i
++) {
1753 var h
= a
[i
].toString(16);
1754 while (h
.length
< 2) {
1762 function showWordIndexes() {
1763 var phrase
= DOM
.phrase
.val();
1764 var words
= phraseToWordArray(phrase
);
1765 var wordIndexes
= [];
1766 var language
= getLanguage();
1767 for (var i
=0; i
<words
.length
; i
++) {
1768 var word
= words
[i
];
1769 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1770 wordIndexes
.push(wordIndex
);
1772 var wordIndexesStr
= wordIndexes
.join(", ");
1773 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1776 function showChecksum() {
1777 var phrase
= DOM
.phrase
.val();
1778 var words
= phraseToWordArray(phrase
);
1779 var checksumBitlength
= words
.length
/ 3;
1782 var language
= getLanguage();
1783 for (var i
=words
.length
-1; i
>=0; i
--) {
1784 var word
= words
[i
];
1785 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1786 var wordBinary
= wordIndex
.toString(2);
1787 while (wordBinary
.length
< 11) {
1788 wordBinary
= "0" + wordBinary
;
1790 var binaryStr
= wordBinary
+ binaryStr
;
1791 if (binaryStr
.length
>= checksumBitlength
) {
1792 var start
= binaryStr
.length
- checksumBitlength
;
1793 var end
= binaryStr
.length
;
1794 checksum
= binaryStr
.substring(start
, end
);
1795 // add spaces so the last group is 11 bits, not the first
1796 checksum
= checksum
.split("").reverse().join("")
1797 checksum
= addSpacesEveryElevenBits(checksum
);
1798 checksum
= checksum
.split("").reverse().join("")
1802 DOM
.entropyChecksum
.text(checksum
);
1805 function updateCsv() {
1806 var tableCsv
= "path,address,public key,private key\n";
1807 var rows
= DOM
.addresses
.find("tr");
1808 for (var i
=0; i
<rows
.length
; i
++) {
1809 var row
= $(rows
[i
]);
1810 var cells
= row
.find("td");
1811 for (var j
=0; j
<cells
.length
; j
++) {
1812 var cell
= $(cells
[j
]);
1813 if (!cell
.children().hasClass("invisible")) {
1814 tableCsv
= tableCsv
+ cell
.text();
1816 if (j
!= cells
.length
- 1) {
1817 tableCsv
= tableCsv
+ ",";
1820 tableCsv
= tableCsv
+ "\n";
1822 DOM
.csv
.val(tableCsv
);
1825 function addSpacesEveryElevenBits(binaryStr
) {
1826 return binaryStr
.match(/.{1,11}/g).join(" ");
1831 name: "AC - Asiacoin",
1832 onSelect: function() {
1833 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1838 name: "ACC - Adcoin",
1839 onSelect: function() {
1840 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1845 name: "ARYA - Aryacoin",
1846 onSelect: function() {
1847 network
= bitcoinjs
.bitcoin
.networks
.aryacoin
;
1852 name: "AUR - Auroracoin",
1853 onSelect: function() {
1854 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1860 onSelect: function() {
1861 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1866 name: "ANON - ANON",
1867 onSelect: function() {
1868 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1873 name: "BOLI - Bolivarcoin",
1874 onSelect: function() {
1875 network
= bitcoinjs
.bitcoin
.networks
.bolivarcoin
;
1880 name: "BCA - Bitcoin Atom",
1881 onSelect: function() {
1882 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1887 name: "BCH - Bitcoin Cash",
1888 onSelect: function() {
1889 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1894 name: "BEET - Beetlecoin",
1895 onSelect: function() {
1896 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1901 name: "BELA - Belacoin",
1902 onSelect: function() {
1903 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1908 name: "BLK - BlackCoin",
1909 onSelect: function() {
1910 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1915 name: "BND - Blocknode",
1916 onSelect: function() {
1917 network
= bitcoinjs
.bitcoin
.networks
.blocknode
;
1922 name: "tBND - Blocknode Testnet",
1923 onSelect: function() {
1924 network
= bitcoinjs
.bitcoin
.networks
.blocknode_testnet
;
1929 name: "BRIT - Britcoin",
1930 onSelect: function() {
1931 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
1936 name: "BSD - Bitsend",
1937 onSelect: function() {
1938 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
1943 name: "BST - BlockStamp",
1944 onSelect: function() {
1945 network
= bitcoinjs
.bitcoin
.networks
.blockstamp
;
1951 onSelect: function() {
1952 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1957 name: "BTC - Bitcoin",
1958 onSelect: function() {
1959 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1964 name: "BTC - Bitcoin Testnet",
1965 onSelect: function() {
1966 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1971 name: "BITG - Bitcoin Green",
1972 onSelect: function() {
1973 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1978 name: "BTCP - Bitcoin Private",
1979 onSelect: function() {
1980 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
1985 name: "BSV - BitcoinSV",
1986 onSelect: function() {
1987 network
= bitcoinjs
.bitcoin
.networks
.bitcoinsv
;
1992 name: "BTCZ - Bitcoinz",
1993 onSelect: function() {
1994 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
1999 name: "BTDX - BitCloud",
2000 onSelect: function() {
2001 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
2006 name: "BTG - Bitcoin Gold",
2007 onSelect: function() {
2008 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
2013 name: "BTX - Bitcore",
2014 onSelect: function() {
2015 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
2020 name: "CCN - Cannacoin",
2021 onSelect: function() {
2022 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2027 name: "CESC - Cryptoescudo",
2028 onSelect: function() {
2029 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2034 name: "CDN - Canadaecoin",
2035 onSelect: function() {
2036 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
2041 name: "CLAM - Clams",
2042 onSelect: function() {
2043 network
= bitcoinjs
.bitcoin
.networks
.clam
;
2048 name: "CLO - Callisto",
2049 segwitAvailable: false,
2050 onSelect: function() {
2051 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2056 name: "CLUB - Clubcoin",
2057 onSelect: function() {
2058 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
2063 name: "CMP - Compcoin",
2064 onSelect: function() {
2065 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
2070 name: "CPU - CPUchain",
2071 onSelect: function() {
2072 network
= bitcoinjs
.bitcoin
.networks
.cpuchain
;
2077 name: "CRAVE - Crave",
2078 onSelect: function() {
2079 network
= bitcoinjs
.bitcoin
.networks
.crave
;
2084 name: "CRW - Crown (Legacy)",
2085 onSelect: function() {
2086 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2091 name: "CRW - Crown",
2092 onSelect: function() {
2093 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2098 name: "CSC - CasinoCoin",
2099 onSelect: function() {
2100 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2105 name: "DASH - Dash",
2106 onSelect: function() {
2107 network
= bitcoinjs
.bitcoin
.networks
.dash
;
2112 name: "DASH - Dash Testnet",
2113 onSelect: function() {
2114 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
2119 name: "DFC - Defcoin",
2120 onSelect: function() {
2121 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
2126 name: "DGB - Digibyte",
2127 onSelect: function() {
2128 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
2133 name: "DGC - Digitalcoin",
2134 onSelect: function() {
2135 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
2140 name: "DMD - Diamond",
2141 onSelect: function() {
2142 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
2147 name: "DNR - Denarius",
2148 onSelect: function() {
2149 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
2154 name: "DOGE - Dogecoin",
2155 onSelect: function() {
2156 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
2161 name: "DOGEt - Dogecoin Testnet",
2162 onSelect: function() {
2163 network
= bitcoinjs
.bitcoin
.networks
.dogecointestnet
;
2168 name: "DXN - DEXON",
2169 onSelect: function() {
2170 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2175 name: "ECN - Ecoin",
2176 onSelect: function() {
2177 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
2182 name: "EDRC - Edrcoin",
2183 onSelect: function() {
2184 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
2189 name: "EFL - Egulden",
2190 onSelect: function() {
2191 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
2196 name: "ELLA - Ellaism",
2197 segwitAvailable: false,
2198 onSelect: function() {
2199 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2204 name: "EMC2 - Einsteinium",
2205 onSelect: function() {
2206 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
2211 name: "ERC - Europecoin",
2212 onSelect: function() {
2213 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
2218 name: "EOS - EOSIO",
2219 onSelect: function() {
2220 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2225 name: "ESN - Ethersocial Network",
2226 segwitAvailable: false,
2227 onSelect: function() {
2228 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2233 name: "ETC - Ethereum Classic",
2234 segwitAvailable: false,
2235 onSelect: function() {
2236 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2241 name: "ETH - Ethereum",
2242 onSelect: function() {
2243 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2248 name: "EXCL - Exclusivecoin",
2249 onSelect: function() {
2250 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
2255 name: "EXCC - ExchangeCoin",
2256 onSelect: function() {
2257 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
2262 name: "EXP - Expanse",
2263 segwitAvailable: false,
2264 onSelect: function() {
2265 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2271 onSelect: function() {
2272 network
= bitcoinjs
.bitcoin
.networks
.fix
;
2277 name: "FIX - FIX Testnet",
2278 onSelect: function() {
2279 network
= bitcoinjs
.bitcoin
.networks
.fixtestnet
;
2284 name: "FJC - Fujicoin",
2285 onSelect: function() {
2286 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2291 name: "FLASH - Flashcoin",
2292 onSelect: function() {
2293 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2298 name: "FRST - Firstcoin",
2299 onSelect: function() {
2300 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2305 name: "FTC - Feathercoin",
2306 onSelect: function() {
2307 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2312 name: "GAME - GameCredits",
2313 onSelect: function() {
2314 network
= bitcoinjs
.bitcoin
.networks
.game
;
2319 name: "GBX - Gobyte",
2320 onSelect: function() {
2321 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2326 name: "GCR - GCRCoin",
2327 onSelect: function() {
2328 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2333 name: "GRC - Gridcoin",
2334 onSelect: function() {
2335 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2340 name: "GRS - Groestlcoin",
2341 onSelect: function() {
2342 network
= bitcoinjs
.bitcoin
.networks
.groestlcoin
;
2347 name: "GRS - Groestlcoin Testnet",
2348 onSelect: function() {
2349 network
= bitcoinjs
.bitcoin
.networks
.groestlcointestnet
;
2354 name: "HNC - Helleniccoin",
2355 onSelect: function() {
2356 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2361 name: "HUSH - Hush (Legacy)",
2362 onSelect: function() {
2363 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2368 name: "HUSH - Hush3",
2369 onSelect: function() {
2370 network
= bitcoinjs
.bitcoin
.networks
.hush3
;
2375 name: "INSN - Insane",
2376 onSelect: function() {
2377 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2383 onSelect: function() {
2384 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2389 name: "IXC - Ixcoin",
2390 onSelect: function() {
2391 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2396 name: "JBS - Jumbucks",
2397 onSelect: function() {
2398 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2403 name: "KMD - Komodo",
2404 bip49available: false,
2405 onSelect: function() {
2406 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2411 name: "KOBO - Kobocoin",
2412 bip49available: false,
2413 onSelect: function() {
2414 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2419 name: "LBC - Library Credits",
2420 onSelect: function() {
2421 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2426 name: "LCC - Litecoincash",
2427 onSelect: function() {
2428 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2433 name: "LDCN - Landcoin",
2434 onSelect: function() {
2435 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2440 name: "LINX - Linx",
2441 onSelect: function() {
2442 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2447 name: "LKR - Lkrcoin",
2448 segwitAvailable: false,
2449 onSelect: function() {
2450 network
= bitcoinjs
.bitcoin
.networks
.lkrcoin
;
2455 name: "LTC - Litecoin",
2456 onSelect: function() {
2457 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2459 DOM
.litecoinLtubContainer
.removeClass("hidden");
2463 name: "LTCt - Litecoin Testnet",
2464 onSelect: function() {
2465 network
= bitcoinjs
.bitcoin
.networks
.litecointestnet
;
2467 DOM
.litecoinLtubContainer
.removeClass("hidden");
2471 name: "LTZ - LitecoinZ",
2472 onSelect: function() {
2473 network
= bitcoinjs
.bitcoin
.networks
.litecoinz
;
2478 name: "LYNX - Lynx",
2479 onSelect: function() {
2480 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2485 name: "MAZA - Maza",
2486 onSelect: function() {
2487 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2492 name: "MEC - Megacoin",
2493 onSelect: function() {
2494 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2500 segwitAvailable: false,
2501 onSelect: function() {
2502 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2507 name: "MNX - Minexcoin",
2508 onSelect: function() {
2509 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2514 name: "MONA - Monacoin",
2515 onSelect: function() {
2516 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2521 name: "MONK - Monkey Project",
2522 onSelect: function() {
2523 network
= bitcoinjs
.bitcoin
.networks
.monkeyproject
,
2528 name: "MUSIC - Musicoin",
2529 segwitAvailable: false,
2530 onSelect: function() {
2531 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2536 name: "NAV - Navcoin",
2537 onSelect: function() {
2538 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2543 name: "NAS - Nebulas",
2544 onSelect: function() {
2545 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2550 name: "NEBL - Neblio",
2551 onSelect: function() {
2552 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2557 name: "NEOS - Neoscoin",
2558 onSelect: function() {
2559 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2564 name: "NIX - NIX Platform",
2565 onSelect: function() {
2566 network
= bitcoinjs
.bitcoin
.networks
.nix
;
2571 name: "NLG - Gulden",
2572 onSelect: function() {
2573 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2578 name: "NMC - Namecoin",
2579 onSelect: function() {
2580 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2585 name: "NRG - Energi",
2586 onSelect: function() {
2587 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2592 name: "NRO - Neurocoin",
2593 onSelect: function() {
2594 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2599 name: "NSR - Nushares",
2600 onSelect: function() {
2601 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2606 name: "NYC - Newyorkc",
2607 onSelect: function() {
2608 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2613 name: "NVC - Novacoin",
2614 onSelect: function() {
2615 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2620 name: "OK - Okcash",
2621 onSelect: function() {
2622 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2627 name: "OMNI - Omnicore",
2628 onSelect: function() {
2629 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2634 name: "ONION - DeepOnion",
2635 onSelect: function() {
2636 network
= bitcoinjs
.bitcoin
.networks
.deeponion
;
2641 name: "ONX - Onixcoin",
2642 onSelect: function() {
2643 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2648 name: "PHR - Phore",
2649 onSelect: function() {
2650 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2655 name: "PINK - Pinkcoin",
2656 onSelect: function() {
2657 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2662 name: "PIRL - Pirl",
2663 segwitAvailable: false,
2664 onSelect: function() {
2665 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2670 name: "PIVX - PIVX",
2671 onSelect: function() {
2672 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2677 name: "PIVX - PIVX Testnet",
2678 onSelect: function() {
2679 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2685 segwitAvailable: false,
2686 onSelect: function() {
2687 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2692 name: "POSW - POSWcoin",
2693 onSelect: function() {
2694 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2699 name: "POT - Potcoin",
2700 onSelect: function() {
2701 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2706 name: "PPC - Peercoin",
2707 onSelect: function() {
2708 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2713 name: "PRJ - ProjectCoin",
2714 onSelect: function() {
2715 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2720 name: "PSB - Pesobit",
2721 onSelect: function() {
2722 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2727 name: "PUT - Putincoin",
2728 onSelect: function() {
2729 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2734 name: "RPD - Rapids",
2735 onSelect: function() {
2736 network
= bitcoinjs
.bitcoin
.networks
.rapids
;
2741 name: "RVN - Ravencoin",
2742 onSelect: function() {
2743 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2748 name: "RBY - Rubycoin",
2749 onSelect: function() {
2750 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2755 name: "RDD - Reddcoin",
2756 onSelect: function() {
2757 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2762 name: "RVR - RevolutionVR",
2763 onSelect: function() {
2764 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2769 name: "SAFE - Safecoin",
2770 onSelect: function() {
2771 network
= bitcoinjs
.bitcoin
.networks
.safecoin
;
2776 name: "SLS - Salus",
2777 onSelect: function() {
2778 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2783 name: "SDC - ShadowCash",
2784 onSelect: function() {
2785 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2790 name: "SDC - ShadowCash Testnet",
2791 onSelect: function() {
2792 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2797 name: "SLM - Slimcoin",
2798 onSelect: function() {
2799 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2804 name: "SLM - Slimcoin Testnet",
2805 onSelect: function() {
2806 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2811 name: "SLP - Simple Ledger Protocol",
2812 onSelect: function() {
2813 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2818 name: "SLR - Solarcoin",
2819 onSelect: function() {
2820 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2825 name: "SMLY - Smileycoin",
2826 onSelect: function() {
2827 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2832 name: "STASH - Stash",
2833 onSelect: function() {
2834 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2839 name: "STASH - Stash Testnet",
2840 onSelect: function() {
2841 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2846 name: "STRAT - Stratis",
2847 onSelect: function() {
2848 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2853 name: "TSTRAT - Stratis Testnet",
2854 onSelect: function() {
2855 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2860 name: "SYS - Syscoin",
2861 onSelect: function() {
2862 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2867 name: "THC - Hempcoin",
2868 onSelect: function() {
2869 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2875 onSelect: function() {
2876 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2881 name: "TWINS - TWINS",
2882 onSelect: function() {
2883 network
= bitcoinjs
.bitcoin
.networks
.twins
;
2888 name: "TWINS - TWINS Testnet",
2889 onSelect: function() {
2890 network
= bitcoinjs
.bitcoin
.networks
.twinstestnet
;
2895 name: "USC - Ultimatesecurecash",
2896 onSelect: function() {
2897 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2902 name: "USNBT - NuBits",
2903 onSelect: function() {
2904 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2909 name: "UNO - Unobtanium",
2910 onSelect: function() {
2911 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2916 name: "VASH - Vpncoin",
2917 onSelect: function() {
2918 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2923 name: "VET - VeChain",
2924 onSelect: function() {
2925 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2930 name: "VIA - Viacoin",
2931 onSelect: function() {
2932 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2937 name: "VIA - Viacoin Testnet",
2938 onSelect: function() {
2939 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2944 name: "VIVO - Vivo",
2945 onSelect: function() {
2946 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2951 name: "VTC - Vertcoin",
2952 onSelect: function() {
2953 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2958 name: "WGR - Wagerr",
2959 onSelect: function() {
2960 network
= bitcoinjs
.bitcoin
.networks
.wagerr
;
2965 name: "WC - Wincoin",
2966 onSelect: function() {
2967 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2972 name: "XAX - Artax",
2973 onSelect: function() {
2974 network
= bitcoinjs
.bitcoin
.networks
.artax
;
2979 name: "XBC - Bitcoinplus",
2980 onSelect: function() {
2981 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
2986 name: "XLM - Stellar",
2987 onSelect: function() {
2988 network
= stellarUtil
.dummyNetwork
;
2993 name: "XMY - Myriadcoin",
2994 onSelect: function() {
2995 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
3000 name: "XRP - Ripple",
3001 onSelect: function() {
3002 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
3007 name: "XVC - Vcash",
3008 onSelect: function() {
3009 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
3014 name: "XVG - Verge",
3015 onSelect: function() {
3016 network
= bitcoinjs
.bitcoin
.networks
.verge
;
3021 name: "XUEZ - Xuez",
3022 segwitAvailable: false,
3023 onSelect: function() {
3024 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
3029 name: "XWC - Whitecoin",
3030 onSelect: function() {
3031 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
3036 name: "XZC - Zcoin",
3037 onSelect: function() {
3038 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
3043 name: "ZCL - Zclassic",
3044 onSelect: function() {
3045 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
3050 name: "ZEC - Zcash",
3051 onSelect: function() {
3052 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
3057 name: "ZEN - Horizen",
3058 onSelect: function() {
3059 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
3067 name: "Bitcoin Core",
3068 onSelect: function() {
3069 DOM
.bip32path
.val("m/0'/0'");
3070 DOM
.hardenedAddresses
.prop('checked', true);
3074 name: "blockchain.info",
3075 onSelect: function() {
3076 DOM
.bip32path
.val("m/44'/0'/0'");
3077 DOM
.hardenedAddresses
.prop('checked', false);
3081 name: "MultiBit HD",
3082 onSelect: function() {
3083 DOM
.bip32path
.val("m/0'/0");
3084 DOM
.hardenedAddresses
.prop('checked', false);
3088 name: "Coinomi, Ledger",
3089 onSelect: function() {
3090 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
3091 DOM
.hardenedAddresses
.prop('checked', false);