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
);
493 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
494 // try parsing with various segwit network params since this extended
495 // key may be from any one of them.
496 if (networkHasSegwit()) {
498 if ("baseNetwork" in n
) {
499 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
501 // try parsing using base network params
503 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
507 // try parsing using p2wpkh params
510 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
515 // try parsing using p2wpkh-in-p2sh network params
516 if ("p2wpkhInP2sh" in n
) {
518 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
524 // try the network params as currently specified
525 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
528 function calcBip32ExtendedKey(path
) {
529 // Check there's a root key to derive from
533 var extendedKey
= bip32RootKey
;
534 // Derive the key from the path
535 var pathBits
= path
.split("/");
536 for (var i
=0; i
<pathBits
.length
; i
++) {
537 var bit
= pathBits
[i
];
538 var index
= parseInt(bit
);
542 var hardened
= bit
[bit
.length
-1] == "'";
543 var isPriv
= !(extendedKey
.isNeutered());
544 var invalidDerivationPath
= hardened
&& !isPriv
;
545 if (invalidDerivationPath
) {
549 extendedKey
= extendedKey
.deriveHardened(index
);
552 extendedKey
= extendedKey
.derive(index
);
558 function showValidationError(errorText
) {
564 function hideValidationError() {
570 function findPhraseErrors(phrase
) {
571 // Preprocess the words
572 phrase
= mnemonic
.normalizeString(phrase
);
573 var words
= phraseToWordArray(phrase
);
574 // Detect blank phrase
575 if (words
.length
== 0) {
576 return "Blank mnemonic";
579 for (var i
=0; i
<words
.length
; i
++) {
581 var language
= getLanguage();
582 if (WORDLISTS
[language
].indexOf(word
) == -1) {
583 console
.log("Finding closest match to " + word
);
584 var nearestWord
= findNearestWord(word
);
585 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
588 // Check the words are valid
589 var properPhrase
= wordArrayToPhrase(words
);
590 var isValid
= mnemonic
.check(properPhrase
);
592 return "Invalid mnemonic";
597 function validateRootKey(rootKeyBase58
) {
598 // try various segwit network params since this extended key may be from
600 if (networkHasSegwit()) {
602 if ("baseNetwork" in n
) {
603 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
605 // try parsing using base network params
607 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
611 // try parsing using p2wpkh params
614 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
619 // try parsing using p2wpkh-in-p2sh network params
620 if ("p2wpkhInP2sh" in n
) {
622 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
628 // try the network params as currently specified
630 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
633 return "Invalid root key";
638 function getDerivationPath() {
639 if (bip44TabSelected()) {
640 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
641 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
642 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
643 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
645 path
+= purpose
+ "'/";
647 path
+= account
+ "'/";
649 DOM
.bip44path
.val(path
);
650 var derivationPath
= DOM
.bip44path
.val();
651 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
652 return derivationPath
;
654 else if (bip49TabSelected()) {
655 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
656 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
657 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
658 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
660 path
+= purpose
+ "'/";
662 path
+= account
+ "'/";
664 DOM
.bip49path
.val(path
);
665 var derivationPath
= DOM
.bip49path
.val();
666 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
667 return derivationPath
;
669 else if (bip84TabSelected()) {
670 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
671 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
672 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
673 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
675 path
+= purpose
+ "'/";
677 path
+= account
+ "'/";
679 DOM
.bip84path
.val(path
);
680 var derivationPath
= DOM
.bip84path
.val();
681 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
682 return derivationPath
;
684 else if (bip32TabSelected()) {
685 var derivationPath
= DOM
.bip32path
.val();
686 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
687 return derivationPath
;
689 else if (bip141TabSelected()) {
690 var derivationPath
= DOM
.bip141path
.val();
691 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
692 return derivationPath
;
695 console
.log("Unknown derivation path");
699 function findDerivationPathErrors(path
) {
700 // TODO is not perfect but is better than nothing
702 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
704 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
705 var maxDepth
= 255; // TODO verify this!!
706 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
707 if (path
[0] != "m") {
708 return "First character must be 'm'";
710 if (path
.length
> 1) {
711 if (path
[1] != "/") {
712 return "Separator must be '/'";
714 var indexes
= path
.split("/");
715 if (indexes
.length
> maxDepth
) {
716 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
718 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
719 var index
= indexes
[depth
];
720 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
721 if (invalidChars
.length
> 0) {
722 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
724 var indexValue
= parseInt(index
.replace("'", ""));
726 return "Invalid number at depth " + depth
;
728 if (indexValue
> maxIndexValue
) {
729 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
733 // Check root key exists or else derivation path is useless!
735 return "No root key";
737 // Check no hardened derivation path when using xpub keys
738 var hardenedPath
= path
.indexOf("'") > -1;
739 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
740 var hardened
= hardenedPath
|| hardenedAddresses
;
741 var isXpubkey
= bip32RootKey
.isNeutered();
742 if (hardened
&& isXpubkey
) {
743 return "Hardened derivation path is invalid with xpub key";
748 function displayBip44Info() {
749 // Get the derivation path for the account
750 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
751 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
752 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
754 path
+= purpose
+ "'/";
756 path
+= account
+ "'/";
757 // Calculate the account extended keys
758 var accountExtendedKey
= calcBip32ExtendedKey(path
);
759 var accountXprv
= accountExtendedKey
.toBase58();
760 var accountXpub
= accountExtendedKey
.neutered().toBase58();
761 // Display the extended keys
762 DOM
.bip44accountXprv
.val(accountXprv
);
763 DOM
.bip44accountXpub
.val(accountXpub
);
766 function displayBip49Info() {
767 // Get the derivation path for the account
768 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
769 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
770 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
772 path
+= purpose
+ "'/";
774 path
+= account
+ "'/";
775 // Calculate the account extended keys
776 var accountExtendedKey
= calcBip32ExtendedKey(path
);
777 var accountXprv
= accountExtendedKey
.toBase58();
778 var accountXpub
= accountExtendedKey
.neutered().toBase58();
779 // Display the extended keys
780 DOM
.bip49accountXprv
.val(accountXprv
);
781 DOM
.bip49accountXpub
.val(accountXpub
);
784 function displayBip84Info() {
785 // Get the derivation path for the account
786 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
787 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
788 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
790 path
+= purpose
+ "'/";
792 path
+= account
+ "'/";
793 // Calculate the account extended keys
794 var accountExtendedKey
= calcBip32ExtendedKey(path
);
795 var accountXprv
= accountExtendedKey
.toBase58();
796 var accountXpub
= accountExtendedKey
.neutered().toBase58();
797 // Display the extended keys
798 DOM
.bip84accountXprv
.val(accountXprv
);
799 DOM
.bip84accountXpub
.val(accountXpub
);
802 function displayBip32Info() {
805 var rootKey
= bip32RootKey
.toBase58();
806 DOM
.rootKey
.val(rootKey
);
807 var xprvkeyB58
= "NA";
808 if (!bip32ExtendedKey
.isNeutered()) {
809 xprvkeyB58
= bip32ExtendedKey
.toBase58();
811 var extendedPrivKey
= xprvkeyB58
;
812 DOM
.extendedPrivKey
.val(extendedPrivKey
);
813 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
814 DOM
.extendedPubKey
.val(extendedPubKey
);
815 // Display the addresses and privkeys
816 clearAddressesList();
817 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
818 displayAddresses(0, initialAddressCount
);
821 function displayAddresses(start
, total
) {
822 generationProcesses
.push(new (function() {
826 this.stop = function() {
827 for (var i
=0; i
<rows
.length
; i
++) {
828 rows
[i
].shouldGenerate
= false;
833 for (var i
=0; i
<total
; i
++) {
834 var index
= i
+ start
;
835 var isLast
= i
== total
- 1;
836 rows
.push(new TableRow(index
, isLast
));
842 function segwitSelected() {
843 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
846 function p2wpkhSelected() {
847 return bip84TabSelected() ||
848 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
851 function p2wpkhInP2shSelected() {
852 return bip49TabSelected() ||
853 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
856 function TableRow(index
, isLast
) {
859 this.shouldGenerate
= true;
860 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
861 var useBip38
= DOM
.useBip38
.prop("checked");
862 var bip38password
= DOM
.bip38Password
.val();
863 var isSegwit
= segwitSelected();
864 var segwitAvailable
= networkHasSegwit();
865 var isP2wpkh
= p2wpkhSelected();
866 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
872 function calculateValues() {
873 setTimeout(function() {
874 if (!self
.shouldGenerate
) {
877 // derive HDkey for this row of the table
879 if (useHardenedAddresses
) {
880 key
= bip32ExtendedKey
.deriveHardened(index
);
883 key
= bip32ExtendedKey
.derive(index
);
885 // bip38 requires uncompressed keys
886 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
887 var keyPair
= key
.keyPair
;
888 var useUncompressed
= useBip38
;
889 if (useUncompressed
) {
890 keyPair
= new bitcoinjs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
893 var address
= keyPair
.getAddress().toString();
895 var hasPrivkey
= !key
.isNeutered();
898 privkey
= keyPair
.toWIF();
899 // BIP38 encode private key if required
901 privkey
= bitcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
902 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
907 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
908 var indexText
= getDerivationPath() + "/" + index
;
909 if (useHardenedAddresses
) {
910 indexText
= indexText
+ "'";
912 // Ethereum values are different
913 if ((networks
[DOM
.network
.val()].name
== "ETH - Ethereum")
914 || (networks
[DOM
.network
.val()].name
== "ETC - Ethereum Classic")
915 || (networks
[DOM
.network
.val()].name
== "PIRL - Pirl")
916 || (networks
[DOM
.network
.val()].name
== "MIX - MIX")
917 || (networks
[DOM
.network
.val()].name
== "MUSIC - Musicoin")
918 || (networks
[DOM
.network
.val()].name
== "POA - Poa")
919 || (networks
[DOM
.network
.val()].name
== "EXP - Expanse")
920 || (networks
[DOM
.network
.val()].name
== "CLO - Callisto")
921 || (networks
[DOM
.network
.val()].name
== "DXN - DEXON")
922 || (networks
[DOM
.network
.val()].name
== "ELLA - Ellaism")
923 || (networks
[DOM
.network
.val()].name
== "ESN - Ethersocial Network")
925 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
926 privkey
= privKeyBuffer
.toString('hex');
927 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
928 var hexAddress
= addressBuffer
.toString('hex');
929 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
930 address
= ethUtil
.addHexPrefix(checksumAddress
);
931 privkey
= ethUtil
.addHexPrefix(privkey
);
932 pubkey
= ethUtil
.addHexPrefix(pubkey
);
935 // Stellar is different
936 if (networks
[DOM
.network
.val()].name
== "XLM - Stellar") {
937 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
938 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
940 path
+= purpose
+ "'/";
941 path
+= coin
+ "'/" + index
+ "'";
942 var keypair
= stellarUtil
.getKeypair(path
, seed
);
944 privkey
= keypair
.secret();
945 pubkey
= address
= keypair
.publicKey();
947 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
948 var NasAccount
= require("nebulas-account");
949 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
950 var nebulasAccount
= new NasAccount();
951 nebulasAccount
.setPrivateKey(privKeyBuffer
);
952 address
= nebulasAccount
.getAddressString();
953 privkey
= nebulasAccount
.getPrivateKeyString();
954 pubkey
= nebulasAccount
.getPublicKeyString();
956 // Ripple values are different
957 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
958 privkey
= convertRipplePriv(privkey
);
959 address
= convertRippleAdrr(address
);
961 // Bitcoin Cash address format may vary
962 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
963 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
964 if (bchAddrType
== "cashaddr") {
965 address
= bchaddr
.toCashAddress(address
);
967 else if (bchAddrType
== "bitpay") {
968 address
= bchaddr
.toBitpayAddress(address
);
971 // Bitcoin Cash address format may vary
972 if (networks
[DOM
.network
.val()].name
== "SLP - Simple Ledger Protocol") {
973 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
974 if (bchAddrType
== "cashaddr") {
975 address
= bchaddr
.toSlpAddress(address
);
978 // Segwit addresses are different
980 if (!segwitAvailable
) {
984 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
985 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
986 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
988 else if (isP2wpkhInP2sh
) {
989 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
990 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
991 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
992 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
993 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
997 if ((networks
[DOM
.network
.val()].name
== "CRW - Crown")) {
998 address
= bitcoinjs
.bitcoin
.networks
.crown
.toNewAddress(address
);
1001 addAddressToList(indexText
, address
, pubkey
, privkey
);
1013 function showMore() {
1014 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
1015 if (isNaN(rowsToAdd
)) {
1017 DOM
.rowsToAdd
.val("20");
1019 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
1021 start
= lastIndexInTable() + 1;
1024 var newStart
= start
+ rowsToAdd
;
1025 DOM
.moreRowsStartIndex
.val(newStart
);
1027 if (rowsToAdd
> 200) {
1028 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1029 msg
+= "Do you want to continue?";
1030 if (!confirm(msg
)) {
1034 displayAddresses(start
, rowsToAdd
);
1037 function clearDisplay() {
1038 clearAddressesList();
1040 hideValidationError();
1043 function clearAddressesList() {
1044 DOM
.addresses
.empty();
1049 function stopGenerating() {
1050 while (generationProcesses
.length
> 0) {
1051 var generation
= generationProcesses
.shift();
1056 function clearKeys() {
1061 function clearRootKey() {
1062 DOM
.rootKey
.val("");
1065 function clearDerivedKeys() {
1066 DOM
.extendedPrivKey
.val("");
1067 DOM
.extendedPubKey
.val("");
1068 DOM
.bip44accountXprv
.val("");
1069 DOM
.bip44accountXpub
.val("");
1072 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1073 var row
= $(addressRowTemplate
.html());
1075 var indexCell
= row
.find(".index span");
1076 var addressCell
= row
.find(".address span");
1077 var pubkeyCell
= row
.find(".pubkey span");
1078 var privkeyCell
= row
.find(".privkey span");
1080 indexCell
.text(indexText
);
1081 addressCell
.text(address
);
1082 pubkeyCell
.text(pubkey
);
1083 privkeyCell
.text(privkey
);
1086 indexCell
.addClass("invisible");
1089 addressCell
.addClass("invisible");
1092 pubkeyCell
.addClass("invisible");
1095 privkeyCell
.addClass("invisible");
1097 DOM
.addresses
.append(row
);
1098 var rowShowQrEls
= row
.find("[data-show-qr]");
1099 setQrEvents(rowShowQrEls
);
1102 function hasStrongRandom() {
1103 return 'crypto' in window
&& window
['crypto'] !== null;
1106 function disableForms() {
1107 $("form").on("submit", function(e
) {
1112 function parseIntNoNaN(val
, defaultVal
) {
1113 var v
= parseInt(val
);
1120 function showPending() {
1122 .text("Calculating...")
1126 function findNearestWord(word
) {
1127 var language
= getLanguage();
1128 var words
= WORDLISTS
[language
];
1129 var minDistance
= 99;
1130 var closestWord
= words
[0];
1131 for (var i
=0; i
<words
.length
; i
++) {
1132 var comparedTo
= words
[i
];
1133 if (comparedTo
.indexOf(word
) == 0) {
1136 var distance
= Levenshtein
.get(word
, comparedTo
);
1137 if (distance
< minDistance
) {
1138 closestWord
= comparedTo
;
1139 minDistance
= distance
;
1145 function hidePending() {
1151 function populateNetworkSelect() {
1152 for (var i
=0; i
<networks
.length
; i
++) {
1153 var network
= networks
[i
];
1154 var option
= $("<option>");
1155 option
.attr("value", i
);
1156 option
.text(network
.name
);
1157 if (network
.name
== "BTC - Bitcoin") {
1158 option
.prop("selected", true);
1160 DOM
.phraseNetwork
.append(option
);
1164 function populateClientSelect() {
1165 for (var i
=0; i
<clients
.length
; i
++) {
1166 var client
= clients
[i
];
1167 var option
= $("<option>");
1168 option
.attr("value", i
);
1169 option
.text(client
.name
);
1170 DOM
.bip32Client
.append(option
);
1174 function getLanguage() {
1175 var defaultLanguage
= "english";
1176 // Try to get from existing phrase
1177 var language
= getLanguageFromPhrase();
1178 // Try to get from url if not from phrase
1179 if (language
.length
== 0) {
1180 language
= getLanguageFromUrl();
1182 // Default to English if no other option
1183 if (language
.length
== 0) {
1184 language
= defaultLanguage
;
1189 function getLanguageFromPhrase(phrase
) {
1190 // Check if how many words from existing phrase match a language.
1193 phrase
= DOM
.phrase
.val();
1195 if (phrase
.length
> 0) {
1196 var words
= phraseToWordArray(phrase
);
1197 var languageMatches
= {};
1198 for (l
in WORDLISTS
) {
1199 // Track how many words match in this language
1200 languageMatches
[l
] = 0;
1201 for (var i
=0; i
<words
.length
; i
++) {
1202 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1203 if (wordInLanguage
) {
1204 languageMatches
[l
]++;
1207 // Find languages with most word matches.
1208 // This is made difficult due to commonalities between Chinese
1209 // simplified vs traditional.
1210 var mostMatches
= 0;
1211 var mostMatchedLanguages
= [];
1212 for (var l
in languageMatches
) {
1213 var numMatches
= languageMatches
[l
];
1214 if (numMatches
> mostMatches
) {
1215 mostMatches
= numMatches
;
1216 mostMatchedLanguages
= [l
];
1218 else if (numMatches
== mostMatches
) {
1219 mostMatchedLanguages
.push(l
);
1223 if (mostMatchedLanguages
.length
> 0) {
1224 // Use first language and warn if multiple detected
1225 language
= mostMatchedLanguages
[0];
1226 if (mostMatchedLanguages
.length
> 1) {
1227 console
.warn("Multiple possible languages");
1228 console
.warn(mostMatchedLanguages
);
1235 function getLanguageFromUrl() {
1236 for (var language
in WORDLISTS
) {
1237 if (window
.location
.hash
.indexOf(language
) > -1) {
1244 function setMnemonicLanguage() {
1245 var language
= getLanguage();
1246 // Load the bip39 mnemonic generator for this language if required
1247 if (!(language
in mnemonics
)) {
1248 mnemonics
[language
] = new Mnemonic(language
);
1250 mnemonic
= mnemonics
[language
];
1253 function convertPhraseToNewLanguage() {
1254 var oldLanguage
= getLanguageFromPhrase();
1255 var newLanguage
= getLanguageFromUrl();
1256 var oldPhrase
= DOM
.phrase
.val();
1257 var oldWords
= phraseToWordArray(oldPhrase
);
1259 for (var i
=0; i
<oldWords
.length
; i
++) {
1260 var oldWord
= oldWords
[i
];
1261 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1262 var newWord
= WORDLISTS
[newLanguage
][index
];
1263 newWords
.push(newWord
);
1265 newPhrase
= wordArrayToPhrase(newWords
);
1269 // TODO look at jsbip39 - mnemonic.splitWords
1270 function phraseToWordArray(phrase
) {
1271 var words
= phrase
.split(/\s/g);
1273 for (var i
=0; i
<words
.length
; i
++) {
1274 var word
= words
[i
];
1275 if (word
.length
> 0) {
1276 noBlanks
.push(word
);
1282 // TODO look at jsbip39 - mnemonic.joinWords
1283 function wordArrayToPhrase(words
) {
1284 var phrase
= words
.join(" ");
1285 var language
= getLanguageFromPhrase(phrase
);
1286 if (language
== "japanese") {
1287 phrase
= words
.join("\u3000");
1292 function isUsingOwnEntropy() {
1293 return DOM
.useEntropy
.prop("checked");
1296 function setMnemonicFromEntropy() {
1297 clearEntropyFeedback();
1298 // Get entropy value
1299 var entropyStr
= DOM
.entropy
.val();
1300 // Work out minimum base for entropy
1301 var entropy
= Entropy
.fromString(entropyStr
);
1302 if (entropy
.binaryStr
.length
== 0) {
1305 // Show entropy details
1306 showEntropyFeedback(entropy
);
1307 // Use entropy hash if not using raw entropy
1308 var bits
= entropy
.binaryStr
;
1309 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1310 if (mnemonicLength
!= "raw") {
1311 // Get bits by hashing entropy with SHA256
1312 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1313 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1314 bits
= BigInteger
.parse(hex
, 16).toString(2);
1315 while (bits
.length
% 256 != 0) {
1318 // Truncate hash to suit number of words
1319 mnemonicLength
= parseInt(mnemonicLength
);
1320 var numberOfBits
= 32 * mnemonicLength
/ 3;
1321 bits
= bits
.substring(0, numberOfBits
);
1322 // show warning for weak entropy override
1323 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1324 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1327 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1331 // hide warning for weak entropy override
1332 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1334 // Discard trailing entropy
1335 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1336 var start
= bits
.length
- bitsToUse
;
1337 var binaryStr
= bits
.substring(start
);
1338 // Convert entropy string to numeric array
1339 var entropyArr
= [];
1340 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1341 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1342 var entropyByte
= parseInt(byteAsBits
, 2);
1343 entropyArr
.push(entropyByte
)
1345 // Convert entropy array to mnemonic
1346 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1347 // Set the mnemonic in the UI
1348 DOM
.phrase
.val(phrase
);
1349 // Show the word indexes
1351 // Show the checksum
1355 function clearEntropyFeedback() {
1356 DOM
.entropyCrackTime
.text("...");
1357 DOM
.entropyType
.text("");
1358 DOM
.entropyWordCount
.text("0");
1359 DOM
.entropyEventCount
.text("0");
1360 DOM
.entropyBitsPerEvent
.text("0");
1361 DOM
.entropyBits
.text("0");
1362 DOM
.entropyFiltered
.html(" ");
1363 DOM
.entropyBinary
.html(" ");
1366 function showEntropyFeedback(entropy
) {
1367 var numberOfBits
= entropy
.binaryStr
.length
;
1368 var timeToCrack
= "unknown";
1370 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1371 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1372 if (z
.feedback
.warning
!= "") {
1373 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1377 console
.log("Error detecting entropy strength with zxcvbn:");
1380 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1381 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1382 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1383 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1384 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1385 DOM
.entropyType
.text(entropyTypeStr
);
1386 DOM
.entropyCrackTime
.text(timeToCrack
);
1387 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1388 DOM
.entropyBits
.text(numberOfBits
);
1389 DOM
.entropyWordCount
.text(wordCount
);
1390 DOM
.entropyBinary
.text(spacedBinaryStr
);
1391 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1392 // detect and warn of filtering
1393 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1394 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1395 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1397 DOM
.entropyFilterWarning
.removeClass('hidden');
1400 DOM
.entropyFilterWarning
.addClass('hidden');
1404 function getEntropyTypeStr(entropy
) {
1405 var typeStr
= entropy
.base
.str
;
1406 // Add some detail if these are cards
1407 if (entropy
.base
.asInt
== 52) {
1408 var cardDetail
= []; // array of message strings
1409 // Detect duplicates
1411 var dupeTracker
= {};
1412 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1413 var card
= entropy
.base
.parts
[i
];
1414 var cardUpper
= card
.toUpperCase();
1415 if (cardUpper
in dupeTracker
) {
1418 dupeTracker
[cardUpper
] = true;
1420 if (dupes
.length
> 0) {
1421 var dupeWord
= "duplicates";
1422 if (dupes
.length
== 1) {
1423 dupeWord
= "duplicate";
1425 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1426 if (dupes
.length
> 3) {
1429 cardDetail
.push(msg
);
1432 var uniqueCards
= [];
1433 for (var uniqueCard
in dupeTracker
) {
1434 uniqueCards
.push(uniqueCard
);
1436 if (uniqueCards
.length
== 52) {
1437 cardDetail
.unshift("full deck");
1439 // Detect missing cards
1440 var values
= "A23456789TJQK";
1442 var missingCards
= [];
1443 for (var i
=0; i
<suits
.length
; i
++) {
1444 for (var j
=0; j
<values
.length
; j
++) {
1445 var card
= values
[j
] + suits
[i
];
1446 if (!(card
in dupeTracker
)) {
1447 missingCards
.push(card
);
1451 // Display missing cards if six or less, ie clearly going for full deck
1452 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1453 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1454 if (missingCards
.length
> 3) {
1457 cardDetail
.push(msg
);
1459 // Add card details to typeStr
1460 if (cardDetail
.length
> 0) {
1461 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1467 function setQrEvents(els
) {
1468 els
.on("mouseenter", createQr
);
1469 els
.on("mouseleave", destroyQr
);
1470 els
.on("click", toggleQr
);
1473 function createQr(e
) {
1474 var content
= e
.target
.textContent
|| e
.target
.value
;
1482 DOM
.qrImage
.append(qrEl
);
1484 DOM
.qrHider
.addClass("hidden");
1487 DOM
.qrHider
.removeClass("hidden");
1489 DOM
.qrContainer
.removeClass("hidden");
1493 function destroyQr() {
1494 DOM
.qrImage
.text("");
1495 DOM
.qrContainer
.addClass("hidden");
1498 function toggleQr() {
1500 DOM
.qrHider
.toggleClass("hidden");
1501 DOM
.qrHint
.toggleClass("hidden");
1504 function bip44TabSelected() {
1505 return DOM
.bip44tab
.hasClass("active");
1508 function bip32TabSelected() {
1509 return DOM
.bip32tab
.hasClass("active");
1512 function networkHasSegwit() {
1514 if ("baseNetwork" in network
) {
1515 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1517 // check if only p2wpkh params are required
1518 if (p2wpkhSelected()) {
1519 return "p2wpkh" in n
;
1521 // check if only p2wpkh-in-p2sh params are required
1522 else if (p2wpkhInP2shSelected()) {
1523 return "p2wpkhInP2sh" in n
;
1525 // require both if it's unclear which params are required
1526 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1529 function bip49TabSelected() {
1530 return DOM
.bip49tab
.hasClass("active");
1533 function bip84TabSelected() {
1534 return DOM
.bip84tab
.hasClass("active");
1537 function bip141TabSelected() {
1538 return DOM
.bip141tab
.hasClass("active");
1541 function setHdCoin(coinValue
) {
1542 DOM
.bip44coin
.val(coinValue
);
1543 DOM
.bip49coin
.val(coinValue
);
1544 DOM
.bip84coin
.val(coinValue
);
1547 function showSegwitAvailable() {
1548 DOM
.bip49unavailable
.addClass("hidden");
1549 DOM
.bip49available
.removeClass("hidden");
1550 DOM
.bip84unavailable
.addClass("hidden");
1551 DOM
.bip84available
.removeClass("hidden");
1552 DOM
.bip141unavailable
.addClass("hidden");
1553 DOM
.bip141available
.removeClass("hidden");
1556 function showSegwitUnavailable() {
1557 DOM
.bip49available
.addClass("hidden");
1558 DOM
.bip49unavailable
.removeClass("hidden");
1559 DOM
.bip84available
.addClass("hidden");
1560 DOM
.bip84unavailable
.removeClass("hidden");
1561 DOM
.bip141available
.addClass("hidden");
1562 DOM
.bip141unavailable
.removeClass("hidden");
1565 function adjustNetworkForSegwit() {
1566 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1567 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1569 // See https://github.com/iancoleman/bip39/issues/125
1570 var segwitNetworks
= null;
1571 // if a segwit network is alread selected, need to use base network to
1572 // look up new parameters
1573 if ("baseNetwork" in network
) {
1574 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1576 // choose the right segwit params
1577 if (p2wpkhSelected() && "p2wpkh" in network
) {
1578 network
= network
.p2wpkh
;
1580 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1581 network
= network
.p2wpkhInP2sh
;
1585 function lastIndexInTable() {
1586 var pathText
= DOM
.addresses
.find(".index").last().text();
1587 var pathBits
= pathText
.split("/");
1588 var lastBit
= pathBits
[pathBits
.length
-1];
1589 var lastBitClean
= lastBit
.replace("'", "");
1590 return parseInt(lastBitClean
);
1593 function uint8ArrayToHex(a
) {
1595 for (var i
=0; i
<a
.length
; i
++) {
1596 var h
= a
[i
].toString(16);
1597 while (h
.length
< 2) {
1605 function showWordIndexes() {
1606 var phrase
= DOM
.phrase
.val();
1607 var words
= phraseToWordArray(phrase
);
1608 var wordIndexes
= [];
1609 var language
= getLanguage();
1610 for (var i
=0; i
<words
.length
; i
++) {
1611 var word
= words
[i
];
1612 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1613 wordIndexes
.push(wordIndex
);
1615 var wordIndexesStr
= wordIndexes
.join(", ");
1616 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1619 function showChecksum() {
1620 var phrase
= DOM
.phrase
.val();
1621 var words
= phraseToWordArray(phrase
);
1622 var checksumBitlength
= words
.length
/ 3;
1625 var language
= getLanguage();
1626 for (var i
=words
.length
-1; i
>=0; i
--) {
1627 var word
= words
[i
];
1628 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1629 var wordBinary
= wordIndex
.toString(2);
1630 while (wordBinary
.length
< 11) {
1631 wordBinary
= "0" + wordBinary
;
1633 var binaryStr
= wordBinary
+ binaryStr
;
1634 if (binaryStr
.length
>= checksumBitlength
) {
1635 var start
= binaryStr
.length
- checksumBitlength
;
1636 var end
= binaryStr
.length
;
1637 checksum
= binaryStr
.substring(start
, end
);
1638 // add spaces so the last group is 11 bits, not the first
1639 checksum
= checksum
.split("").reverse().join("")
1640 checksum
= addSpacesEveryElevenBits(checksum
);
1641 checksum
= checksum
.split("").reverse().join("")
1645 DOM
.entropyChecksum
.text(checksum
);
1648 function updateCsv() {
1649 var tableCsv
= "path,address,public key,private key\n";
1650 var rows
= DOM
.addresses
.find("tr");
1651 for (var i
=0; i
<rows
.length
; i
++) {
1652 var row
= $(rows
[i
]);
1653 var cells
= row
.find("td");
1654 for (var j
=0; j
<cells
.length
; j
++) {
1655 var cell
= $(cells
[j
]);
1656 if (!cell
.children().hasClass("invisible")) {
1657 tableCsv
= tableCsv
+ cell
.text();
1659 if (j
!= cells
.length
- 1) {
1660 tableCsv
= tableCsv
+ ",";
1663 tableCsv
= tableCsv
+ "\n";
1665 DOM
.csv
.val(tableCsv
);
1668 function addSpacesEveryElevenBits(binaryStr
) {
1669 return binaryStr
.match(/.{1,11}/g).join(" ");
1674 name: "AC - Asiacoin",
1675 onSelect: function() {
1676 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1681 name: "ACC - Adcoin",
1682 onSelect: function() {
1683 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1688 name: "AUR - Auroracoin",
1689 onSelect: function() {
1690 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1696 onSelect: function() {
1697 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1702 name: "ANON - ANON",
1703 onSelect: function() {
1704 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1709 name: "BOLI - Bolivarcoin",
1710 onSelect: function() {
1711 network
= bitcoinjs
.bitcoin
.networks
.bolivarcoin
;
1716 name: "BCA - Bitcoin Atom",
1717 onSelect: function() {
1718 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1723 name: "BCH - Bitcoin Cash",
1724 onSelect: function() {
1725 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1730 name: "BEET - Beetlecoin",
1731 onSelect: function() {
1732 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1737 name: "BELA - Belacoin",
1738 onSelect: function() {
1739 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1744 name: "BLK - BlackCoin",
1745 onSelect: function() {
1746 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1751 name: "BND - Blocknode",
1752 onSelect: function() {
1753 network
= bitcoinjs
.bitcoin
.networks
.blocknode
;
1758 name: "tBND - Blocknode Testnet",
1759 onSelect: function() {
1760 network
= bitcoinjs
.bitcoin
.networks
.blocknode_testnet
;
1765 name: "BRIT - Britcoin",
1766 onSelect: function() {
1767 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
1772 name: "BSD - Bitsend",
1773 onSelect: function() {
1774 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
1779 name: "BST - BlockStamp",
1780 onSelect: function() {
1781 network
= bitcoinjs
.bitcoin
.networks
.blockstamp
;
1787 onSelect: function() {
1788 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1793 name: "BTC - Bitcoin",
1794 onSelect: function() {
1795 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1800 name: "BTC - Bitcoin Testnet",
1801 onSelect: function() {
1802 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1807 name: "BITG - Bitcoin Green",
1808 onSelect: function() {
1809 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1814 name: "BTCP - Bitcoin Private",
1815 onSelect: function() {
1816 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
1821 name: "BTCZ - Bitcoinz",
1822 onSelect: function() {
1823 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
1828 name: "BTDX - BitCloud",
1829 onSelect: function() {
1830 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
1835 name: "BTG - Bitcoin Gold",
1836 onSelect: function() {
1837 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
1842 name: "BTX - Bitcore",
1843 onSelect: function() {
1844 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
1849 name: "CCN - Cannacoin",
1850 onSelect: function() {
1851 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1856 name: "CESC - Cryptoescudo",
1857 onSelect: function() {
1858 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1863 name: "CDN - Canadaecoin",
1864 onSelect: function() {
1865 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
1870 name: "CLAM - Clams",
1871 onSelect: function() {
1872 network
= bitcoinjs
.bitcoin
.networks
.clam
;
1877 name: "CLO - Callisto",
1878 segwitAvailable: false,
1879 onSelect: function() {
1880 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1885 name: "CLUB - Clubcoin",
1886 onSelect: function() {
1887 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
1892 name: "CMP - Compcoin",
1893 onSelect: function() {
1894 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
1899 name: "CRAVE - Crave",
1900 onSelect: function() {
1901 network
= bitcoinjs
.bitcoin
.networks
.crave
;
1906 name: "CRW - Crown (Legacy)",
1907 onSelect: function() {
1908 network
= bitcoinjs
.bitcoin
.networks
.crown
;
1913 name: "CRW - Crown",
1914 onSelect: function() {
1915 network
= bitcoinjs
.bitcoin
.networks
.crown
;
1920 name: "DASH - Dash",
1921 onSelect: function() {
1922 network
= bitcoinjs
.bitcoin
.networks
.dash
;
1927 name: "DASH - Dash Testnet",
1928 onSelect: function() {
1929 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
1934 name: "DFC - Defcoin",
1935 onSelect: function() {
1936 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
1941 name: "DGB - Digibyte",
1942 onSelect: function() {
1943 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
1948 name: "DGC - Digitalcoin",
1949 onSelect: function() {
1950 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
1955 name: "DMD - Diamond",
1956 onSelect: function() {
1957 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
1962 name: "DNR - Denarius",
1963 onSelect: function() {
1964 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
1969 name: "DOGE - Dogecoin",
1970 onSelect: function() {
1971 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
1976 name: "DXN - DEXON",
1977 onSelect: function() {
1978 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1983 name: "ECN - Ecoin",
1984 onSelect: function() {
1985 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
1990 name: "EDRC - Edrcoin",
1991 onSelect: function() {
1992 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
1997 name: "EFL - Egulden",
1998 onSelect: function() {
1999 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
2004 name: "ELLA - Ellaism",
2005 segwitAvailable: false,
2006 onSelect: function() {
2007 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2012 name: "EMC2 - Einsteinium",
2013 onSelect: function() {
2014 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
2019 name: "ERC - Europecoin",
2020 onSelect: function() {
2021 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
2026 name: "ESN - Ethersocial Network",
2027 segwitAvailable: false,
2028 onSelect: function() {
2029 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2034 name: "ETC - Ethereum Classic",
2035 segwitAvailable: false,
2036 onSelect: function() {
2037 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2042 name: "ETH - Ethereum",
2043 onSelect: function() {
2044 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2049 name: "EXCL - Exclusivecoin",
2050 onSelect: function() {
2051 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
2056 name: "EXCC - ExchangeCoin",
2057 onSelect: function() {
2058 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
2063 name: "EXP - Expanse",
2064 segwitAvailable: false,
2065 onSelect: function() {
2066 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2071 name: "FJC - Fujicoin",
2072 onSelect: function() {
2073 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2078 name: "FLASH - Flashcoin",
2079 onSelect: function() {
2080 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2085 name: "FRST - Firstcoin",
2086 onSelect: function() {
2087 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2092 name: "FTC - Feathercoin",
2093 onSelect: function() {
2094 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2099 name: "GAME - GameCredits",
2100 onSelect: function() {
2101 network
= bitcoinjs
.bitcoin
.networks
.game
;
2106 name: "GBX - Gobyte",
2107 onSelect: function() {
2108 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2113 name: "GCR - GCRCoin",
2114 onSelect: function() {
2115 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2120 name: "GRC - Gridcoin",
2121 onSelect: function() {
2122 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2127 name: "HNC - Helleniccoin",
2128 onSelect: function() {
2129 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2134 name: "HUSH - Hush",
2135 onSelect: function() {
2136 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2141 name: "INSN - Insane",
2142 onSelect: function() {
2143 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2149 onSelect: function() {
2150 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2155 name: "IXC - Ixcoin",
2156 onSelect: function() {
2157 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2162 name: "JBS - Jumbucks",
2163 onSelect: function() {
2164 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2169 name: "KMD - Komodo",
2170 bip49available: false,
2171 onSelect: function() {
2172 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2177 name: "KOBO - Kobocoin",
2178 bip49available: false,
2179 onSelect: function() {
2180 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2185 name: "LBC - Library Credits",
2186 onSelect: function() {
2187 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2192 name: "LCC - Litecoincash",
2193 onSelect: function() {
2194 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2199 name: "LDCN - Landcoin",
2200 onSelect: function() {
2201 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2206 name: "LINX - Linx",
2207 onSelect: function() {
2208 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2213 name: "LKR - Lkrcoin",
2214 segwitAvailable: false,
2215 onSelect: function() {
2216 network
= bitcoinjs
.bitcoin
.networks
.lkrcoin
;
2221 name: "LTC - Litecoin",
2222 onSelect: function() {
2223 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2225 DOM
.litecoinLtubContainer
.removeClass("hidden");
2229 name: "LTZ - LitecoinZ",
2230 onSelect: function() {
2231 network
= bitcoinjs
.bitcoin
.networks
.litecoinz
;
2236 name: "LYNX - Lynx",
2237 onSelect: function() {
2238 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2243 name: "MAZA - Maza",
2244 onSelect: function() {
2245 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2250 name: "MEC - Megacoin",
2251 onSelect: function() {
2252 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2258 segwitAvailable: false,
2259 onSelect: function() {
2260 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2265 name: "MNX - Minexcoin",
2266 onSelect: function() {
2267 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2272 name: "MONA - Monacoin",
2273 onSelect: function() {
2274 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2279 name: "MUSIC - Musicoin",
2280 segwitAvailable: false,
2281 onSelect: function() {
2282 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2287 name: "NAV - Navcoin",
2288 onSelect: function() {
2289 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2294 name: "NAS - Nebulas",
2295 onSelect: function() {
2296 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2301 name: "NEBL - Neblio",
2302 onSelect: function() {
2303 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2308 name: "NEOS - Neoscoin",
2309 onSelect: function() {
2310 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2315 name: "NIX - NIX Platform",
2316 onSelect: function() {
2317 network
= bitcoinjs
.bitcoin
.networks
.nix
;
2322 name: "NLG - Gulden",
2323 onSelect: function() {
2324 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2329 name: "NMC - Namecoin",
2330 onSelect: function() {
2331 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2336 name: "NRG - Energi",
2337 onSelect: function() {
2338 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2343 name: "NRO - Neurocoin",
2344 onSelect: function() {
2345 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2350 name: "NSR - Nushares",
2351 onSelect: function() {
2352 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2357 name: "NYC - Newyorkc",
2358 onSelect: function() {
2359 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2364 name: "NVC - Novacoin",
2365 onSelect: function() {
2366 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2371 name: "OK - Okcash",
2372 onSelect: function() {
2373 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2378 name: "OMNI - Omnicore",
2379 onSelect: function() {
2380 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2385 name: "ONX - Onixcoin",
2386 onSelect: function() {
2387 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2392 name: "PHR - Phore",
2393 onSelect: function() {
2394 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2399 name: "PINK - Pinkcoin",
2400 onSelect: function() {
2401 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2406 name: "PIRL - Pirl",
2407 segwitAvailable: false,
2408 onSelect: function() {
2409 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2414 name: "PIVX - PIVX",
2415 onSelect: function() {
2416 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2421 name: "PIVX - PIVX Testnet",
2422 onSelect: function() {
2423 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2429 segwitAvailable: false,
2430 onSelect: function() {
2431 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2436 name: "POSW - POSWcoin",
2437 onSelect: function() {
2438 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2443 name: "POT - Potcoin",
2444 onSelect: function() {
2445 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2450 name: "PPC - Peercoin",
2451 onSelect: function() {
2452 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2457 name: "PRJ - ProjectCoin",
2458 onSelect: function() {
2459 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2464 name: "PSB - Pesobit",
2465 onSelect: function() {
2466 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2471 name: "PUT - Putincoin",
2472 onSelect: function() {
2473 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2478 name: "RVN - Ravencoin",
2479 onSelect: function() {
2480 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2485 name: "RBY - Rubycoin",
2486 onSelect: function() {
2487 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2492 name: "RDD - Reddcoin",
2493 onSelect: function() {
2494 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2499 name: "RVR - RevolutionVR",
2500 onSelect: function() {
2501 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2506 name: "SAFE - Safecoin",
2507 onSelect: function() {
2508 network
= bitcoinjs
.bitcoin
.networks
.safecoin
;
2513 name: "SLS - Salus",
2514 onSelect: function() {
2515 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2520 name: "SDC - ShadowCash",
2521 onSelect: function() {
2522 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2527 name: "SDC - ShadowCash Testnet",
2528 onSelect: function() {
2529 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2534 name: "SLM - Slimcoin",
2535 onSelect: function() {
2536 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2541 name: "SLM - Slimcoin Testnet",
2542 onSelect: function() {
2543 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2548 name: "SLP - Simple Ledger Protocol",
2549 onSelect: function() {
2550 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2555 name: "SLR - Solarcoin",
2556 onSelect: function() {
2557 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2562 name: "SMLY - Smileycoin",
2563 onSelect: function() {
2564 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2569 name: "STASH - Stash",
2570 onSelect: function() {
2571 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2576 name: "STASH - Stash Testnet",
2577 onSelect: function() {
2578 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2583 name: "STRAT - Stratis",
2584 onSelect: function() {
2585 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2590 name: "TSTRAT - Stratis Testnet",
2591 onSelect: function() {
2592 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2597 name: "SYS - Syscoin",
2598 onSelect: function() {
2599 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2604 name: "THC - Hempcoin",
2605 onSelect: function() {
2606 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2612 onSelect: function() {
2613 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2618 name: "USC - Ultimatesecurecash",
2619 onSelect: function() {
2620 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2625 name: "USNBT - NuBits",
2626 onSelect: function() {
2627 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2632 name: "UNO - Unobtanium",
2633 onSelect: function() {
2634 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2639 name: "VASH - Vpncoin",
2640 onSelect: function() {
2641 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2646 name: "VIA - Viacoin",
2647 onSelect: function() {
2648 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2653 name: "VIA - Viacoin Testnet",
2654 onSelect: function() {
2655 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2660 name: "VIVO - Vivo",
2661 onSelect: function() {
2662 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2667 name: "VTC - Vertcoin",
2668 onSelect: function() {
2669 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2674 name: "WC - Wincoin",
2675 onSelect: function() {
2676 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2681 name: "XAX - Artax",
2682 onSelect: function() {
2683 network
= bitcoinjs
.bitcoin
.networks
.artax
;
2688 name: "XBC - Bitcoinplus",
2689 onSelect: function() {
2690 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
2695 name: "XLM - Stellar",
2696 onSelect: function() {
2697 network
= ''; // doesn't apply, using stellar-lib
2702 name: "XMY - Myriadcoin",
2703 onSelect: function() {
2704 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
2709 name: "XRP - Ripple",
2710 onSelect: function() {
2711 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2716 name: "XVC - Vcash",
2717 onSelect: function() {
2718 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
2723 name: "XVG - Verge",
2724 onSelect: function() {
2725 network
= bitcoinjs
.bitcoin
.networks
.verge
;
2730 name: "XUEZ - Xuez",
2731 segwitAvailable: false,
2732 onSelect: function() {
2733 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
2738 name: "XWC - Whitecoin",
2739 onSelect: function() {
2740 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
2745 name: "XZC - Zcoin",
2746 onSelect: function() {
2747 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
2752 name: "ZCL - Zclassic",
2753 onSelect: function() {
2754 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
2759 name: "ZEC - Zcash",
2760 onSelect: function() {
2761 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
2766 name: "ZEN - Zencash",
2767 onSelect: function() {
2768 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
2776 name: "Bitcoin Core",
2777 onSelect: function() {
2778 DOM
.bip32path
.val("m/0'/0'");
2779 DOM
.hardenedAddresses
.prop('checked', true);
2783 name: "blockchain.info",
2784 onSelect: function() {
2785 DOM
.bip32path
.val("m/44'/0'/0'");
2786 DOM
.hardenedAddresses
.prop('checked', false);
2790 name: "MultiBit HD",
2791 onSelect: function() {
2792 DOM
.bip32path
.val("m/0'/0");
2793 DOM
.hardenedAddresses
.prop('checked', false);
2797 name: "Coinomi, Ledger",
2798 onSelect: function() {
2799 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
2800 DOM
.hardenedAddresses
.prop('checked', false);