3 // mnemonics is populated as required by getLanguage
4 var mnemonics
= { "english": new Mnemonic("english") };
5 var mnemonic
= mnemonics
["english"];
7 var bip32RootKey
= null;
8 var bip32ExtendedKey
= null;
9 var network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
10 var addressRowTemplate
= $("#address-row-template");
13 var showAddress
= true;
14 var showPubKey
= true;
15 var showPrivKey
= true;
17 var litecoinUseLtub
= true;
19 var entropyChangeTimeoutEvent
= null;
20 var phraseChangeTimeoutEvent
= null;
21 var rootKeyChangedTimeoutEvent
= null;
23 var generationProcesses
= [];
26 DOM
.privacyScreenToggle
= $(".privacy-screen-toggle");
27 DOM
.network
= $(".network");
28 DOM
.bip32Client
= $("#bip32-client");
29 DOM
.phraseNetwork
= $("#network-phrase");
30 DOM
.useEntropy
= $(".use-entropy");
31 DOM
.entropyContainer
= $(".entropy-container");
32 DOM
.entropy
= $(".entropy");
33 DOM
.entropyFiltered
= DOM
.entropyContainer
.find(".filtered");
34 DOM
.entropyType
= DOM
.entropyContainer
.find(".type");
35 DOM
.entropyCrackTime
= DOM
.entropyContainer
.find(".crack-time");
36 DOM
.entropyEventCount
= DOM
.entropyContainer
.find(".event-count");
37 DOM
.entropyBits
= DOM
.entropyContainer
.find(".bits");
38 DOM
.entropyBitsPerEvent
= DOM
.entropyContainer
.find(".bits-per-event");
39 DOM
.entropyWordCount
= DOM
.entropyContainer
.find(".word-count");
40 DOM
.entropyBinary
= DOM
.entropyContainer
.find(".binary");
41 DOM
.entropyWordIndexes
= DOM
.entropyContainer
.find(".word-indexes");
42 DOM
.entropyChecksum
= DOM
.entropyContainer
.find(".checksum");
43 DOM
.entropyMnemonicLength
= DOM
.entropyContainer
.find(".mnemonic-length");
44 DOM
.entropyWeakEntropyOverrideWarning
= DOM
.entropyContainer
.find(".weak-entropy-override-warning");
45 DOM
.entropyFilterWarning
= DOM
.entropyContainer
.find(".filter-warning");
46 DOM
.phrase
= $(".phrase");
47 DOM
.splitPhrase
= $(".phraseSplit");
48 DOM
.phraseSplitWarn
= $(".phraseSplitWarn");
49 DOM
.passphrase
= $(".passphrase");
50 DOM
.generateContainer
= $(".generate-container");
51 DOM
.generate
= $(".generate");
52 DOM
.seed
= $(".seed");
53 DOM
.rootKey
= $(".root-key");
54 DOM
.litecoinLtubContainer
= $(".litecoin-ltub-container");
55 DOM
.litecoinUseLtub
= $(".litecoin-use-ltub");
56 DOM
.extendedPrivKey
= $(".extended-priv-key");
57 DOM
.extendedPubKey
= $(".extended-pub-key");
58 DOM
.bip32tab
= $("#bip32-tab");
59 DOM
.bip44tab
= $("#bip44-tab");
60 DOM
.bip49tab
= $("#bip49-tab");
61 DOM
.bip84tab
= $("#bip84-tab");
62 DOM
.bip141tab
= $("#bip141-tab");
63 DOM
.bip32panel
= $("#bip32");
64 DOM
.bip44panel
= $("#bip44");
65 DOM
.bip49panel
= $("#bip49");
66 DOM
.bip32path
= $("#bip32-path");
67 DOM
.bip44path
= $("#bip44-path");
68 DOM
.bip44purpose
= $("#bip44 .purpose");
69 DOM
.bip44coin
= $("#bip44 .coin");
70 DOM
.bip44account
= $("#bip44 .account");
71 DOM
.bip44accountXprv
= $("#bip44 .account-xprv");
72 DOM
.bip44accountXpub
= $("#bip44 .account-xpub");
73 DOM
.bip44change
= $("#bip44 .change");
74 DOM
.bip49unavailable
= $("#bip49 .unavailable");
75 DOM
.bip49available
= $("#bip49 .available");
76 DOM
.bip49path
= $("#bip49-path");
77 DOM
.bip49purpose
= $("#bip49 .purpose");
78 DOM
.bip49coin
= $("#bip49 .coin");
79 DOM
.bip49account
= $("#bip49 .account");
80 DOM
.bip49accountXprv
= $("#bip49 .account-xprv");
81 DOM
.bip49accountXpub
= $("#bip49 .account-xpub");
82 DOM
.bip49change
= $("#bip49 .change");
83 DOM
.bip84unavailable
= $("#bip84 .unavailable");
84 DOM
.bip84available
= $("#bip84 .available");
85 DOM
.bip84path
= $("#bip84-path");
86 DOM
.bip84purpose
= $("#bip84 .purpose");
87 DOM
.bip84coin
= $("#bip84 .coin");
88 DOM
.bip84account
= $("#bip84 .account");
89 DOM
.bip84accountXprv
= $("#bip84 .account-xprv");
90 DOM
.bip84accountXpub
= $("#bip84 .account-xpub");
91 DOM
.bip84change
= $("#bip84 .change");
92 DOM
.bip141unavailable
= $("#bip141 .unavailable");
93 DOM
.bip141available
= $("#bip141 .available");
94 DOM
.bip141path
= $("#bip141-path");
95 DOM
.bip141semantics
= $(".bip141-semantics");
96 DOM
.generatedStrength
= $(".generate-container .strength");
97 DOM
.generatedStrengthWarning
= $(".generate-container .warning");
98 DOM
.hardenedAddresses
= $(".hardened-addresses");
99 DOM
.bitcoinCashAddressTypeContainer
= $(".bch-addr-type-container");
100 DOM
.bitcoinCashAddressType
= $("[name=bch-addr-type]")
101 DOM
.useBip38
= $(".use-bip38");
102 DOM
.bip38Password
= $(".bip38-password");
103 DOM
.addresses
= $(".addresses");
104 DOM
.csvTab
= $("#csv-tab a");
106 DOM
.rowsToAdd
= $(".rows-to-add");
107 DOM
.more
= $(".more");
108 DOM
.moreRowsStartIndex
= $(".more-rows-start-index");
109 DOM
.feedback
= $(".feedback");
110 DOM
.tab
= $(".derivation-type a");
111 DOM
.indexToggle
= $(".index-toggle");
112 DOM
.addressToggle
= $(".address-toggle");
113 DOM
.publicKeyToggle
= $(".public-key-toggle");
114 DOM
.privateKeyToggle
= $(".private-key-toggle");
115 DOM
.languages
= $(".languages a");
116 DOM
.qrContainer
= $(".qr-container");
117 DOM
.qrHider
= DOM
.qrContainer
.find(".qr-hider");
118 DOM
.qrImage
= DOM
.qrContainer
.find(".qr-image");
119 DOM
.qrHint
= DOM
.qrContainer
.find(".qr-hint");
120 DOM
.showQrEls
= $("[data-show-qr]");
124 DOM
.privacyScreenToggle
.on("change", privacyScreenToggled
);
125 DOM
.generatedStrength
.on("change", generatedStrengthChanged
);
126 DOM
.network
.on("change", networkChanged
);
127 DOM
.bip32Client
.on("change", bip32ClientChanged
);
128 DOM
.useEntropy
.on("change", setEntropyVisibility
);
129 DOM
.entropy
.on("input", delayedEntropyChanged
);
130 DOM
.entropyMnemonicLength
.on("change", entropyChanged
);
131 DOM
.phrase
.on("input", delayedPhraseChanged
);
132 DOM
.passphrase
.on("input", delayedPhraseChanged
);
133 DOM
.generate
.on("click", generateClicked
);
134 DOM
.more
.on("click", showMore
);
135 DOM
.rootKey
.on("input", delayedRootKeyChanged
);
136 DOM
.litecoinUseLtub
.on("change", litecoinUseLtubChanged
);
137 DOM
.bip32path
.on("input", calcForDerivationPath
);
138 DOM
.bip44account
.on("input", calcForDerivationPath
);
139 DOM
.bip44change
.on("input", calcForDerivationPath
);
140 DOM
.bip49account
.on("input", calcForDerivationPath
);
141 DOM
.bip49change
.on("input", calcForDerivationPath
);
142 DOM
.bip84account
.on("input", calcForDerivationPath
);
143 DOM
.bip84change
.on("input", calcForDerivationPath
);
144 DOM
.bip141path
.on("input", calcForDerivationPath
);
145 DOM
.bip141semantics
.on("change", tabChanged
);
146 DOM
.tab
.on("shown.bs.tab", tabChanged
);
147 DOM
.hardenedAddresses
.on("change", calcForDerivationPath
);
148 DOM
.useBip38
.on("change", calcForDerivationPath
);
149 DOM
.bip38Password
.on("change", calcForDerivationPath
);
150 DOM
.indexToggle
.on("click", toggleIndexes
);
151 DOM
.addressToggle
.on("click", toggleAddresses
);
152 DOM
.publicKeyToggle
.on("click", togglePublicKeys
);
153 DOM
.privateKeyToggle
.on("click", togglePrivateKeys
);
154 DOM
.csvTab
.on("click", updateCsv
);
155 DOM
.languages
.on("click", languageChanged
);
156 DOM
.bitcoinCashAddressType
.on("change", bitcoinCashAddressTypeChange
);
157 setQrEvents(DOM
.showQrEls
);
160 hideValidationError();
161 populateNetworkSelect();
162 populateClientSelect();
167 function generatedStrengthChanged() {
168 var strength
= parseInt(DOM
.generatedStrength
.val());
170 DOM
.generatedStrengthWarning
.removeClass("hidden");
173 DOM
.generatedStrengthWarning
.addClass("hidden");
177 function networkChanged(e
) {
179 clearAddressesList();
180 DOM
.litecoinLtubContainer
.addClass("hidden");
181 DOM
.bitcoinCashAddressTypeContainer
.addClass("hidden");
182 var networkIndex
= e
.target
.value
;
183 var network
= networks
[networkIndex
];
185 adjustNetworkForSegwit();
194 function bip32ClientChanged(e
) {
195 var clientIndex
= DOM
.bip32Client
.val();
196 if (clientIndex
== "custom") {
197 DOM
.bip32path
.prop("readonly", false);
200 DOM
.bip32path
.prop("readonly", true);
201 clients
[clientIndex
].onSelect();
211 function setEntropyVisibility() {
212 if (isUsingOwnEntropy()) {
213 DOM
.entropyContainer
.removeClass("hidden");
214 DOM
.generateContainer
.addClass("hidden");
215 DOM
.phrase
.prop("readonly", true);
220 DOM
.entropyContainer
.addClass("hidden");
221 DOM
.generateContainer
.removeClass("hidden");
222 DOM
.phrase
.prop("readonly", false);
227 function delayedPhraseChanged() {
228 hideValidationError();
231 bip32ExtendedKey
= null;
232 clearAddressesList();
234 if (phraseChangeTimeoutEvent
!= null) {
235 clearTimeout(phraseChangeTimeoutEvent
);
237 phraseChangeTimeoutEvent
= setTimeout(phraseChanged
, 400);
240 function phraseChanged() {
242 setMnemonicLanguage();
243 // Get the mnemonic phrase
244 var phrase
= DOM
.phrase
.val();
245 var errorText
= findPhraseErrors(phrase
);
247 showValidationError(errorText
);
250 // Calculate and display
251 var passphrase
= DOM
.passphrase
.val();
252 calcBip32RootKeyFromSeed(phrase
, passphrase
);
253 calcForDerivationPath();
254 // Show the word indexes
258 function tabChanged() {
260 adjustNetworkForSegwit();
261 var phrase
= DOM
.phrase
.val();
263 // Calculate and display for mnemonic
264 var errorText
= findPhraseErrors(phrase
);
266 showValidationError(errorText
);
269 // Calculate and display
270 var passphrase
= DOM
.passphrase
.val();
271 calcBip32RootKeyFromSeed(phrase
, passphrase
);
274 // Calculate and display for root key
275 var rootKeyBase58
= DOM
.rootKey
.val();
276 var errorText
= validateRootKey(rootKeyBase58
);
278 showValidationError(errorText
);
281 // Calculate and display
282 calcBip32RootKeyFromBase58(rootKeyBase58
);
284 calcForDerivationPath();
287 function delayedEntropyChanged() {
288 hideValidationError();
290 if (entropyChangeTimeoutEvent
!= null) {
291 clearTimeout(entropyChangeTimeoutEvent
);
293 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
296 function entropyChanged() {
297 // If blank entropy, clear mnemonic, addresses, errors
298 if (DOM
.entropy
.val().trim().length
== 0) {
300 clearEntropyFeedback();
302 DOM
.phraseSplit
.val("");
303 showValidationError("Blank entropy");
306 // Get the current phrase to detect changes
307 var phrase
= DOM
.phrase
.val();
308 // Set the phrase from the entropy
309 setMnemonicFromEntropy();
310 // Recalc addresses if the phrase has changed
311 var newPhrase
= DOM
.phrase
.val();
312 if (newPhrase
!= phrase
) {
313 if (newPhrase
.length
== 0) {
325 function delayedRootKeyChanged() {
326 // Warn if there is an existing mnemonic or passphrase.
327 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
328 if (!confirm("This will clear existing mnemonic and passphrase")) {
329 DOM
.rootKey
.val(bip32RootKey
);
333 hideValidationError();
335 // Clear existing mnemonic and passphrase
337 DOM
.phraseSplit
.val("");
338 DOM
.passphrase
.val("");
340 if (rootKeyChangedTimeoutEvent
!= null) {
341 clearTimeout(rootKeyChangedTimeoutEvent
);
343 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
346 function rootKeyChanged() {
348 hideValidationError();
349 var rootKeyBase58
= DOM
.rootKey
.val();
350 var errorText
= validateRootKey(rootKeyBase58
);
352 showValidationError(errorText
);
355 // Calculate and display
356 calcBip32RootKeyFromBase58(rootKeyBase58
);
357 calcForDerivationPath();
360 function litecoinUseLtubChanged() {
361 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
362 if (litecoinUseLtub
) {
363 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
366 network
= bitcoinjs
.bitcoin
.networks
.litecoinXprv
;
371 function calcForDerivationPath() {
373 clearAddressesList();
375 // Don't show segwit if it's selected but network doesn't support it
376 if (segwitSelected() && !networkHasSegwit()) {
377 showSegwitUnavailable();
381 showSegwitAvailable();
382 // Get the derivation path
383 var derivationPath
= getDerivationPath();
384 var errorText
= findDerivationPathErrors(derivationPath
);
386 showValidationError(errorText
);
389 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
390 if (bip44TabSelected()) {
393 else if (bip49TabSelected()) {
396 else if (bip84TabSelected()) {
402 function generateClicked() {
403 if (isUsingOwnEntropy()) {
408 setTimeout(function() {
409 setMnemonicLanguage();
410 var phrase
= generateRandomPhrase();
418 function languageChanged() {
419 setTimeout(function() {
420 setMnemonicLanguage();
421 if (DOM
.phrase
.val().length
> 0) {
422 var newPhrase
= convertPhraseToNewLanguage();
423 DOM
.phrase
.val(newPhrase
);
424 writeSplitPhrase(newPhrase
);
428 DOM
.generate
.trigger("click");
433 function bitcoinCashAddressTypeChange() {
437 function toggleIndexes() {
438 showIndex
= !showIndex
;
439 $("td.index span").toggleClass("invisible");
442 function toggleAddresses() {
443 showAddress
= !showAddress
;
444 $("td.address span").toggleClass("invisible");
447 function togglePublicKeys() {
448 showPubKey
= !showPubKey
;
449 $("td.pubkey span").toggleClass("invisible");
452 function togglePrivateKeys() {
453 showPrivKey
= !showPrivKey
;
454 $("td.privkey span").toggleClass("invisible");
457 function privacyScreenToggled() {
458 // private-data contains elements added to DOM at runtime
459 // so catch all by adding visual privacy class to the root of the DOM
460 if (DOM
.privacyScreenToggle
.prop("checked")) {
461 $("body").addClass("visual-privacy");
464 $("body").removeClass("visual-privacy");
470 function generateRandomPhrase() {
471 if (!hasStrongRandom()) {
472 var errorText
= "This browser does not support strong randomness";
473 showValidationError(errorText
);
476 // get the amount of entropy to use
477 var numWords
= parseInt(DOM
.generatedStrength
.val());
478 var strength
= numWords
/ 3 * 32;
479 var buffer
= new Uint8Array(strength
/ 8);
480 // create secure entropy
481 var data
= crypto
.getRandomValues(buffer
);
483 var words
= mnemonic
.toMnemonic(data
);
484 DOM
.phrase
.val(words
);
485 writeSplitPhrase(words
);
487 var entropyHex
= uint8ArrayToHex(data
);
488 DOM
.entropy
.val(entropyHex
);
489 // ensure entropy fields are consistent with what is being displayed
490 DOM
.entropyMnemonicLength
.val("raw");
494 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
495 seed
= mnemonic
.toSeed(phrase
, passphrase
);
496 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
499 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
500 // try parsing with various segwit network params since this extended
501 // key may be from any one of them.
502 if (networkHasSegwit()) {
504 if ("baseNetwork" in n
) {
505 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
507 // try parsing using base network params
509 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
513 // try parsing using p2wpkh params
516 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
521 // try parsing using p2wpkh-in-p2sh network params
522 if ("p2wpkhInP2sh" in n
) {
524 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
530 // try the network params as currently specified
531 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
534 function calcBip32ExtendedKey(path
) {
535 // Check there's a root key to derive from
539 var extendedKey
= bip32RootKey
;
540 // Derive the key from the path
541 var pathBits
= path
.split("/");
542 for (var i
=0; i
<pathBits
.length
; i
++) {
543 var bit
= pathBits
[i
];
544 var index
= parseInt(bit
);
548 var hardened
= bit
[bit
.length
-1] == "'";
549 var isPriv
= !(extendedKey
.isNeutered());
550 var invalidDerivationPath
= hardened
&& !isPriv
;
551 if (invalidDerivationPath
) {
555 extendedKey
= extendedKey
.deriveHardened(index
);
558 extendedKey
= extendedKey
.derive(index
);
564 function showValidationError(errorText
) {
570 function hideValidationError() {
576 function findPhraseErrors(phrase
) {
577 // Preprocess the words
578 phrase
= mnemonic
.normalizeString(phrase
);
579 var words
= phraseToWordArray(phrase
);
580 // Detect blank phrase
581 if (words
.length
== 0) {
582 return "Blank mnemonic";
585 for (var i
=0; i
<words
.length
; i
++) {
587 var language
= getLanguage();
588 if (WORDLISTS
[language
].indexOf(word
) == -1) {
589 console
.log("Finding closest match to " + word
);
590 var nearestWord
= findNearestWord(word
);
591 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
594 // Check the words are valid
595 var properPhrase
= wordArrayToPhrase(words
);
596 var isValid
= mnemonic
.check(properPhrase
);
598 return "Invalid mnemonic";
603 function validateRootKey(rootKeyBase58
) {
604 // try various segwit network params since this extended key may be from
606 if (networkHasSegwit()) {
608 if ("baseNetwork" in n
) {
609 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
611 // try parsing using base network params
613 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
617 // try parsing using p2wpkh params
620 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
625 // try parsing using p2wpkh-in-p2sh network params
626 if ("p2wpkhInP2sh" in n
) {
628 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
634 // try the network params as currently specified
636 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
639 return "Invalid root key";
644 function getDerivationPath() {
645 if (bip44TabSelected()) {
646 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
647 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
648 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
649 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
651 path
+= purpose
+ "'/";
653 path
+= account
+ "'/";
655 DOM
.bip44path
.val(path
);
656 var derivationPath
= DOM
.bip44path
.val();
657 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
658 return derivationPath
;
660 else if (bip49TabSelected()) {
661 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
662 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
663 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
664 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
666 path
+= purpose
+ "'/";
668 path
+= account
+ "'/";
670 DOM
.bip49path
.val(path
);
671 var derivationPath
= DOM
.bip49path
.val();
672 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
673 return derivationPath
;
675 else if (bip84TabSelected()) {
676 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
677 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
678 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
679 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
681 path
+= purpose
+ "'/";
683 path
+= account
+ "'/";
685 DOM
.bip84path
.val(path
);
686 var derivationPath
= DOM
.bip84path
.val();
687 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
688 return derivationPath
;
690 else if (bip32TabSelected()) {
691 var derivationPath
= DOM
.bip32path
.val();
692 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
693 return derivationPath
;
695 else if (bip141TabSelected()) {
696 var derivationPath
= DOM
.bip141path
.val();
697 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
698 return derivationPath
;
701 console
.log("Unknown derivation path");
705 function findDerivationPathErrors(path
) {
706 // TODO is not perfect but is better than nothing
708 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
710 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
711 var maxDepth
= 255; // TODO verify this!!
712 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
713 if (path
[0] != "m") {
714 return "First character must be 'm'";
716 if (path
.length
> 1) {
717 if (path
[1] != "/") {
718 return "Separator must be '/'";
720 var indexes
= path
.split("/");
721 if (indexes
.length
> maxDepth
) {
722 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
724 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
725 var index
= indexes
[depth
];
726 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
727 if (invalidChars
.length
> 0) {
728 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
730 var indexValue
= parseInt(index
.replace("'", ""));
732 return "Invalid number at depth " + depth
;
734 if (indexValue
> maxIndexValue
) {
735 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
739 // Check root key exists or else derivation path is useless!
741 return "No root key";
743 // Check no hardened derivation path when using xpub keys
744 var hardenedPath
= path
.indexOf("'") > -1;
745 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
746 var hardened
= hardenedPath
|| hardenedAddresses
;
747 var isXpubkey
= bip32RootKey
.isNeutered();
748 if (hardened
&& isXpubkey
) {
749 return "Hardened derivation path is invalid with xpub key";
754 function displayBip44Info() {
755 // Get the derivation path for the account
756 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
757 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
758 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
760 path
+= purpose
+ "'/";
762 path
+= account
+ "'/";
763 // Calculate the account extended keys
764 var accountExtendedKey
= calcBip32ExtendedKey(path
);
765 var accountXprv
= accountExtendedKey
.toBase58();
766 var accountXpub
= accountExtendedKey
.neutered().toBase58();
767 // Display the extended keys
768 DOM
.bip44accountXprv
.val(accountXprv
);
769 DOM
.bip44accountXpub
.val(accountXpub
);
772 function displayBip49Info() {
773 // Get the derivation path for the account
774 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
775 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
776 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
778 path
+= purpose
+ "'/";
780 path
+= account
+ "'/";
781 // Calculate the account extended keys
782 var accountExtendedKey
= calcBip32ExtendedKey(path
);
783 var accountXprv
= accountExtendedKey
.toBase58();
784 var accountXpub
= accountExtendedKey
.neutered().toBase58();
785 // Display the extended keys
786 DOM
.bip49accountXprv
.val(accountXprv
);
787 DOM
.bip49accountXpub
.val(accountXpub
);
790 function displayBip84Info() {
791 // Get the derivation path for the account
792 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
793 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
794 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
796 path
+= purpose
+ "'/";
798 path
+= account
+ "'/";
799 // Calculate the account extended keys
800 var accountExtendedKey
= calcBip32ExtendedKey(path
);
801 var accountXprv
= accountExtendedKey
.toBase58();
802 var accountXpub
= accountExtendedKey
.neutered().toBase58();
803 // Display the extended keys
804 DOM
.bip84accountXprv
.val(accountXprv
);
805 DOM
.bip84accountXpub
.val(accountXpub
);
808 function displayBip32Info() {
811 var rootKey
= bip32RootKey
.toBase58();
812 DOM
.rootKey
.val(rootKey
);
813 var xprvkeyB58
= "NA";
814 if (!bip32ExtendedKey
.isNeutered()) {
815 xprvkeyB58
= bip32ExtendedKey
.toBase58();
817 var extendedPrivKey
= xprvkeyB58
;
818 DOM
.extendedPrivKey
.val(extendedPrivKey
);
819 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
820 DOM
.extendedPubKey
.val(extendedPubKey
);
821 // Display the addresses and privkeys
822 clearAddressesList();
823 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
824 displayAddresses(0, initialAddressCount
);
827 function displayAddresses(start
, total
) {
828 generationProcesses
.push(new (function() {
832 this.stop = function() {
833 for (var i
=0; i
<rows
.length
; i
++) {
834 rows
[i
].shouldGenerate
= false;
839 for (var i
=0; i
<total
; i
++) {
840 var index
= i
+ start
;
841 var isLast
= i
== total
- 1;
842 rows
.push(new TableRow(index
, isLast
));
848 function segwitSelected() {
849 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
852 function p2wpkhSelected() {
853 return bip84TabSelected() ||
854 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
857 function p2wpkhInP2shSelected() {
858 return bip49TabSelected() ||
859 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
862 function TableRow(index
, isLast
) {
865 this.shouldGenerate
= true;
866 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
867 var useBip38
= DOM
.useBip38
.prop("checked");
868 var bip38password
= DOM
.bip38Password
.val();
869 var isSegwit
= segwitSelected();
870 var segwitAvailable
= networkHasSegwit();
871 var isP2wpkh
= p2wpkhSelected();
872 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
878 function calculateValues() {
879 setTimeout(function() {
880 if (!self
.shouldGenerate
) {
883 // derive HDkey for this row of the table
885 if (useHardenedAddresses
) {
886 key
= bip32ExtendedKey
.deriveHardened(index
);
889 key
= bip32ExtendedKey
.derive(index
);
891 // bip38 requires uncompressed keys
892 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
893 var keyPair
= key
.keyPair
;
894 var useUncompressed
= useBip38
;
895 if (useUncompressed
) {
896 keyPair
= new bitcoinjs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
899 var address
= keyPair
.getAddress().toString();
901 var hasPrivkey
= !key
.isNeutered();
904 privkey
= keyPair
.toWIF();
905 // BIP38 encode private key if required
907 privkey
= bitcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
908 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
913 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
914 var indexText
= getDerivationPath() + "/" + index
;
915 if (useHardenedAddresses
) {
916 indexText
= indexText
+ "'";
918 // Ethereum values are different
919 if ((networks
[DOM
.network
.val()].name
== "ETH - Ethereum")
920 || (networks
[DOM
.network
.val()].name
== "ETC - Ethereum Classic")
921 || (networks
[DOM
.network
.val()].name
== "PIRL - Pirl")
922 || (networks
[DOM
.network
.val()].name
== "MIX - MIX")
923 || (networks
[DOM
.network
.val()].name
== "MUSIC - Musicoin")
924 || (networks
[DOM
.network
.val()].name
== "POA - Poa")
925 || (networks
[DOM
.network
.val()].name
== "EXP - Expanse")
926 || (networks
[DOM
.network
.val()].name
== "CLO - Callisto")) {
927 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
928 privkey
= privKeyBuffer
.toString('hex');
929 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
930 var hexAddress
= addressBuffer
.toString('hex');
931 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
932 address
= ethUtil
.addHexPrefix(checksumAddress
);
933 privkey
= ethUtil
.addHexPrefix(privkey
);
934 pubkey
= ethUtil
.addHexPrefix(pubkey
);
936 // Ripple values are different
937 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
938 privkey
= convertRipplePriv(privkey
);
939 address
= convertRippleAdrr(address
);
941 // Bitcoin Cash address format may vary
942 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
943 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
944 if (bchAddrType
== "cashaddr") {
945 address
= bchaddr
.toCashAddress(address
);
947 else if (bchAddrType
== "bitpay") {
948 address
= bchaddr
.toBitpayAddress(address
);
951 // Segwit addresses are different
953 if (!segwitAvailable
) {
957 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
958 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
959 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
961 else if (isP2wpkhInP2sh
) {
962 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
963 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
964 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
965 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
966 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
969 addAddressToList(indexText
, address
, pubkey
, privkey
);
981 function showMore() {
982 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
983 if (isNaN(rowsToAdd
)) {
985 DOM
.rowsToAdd
.val("20");
987 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
989 start
= lastIndexInTable() + 1;
992 var newStart
= start
+ rowsToAdd
;
993 DOM
.moreRowsStartIndex
.val(newStart
);
995 if (rowsToAdd
> 200) {
996 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
997 msg
+= "Do you want to continue?";
1002 displayAddresses(start
, rowsToAdd
);
1005 function clearDisplay() {
1006 clearAddressesList();
1008 hideValidationError();
1011 function clearAddressesList() {
1012 DOM
.addresses
.empty();
1017 function stopGenerating() {
1018 while (generationProcesses
.length
> 0) {
1019 var generation
= generationProcesses
.shift();
1024 function clearKeys() {
1029 function clearRootKey() {
1030 DOM
.rootKey
.val("");
1033 function clearDerivedKeys() {
1034 DOM
.extendedPrivKey
.val("");
1035 DOM
.extendedPubKey
.val("");
1036 DOM
.bip44accountXprv
.val("");
1037 DOM
.bip44accountXpub
.val("");
1040 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1041 var row
= $(addressRowTemplate
.html());
1043 var indexCell
= row
.find(".index span");
1044 var addressCell
= row
.find(".address span");
1045 var pubkeyCell
= row
.find(".pubkey span");
1046 var privkeyCell
= row
.find(".privkey span");
1048 indexCell
.text(indexText
);
1049 addressCell
.text(address
);
1050 pubkeyCell
.text(pubkey
);
1051 privkeyCell
.text(privkey
);
1054 indexCell
.addClass("invisible");
1057 addressCell
.addClass("invisible");
1060 pubkeyCell
.addClass("invisible");
1063 privkeyCell
.addClass("invisible");
1065 DOM
.addresses
.append(row
);
1066 var rowShowQrEls
= row
.find("[data-show-qr]");
1067 setQrEvents(rowShowQrEls
);
1070 function hasStrongRandom() {
1071 return 'crypto' in window
&& window
['crypto'] !== null;
1074 function disableForms() {
1075 $("form").on("submit", function(e
) {
1080 function parseIntNoNaN(val
, defaultVal
) {
1081 var v
= parseInt(val
);
1088 function showPending() {
1090 .text("Calculating...")
1094 function findNearestWord(word
) {
1095 var language
= getLanguage();
1096 var words
= WORDLISTS
[language
];
1097 var minDistance
= 99;
1098 var closestWord
= words
[0];
1099 for (var i
=0; i
<words
.length
; i
++) {
1100 var comparedTo
= words
[i
];
1101 if (comparedTo
.indexOf(word
) == 0) {
1104 var distance
= Levenshtein
.get(word
, comparedTo
);
1105 if (distance
< minDistance
) {
1106 closestWord
= comparedTo
;
1107 minDistance
= distance
;
1113 function hidePending() {
1119 function populateNetworkSelect() {
1120 for (var i
=0; i
<networks
.length
; i
++) {
1121 var network
= networks
[i
];
1122 var option
= $("<option>");
1123 option
.attr("value", i
);
1124 option
.text(network
.name
);
1125 if (network
.name
== "BTC - Bitcoin") {
1126 option
.prop("selected", true);
1128 DOM
.phraseNetwork
.append(option
);
1132 function populateClientSelect() {
1133 for (var i
=0; i
<clients
.length
; i
++) {
1134 var client
= clients
[i
];
1135 var option
= $("<option>");
1136 option
.attr("value", i
);
1137 option
.text(client
.name
);
1138 DOM
.bip32Client
.append(option
);
1142 function getLanguage() {
1143 var defaultLanguage
= "english";
1144 // Try to get from existing phrase
1145 var language
= getLanguageFromPhrase();
1146 // Try to get from url if not from phrase
1147 if (language
.length
== 0) {
1148 language
= getLanguageFromUrl();
1150 // Default to English if no other option
1151 if (language
.length
== 0) {
1152 language
= defaultLanguage
;
1157 function getLanguageFromPhrase(phrase
) {
1158 // Check if how many words from existing phrase match a language.
1161 phrase
= DOM
.phrase
.val();
1163 if (phrase
.length
> 0) {
1164 var words
= phraseToWordArray(phrase
);
1165 var languageMatches
= {};
1166 for (l
in WORDLISTS
) {
1167 // Track how many words match in this language
1168 languageMatches
[l
] = 0;
1169 for (var i
=0; i
<words
.length
; i
++) {
1170 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1171 if (wordInLanguage
) {
1172 languageMatches
[l
]++;
1175 // Find languages with most word matches.
1176 // This is made difficult due to commonalities between Chinese
1177 // simplified vs traditional.
1178 var mostMatches
= 0;
1179 var mostMatchedLanguages
= [];
1180 for (var l
in languageMatches
) {
1181 var numMatches
= languageMatches
[l
];
1182 if (numMatches
> mostMatches
) {
1183 mostMatches
= numMatches
;
1184 mostMatchedLanguages
= [l
];
1186 else if (numMatches
== mostMatches
) {
1187 mostMatchedLanguages
.push(l
);
1191 if (mostMatchedLanguages
.length
> 0) {
1192 // Use first language and warn if multiple detected
1193 language
= mostMatchedLanguages
[0];
1194 if (mostMatchedLanguages
.length
> 1) {
1195 console
.warn("Multiple possible languages");
1196 console
.warn(mostMatchedLanguages
);
1203 function getLanguageFromUrl() {
1204 for (var language
in WORDLISTS
) {
1205 if (window
.location
.hash
.indexOf(language
) > -1) {
1212 function setMnemonicLanguage() {
1213 var language
= getLanguage();
1214 // Load the bip39 mnemonic generator for this language if required
1215 if (!(language
in mnemonics
)) {
1216 mnemonics
[language
] = new Mnemonic(language
);
1218 mnemonic
= mnemonics
[language
];
1221 function convertPhraseToNewLanguage() {
1222 var oldLanguage
= getLanguageFromPhrase();
1223 var newLanguage
= getLanguageFromUrl();
1224 var oldPhrase
= DOM
.phrase
.val();
1225 var oldWords
= phraseToWordArray(oldPhrase
);
1227 for (var i
=0; i
<oldWords
.length
; i
++) {
1228 var oldWord
= oldWords
[i
];
1229 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1230 var newWord
= WORDLISTS
[newLanguage
][index
];
1231 newWords
.push(newWord
);
1233 newPhrase
= wordArrayToPhrase(newWords
);
1237 // TODO look at jsbip39 - mnemonic.splitWords
1238 function phraseToWordArray(phrase
) {
1239 var words
= phrase
.split(/\s/g);
1241 for (var i
=0; i
<words
.length
; i
++) {
1242 var word
= words
[i
];
1243 if (word
.length
> 0) {
1244 noBlanks
.push(word
);
1250 // TODO look at jsbip39 - mnemonic.joinWords
1251 function wordArrayToPhrase(words
) {
1252 var phrase
= words
.join(" ");
1253 var language
= getLanguageFromPhrase(phrase
);
1254 if (language
== "japanese") {
1255 phrase
= words
.join("\u3000");
1260 function writeSplitPhrase(phrase
) {
1261 var wordCount
= phrase
.split(/\s/g).length
; //get number of words in phrase
1262 var left
=[]; //initialize array of indexs
1263 for (var i
=0;i
<wordCount
;i
++) left
.push(i
); //add all indexs to array
1264 var group
=[[],[],[]], //make array for 3 groups
1265 groupI
=-1; //initialize group index
1266 var seed
= Math
.abs(sjcl
.hash
.sha256
.hash(phrase
)[0])% 2147483647; //start seed at sudo random value based on hash of words
1267 while (left
.length
>0) { //while indexs left
1268 groupI
=(groupI
+1)%3; //get next group to insert index into
1269 seed
= seed
* 16807 % 2147483647; //change random value.(simple predicatable random number generator works well for this use)
1270 var selected
=Math
.floor(left
.length
*(seed
- 1) / 2147483646); //get index in left we will use for this group
1271 group
[groupI
].push(left
[selected
]); //add index to group
1272 left
.splice(selected
,1); //remove selected index
1274 var cards
=[phrase
.split(/\s/g),phrase
.split(/\s/g),phrase
.split(/\s/g)];//make array of cards
1275 for (var i
=0;i
<3;i
++) { //go through each card
1276 for (var ii
=0;ii
<wordCount
/3;ii
++) cards
[i
][group
[i
][ii
]]='XXXX'; //erase words listed in the group
1277 cards
[i
]='Card '+(i
+1)+': '+wordArrayToPhrase(cards
[i
]); //combine words on card back to string
1279 DOM
.splitPhrase
.val(cards
.join("\r\n")); //make words visible
1280 var triesPerSecond
=10000000000; //assumed number of tries per second
1281 var hackTime
=Math
.pow(2,wordCount
*10/3)/triesPerSecond
; //get number of bits of unknown data per card
1283 hackTime
="<1 second";
1284 } else if (hackTime
<86400) {
1285 hackTime
=Math
.floor(hackTime
)+" seconds";
1286 } else if(hackTime
<31557600) {
1287 hackTime
=Math
.floor(hackTime
/86400)+" days";
1289 hackTime
=Math
.floor(hackTime
/31557600)+" years";
1291 DOM
.phraseSplitWarn
.html("Time to hack with only one card: "+hackTime
);
1294 function isUsingOwnEntropy() {
1295 return DOM
.useEntropy
.prop("checked");
1298 function setMnemonicFromEntropy() {
1299 clearEntropyFeedback();
1300 // Get entropy value
1301 var entropyStr
= DOM
.entropy
.val();
1302 // Work out minimum base for entropy
1303 var entropy
= Entropy
.fromString(entropyStr
);
1304 if (entropy
.binaryStr
.length
== 0) {
1307 // Show entropy details
1308 showEntropyFeedback(entropy
);
1309 // Use entropy hash if not using raw entropy
1310 var bits
= entropy
.binaryStr
;
1311 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1312 if (mnemonicLength
!= "raw") {
1313 // Get bits by hashing entropy with SHA256
1314 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1315 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1316 bits
= BigInteger
.parse(hex
, 16).toString(2);
1317 while (bits
.length
% 256 != 0) {
1320 // Truncate hash to suit number of words
1321 mnemonicLength
= parseInt(mnemonicLength
);
1322 var numberOfBits
= 32 * mnemonicLength
/ 3;
1323 bits
= bits
.substring(0, numberOfBits
);
1324 // show warning for weak entropy override
1325 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1326 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1329 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1333 // hide warning for weak entropy override
1334 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1336 // Discard trailing entropy
1337 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1338 var start
= bits
.length
- bitsToUse
;
1339 var binaryStr
= bits
.substring(start
);
1340 // Convert entropy string to numeric array
1341 var entropyArr
= [];
1342 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1343 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1344 var entropyByte
= parseInt(byteAsBits
, 2);
1345 entropyArr
.push(entropyByte
)
1347 // Convert entropy array to mnemonic
1348 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1349 // Set the mnemonic in the UI
1350 DOM
.phrase
.val(phrase
);
1351 writeSplitPhrase(phrase
);
1352 // Show the word indexes
1354 // Show the checksum
1358 function clearEntropyFeedback() {
1359 DOM
.entropyCrackTime
.text("...");
1360 DOM
.entropyType
.text("");
1361 DOM
.entropyWordCount
.text("0");
1362 DOM
.entropyEventCount
.text("0");
1363 DOM
.entropyBitsPerEvent
.text("0");
1364 DOM
.entropyBits
.text("0");
1365 DOM
.entropyFiltered
.html(" ");
1366 DOM
.entropyBinary
.html(" ");
1369 function showEntropyFeedback(entropy
) {
1370 var numberOfBits
= entropy
.binaryStr
.length
;
1371 var timeToCrack
= "unknown";
1373 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1374 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1375 if (z
.feedback
.warning
!= "") {
1376 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1380 console
.log("Error detecting entropy strength with zxcvbn:");
1383 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1384 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1385 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1386 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1387 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1388 DOM
.entropyType
.text(entropyTypeStr
);
1389 DOM
.entropyCrackTime
.text(timeToCrack
);
1390 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1391 DOM
.entropyBits
.text(numberOfBits
);
1392 DOM
.entropyWordCount
.text(wordCount
);
1393 DOM
.entropyBinary
.text(spacedBinaryStr
);
1394 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1395 // detect and warn of filtering
1396 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1397 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1398 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1400 DOM
.entropyFilterWarning
.removeClass('hidden');
1403 DOM
.entropyFilterWarning
.addClass('hidden');
1407 function getEntropyTypeStr(entropy
) {
1408 var typeStr
= entropy
.base
.str
;
1409 // Add some detail if these are cards
1410 if (entropy
.base
.asInt
== 52) {
1411 var cardDetail
= []; // array of message strings
1412 // Detect duplicates
1414 var dupeTracker
= {};
1415 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1416 var card
= entropy
.base
.parts
[i
];
1417 var cardUpper
= card
.toUpperCase();
1418 if (cardUpper
in dupeTracker
) {
1421 dupeTracker
[cardUpper
] = true;
1423 if (dupes
.length
> 0) {
1424 var dupeWord
= "duplicates";
1425 if (dupes
.length
== 1) {
1426 dupeWord
= "duplicate";
1428 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1429 if (dupes
.length
> 3) {
1432 cardDetail
.push(msg
);
1435 var uniqueCards
= [];
1436 for (var uniqueCard
in dupeTracker
) {
1437 uniqueCards
.push(uniqueCard
);
1439 if (uniqueCards
.length
== 52) {
1440 cardDetail
.unshift("full deck");
1442 // Detect missing cards
1443 var values
= "A23456789TJQK";
1445 var missingCards
= [];
1446 for (var i
=0; i
<suits
.length
; i
++) {
1447 for (var j
=0; j
<values
.length
; j
++) {
1448 var card
= values
[j
] + suits
[i
];
1449 if (!(card
in dupeTracker
)) {
1450 missingCards
.push(card
);
1454 // Display missing cards if six or less, ie clearly going for full deck
1455 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1456 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1457 if (missingCards
.length
> 3) {
1460 cardDetail
.push(msg
);
1462 // Add card details to typeStr
1463 if (cardDetail
.length
> 0) {
1464 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1470 function setQrEvents(els
) {
1471 els
.on("mouseenter", createQr
);
1472 els
.on("mouseleave", destroyQr
);
1473 els
.on("click", toggleQr
);
1476 function createQr(e
) {
1477 var content
= e
.target
.textContent
|| e
.target
.value
;
1485 DOM
.qrImage
.append(qrEl
);
1487 DOM
.qrHider
.addClass("hidden");
1490 DOM
.qrHider
.removeClass("hidden");
1492 DOM
.qrContainer
.removeClass("hidden");
1496 function destroyQr() {
1497 DOM
.qrImage
.text("");
1498 DOM
.qrContainer
.addClass("hidden");
1501 function toggleQr() {
1503 DOM
.qrHider
.toggleClass("hidden");
1504 DOM
.qrHint
.toggleClass("hidden");
1507 function bip44TabSelected() {
1508 return DOM
.bip44tab
.hasClass("active");
1511 function bip32TabSelected() {
1512 return DOM
.bip32tab
.hasClass("active");
1515 function networkHasSegwit() {
1517 if ("baseNetwork" in network
) {
1518 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1520 // check if only p2wpkh params are required
1521 if (p2wpkhSelected()) {
1522 return "p2wpkh" in n
;
1524 // check if only p2wpkh-in-p2sh params are required
1525 else if (p2wpkhInP2shSelected()) {
1526 return "p2wpkhInP2sh" in n
;
1528 // require both if it's unclear which params are required
1529 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1532 function bip49TabSelected() {
1533 return DOM
.bip49tab
.hasClass("active");
1536 function bip84TabSelected() {
1537 return DOM
.bip84tab
.hasClass("active");
1540 function bip141TabSelected() {
1541 return DOM
.bip141tab
.hasClass("active");
1544 function setHdCoin(coinValue
) {
1545 DOM
.bip44coin
.val(coinValue
);
1546 DOM
.bip49coin
.val(coinValue
);
1547 DOM
.bip84coin
.val(coinValue
);
1550 function showSegwitAvailable() {
1551 DOM
.bip49unavailable
.addClass("hidden");
1552 DOM
.bip49available
.removeClass("hidden");
1553 DOM
.bip84unavailable
.addClass("hidden");
1554 DOM
.bip84available
.removeClass("hidden");
1555 DOM
.bip141unavailable
.addClass("hidden");
1556 DOM
.bip141available
.removeClass("hidden");
1559 function showSegwitUnavailable() {
1560 DOM
.bip49available
.addClass("hidden");
1561 DOM
.bip49unavailable
.removeClass("hidden");
1562 DOM
.bip84available
.addClass("hidden");
1563 DOM
.bip84unavailable
.removeClass("hidden");
1564 DOM
.bip141available
.addClass("hidden");
1565 DOM
.bip141unavailable
.removeClass("hidden");
1568 function adjustNetworkForSegwit() {
1569 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1570 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1572 // See https://github.com/iancoleman/bip39/issues/125
1573 var segwitNetworks
= null;
1574 // if a segwit network is alread selected, need to use base network to
1575 // look up new parameters
1576 if ("baseNetwork" in network
) {
1577 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1579 // choose the right segwit params
1580 if (p2wpkhSelected() && "p2wpkh" in network
) {
1581 network
= network
.p2wpkh
;
1583 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1584 network
= network
.p2wpkhInP2sh
;
1588 function lastIndexInTable() {
1589 var pathText
= DOM
.addresses
.find(".index").last().text();
1590 var pathBits
= pathText
.split("/");
1591 var lastBit
= pathBits
[pathBits
.length
-1];
1592 var lastBitClean
= lastBit
.replace("'", "");
1593 return parseInt(lastBitClean
);
1596 function uint8ArrayToHex(a
) {
1598 for (var i
=0; i
<a
.length
; i
++) {
1599 var h
= a
[i
].toString(16);
1600 while (h
.length
< 2) {
1608 function showWordIndexes() {
1609 var phrase
= DOM
.phrase
.val();
1610 var words
= phraseToWordArray(phrase
);
1611 var wordIndexes
= [];
1612 var language
= getLanguage();
1613 for (var i
=0; i
<words
.length
; i
++) {
1614 var word
= words
[i
];
1615 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1616 wordIndexes
.push(wordIndex
);
1618 var wordIndexesStr
= wordIndexes
.join(", ");
1619 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1622 function showChecksum() {
1623 var phrase
= DOM
.phrase
.val();
1624 var words
= phraseToWordArray(phrase
);
1625 var checksumBitlength
= words
.length
/ 3;
1628 var language
= getLanguage();
1629 for (var i
=words
.length
-1; i
>=0; i
--) {
1630 var word
= words
[i
];
1631 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1632 var wordBinary
= wordIndex
.toString(2);
1633 while (wordBinary
.length
< 11) {
1634 wordBinary
= "0" + wordBinary
;
1636 var binaryStr
= wordBinary
+ binaryStr
;
1637 if (binaryStr
.length
>= checksumBitlength
) {
1638 var start
= binaryStr
.length
- checksumBitlength
;
1639 var end
= binaryStr
.length
;
1640 checksum
= binaryStr
.substring(start
, end
);
1641 // add spaces so the last group is 11 bits, not the first
1642 checksum
= checksum
.split("").reverse().join("")
1643 checksum
= addSpacesEveryElevenBits(checksum
);
1644 checksum
= checksum
.split("").reverse().join("")
1648 DOM
.entropyChecksum
.text(checksum
);
1651 function updateCsv() {
1652 var tableCsv
= "path,address,public key,private key\n";
1653 var rows
= DOM
.addresses
.find("tr");
1654 for (var i
=0; i
<rows
.length
; i
++) {
1655 var row
= $(rows
[i
]);
1656 var cells
= row
.find("td");
1657 for (var j
=0; j
<cells
.length
; j
++) {
1658 var cell
= $(cells
[j
]);
1659 if (!cell
.children().hasClass("invisible")) {
1660 tableCsv
= tableCsv
+ cell
.text();
1662 if (j
!= cells
.length
- 1) {
1663 tableCsv
= tableCsv
+ ",";
1666 tableCsv
= tableCsv
+ "\n";
1668 DOM
.csv
.val(tableCsv
);
1671 function addSpacesEveryElevenBits(binaryStr
) {
1672 return binaryStr
.match(/.{1,11}/g).join(" ");
1677 name: "AC - Asiacoin",
1678 onSelect: function() {
1679 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1684 name: "ACC - Adcoin",
1685 onSelect: function() {
1686 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1691 name: "AUR - Auroracoin",
1692 onSelect: function() {
1693 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1699 onSelect: function() {
1700 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1705 name: "ANON - ANON",
1706 onSelect: function() {
1707 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1712 name: "BCA - Bitcoin Atom",
1713 onSelect: function() {
1714 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1719 name: "BCH - Bitcoin Cash",
1720 onSelect: function() {
1721 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1726 name: "BEET - Beetlecoin",
1727 onSelect: function() {
1728 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1733 name: "BELA - Belacoin",
1734 onSelect: function() {
1735 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1740 name: "BLK - BlackCoin",
1741 onSelect: function() {
1742 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1747 name: "BRIT - Britcoin",
1748 onSelect: function() {
1749 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
1754 name: "BSD - Bitsend",
1755 onSelect: function() {
1756 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
1762 onSelect: function() {
1763 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1768 name: "BTC - Bitcoin",
1769 onSelect: function() {
1770 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1775 name: "BTC - Bitcoin Testnet",
1776 onSelect: function() {
1777 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1782 name: "BITG - Bitcoin Green",
1783 onSelect: function() {
1784 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1789 name: "BTCP - Bitcoin Private",
1790 onSelect: function() {
1791 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
1796 name: "BTCZ - Bitcoinz",
1797 onSelect: function() {
1798 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
1803 name: "BTDX - BitCloud",
1804 onSelect: function() {
1805 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
1810 name: "BTG - Bitcoin Gold",
1811 onSelect: function() {
1812 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
1817 name: "BTX - Bitcore",
1818 onSelect: function() {
1819 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
1824 name: "CCN - Cannacoin",
1825 onSelect: function() {
1826 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1831 name: "CESC - Cryptoescudo",
1832 onSelect: function() {
1833 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1838 name: "CDN - Canadaecoin",
1839 onSelect: function() {
1840 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
1845 name: "CLAM - Clams",
1846 onSelect: function() {
1847 network
= bitcoinjs
.bitcoin
.networks
.clam
;
1852 name: "CLO - Callisto",
1853 segwitAvailable: false,
1854 onSelect: function() {
1855 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1860 name: "CLUB - Clubcoin",
1861 onSelect: function() {
1862 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
1867 name: "CMP - Compcoin",
1868 onSelect: function() {
1869 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
1874 name: "CRAVE - Crave",
1875 onSelect: function() {
1876 network
= bitcoinjs
.bitcoin
.networks
.crave
;
1881 name: "CRW - Crown",
1882 onSelect: function() {
1883 network
= bitcoinjs
.bitcoin
.networks
.crown
;
1888 name: "DASH - Dash",
1889 onSelect: function() {
1890 network
= bitcoinjs
.bitcoin
.networks
.dash
;
1895 name: "DASH - Dash Testnet",
1896 onSelect: function() {
1897 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
1902 name: "DFC - Defcoin",
1903 onSelect: function() {
1904 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
1909 name: "DGB - Digibyte",
1910 onSelect: function() {
1911 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
1916 name: "DGC - Digitalcoin",
1917 onSelect: function() {
1918 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
1923 name: "DMD - Diamond",
1924 onSelect: function() {
1925 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
1930 name: "DNR - Denarius",
1931 onSelect: function() {
1932 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
1937 name: "DOGE - Dogecoin",
1938 onSelect: function() {
1939 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
1944 name: "ECN - Ecoin",
1945 onSelect: function() {
1946 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
1951 name: "EDRC - Edrcoin",
1952 onSelect: function() {
1953 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
1958 name: "EFL - Egulden",
1959 onSelect: function() {
1960 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
1965 name: "EMC2 - Einsteinium",
1966 onSelect: function() {
1967 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
1972 name: "ERC - Europecoin",
1973 onSelect: function() {
1974 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
1979 name: "ETC - Ethereum Classic",
1980 segwitAvailable: false,
1981 onSelect: function() {
1982 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1987 name: "ETH - Ethereum",
1988 onSelect: function() {
1989 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1994 name: "EXCL - Exclusivecoin",
1995 onSelect: function() {
1996 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
2001 name: "EXCC - ExchangeCoin",
2002 onSelect: function() {
2003 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
2008 name: "EXP - Expanse",
2009 segwitAvailable: false,
2010 onSelect: function() {
2011 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2016 name: "FJC - Fujicoin",
2017 onSelect: function() {
2018 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2023 name: "FLASH - Flashcoin",
2024 onSelect: function() {
2025 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2030 name: "FRST - Firstcoin",
2031 onSelect: function() {
2032 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2037 name: "FTC - Feathercoin",
2038 onSelect: function() {
2039 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2044 name: "GAME - GameCredits",
2045 onSelect: function() {
2046 network
= bitcoinjs
.bitcoin
.networks
.game
;
2051 name: "GBX - Gobyte",
2052 onSelect: function() {
2053 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2058 name: "GCR - GCRCoin",
2059 onSelect: function() {
2060 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2065 name: "GRC - Gridcoin",
2066 onSelect: function() {
2067 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2072 name: "HNC - Helleniccoin",
2073 onSelect: function() {
2074 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2079 name: "HUSH - Hush",
2080 onSelect: function() {
2081 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2086 name: "INSN - Insane",
2087 onSelect: function() {
2088 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2094 onSelect: function() {
2095 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2100 name: "IXC - Ixcoin",
2101 onSelect: function() {
2102 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2107 name: "JBS - Jumbucks",
2108 onSelect: function() {
2109 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2114 name: "KMD - Komodo",
2115 bip49available: false,
2116 onSelect: function() {
2117 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2122 name: "KOBO - Kobocoin",
2123 bip49available: false,
2124 onSelect: function() {
2125 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2130 name: "LBC - Library Credits",
2131 onSelect: function() {
2132 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2137 name: "LCC - Litecoincash",
2138 onSelect: function() {
2139 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2144 name: "LDCN - Landcoin",
2145 onSelect: function() {
2146 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2151 name: "LINX - Linx",
2152 onSelect: function() {
2153 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2158 name: "LTC - Litecoin",
2159 onSelect: function() {
2160 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2162 DOM
.litecoinLtubContainer
.removeClass("hidden");
2166 name: "LYNX - Lynx",
2167 onSelect: function() {
2168 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2173 name: "MAZA - Maza",
2174 onSelect: function() {
2175 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2180 name: "MEC - Megacoin",
2181 onSelect: function() {
2182 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2188 segwitAvailable: false,
2189 onSelect: function() {
2190 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2195 name: "MNX - Minexcoin",
2196 onSelect: function() {
2197 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2202 name: "MONA - Monacoin",
2203 onSelect: function() {
2204 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2209 name: "MUSIC - Musicoin",
2210 segwitAvailable: false,
2211 onSelect: function() {
2212 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2217 name: "NAV - Navcoin",
2218 onSelect: function() {
2219 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2224 name: "NEBL - Neblio",
2225 onSelect: function() {
2226 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2231 name: "NEOS - Neoscoin",
2232 onSelect: function() {
2233 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2238 name: "NLG - Gulden",
2239 onSelect: function() {
2240 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2245 name: "NMC - Namecoin",
2246 onSelect: function() {
2247 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2252 name: "NRG - Energi",
2253 onSelect: function() {
2254 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2259 name: "NRO - Neurocoin",
2260 onSelect: function() {
2261 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2266 name: "NSR - Nushares",
2267 onSelect: function() {
2268 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2273 name: "NYC - Newyorkc",
2274 onSelect: function() {
2275 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2280 name: "NVC - Novacoin",
2281 onSelect: function() {
2282 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2287 name: "OK - Okcash",
2288 onSelect: function() {
2289 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2294 name: "OMNI - Omnicore",
2295 onSelect: function() {
2296 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2301 name: "ONX - Onixcoin",
2302 onSelect: function() {
2303 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2308 name: "PHR - Phore",
2309 onSelect: function() {
2310 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2315 name: "PINK - Pinkcoin",
2316 onSelect: function() {
2317 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2322 name: "PIRL - Pirl",
2323 segwitAvailable: false,
2324 onSelect: function() {
2325 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2330 name: "PIVX - PIVX",
2331 onSelect: function() {
2332 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2337 name: "PIVX - PIVX Testnet",
2338 onSelect: function() {
2339 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2345 segwitAvailable: false,
2346 onSelect: function() {
2347 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2352 name: "POSW - POSWcoin",
2353 onSelect: function() {
2354 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2359 name: "POT - Potcoin",
2360 onSelect: function() {
2361 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2366 name: "PPC - Peercoin",
2367 onSelect: function() {
2368 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2373 name: "PRJ - ProjectCoin",
2374 onSelect: function() {
2375 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2380 name: "PSB - Pesobit",
2381 onSelect: function() {
2382 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2387 name: "PUT - Putincoin",
2388 onSelect: function() {
2389 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2394 name: "RVN - Ravencoin",
2395 onSelect: function() {
2396 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2401 name: "RBY - Rubycoin",
2402 onSelect: function() {
2403 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2408 name: "RDD - Reddcoin",
2409 onSelect: function() {
2410 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2415 name: "RVR - RevolutionVR",
2416 onSelect: function() {
2417 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2422 name: "SLS - Salus",
2423 onSelect: function() {
2424 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2429 name: "SDC - ShadowCash",
2430 onSelect: function() {
2431 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2436 name: "SDC - ShadowCash Testnet",
2437 onSelect: function() {
2438 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2443 name: "SLM - Slimcoin",
2444 onSelect: function() {
2445 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2450 name: "SLM - Slimcoin Testnet",
2451 onSelect: function() {
2452 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2457 name: "SLR - Solarcoin",
2458 onSelect: function() {
2459 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2464 name: "SMLY - Smileycoin",
2465 onSelect: function() {
2466 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2471 name: "STASH - Stash",
2472 onSelect: function() {
2473 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2478 name: "STASH - Stash Testnet",
2479 onSelect: function() {
2480 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2485 name: "STRAT - Stratis",
2486 onSelect: function() {
2487 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2492 name: "TSTRAT - Stratis Testnet",
2493 onSelect: function() {
2494 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2499 name: "SYS - Syscoin",
2500 onSelect: function() {
2501 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2506 name: "THC - Hempcoin",
2507 onSelect: function() {
2508 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2514 onSelect: function() {
2515 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2520 name: "USC - Ultimatesecurecash",
2521 onSelect: function() {
2522 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2527 name: "USNBT - NuBits",
2528 onSelect: function() {
2529 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2534 name: "UNO - Unobtanium",
2535 onSelect: function() {
2536 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2541 name: "VASH - Vpncoin",
2542 onSelect: function() {
2543 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2548 name: "VIA - Viacoin",
2549 onSelect: function() {
2550 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2555 name: "VIA - Viacoin Testnet",
2556 onSelect: function() {
2557 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2562 name: "VIVO - Vivo",
2563 onSelect: function() {
2564 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2569 name: "VTC - Vertcoin",
2570 onSelect: function() {
2571 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2576 name: "WC - Wincoin",
2577 onSelect: function() {
2578 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2583 name: "XAX - Artax",
2584 onSelect: function() {
2585 network
= bitcoinjs
.bitcoin
.networks
.artax
;
2590 name: "XBC - Bitcoinplus",
2591 onSelect: function() {
2592 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
2597 name: "XMY - Myriadcoin",
2598 onSelect: function() {
2599 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
2604 name: "XRP - Ripple",
2605 onSelect: function() {
2606 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2611 name: "XVC - Vcash",
2612 onSelect: function() {
2613 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
2618 name: "XVG - Verge",
2619 onSelect: function() {
2620 network
= bitcoinjs
.bitcoin
.networks
.verge
;
2625 name: "XUEZ - Xuez",
2626 segwitAvailable: false,
2627 onSelect: function() {
2628 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
2633 name: "XWC - Whitecoin",
2634 onSelect: function() {
2635 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
2640 name: "XZC - Zcoin",
2641 onSelect: function() {
2642 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
2647 name: "ZCL - Zclassic",
2648 onSelect: function() {
2649 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
2654 name: "ZEC - Zcash",
2655 onSelect: function() {
2656 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
2661 name: "ZEN - Zencash",
2662 onSelect: function() {
2663 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
2671 name: "Bitcoin Core",
2672 onSelect: function() {
2673 DOM
.bip32path
.val("m/0'/0'");
2674 DOM
.hardenedAddresses
.prop('checked', true);
2678 name: "blockchain.info",
2679 onSelect: function() {
2680 DOM
.bip32path
.val("m/44'/0'/0'");
2681 DOM
.hardenedAddresses
.prop('checked', false);
2685 name: "MultiBit HD",
2686 onSelect: function() {
2687 DOM
.bip32path
.val("m/0'/0");
2688 DOM
.hardenedAddresses
.prop('checked', false);
2692 name: "Coinomi, Ledger",
2693 onSelect: function() {
2694 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
2695 DOM
.hardenedAddresses
.prop('checked', false);