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(phraseChanged
, 400);
238 function phraseChanged() {
240 setMnemonicLanguage();
241 // Get the mnemonic phrase
242 var phrase
= DOM
.phrase
.val();
243 var errorText
= findPhraseErrors(phrase
);
245 showValidationError(errorText
);
248 // Calculate and display
249 var passphrase
= DOM
.passphrase
.val();
250 calcBip32RootKeyFromSeed(phrase
, passphrase
);
251 calcForDerivationPath();
252 // Show the word indexes
256 function tabChanged() {
258 adjustNetworkForSegwit();
259 var phrase
= DOM
.phrase
.val();
261 // Calculate and display for mnemonic
262 var errorText
= findPhraseErrors(phrase
);
264 showValidationError(errorText
);
267 // Calculate and display
268 var passphrase
= DOM
.passphrase
.val();
269 calcBip32RootKeyFromSeed(phrase
, passphrase
);
272 // Calculate and display for root key
273 var rootKeyBase58
= DOM
.rootKey
.val();
274 var errorText
= validateRootKey(rootKeyBase58
);
276 showValidationError(errorText
);
279 // Calculate and display
280 calcBip32RootKeyFromBase58(rootKeyBase58
);
282 calcForDerivationPath();
285 function delayedEntropyChanged() {
286 hideValidationError();
288 if (entropyChangeTimeoutEvent
!= null) {
289 clearTimeout(entropyChangeTimeoutEvent
);
291 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
294 function entropyChanged() {
295 // If blank entropy, clear mnemonic, addresses, errors
296 if (DOM
.entropy
.val().trim().length
== 0) {
298 clearEntropyFeedback();
300 showValidationError("Blank entropy");
303 // Get the current phrase to detect changes
304 var phrase
= DOM
.phrase
.val();
305 // Set the phrase from the entropy
306 setMnemonicFromEntropy();
307 // Recalc addresses if the phrase has changed
308 var newPhrase
= DOM
.phrase
.val();
309 if (newPhrase
!= phrase
) {
310 if (newPhrase
.length
== 0) {
322 function delayedRootKeyChanged() {
323 // Warn if there is an existing mnemonic or passphrase.
324 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
325 if (!confirm("This will clear existing mnemonic and passphrase")) {
326 DOM
.rootKey
.val(bip32RootKey
);
330 hideValidationError();
332 // Clear existing mnemonic and passphrase
334 DOM
.passphrase
.val("");
336 if (rootKeyChangedTimeoutEvent
!= null) {
337 clearTimeout(rootKeyChangedTimeoutEvent
);
339 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
342 function rootKeyChanged() {
344 hideValidationError();
345 var rootKeyBase58
= DOM
.rootKey
.val();
346 var errorText
= validateRootKey(rootKeyBase58
);
348 showValidationError(errorText
);
351 // Calculate and display
352 calcBip32RootKeyFromBase58(rootKeyBase58
);
353 calcForDerivationPath();
356 function litecoinUseLtubChanged() {
357 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
358 if (litecoinUseLtub
) {
359 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
362 network
= bitcoinjs
.bitcoin
.networks
.litecoinXprv
;
367 function calcForDerivationPath() {
369 clearAddressesList();
371 // Don't show segwit if it's selected but network doesn't support it
372 if (segwitSelected() && !networkHasSegwit()) {
373 showSegwitUnavailable();
377 showSegwitAvailable();
378 // Get the derivation path
379 var derivationPath
= getDerivationPath();
380 var errorText
= findDerivationPathErrors(derivationPath
);
382 showValidationError(errorText
);
385 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
386 if (bip44TabSelected()) {
389 else if (bip49TabSelected()) {
392 else if (bip84TabSelected()) {
398 function generateClicked() {
399 if (isUsingOwnEntropy()) {
404 setTimeout(function() {
405 setMnemonicLanguage();
406 var phrase
= generateRandomPhrase();
414 function languageChanged() {
415 setTimeout(function() {
416 setMnemonicLanguage();
417 if (DOM
.phrase
.val().length
> 0) {
418 var newPhrase
= convertPhraseToNewLanguage();
419 DOM
.phrase
.val(newPhrase
);
423 DOM
.generate
.trigger("click");
428 function bitcoinCashAddressTypeChange() {
432 function toggleIndexes() {
433 showIndex
= !showIndex
;
434 $("td.index span").toggleClass("invisible");
437 function toggleAddresses() {
438 showAddress
= !showAddress
;
439 $("td.address span").toggleClass("invisible");
442 function togglePublicKeys() {
443 showPubKey
= !showPubKey
;
444 $("td.pubkey span").toggleClass("invisible");
447 function togglePrivateKeys() {
448 showPrivKey
= !showPrivKey
;
449 $("td.privkey span").toggleClass("invisible");
452 function privacyScreenToggled() {
453 // private-data contains elements added to DOM at runtime
454 // so catch all by adding visual privacy class to the root of the DOM
455 if (DOM
.privacyScreenToggle
.prop("checked")) {
456 $("body").addClass("visual-privacy");
459 $("body").removeClass("visual-privacy");
465 function generateRandomPhrase() {
466 if (!hasStrongRandom()) {
467 var errorText
= "This browser does not support strong randomness";
468 showValidationError(errorText
);
471 // get the amount of entropy to use
472 var numWords
= parseInt(DOM
.generatedStrength
.val());
473 var strength
= numWords
/ 3 * 32;
474 var buffer
= new Uint8Array(strength
/ 8);
475 // create secure entropy
476 var data
= crypto
.getRandomValues(buffer
);
478 var words
= mnemonic
.toMnemonic(data
);
479 DOM
.phrase
.val(words
);
481 var entropyHex
= uint8ArrayToHex(data
);
482 DOM
.entropy
.val(entropyHex
);
483 // ensure entropy fields are consistent with what is being displayed
484 DOM
.entropyMnemonicLength
.val("raw");
488 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
489 seed
= mnemonic
.toSeed(phrase
, passphrase
);
490 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
492 bip32RootKey
= groestlcoinjs
.HDNode
.fromSeedHex(seed
, network
);
496 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
498 calcBip32RootKeyFromBase58GRS(rootKeyBase58
);
501 // try parsing with various segwit network params since this extended
502 // key may be from any one of them.
503 if (networkHasSegwit()) {
505 if ("baseNetwork" in n
) {
506 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
508 // try parsing using base network params
510 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
514 // try parsing using p2wpkh params
517 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
522 // try parsing using p2wpkh-in-p2sh network params
523 if ("p2wpkhInP2sh" in n
) {
525 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
531 // try the network params as currently specified
532 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
535 function calcBip32RootKeyFromBase58GRS(rootKeyBase58
) {
536 // try parsing with various segwit network params since this extended
537 // key may be from any one of them.
538 if (networkHasSegwit()) {
540 if ("baseNetwork" in n
) {
541 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
543 // try parsing using base network params
545 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
549 // try parsing using p2wpkh params
552 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
557 // try parsing using p2wpkh-in-p2sh network params
558 if ("p2wpkhInP2sh" in n
) {
560 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
566 // try the network params as currently specified
567 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
570 function calcBip32ExtendedKey(path
) {
571 // Check there's a root key to derive from
575 var extendedKey
= bip32RootKey
;
576 // Derive the key from the path
577 var pathBits
= path
.split("/");
578 for (var i
=0; i
<pathBits
.length
; i
++) {
579 var bit
= pathBits
[i
];
580 var index
= parseInt(bit
);
584 var hardened
= bit
[bit
.length
-1] == "'";
585 var isPriv
= !(extendedKey
.isNeutered());
586 var invalidDerivationPath
= hardened
&& !isPriv
;
587 if (invalidDerivationPath
) {
591 extendedKey
= extendedKey
.deriveHardened(index
);
594 extendedKey
= extendedKey
.derive(index
);
600 function showValidationError(errorText
) {
606 function hideValidationError() {
612 function findPhraseErrors(phrase
) {
613 // Preprocess the words
614 phrase
= mnemonic
.normalizeString(phrase
);
615 var words
= phraseToWordArray(phrase
);
616 // Detect blank phrase
617 if (words
.length
== 0) {
618 return "Blank mnemonic";
621 for (var i
=0; i
<words
.length
; i
++) {
623 var language
= getLanguage();
624 if (WORDLISTS
[language
].indexOf(word
) == -1) {
625 console
.log("Finding closest match to " + word
);
626 var nearestWord
= findNearestWord(word
);
627 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
630 // Check the words are valid
631 var properPhrase
= wordArrayToPhrase(words
);
632 var isValid
= mnemonic
.check(properPhrase
);
634 return "Invalid mnemonic";
639 function validateRootKey(rootKeyBase58
) {
641 return validateRootKeyGRS(rootKeyBase58
);
643 // try various segwit network params since this extended key may be from
645 if (networkHasSegwit()) {
647 if ("baseNetwork" in n
) {
648 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
650 // try parsing using base network params
652 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
656 // try parsing using p2wpkh params
659 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
664 // try parsing using p2wpkh-in-p2sh network params
665 if ("p2wpkhInP2sh" in n
) {
667 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
673 // try the network params as currently specified
675 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
678 return "Invalid root key";
683 function validateRootKeyGRS(rootKeyBase58
) {
684 // try various segwit network params since this extended key may be from
686 if (networkHasSegwit()) {
688 if ("baseNetwork" in n
) {
689 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
691 // try parsing using base network params
693 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
697 // try parsing using p2wpkh params
700 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
705 // try parsing using p2wpkh-in-p2sh network params
706 if ("p2wpkhInP2sh" in n
) {
708 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
714 // try the network params as currently specified
716 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
719 return "Invalid root key";
724 function getDerivationPath() {
725 if (bip44TabSelected()) {
726 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
727 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
728 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
729 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
731 path
+= purpose
+ "'/";
733 path
+= account
+ "'/";
735 DOM
.bip44path
.val(path
);
736 var derivationPath
= DOM
.bip44path
.val();
737 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
738 return derivationPath
;
740 else if (bip49TabSelected()) {
741 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
742 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
743 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
744 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
746 path
+= purpose
+ "'/";
748 path
+= account
+ "'/";
750 DOM
.bip49path
.val(path
);
751 var derivationPath
= DOM
.bip49path
.val();
752 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
753 return derivationPath
;
755 else if (bip84TabSelected()) {
756 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
757 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
758 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
759 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
761 path
+= purpose
+ "'/";
763 path
+= account
+ "'/";
765 DOM
.bip84path
.val(path
);
766 var derivationPath
= DOM
.bip84path
.val();
767 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
768 return derivationPath
;
770 else if (bip32TabSelected()) {
771 var derivationPath
= DOM
.bip32path
.val();
772 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
773 return derivationPath
;
775 else if (bip141TabSelected()) {
776 var derivationPath
= DOM
.bip141path
.val();
777 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
778 return derivationPath
;
781 console
.log("Unknown derivation path");
785 function findDerivationPathErrors(path
) {
786 // TODO is not perfect but is better than nothing
788 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
790 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
791 var maxDepth
= 255; // TODO verify this!!
792 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
793 if (path
[0] != "m") {
794 return "First character must be 'm'";
796 if (path
.length
> 1) {
797 if (path
[1] != "/") {
798 return "Separator must be '/'";
800 var indexes
= path
.split("/");
801 if (indexes
.length
> maxDepth
) {
802 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
804 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
805 var index
= indexes
[depth
];
806 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
807 if (invalidChars
.length
> 0) {
808 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
810 var indexValue
= parseInt(index
.replace("'", ""));
812 return "Invalid number at depth " + depth
;
814 if (indexValue
> maxIndexValue
) {
815 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
819 // Check root key exists or else derivation path is useless!
821 return "No root key";
823 // Check no hardened derivation path when using xpub keys
824 var hardenedPath
= path
.indexOf("'") > -1;
825 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
826 var hardened
= hardenedPath
|| hardenedAddresses
;
827 var isXpubkey
= bip32RootKey
.isNeutered();
828 if (hardened
&& isXpubkey
) {
829 return "Hardened derivation path is invalid with xpub key";
835 return networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin" || networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin Testnet";
838 function displayBip44Info() {
839 // Get the derivation path for the account
840 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
841 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
842 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
844 path
+= purpose
+ "'/";
846 path
+= account
+ "'/";
847 // Calculate the account extended keys
848 var accountExtendedKey
= calcBip32ExtendedKey(path
);
849 var accountXprv
= accountExtendedKey
.toBase58();
850 var accountXpub
= accountExtendedKey
.neutered().toBase58();
851 // Display the extended keys
852 DOM
.bip44accountXprv
.val(accountXprv
);
853 DOM
.bip44accountXpub
.val(accountXpub
);
856 function displayBip49Info() {
857 // Get the derivation path for the account
858 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
859 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
860 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
862 path
+= purpose
+ "'/";
864 path
+= account
+ "'/";
865 // Calculate the account extended keys
866 var accountExtendedKey
= calcBip32ExtendedKey(path
);
867 var accountXprv
= accountExtendedKey
.toBase58();
868 var accountXpub
= accountExtendedKey
.neutered().toBase58();
869 // Display the extended keys
870 DOM
.bip49accountXprv
.val(accountXprv
);
871 DOM
.bip49accountXpub
.val(accountXpub
);
874 function displayBip84Info() {
875 // Get the derivation path for the account
876 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
877 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
878 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
880 path
+= purpose
+ "'/";
882 path
+= account
+ "'/";
883 // Calculate the account extended keys
884 var accountExtendedKey
= calcBip32ExtendedKey(path
);
885 var accountXprv
= accountExtendedKey
.toBase58();
886 var accountXpub
= accountExtendedKey
.neutered().toBase58();
887 // Display the extended keys
888 DOM
.bip84accountXprv
.val(accountXprv
);
889 DOM
.bip84accountXpub
.val(accountXpub
);
892 function displayBip32Info() {
895 var rootKey
= bip32RootKey
.toBase58();
896 DOM
.rootKey
.val(rootKey
);
897 var xprvkeyB58
= "NA";
898 if (!bip32ExtendedKey
.isNeutered()) {
899 xprvkeyB58
= bip32ExtendedKey
.toBase58();
901 var extendedPrivKey
= xprvkeyB58
;
902 DOM
.extendedPrivKey
.val(extendedPrivKey
);
903 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
904 DOM
.extendedPubKey
.val(extendedPubKey
);
905 // Display the addresses and privkeys
906 clearAddressesList();
907 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
908 displayAddresses(0, initialAddressCount
);
911 function displayAddresses(start
, total
) {
912 generationProcesses
.push(new (function() {
916 this.stop = function() {
917 for (var i
=0; i
<rows
.length
; i
++) {
918 rows
[i
].shouldGenerate
= false;
923 for (var i
=0; i
<total
; i
++) {
924 var index
= i
+ start
;
925 var isLast
= i
== total
- 1;
926 rows
.push(new TableRow(index
, isLast
));
932 function segwitSelected() {
933 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
936 function p2wpkhSelected() {
937 return bip84TabSelected() ||
938 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
941 function p2wpkhInP2shSelected() {
942 return bip49TabSelected() ||
943 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
946 function TableRow(index
, isLast
) {
949 this.shouldGenerate
= true;
950 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
951 var useBip38
= DOM
.useBip38
.prop("checked");
952 var bip38password
= DOM
.bip38Password
.val();
953 var isSegwit
= segwitSelected();
954 var segwitAvailable
= networkHasSegwit();
955 var isP2wpkh
= p2wpkhSelected();
956 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
962 function calculateValues() {
963 setTimeout(function() {
964 if (!self
.shouldGenerate
) {
967 // derive HDkey for this row of the table
969 if (useHardenedAddresses
) {
970 key
= bip32ExtendedKey
.deriveHardened(index
);
973 key
= bip32ExtendedKey
.derive(index
);
975 // bip38 requires uncompressed keys
976 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
977 var keyPair
= key
.keyPair
;
978 var useUncompressed
= useBip38
;
979 if (useUncompressed
) {
980 keyPair
= new bitcoinjs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
982 keyPair
= new groestlcoinjs
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
986 var address
= keyPair
.getAddress().toString();
988 var hasPrivkey
= !key
.isNeutered();
991 privkey
= keyPair
.toWIF();
992 // BIP38 encode private key if required
995 privkey
= groestlcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
996 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
997 }, null, networks
[DOM
.network
.val()].name
.includes("Testnet"));
999 privkey
= bitcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1000 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1005 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
1006 var indexText
= getDerivationPath() + "/" + index
;
1007 if (useHardenedAddresses
) {
1008 indexText
= indexText
+ "'";
1010 // Ethereum values are different
1011 if ((networks
[DOM
.network
.val()].name
== "ETH - Ethereum")
1012 || (networks
[DOM
.network
.val()].name
== "ETC - Ethereum Classic")
1013 || (networks
[DOM
.network
.val()].name
== "PIRL - Pirl")
1014 || (networks
[DOM
.network
.val()].name
== "MIX - MIX")
1015 || (networks
[DOM
.network
.val()].name
== "MUSIC - Musicoin")
1016 || (networks
[DOM
.network
.val()].name
== "POA - Poa")
1017 || (networks
[DOM
.network
.val()].name
== "EXP - Expanse")
1018 || (networks
[DOM
.network
.val()].name
== "CLO - Callisto")
1019 || (networks
[DOM
.network
.val()].name
== "DXN - DEXON")
1020 || (networks
[DOM
.network
.val()].name
== "ELLA - Ellaism")
1021 || (networks
[DOM
.network
.val()].name
== "ESN - Ethersocial Network")
1022 || (networks
[DOM
.network
.val()].name
== "VET - VeChain")
1024 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1025 privkey
= privKeyBuffer
.toString('hex');
1026 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
1027 var hexAddress
= addressBuffer
.toString('hex');
1028 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
1029 address
= ethUtil
.addHexPrefix(checksumAddress
);
1030 privkey
= ethUtil
.addHexPrefix(privkey
);
1031 pubkey
= ethUtil
.addHexPrefix(pubkey
);
1034 // Stellar is different
1035 if (networks
[DOM
.network
.val()].name
== "XLM - Stellar") {
1036 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
1037 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
1039 path
+= purpose
+ "'/";
1040 path
+= coin
+ "'/" + index
+ "'";
1041 var keypair
= stellarUtil
.getKeypair(path
, seed
);
1043 privkey
= keypair
.secret();
1044 pubkey
= address
= keypair
.publicKey();
1046 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
1047 var NasAccount
= require("nebulas-account");
1048 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1049 var nebulasAccount
= new NasAccount();
1050 nebulasAccount
.setPrivateKey(privKeyBuffer
);
1051 address
= nebulasAccount
.getAddressString();
1052 privkey
= nebulasAccount
.getPrivateKeyString();
1053 pubkey
= nebulasAccount
.getPublicKeyString();
1055 // Ripple values are different
1056 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
1057 privkey
= convertRipplePriv(privkey
);
1058 address
= convertRippleAdrr(address
);
1060 // CasinoCoin values are different
1061 if (networks
[DOM
.network
.val()].name
== "CSC - CasinoCoin") {
1062 privkey
= convertCasinoCoinPriv(privkey
);
1063 address
= convertCasinoCoinAdrr(address
);
1065 // Bitcoin Cash address format may vary
1066 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
1067 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1068 if (bchAddrType
== "cashaddr") {
1069 address
= bchaddr
.toCashAddress(address
);
1071 else if (bchAddrType
== "bitpay") {
1072 address
= bchaddr
.toBitpayAddress(address
);
1075 // Bitcoin Cash address format may vary
1076 if (networks
[DOM
.network
.val()].name
== "SLP - Simple Ledger Protocol") {
1077 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1078 if (bchAddrType
== "cashaddr") {
1079 address
= bchaddr
.toSlpAddress(address
);
1082 // Segwit addresses are different
1084 if (!segwitAvailable
) {
1088 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1089 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1090 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1092 else if (isP2wpkhInP2sh
) {
1093 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1094 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1095 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
1096 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
1097 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1101 if ((networks
[DOM
.network
.val()].name
== "CRW - Crown")) {
1102 address
= bitcoinjs
.bitcoin
.networks
.crown
.toNewAddress(address
);
1105 if (networks
[DOM
.network
.val()].name
== "EOS - EOSIO") {
1107 pubkey
= eosUtil
.bufferToPublic(keyPair
.getPublicKeyBuffer());
1108 privkey
= eosUtil
.bufferToPrivate(keyPair
.d
.toBuffer(32));
1111 //Groestlcoin Addresses are different
1115 if (!segwitAvailable
) {
1119 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1121 else if (isP2wpkhInP2sh
) {
1122 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1125 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1128 addAddressToList(indexText
, address
, pubkey
, privkey
);
1140 function showMore() {
1141 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
1142 if (isNaN(rowsToAdd
)) {
1144 DOM
.rowsToAdd
.val("20");
1146 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
1148 start
= lastIndexInTable() + 1;
1151 var newStart
= start
+ rowsToAdd
;
1152 DOM
.moreRowsStartIndex
.val(newStart
);
1154 if (rowsToAdd
> 200) {
1155 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1156 msg
+= "Do you want to continue?";
1157 if (!confirm(msg
)) {
1161 displayAddresses(start
, rowsToAdd
);
1164 function clearDisplay() {
1165 clearAddressesList();
1167 hideValidationError();
1170 function clearAddressesList() {
1171 DOM
.addresses
.empty();
1176 function stopGenerating() {
1177 while (generationProcesses
.length
> 0) {
1178 var generation
= generationProcesses
.shift();
1183 function clearKeys() {
1188 function clearRootKey() {
1189 DOM
.rootKey
.val("");
1192 function clearDerivedKeys() {
1193 DOM
.extendedPrivKey
.val("");
1194 DOM
.extendedPubKey
.val("");
1195 DOM
.bip44accountXprv
.val("");
1196 DOM
.bip44accountXpub
.val("");
1199 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1200 var row
= $(addressRowTemplate
.html());
1202 var indexCell
= row
.find(".index span");
1203 var addressCell
= row
.find(".address span");
1204 var pubkeyCell
= row
.find(".pubkey span");
1205 var privkeyCell
= row
.find(".privkey span");
1207 indexCell
.text(indexText
);
1208 addressCell
.text(address
);
1209 pubkeyCell
.text(pubkey
);
1210 privkeyCell
.text(privkey
);
1213 indexCell
.addClass("invisible");
1216 addressCell
.addClass("invisible");
1219 pubkeyCell
.addClass("invisible");
1222 privkeyCell
.addClass("invisible");
1224 DOM
.addresses
.append(row
);
1225 var rowShowQrEls
= row
.find("[data-show-qr]");
1226 setQrEvents(rowShowQrEls
);
1229 function hasStrongRandom() {
1230 return 'crypto' in window
&& window
['crypto'] !== null;
1233 function disableForms() {
1234 $("form").on("submit", function(e
) {
1239 function parseIntNoNaN(val
, defaultVal
) {
1240 var v
= parseInt(val
);
1247 function showPending() {
1249 .text("Calculating...")
1253 function findNearestWord(word
) {
1254 var language
= getLanguage();
1255 var words
= WORDLISTS
[language
];
1256 var minDistance
= 99;
1257 var closestWord
= words
[0];
1258 for (var i
=0; i
<words
.length
; i
++) {
1259 var comparedTo
= words
[i
];
1260 if (comparedTo
.indexOf(word
) == 0) {
1263 var distance
= Levenshtein
.get(word
, comparedTo
);
1264 if (distance
< minDistance
) {
1265 closestWord
= comparedTo
;
1266 minDistance
= distance
;
1272 function hidePending() {
1278 function populateNetworkSelect() {
1279 for (var i
=0; i
<networks
.length
; i
++) {
1280 var network
= networks
[i
];
1281 var option
= $("<option>");
1282 option
.attr("value", i
);
1283 option
.text(network
.name
);
1284 if (network
.name
== "BTC - Bitcoin") {
1285 option
.prop("selected", true);
1287 DOM
.phraseNetwork
.append(option
);
1291 function populateClientSelect() {
1292 for (var i
=0; i
<clients
.length
; i
++) {
1293 var client
= clients
[i
];
1294 var option
= $("<option>");
1295 option
.attr("value", i
);
1296 option
.text(client
.name
);
1297 DOM
.bip32Client
.append(option
);
1301 function getLanguage() {
1302 var defaultLanguage
= "english";
1303 // Try to get from existing phrase
1304 var language
= getLanguageFromPhrase();
1305 // Try to get from url if not from phrase
1306 if (language
.length
== 0) {
1307 language
= getLanguageFromUrl();
1309 // Default to English if no other option
1310 if (language
.length
== 0) {
1311 language
= defaultLanguage
;
1316 function getLanguageFromPhrase(phrase
) {
1317 // Check if how many words from existing phrase match a language.
1320 phrase
= DOM
.phrase
.val();
1322 if (phrase
.length
> 0) {
1323 var words
= phraseToWordArray(phrase
);
1324 var languageMatches
= {};
1325 for (l
in WORDLISTS
) {
1326 // Track how many words match in this language
1327 languageMatches
[l
] = 0;
1328 for (var i
=0; i
<words
.length
; i
++) {
1329 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1330 if (wordInLanguage
) {
1331 languageMatches
[l
]++;
1334 // Find languages with most word matches.
1335 // This is made difficult due to commonalities between Chinese
1336 // simplified vs traditional.
1337 var mostMatches
= 0;
1338 var mostMatchedLanguages
= [];
1339 for (var l
in languageMatches
) {
1340 var numMatches
= languageMatches
[l
];
1341 if (numMatches
> mostMatches
) {
1342 mostMatches
= numMatches
;
1343 mostMatchedLanguages
= [l
];
1345 else if (numMatches
== mostMatches
) {
1346 mostMatchedLanguages
.push(l
);
1350 if (mostMatchedLanguages
.length
> 0) {
1351 // Use first language and warn if multiple detected
1352 language
= mostMatchedLanguages
[0];
1353 if (mostMatchedLanguages
.length
> 1) {
1354 console
.warn("Multiple possible languages");
1355 console
.warn(mostMatchedLanguages
);
1362 function getLanguageFromUrl() {
1363 for (var language
in WORDLISTS
) {
1364 if (window
.location
.hash
.indexOf(language
) > -1) {
1371 function setMnemonicLanguage() {
1372 var language
= getLanguage();
1373 // Load the bip39 mnemonic generator for this language if required
1374 if (!(language
in mnemonics
)) {
1375 mnemonics
[language
] = new Mnemonic(language
);
1377 mnemonic
= mnemonics
[language
];
1380 function convertPhraseToNewLanguage() {
1381 var oldLanguage
= getLanguageFromPhrase();
1382 var newLanguage
= getLanguageFromUrl();
1383 var oldPhrase
= DOM
.phrase
.val();
1384 var oldWords
= phraseToWordArray(oldPhrase
);
1386 for (var i
=0; i
<oldWords
.length
; i
++) {
1387 var oldWord
= oldWords
[i
];
1388 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1389 var newWord
= WORDLISTS
[newLanguage
][index
];
1390 newWords
.push(newWord
);
1392 newPhrase
= wordArrayToPhrase(newWords
);
1396 // TODO look at jsbip39 - mnemonic.splitWords
1397 function phraseToWordArray(phrase
) {
1398 var words
= phrase
.split(/\s/g);
1400 for (var i
=0; i
<words
.length
; i
++) {
1401 var word
= words
[i
];
1402 if (word
.length
> 0) {
1403 noBlanks
.push(word
);
1409 // TODO look at jsbip39 - mnemonic.joinWords
1410 function wordArrayToPhrase(words
) {
1411 var phrase
= words
.join(" ");
1412 var language
= getLanguageFromPhrase(phrase
);
1413 if (language
== "japanese") {
1414 phrase
= words
.join("\u3000");
1419 function isUsingOwnEntropy() {
1420 return DOM
.useEntropy
.prop("checked");
1423 function setMnemonicFromEntropy() {
1424 clearEntropyFeedback();
1425 // Get entropy value
1426 var entropyStr
= DOM
.entropy
.val();
1427 // Work out minimum base for entropy
1428 var entropy
= Entropy
.fromString(entropyStr
);
1429 if (entropy
.binaryStr
.length
== 0) {
1432 // Show entropy details
1433 showEntropyFeedback(entropy
);
1434 // Use entropy hash if not using raw entropy
1435 var bits
= entropy
.binaryStr
;
1436 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1437 if (mnemonicLength
!= "raw") {
1438 // Get bits by hashing entropy with SHA256
1439 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1440 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1441 bits
= BigInteger
.parse(hex
, 16).toString(2);
1442 while (bits
.length
% 256 != 0) {
1445 // Truncate hash to suit number of words
1446 mnemonicLength
= parseInt(mnemonicLength
);
1447 var numberOfBits
= 32 * mnemonicLength
/ 3;
1448 bits
= bits
.substring(0, numberOfBits
);
1449 // show warning for weak entropy override
1450 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1451 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1454 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1458 // hide warning for weak entropy override
1459 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1461 // Discard trailing entropy
1462 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1463 var start
= bits
.length
- bitsToUse
;
1464 var binaryStr
= bits
.substring(start
);
1465 // Convert entropy string to numeric array
1466 var entropyArr
= [];
1467 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1468 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1469 var entropyByte
= parseInt(byteAsBits
, 2);
1470 entropyArr
.push(entropyByte
)
1472 // Convert entropy array to mnemonic
1473 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1474 // Set the mnemonic in the UI
1475 DOM
.phrase
.val(phrase
);
1476 // Show the word indexes
1478 // Show the checksum
1482 function clearEntropyFeedback() {
1483 DOM
.entropyCrackTime
.text("...");
1484 DOM
.entropyType
.text("");
1485 DOM
.entropyWordCount
.text("0");
1486 DOM
.entropyEventCount
.text("0");
1487 DOM
.entropyBitsPerEvent
.text("0");
1488 DOM
.entropyBits
.text("0");
1489 DOM
.entropyFiltered
.html(" ");
1490 DOM
.entropyBinary
.html(" ");
1493 function showEntropyFeedback(entropy
) {
1494 var numberOfBits
= entropy
.binaryStr
.length
;
1495 var timeToCrack
= "unknown";
1497 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1498 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1499 if (z
.feedback
.warning
!= "") {
1500 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1504 console
.log("Error detecting entropy strength with zxcvbn:");
1507 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1508 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1509 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1510 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1511 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1512 DOM
.entropyType
.text(entropyTypeStr
);
1513 DOM
.entropyCrackTime
.text(timeToCrack
);
1514 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1515 DOM
.entropyBits
.text(numberOfBits
);
1516 DOM
.entropyWordCount
.text(wordCount
);
1517 DOM
.entropyBinary
.text(spacedBinaryStr
);
1518 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1519 // detect and warn of filtering
1520 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1521 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1522 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1524 DOM
.entropyFilterWarning
.removeClass('hidden');
1527 DOM
.entropyFilterWarning
.addClass('hidden');
1531 function getEntropyTypeStr(entropy
) {
1532 var typeStr
= entropy
.base
.str
;
1533 // Add some detail if these are cards
1534 if (entropy
.base
.asInt
== 52) {
1535 var cardDetail
= []; // array of message strings
1536 // Detect duplicates
1538 var dupeTracker
= {};
1539 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1540 var card
= entropy
.base
.parts
[i
];
1541 var cardUpper
= card
.toUpperCase();
1542 if (cardUpper
in dupeTracker
) {
1545 dupeTracker
[cardUpper
] = true;
1547 if (dupes
.length
> 0) {
1548 var dupeWord
= "duplicates";
1549 if (dupes
.length
== 1) {
1550 dupeWord
= "duplicate";
1552 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1553 if (dupes
.length
> 3) {
1556 cardDetail
.push(msg
);
1559 var uniqueCards
= [];
1560 for (var uniqueCard
in dupeTracker
) {
1561 uniqueCards
.push(uniqueCard
);
1563 if (uniqueCards
.length
== 52) {
1564 cardDetail
.unshift("full deck");
1566 // Detect missing cards
1567 var values
= "A23456789TJQK";
1569 var missingCards
= [];
1570 for (var i
=0; i
<suits
.length
; i
++) {
1571 for (var j
=0; j
<values
.length
; j
++) {
1572 var card
= values
[j
] + suits
[i
];
1573 if (!(card
in dupeTracker
)) {
1574 missingCards
.push(card
);
1578 // Display missing cards if six or less, ie clearly going for full deck
1579 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1580 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1581 if (missingCards
.length
> 3) {
1584 cardDetail
.push(msg
);
1586 // Add card details to typeStr
1587 if (cardDetail
.length
> 0) {
1588 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1594 function setQrEvents(els
) {
1595 els
.on("mouseenter", createQr
);
1596 els
.on("mouseleave", destroyQr
);
1597 els
.on("click", toggleQr
);
1600 function createQr(e
) {
1601 var content
= e
.target
.textContent
|| e
.target
.value
;
1609 DOM
.qrImage
.append(qrEl
);
1611 DOM
.qrHider
.addClass("hidden");
1614 DOM
.qrHider
.removeClass("hidden");
1616 DOM
.qrContainer
.removeClass("hidden");
1620 function destroyQr() {
1621 DOM
.qrImage
.text("");
1622 DOM
.qrContainer
.addClass("hidden");
1625 function toggleQr() {
1627 DOM
.qrHider
.toggleClass("hidden");
1628 DOM
.qrHint
.toggleClass("hidden");
1631 function bip44TabSelected() {
1632 return DOM
.bip44tab
.hasClass("active");
1635 function bip32TabSelected() {
1636 return DOM
.bip32tab
.hasClass("active");
1639 function networkHasSegwit() {
1641 if ("baseNetwork" in network
) {
1642 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1644 // check if only p2wpkh params are required
1645 if (p2wpkhSelected()) {
1646 return "p2wpkh" in n
;
1648 // check if only p2wpkh-in-p2sh params are required
1649 else if (p2wpkhInP2shSelected()) {
1650 return "p2wpkhInP2sh" in n
;
1652 // require both if it's unclear which params are required
1653 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1656 function bip49TabSelected() {
1657 return DOM
.bip49tab
.hasClass("active");
1660 function bip84TabSelected() {
1661 return DOM
.bip84tab
.hasClass("active");
1664 function bip141TabSelected() {
1665 return DOM
.bip141tab
.hasClass("active");
1668 function setHdCoin(coinValue
) {
1669 DOM
.bip44coin
.val(coinValue
);
1670 DOM
.bip49coin
.val(coinValue
);
1671 DOM
.bip84coin
.val(coinValue
);
1674 function showSegwitAvailable() {
1675 DOM
.bip49unavailable
.addClass("hidden");
1676 DOM
.bip49available
.removeClass("hidden");
1677 DOM
.bip84unavailable
.addClass("hidden");
1678 DOM
.bip84available
.removeClass("hidden");
1679 DOM
.bip141unavailable
.addClass("hidden");
1680 DOM
.bip141available
.removeClass("hidden");
1683 function showSegwitUnavailable() {
1684 DOM
.bip49available
.addClass("hidden");
1685 DOM
.bip49unavailable
.removeClass("hidden");
1686 DOM
.bip84available
.addClass("hidden");
1687 DOM
.bip84unavailable
.removeClass("hidden");
1688 DOM
.bip141available
.addClass("hidden");
1689 DOM
.bip141unavailable
.removeClass("hidden");
1692 function adjustNetworkForSegwit() {
1693 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1694 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1696 // See https://github.com/iancoleman/bip39/issues/125
1697 var segwitNetworks
= null;
1698 // if a segwit network is alread selected, need to use base network to
1699 // look up new parameters
1700 if ("baseNetwork" in network
) {
1701 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1703 // choose the right segwit params
1704 if (p2wpkhSelected() && "p2wpkh" in network
) {
1705 network
= network
.p2wpkh
;
1707 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1708 network
= network
.p2wpkhInP2sh
;
1712 function lastIndexInTable() {
1713 var pathText
= DOM
.addresses
.find(".index").last().text();
1714 var pathBits
= pathText
.split("/");
1715 var lastBit
= pathBits
[pathBits
.length
-1];
1716 var lastBitClean
= lastBit
.replace("'", "");
1717 return parseInt(lastBitClean
);
1720 function uint8ArrayToHex(a
) {
1722 for (var i
=0; i
<a
.length
; i
++) {
1723 var h
= a
[i
].toString(16);
1724 while (h
.length
< 2) {
1732 function showWordIndexes() {
1733 var phrase
= DOM
.phrase
.val();
1734 var words
= phraseToWordArray(phrase
);
1735 var wordIndexes
= [];
1736 var language
= getLanguage();
1737 for (var i
=0; i
<words
.length
; i
++) {
1738 var word
= words
[i
];
1739 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1740 wordIndexes
.push(wordIndex
);
1742 var wordIndexesStr
= wordIndexes
.join(", ");
1743 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1746 function showChecksum() {
1747 var phrase
= DOM
.phrase
.val();
1748 var words
= phraseToWordArray(phrase
);
1749 var checksumBitlength
= words
.length
/ 3;
1752 var language
= getLanguage();
1753 for (var i
=words
.length
-1; i
>=0; i
--) {
1754 var word
= words
[i
];
1755 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1756 var wordBinary
= wordIndex
.toString(2);
1757 while (wordBinary
.length
< 11) {
1758 wordBinary
= "0" + wordBinary
;
1760 var binaryStr
= wordBinary
+ binaryStr
;
1761 if (binaryStr
.length
>= checksumBitlength
) {
1762 var start
= binaryStr
.length
- checksumBitlength
;
1763 var end
= binaryStr
.length
;
1764 checksum
= binaryStr
.substring(start
, end
);
1765 // add spaces so the last group is 11 bits, not the first
1766 checksum
= checksum
.split("").reverse().join("")
1767 checksum
= addSpacesEveryElevenBits(checksum
);
1768 checksum
= checksum
.split("").reverse().join("")
1772 DOM
.entropyChecksum
.text(checksum
);
1775 function updateCsv() {
1776 var tableCsv
= "path,address,public key,private key\n";
1777 var rows
= DOM
.addresses
.find("tr");
1778 for (var i
=0; i
<rows
.length
; i
++) {
1779 var row
= $(rows
[i
]);
1780 var cells
= row
.find("td");
1781 for (var j
=0; j
<cells
.length
; j
++) {
1782 var cell
= $(cells
[j
]);
1783 if (!cell
.children().hasClass("invisible")) {
1784 tableCsv
= tableCsv
+ cell
.text();
1786 if (j
!= cells
.length
- 1) {
1787 tableCsv
= tableCsv
+ ",";
1790 tableCsv
= tableCsv
+ "\n";
1792 DOM
.csv
.val(tableCsv
);
1795 function addSpacesEveryElevenBits(binaryStr
) {
1796 return binaryStr
.match(/.{1,11}/g).join(" ");
1801 name: "AC - Asiacoin",
1802 onSelect: function() {
1803 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1808 name: "ACC - Adcoin",
1809 onSelect: function() {
1810 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1815 name: "ARYA - Aryacoin",
1816 onSelect: function() {
1817 network
= bitcoinjs
.bitcoin
.networks
.aryacoin
;
1822 name: "AUR - Auroracoin",
1823 onSelect: function() {
1824 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1830 onSelect: function() {
1831 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1836 name: "ANON - ANON",
1837 onSelect: function() {
1838 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1843 name: "BOLI - Bolivarcoin",
1844 onSelect: function() {
1845 network
= bitcoinjs
.bitcoin
.networks
.bolivarcoin
;
1850 name: "BCA - Bitcoin Atom",
1851 onSelect: function() {
1852 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1857 name: "BCH - Bitcoin Cash",
1858 onSelect: function() {
1859 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1864 name: "BEET - Beetlecoin",
1865 onSelect: function() {
1866 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1871 name: "BELA - Belacoin",
1872 onSelect: function() {
1873 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1878 name: "BLK - BlackCoin",
1879 onSelect: function() {
1880 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1885 name: "BND - Blocknode",
1886 onSelect: function() {
1887 network
= bitcoinjs
.bitcoin
.networks
.blocknode
;
1892 name: "tBND - Blocknode Testnet",
1893 onSelect: function() {
1894 network
= bitcoinjs
.bitcoin
.networks
.blocknode_testnet
;
1899 name: "BRIT - Britcoin",
1900 onSelect: function() {
1901 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
1906 name: "BSD - Bitsend",
1907 onSelect: function() {
1908 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
1913 name: "BST - BlockStamp",
1914 onSelect: function() {
1915 network
= bitcoinjs
.bitcoin
.networks
.blockstamp
;
1921 onSelect: function() {
1922 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1927 name: "BTC - Bitcoin",
1928 onSelect: function() {
1929 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1934 name: "BTC - Bitcoin Testnet",
1935 onSelect: function() {
1936 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1941 name: "BITG - Bitcoin Green",
1942 onSelect: function() {
1943 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1948 name: "BTCP - Bitcoin Private",
1949 onSelect: function() {
1950 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
1955 name: "BSV - BitcoinSV",
1956 onSelect: function() {
1957 network
= bitcoinjs
.bitcoin
.networks
.bitcoinsv
;
1962 name: "BTCZ - Bitcoinz",
1963 onSelect: function() {
1964 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
1969 name: "BTDX - BitCloud",
1970 onSelect: function() {
1971 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
1976 name: "BTG - Bitcoin Gold",
1977 onSelect: function() {
1978 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
1983 name: "BTX - Bitcore",
1984 onSelect: function() {
1985 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
1990 name: "CCN - Cannacoin",
1991 onSelect: function() {
1992 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1997 name: "CESC - Cryptoescudo",
1998 onSelect: function() {
1999 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2004 name: "CDN - Canadaecoin",
2005 onSelect: function() {
2006 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
2011 name: "CLAM - Clams",
2012 onSelect: function() {
2013 network
= bitcoinjs
.bitcoin
.networks
.clam
;
2018 name: "CLO - Callisto",
2019 segwitAvailable: false,
2020 onSelect: function() {
2021 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2026 name: "CLUB - Clubcoin",
2027 onSelect: function() {
2028 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
2033 name: "CMP - Compcoin",
2034 onSelect: function() {
2035 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
2040 name: "CPU - CPUchain",
2041 onSelect: function() {
2042 network
= bitcoinjs
.bitcoin
.networks
.cpuchain
;
2047 name: "CRAVE - Crave",
2048 onSelect: function() {
2049 network
= bitcoinjs
.bitcoin
.networks
.crave
;
2054 name: "CRW - Crown (Legacy)",
2055 onSelect: function() {
2056 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2061 name: "CRW - Crown",
2062 onSelect: function() {
2063 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2068 name: "CSC - CasinoCoin",
2069 onSelect: function() {
2070 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2075 name: "DASH - Dash",
2076 onSelect: function() {
2077 network
= bitcoinjs
.bitcoin
.networks
.dash
;
2082 name: "DASH - Dash Testnet",
2083 onSelect: function() {
2084 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
2089 name: "DFC - Defcoin",
2090 onSelect: function() {
2091 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
2096 name: "DGB - Digibyte",
2097 onSelect: function() {
2098 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
2103 name: "DGC - Digitalcoin",
2104 onSelect: function() {
2105 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
2110 name: "DMD - Diamond",
2111 onSelect: function() {
2112 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
2117 name: "DNR - Denarius",
2118 onSelect: function() {
2119 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
2124 name: "DOGE - Dogecoin",
2125 onSelect: function() {
2126 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
2131 name: "DOGEt - Dogecoin Testnet",
2132 onSelect: function() {
2133 network
= bitcoinjs
.bitcoin
.networks
.dogecointestnet
;
2138 name: "DXN - DEXON",
2139 onSelect: function() {
2140 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2145 name: "ECN - Ecoin",
2146 onSelect: function() {
2147 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
2152 name: "EDRC - Edrcoin",
2153 onSelect: function() {
2154 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
2159 name: "EFL - Egulden",
2160 onSelect: function() {
2161 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
2166 name: "ELLA - Ellaism",
2167 segwitAvailable: false,
2168 onSelect: function() {
2169 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2174 name: "EMC2 - Einsteinium",
2175 onSelect: function() {
2176 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
2181 name: "ERC - Europecoin",
2182 onSelect: function() {
2183 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
2188 name: "EOS - EOSIO",
2189 onSelect: function() {
2190 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2195 name: "ESN - Ethersocial Network",
2196 segwitAvailable: false,
2197 onSelect: function() {
2198 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2203 name: "ETC - Ethereum Classic",
2204 segwitAvailable: false,
2205 onSelect: function() {
2206 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2211 name: "ETH - Ethereum",
2212 onSelect: function() {
2213 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2218 name: "EXCL - Exclusivecoin",
2219 onSelect: function() {
2220 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
2225 name: "EXCC - ExchangeCoin",
2226 onSelect: function() {
2227 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
2232 name: "EXP - Expanse",
2233 segwitAvailable: false,
2234 onSelect: function() {
2235 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2241 onSelect: function() {
2242 network
= bitcoinjs
.bitcoin
.networks
.fix
;
2247 name: "FIX - FIX Testnet",
2248 onSelect: function() {
2249 network
= bitcoinjs
.bitcoin
.networks
.fixtestnet
;
2254 name: "FJC - Fujicoin",
2255 onSelect: function() {
2256 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2261 name: "FLASH - Flashcoin",
2262 onSelect: function() {
2263 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2268 name: "FRST - Firstcoin",
2269 onSelect: function() {
2270 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2275 name: "FTC - Feathercoin",
2276 onSelect: function() {
2277 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2282 name: "GAME - GameCredits",
2283 onSelect: function() {
2284 network
= bitcoinjs
.bitcoin
.networks
.game
;
2289 name: "GBX - Gobyte",
2290 onSelect: function() {
2291 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2296 name: "GCR - GCRCoin",
2297 onSelect: function() {
2298 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2303 name: "GRC - Gridcoin",
2304 onSelect: function() {
2305 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2310 name: "GRS - Groestlcoin",
2311 onSelect: function() {
2312 network
= bitcoinjs
.bitcoin
.networks
.groestlcoin
;
2317 name: "GRS - Groestlcoin Testnet",
2318 onSelect: function() {
2319 network
= bitcoinjs
.bitcoin
.networks
.groestlcointestnet
;
2324 name: "HNC - Helleniccoin",
2325 onSelect: function() {
2326 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2331 name: "HUSH - Hush (Legacy)",
2332 onSelect: function() {
2333 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2338 name: "HUSH - Hush3",
2339 onSelect: function() {
2340 network
= bitcoinjs
.bitcoin
.networks
.hush3
;
2345 name: "INSN - Insane",
2346 onSelect: function() {
2347 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2353 onSelect: function() {
2354 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2359 name: "IXC - Ixcoin",
2360 onSelect: function() {
2361 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2366 name: "JBS - Jumbucks",
2367 onSelect: function() {
2368 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2373 name: "KMD - Komodo",
2374 bip49available: false,
2375 onSelect: function() {
2376 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2381 name: "KOBO - Kobocoin",
2382 bip49available: false,
2383 onSelect: function() {
2384 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2389 name: "LBC - Library Credits",
2390 onSelect: function() {
2391 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2396 name: "LCC - Litecoincash",
2397 onSelect: function() {
2398 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2403 name: "LDCN - Landcoin",
2404 onSelect: function() {
2405 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2410 name: "LINX - Linx",
2411 onSelect: function() {
2412 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2417 name: "LKR - Lkrcoin",
2418 segwitAvailable: false,
2419 onSelect: function() {
2420 network
= bitcoinjs
.bitcoin
.networks
.lkrcoin
;
2425 name: "LTC - Litecoin",
2426 onSelect: function() {
2427 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2429 DOM
.litecoinLtubContainer
.removeClass("hidden");
2433 name: "LTCt - Litecoin Testnet",
2434 onSelect: function() {
2435 network
= bitcoinjs
.bitcoin
.networks
.litecointestnet
;
2437 DOM
.litecoinLtubContainer
.removeClass("hidden");
2441 name: "LTZ - LitecoinZ",
2442 onSelect: function() {
2443 network
= bitcoinjs
.bitcoin
.networks
.litecoinz
;
2448 name: "LYNX - Lynx",
2449 onSelect: function() {
2450 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2455 name: "MAZA - Maza",
2456 onSelect: function() {
2457 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2462 name: "MEC - Megacoin",
2463 onSelect: function() {
2464 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2470 segwitAvailable: false,
2471 onSelect: function() {
2472 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2477 name: "MNX - Minexcoin",
2478 onSelect: function() {
2479 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2484 name: "MONA - Monacoin",
2485 onSelect: function() {
2486 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2491 name: "MONK - Monkey Project",
2492 onSelect: function() {
2493 network
= bitcoinjs
.bitcoin
.networks
.monkeyproject
,
2498 name: "MUSIC - Musicoin",
2499 segwitAvailable: false,
2500 onSelect: function() {
2501 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2506 name: "NAV - Navcoin",
2507 onSelect: function() {
2508 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2513 name: "NAS - Nebulas",
2514 onSelect: function() {
2515 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2520 name: "NEBL - Neblio",
2521 onSelect: function() {
2522 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2527 name: "NEOS - Neoscoin",
2528 onSelect: function() {
2529 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2534 name: "NIX - NIX Platform",
2535 onSelect: function() {
2536 network
= bitcoinjs
.bitcoin
.networks
.nix
;
2541 name: "NLG - Gulden",
2542 onSelect: function() {
2543 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2548 name: "NMC - Namecoin",
2549 onSelect: function() {
2550 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2555 name: "NRG - Energi",
2556 onSelect: function() {
2557 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2562 name: "NRO - Neurocoin",
2563 onSelect: function() {
2564 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2569 name: "NSR - Nushares",
2570 onSelect: function() {
2571 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2576 name: "NYC - Newyorkc",
2577 onSelect: function() {
2578 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2583 name: "NVC - Novacoin",
2584 onSelect: function() {
2585 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2590 name: "OK - Okcash",
2591 onSelect: function() {
2592 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2597 name: "OMNI - Omnicore",
2598 onSelect: function() {
2599 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2604 name: "ONION - DeepOnion",
2605 onSelect: function() {
2606 network
= bitcoinjs
.bitcoin
.networks
.deeponion
;
2611 name: "ONX - Onixcoin",
2612 onSelect: function() {
2613 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2618 name: "PHR - Phore",
2619 onSelect: function() {
2620 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2625 name: "PINK - Pinkcoin",
2626 onSelect: function() {
2627 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2632 name: "PIRL - Pirl",
2633 segwitAvailable: false,
2634 onSelect: function() {
2635 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2640 name: "PIVX - PIVX",
2641 onSelect: function() {
2642 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2647 name: "PIVX - PIVX Testnet",
2648 onSelect: function() {
2649 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2655 segwitAvailable: false,
2656 onSelect: function() {
2657 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2662 name: "POSW - POSWcoin",
2663 onSelect: function() {
2664 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2669 name: "POT - Potcoin",
2670 onSelect: function() {
2671 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2676 name: "PPC - Peercoin",
2677 onSelect: function() {
2678 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2683 name: "PRJ - ProjectCoin",
2684 onSelect: function() {
2685 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2690 name: "PSB - Pesobit",
2691 onSelect: function() {
2692 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2697 name: "PUT - Putincoin",
2698 onSelect: function() {
2699 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2704 name: "RPD - Rapids",
2705 onSelect: function() {
2706 network
= bitcoinjs
.bitcoin
.networks
.rapids
;
2711 name: "RVN - Ravencoin",
2712 onSelect: function() {
2713 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2718 name: "RBY - Rubycoin",
2719 onSelect: function() {
2720 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2725 name: "RDD - Reddcoin",
2726 onSelect: function() {
2727 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2732 name: "RVR - RevolutionVR",
2733 onSelect: function() {
2734 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2739 name: "SAFE - Safecoin",
2740 onSelect: function() {
2741 network
= bitcoinjs
.bitcoin
.networks
.safecoin
;
2746 name: "SLS - Salus",
2747 onSelect: function() {
2748 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2753 name: "SDC - ShadowCash",
2754 onSelect: function() {
2755 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2760 name: "SDC - ShadowCash Testnet",
2761 onSelect: function() {
2762 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2767 name: "SLM - Slimcoin",
2768 onSelect: function() {
2769 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2774 name: "SLM - Slimcoin Testnet",
2775 onSelect: function() {
2776 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2781 name: "SLP - Simple Ledger Protocol",
2782 onSelect: function() {
2783 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2788 name: "SLR - Solarcoin",
2789 onSelect: function() {
2790 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2795 name: "SMLY - Smileycoin",
2796 onSelect: function() {
2797 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2802 name: "STASH - Stash",
2803 onSelect: function() {
2804 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2809 name: "STASH - Stash Testnet",
2810 onSelect: function() {
2811 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2816 name: "STRAT - Stratis",
2817 onSelect: function() {
2818 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2823 name: "TSTRAT - Stratis Testnet",
2824 onSelect: function() {
2825 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2830 name: "SYS - Syscoin",
2831 onSelect: function() {
2832 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2837 name: "THC - Hempcoin",
2838 onSelect: function() {
2839 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2845 onSelect: function() {
2846 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2851 name: "TWINS - TWINS",
2852 onSelect: function() {
2853 network
= bitcoinjs
.bitcoin
.networks
.twins
;
2858 name: "TWINS - TWINS Testnet",
2859 onSelect: function() {
2860 network
= bitcoinjs
.bitcoin
.networks
.twinstestnet
;
2865 name: "USC - Ultimatesecurecash",
2866 onSelect: function() {
2867 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2872 name: "USNBT - NuBits",
2873 onSelect: function() {
2874 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2879 name: "UNO - Unobtanium",
2880 onSelect: function() {
2881 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2886 name: "VASH - Vpncoin",
2887 onSelect: function() {
2888 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2893 name: "VET - VeChain",
2894 onSelect: function() {
2895 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2900 name: "VIA - Viacoin",
2901 onSelect: function() {
2902 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2907 name: "VIA - Viacoin Testnet",
2908 onSelect: function() {
2909 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2914 name: "VIVO - Vivo",
2915 onSelect: function() {
2916 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2921 name: "VTC - Vertcoin",
2922 onSelect: function() {
2923 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2928 name: "WGR - Wagerr",
2929 onSelect: function() {
2930 network
= bitcoinjs
.bitcoin
.networks
.wagerr
;
2935 name: "WC - Wincoin",
2936 onSelect: function() {
2937 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2942 name: "XAX - Artax",
2943 onSelect: function() {
2944 network
= bitcoinjs
.bitcoin
.networks
.artax
;
2949 name: "XBC - Bitcoinplus",
2950 onSelect: function() {
2951 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
2956 name: "XLM - Stellar",
2957 onSelect: function() {
2958 network
= stellarUtil
.dummyNetwork
;
2963 name: "XMY - Myriadcoin",
2964 onSelect: function() {
2965 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
2970 name: "XRP - Ripple",
2971 onSelect: function() {
2972 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2977 name: "XVC - Vcash",
2978 onSelect: function() {
2979 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
2984 name: "XVG - Verge",
2985 onSelect: function() {
2986 network
= bitcoinjs
.bitcoin
.networks
.verge
;
2991 name: "XUEZ - Xuez",
2992 segwitAvailable: false,
2993 onSelect: function() {
2994 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
2999 name: "XWC - Whitecoin",
3000 onSelect: function() {
3001 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
3006 name: "XZC - Zcoin",
3007 onSelect: function() {
3008 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
3013 name: "ZCL - Zclassic",
3014 onSelect: function() {
3015 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
3020 name: "ZEC - Zcash",
3021 onSelect: function() {
3022 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
3027 name: "ZEN - Horizen",
3028 onSelect: function() {
3029 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
3037 name: "Bitcoin Core",
3038 onSelect: function() {
3039 DOM
.bip32path
.val("m/0'/0'");
3040 DOM
.hardenedAddresses
.prop('checked', true);
3044 name: "blockchain.info",
3045 onSelect: function() {
3046 DOM
.bip32path
.val("m/44'/0'/0'");
3047 DOM
.hardenedAddresses
.prop('checked', false);
3051 name: "MultiBit HD",
3052 onSelect: function() {
3053 DOM
.bip32path
.val("m/0'/0");
3054 DOM
.hardenedAddresses
.prop('checked', false);
3058 name: "Coinomi, Ledger",
3059 onSelect: function() {
3060 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
3061 DOM
.hardenedAddresses
.prop('checked', false);