3 // mnemonics is populated as required by getLanguage
4 var mnemonics
= { "english": new Mnemonic("english") };
5 var mnemonic
= mnemonics
["english"];
7 var bip32RootKey
= null;
8 var bip32ExtendedKey
= null;
9 var network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
10 var addressRowTemplate
= $("#address-row-template");
13 var showAddress
= true;
14 var showPubKey
= true;
15 var showPrivKey
= true;
17 var litecoinUseLtub
= true;
19 var entropyChangeTimeoutEvent
= null;
20 var phraseChangeTimeoutEvent
= null;
21 var rootKeyChangedTimeoutEvent
= null;
23 var generationProcesses
= [];
26 DOM
.privacyScreenToggle
= $(".privacy-screen-toggle");
27 DOM
.network
= $(".network");
28 DOM
.bip32Client
= $("#bip32-client");
29 DOM
.phraseNetwork
= $("#network-phrase");
30 DOM
.useEntropy
= $(".use-entropy");
31 DOM
.entropyContainer
= $(".entropy-container");
32 DOM
.entropy
= $(".entropy");
33 DOM
.entropyFiltered
= DOM
.entropyContainer
.find(".filtered");
34 DOM
.entropyType
= DOM
.entropyContainer
.find(".type");
35 DOM
.entropyCrackTime
= DOM
.entropyContainer
.find(".crack-time");
36 DOM
.entropyEventCount
= DOM
.entropyContainer
.find(".event-count");
37 DOM
.entropyBits
= DOM
.entropyContainer
.find(".bits");
38 DOM
.entropyBitsPerEvent
= DOM
.entropyContainer
.find(".bits-per-event");
39 DOM
.entropyWordCount
= DOM
.entropyContainer
.find(".word-count");
40 DOM
.entropyBinary
= DOM
.entropyContainer
.find(".binary");
41 DOM
.entropyWordIndexes
= DOM
.entropyContainer
.find(".word-indexes");
42 DOM
.entropyChecksum
= DOM
.entropyContainer
.find(".checksum");
43 DOM
.entropyMnemonicLength
= DOM
.entropyContainer
.find(".mnemonic-length");
44 DOM
.entropyWeakEntropyOverrideWarning
= DOM
.entropyContainer
.find(".weak-entropy-override-warning");
45 DOM
.entropyFilterWarning
= DOM
.entropyContainer
.find(".filter-warning");
46 DOM
.phrase
= $(".phrase");
47 DOM
.passphrase
= $(".passphrase");
48 DOM
.generateContainer
= $(".generate-container");
49 DOM
.generate
= $(".generate");
50 DOM
.seed
= $(".seed");
51 DOM
.rootKey
= $(".root-key");
52 DOM
.litecoinLtubContainer
= $(".litecoin-ltub-container");
53 DOM
.litecoinUseLtub
= $(".litecoin-use-ltub");
54 DOM
.extendedPrivKey
= $(".extended-priv-key");
55 DOM
.extendedPubKey
= $(".extended-pub-key");
56 DOM
.bip32tab
= $("#bip32-tab");
57 DOM
.bip44tab
= $("#bip44-tab");
58 DOM
.bip49tab
= $("#bip49-tab");
59 DOM
.bip84tab
= $("#bip84-tab");
60 DOM
.bip141tab
= $("#bip141-tab");
61 DOM
.bip32panel
= $("#bip32");
62 DOM
.bip44panel
= $("#bip44");
63 DOM
.bip49panel
= $("#bip49");
64 DOM
.bip32path
= $("#bip32-path");
65 DOM
.bip44path
= $("#bip44-path");
66 DOM
.bip44purpose
= $("#bip44 .purpose");
67 DOM
.bip44coin
= $("#bip44 .coin");
68 DOM
.bip44account
= $("#bip44 .account");
69 DOM
.bip44accountXprv
= $("#bip44 .account-xprv");
70 DOM
.bip44accountXpub
= $("#bip44 .account-xpub");
71 DOM
.bip44change
= $("#bip44 .change");
72 DOM
.bip49unavailable
= $("#bip49 .unavailable");
73 DOM
.bip49available
= $("#bip49 .available");
74 DOM
.bip49path
= $("#bip49-path");
75 DOM
.bip49purpose
= $("#bip49 .purpose");
76 DOM
.bip49coin
= $("#bip49 .coin");
77 DOM
.bip49account
= $("#bip49 .account");
78 DOM
.bip49accountXprv
= $("#bip49 .account-xprv");
79 DOM
.bip49accountXpub
= $("#bip49 .account-xpub");
80 DOM
.bip49change
= $("#bip49 .change");
81 DOM
.bip84unavailable
= $("#bip84 .unavailable");
82 DOM
.bip84available
= $("#bip84 .available");
83 DOM
.bip84path
= $("#bip84-path");
84 DOM
.bip84purpose
= $("#bip84 .purpose");
85 DOM
.bip84coin
= $("#bip84 .coin");
86 DOM
.bip84account
= $("#bip84 .account");
87 DOM
.bip84accountXprv
= $("#bip84 .account-xprv");
88 DOM
.bip84accountXpub
= $("#bip84 .account-xpub");
89 DOM
.bip84change
= $("#bip84 .change");
90 DOM
.bip141unavailable
= $("#bip141 .unavailable");
91 DOM
.bip141available
= $("#bip141 .available");
92 DOM
.bip141path
= $("#bip141-path");
93 DOM
.bip141semantics
= $(".bip141-semantics");
94 DOM
.generatedStrength
= $(".generate-container .strength");
95 DOM
.generatedStrengthWarning
= $(".generate-container .warning");
96 DOM
.hardenedAddresses
= $(".hardened-addresses");
97 DOM
.bitcoinCashAddressTypeContainer
= $(".bch-addr-type-container");
98 DOM
.bitcoinCashAddressType
= $("[name=bch-addr-type]")
99 DOM
.useBip38
= $(".use-bip38");
100 DOM
.bip38Password
= $(".bip38-password");
101 DOM
.addresses
= $(".addresses");
102 DOM
.csvTab
= $("#csv-tab a");
104 DOM
.rowsToAdd
= $(".rows-to-add");
105 DOM
.more
= $(".more");
106 DOM
.moreRowsStartIndex
= $(".more-rows-start-index");
107 DOM
.feedback
= $(".feedback");
108 DOM
.tab
= $(".derivation-type a");
109 DOM
.indexToggle
= $(".index-toggle");
110 DOM
.addressToggle
= $(".address-toggle");
111 DOM
.publicKeyToggle
= $(".public-key-toggle");
112 DOM
.privateKeyToggle
= $(".private-key-toggle");
113 DOM
.languages
= $(".languages a");
114 DOM
.qrContainer
= $(".qr-container");
115 DOM
.qrHider
= DOM
.qrContainer
.find(".qr-hider");
116 DOM
.qrImage
= DOM
.qrContainer
.find(".qr-image");
117 DOM
.qrHint
= DOM
.qrContainer
.find(".qr-hint");
118 DOM
.showQrEls
= $("[data-show-qr]");
122 DOM
.privacyScreenToggle
.on("change", privacyScreenToggled
);
123 DOM
.generatedStrength
.on("change", generatedStrengthChanged
);
124 DOM
.network
.on("change", networkChanged
);
125 DOM
.bip32Client
.on("change", bip32ClientChanged
);
126 DOM
.useEntropy
.on("change", setEntropyVisibility
);
127 DOM
.entropy
.on("input", delayedEntropyChanged
);
128 DOM
.entropyMnemonicLength
.on("change", entropyChanged
);
129 DOM
.phrase
.on("input", delayedPhraseChanged
);
130 DOM
.passphrase
.on("input", delayedPhraseChanged
);
131 DOM
.generate
.on("click", generateClicked
);
132 DOM
.more
.on("click", showMore
);
133 DOM
.rootKey
.on("input", delayedRootKeyChanged
);
134 DOM
.litecoinUseLtub
.on("change", litecoinUseLtubChanged
);
135 DOM
.bip32path
.on("input", calcForDerivationPath
);
136 DOM
.bip44account
.on("input", calcForDerivationPath
);
137 DOM
.bip44change
.on("input", calcForDerivationPath
);
138 DOM
.bip49account
.on("input", calcForDerivationPath
);
139 DOM
.bip49change
.on("input", calcForDerivationPath
);
140 DOM
.bip84account
.on("input", calcForDerivationPath
);
141 DOM
.bip84change
.on("input", calcForDerivationPath
);
142 DOM
.bip141path
.on("input", calcForDerivationPath
);
143 DOM
.bip141semantics
.on("change", tabChanged
);
144 DOM
.tab
.on("shown.bs.tab", tabChanged
);
145 DOM
.hardenedAddresses
.on("change", calcForDerivationPath
);
146 DOM
.useBip38
.on("change", calcForDerivationPath
);
147 DOM
.bip38Password
.on("change", calcForDerivationPath
);
148 DOM
.indexToggle
.on("click", toggleIndexes
);
149 DOM
.addressToggle
.on("click", toggleAddresses
);
150 DOM
.publicKeyToggle
.on("click", togglePublicKeys
);
151 DOM
.privateKeyToggle
.on("click", togglePrivateKeys
);
152 DOM
.csvTab
.on("click", updateCsv
);
153 DOM
.languages
.on("click", languageChanged
);
154 DOM
.bitcoinCashAddressType
.on("change", bitcoinCashAddressTypeChange
);
155 setQrEvents(DOM
.showQrEls
);
158 hideValidationError();
159 populateNetworkSelect();
160 populateClientSelect();
165 function generatedStrengthChanged() {
166 var strength
= parseInt(DOM
.generatedStrength
.val());
168 DOM
.generatedStrengthWarning
.removeClass("hidden");
171 DOM
.generatedStrengthWarning
.addClass("hidden");
175 function networkChanged(e
) {
177 clearAddressesList();
178 DOM
.litecoinLtubContainer
.addClass("hidden");
179 DOM
.bitcoinCashAddressTypeContainer
.addClass("hidden");
180 var networkIndex
= e
.target
.value
;
181 var network
= networks
[networkIndex
];
183 adjustNetworkForSegwit();
192 function bip32ClientChanged(e
) {
193 var clientIndex
= DOM
.bip32Client
.val();
194 if (clientIndex
== "custom") {
195 DOM
.bip32path
.prop("readonly", false);
198 DOM
.bip32path
.prop("readonly", true);
199 clients
[clientIndex
].onSelect();
209 function setEntropyVisibility() {
210 if (isUsingOwnEntropy()) {
211 DOM
.entropyContainer
.removeClass("hidden");
212 DOM
.generateContainer
.addClass("hidden");
213 DOM
.phrase
.prop("readonly", true);
218 DOM
.entropyContainer
.addClass("hidden");
219 DOM
.generateContainer
.removeClass("hidden");
220 DOM
.phrase
.prop("readonly", false);
225 function delayedPhraseChanged() {
226 hideValidationError();
229 bip32ExtendedKey
= null;
230 clearAddressesList();
232 if (phraseChangeTimeoutEvent
!= null) {
233 clearTimeout(phraseChangeTimeoutEvent
);
235 phraseChangeTimeoutEvent
= setTimeout(function() {
237 var entropy
= mnemonic
.toRawEntropyHex(DOM
.phrase
.val());
238 if (entropy
!== null) {
239 DOM
.entropyMnemonicLength
.val("raw");
240 DOM
.entropy
.val(entropy
);
245 function phraseChanged() {
247 setMnemonicLanguage();
248 // Get the mnemonic phrase
249 var phrase
= DOM
.phrase
.val();
250 var errorText
= findPhraseErrors(phrase
);
252 showValidationError(errorText
);
255 // Calculate and display
256 var passphrase
= DOM
.passphrase
.val();
257 calcBip32RootKeyFromSeed(phrase
, passphrase
);
258 calcForDerivationPath();
259 // Show the word indexes
263 function tabChanged() {
265 adjustNetworkForSegwit();
266 var phrase
= DOM
.phrase
.val();
268 // Calculate and display for mnemonic
269 var errorText
= findPhraseErrors(phrase
);
271 showValidationError(errorText
);
274 // Calculate and display
275 var passphrase
= DOM
.passphrase
.val();
276 calcBip32RootKeyFromSeed(phrase
, passphrase
);
279 // Calculate and display for root key
280 var rootKeyBase58
= DOM
.rootKey
.val();
281 var errorText
= validateRootKey(rootKeyBase58
);
283 showValidationError(errorText
);
286 // Calculate and display
287 calcBip32RootKeyFromBase58(rootKeyBase58
);
289 calcForDerivationPath();
292 function delayedEntropyChanged() {
293 hideValidationError();
295 if (entropyChangeTimeoutEvent
!= null) {
296 clearTimeout(entropyChangeTimeoutEvent
);
298 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
301 function entropyChanged() {
302 // If blank entropy, clear mnemonic, addresses, errors
303 if (DOM
.entropy
.val().trim().length
== 0) {
305 clearEntropyFeedback();
307 showValidationError("Blank entropy");
310 // Get the current phrase to detect changes
311 var phrase
= DOM
.phrase
.val();
312 // Set the phrase from the entropy
313 setMnemonicFromEntropy();
314 // Recalc addresses if the phrase has changed
315 var newPhrase
= DOM
.phrase
.val();
316 if (newPhrase
!= phrase
) {
317 if (newPhrase
.length
== 0) {
329 function delayedRootKeyChanged() {
330 // Warn if there is an existing mnemonic or passphrase.
331 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
332 if (!confirm("This will clear existing mnemonic and passphrase")) {
333 DOM
.rootKey
.val(bip32RootKey
);
337 hideValidationError();
339 // Clear existing mnemonic and passphrase
341 DOM
.passphrase
.val("");
343 if (rootKeyChangedTimeoutEvent
!= null) {
344 clearTimeout(rootKeyChangedTimeoutEvent
);
346 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
349 function rootKeyChanged() {
351 hideValidationError();
352 var rootKeyBase58
= DOM
.rootKey
.val();
353 var errorText
= validateRootKey(rootKeyBase58
);
355 showValidationError(errorText
);
358 // Calculate and display
359 calcBip32RootKeyFromBase58(rootKeyBase58
);
360 calcForDerivationPath();
363 function litecoinUseLtubChanged() {
364 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
365 if (litecoinUseLtub
) {
366 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
369 network
= bitcoinjs
.bitcoin
.networks
.litecoinXprv
;
374 function calcForDerivationPath() {
376 clearAddressesList();
378 // Don't show segwit if it's selected but network doesn't support it
379 if (segwitSelected() && !networkHasSegwit()) {
380 showSegwitUnavailable();
384 showSegwitAvailable();
385 // Get the derivation path
386 var derivationPath
= getDerivationPath();
387 var errorText
= findDerivationPathErrors(derivationPath
);
389 showValidationError(errorText
);
392 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
393 if (bip44TabSelected()) {
396 else if (bip49TabSelected()) {
399 else if (bip84TabSelected()) {
405 function generateClicked() {
406 if (isUsingOwnEntropy()) {
411 setTimeout(function() {
412 setMnemonicLanguage();
413 var phrase
= generateRandomPhrase();
421 function languageChanged() {
422 setTimeout(function() {
423 setMnemonicLanguage();
424 if (DOM
.phrase
.val().length
> 0) {
425 var newPhrase
= convertPhraseToNewLanguage();
426 DOM
.phrase
.val(newPhrase
);
430 DOM
.generate
.trigger("click");
435 function bitcoinCashAddressTypeChange() {
439 function toggleIndexes() {
440 showIndex
= !showIndex
;
441 $("td.index span").toggleClass("invisible");
444 function toggleAddresses() {
445 showAddress
= !showAddress
;
446 $("td.address span").toggleClass("invisible");
449 function togglePublicKeys() {
450 showPubKey
= !showPubKey
;
451 $("td.pubkey span").toggleClass("invisible");
454 function togglePrivateKeys() {
455 showPrivKey
= !showPrivKey
;
456 $("td.privkey span").toggleClass("invisible");
459 function privacyScreenToggled() {
460 // private-data contains elements added to DOM at runtime
461 // so catch all by adding visual privacy class to the root of the DOM
462 if (DOM
.privacyScreenToggle
.prop("checked")) {
463 $("body").addClass("visual-privacy");
466 $("body").removeClass("visual-privacy");
472 function generateRandomPhrase() {
473 if (!hasStrongRandom()) {
474 var errorText
= "This browser does not support strong randomness";
475 showValidationError(errorText
);
478 // get the amount of entropy to use
479 var numWords
= parseInt(DOM
.generatedStrength
.val());
480 var strength
= numWords
/ 3 * 32;
481 var buffer
= new Uint8Array(strength
/ 8);
482 // create secure entropy
483 var data
= crypto
.getRandomValues(buffer
);
485 var words
= mnemonic
.toMnemonic(data
);
486 DOM
.phrase
.val(words
);
488 var entropyHex
= uint8ArrayToHex(data
);
489 DOM
.entropy
.val(entropyHex
);
490 // ensure entropy fields are consistent with what is being displayed
491 DOM
.entropyMnemonicLength
.val("raw");
495 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
496 seed
= mnemonic
.toSeed(phrase
, passphrase
);
497 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
500 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
501 // try parsing with various segwit network params since this extended
502 // key may be from any one of them.
503 if (networkHasSegwit()) {
505 if ("baseNetwork" in n
) {
506 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
508 // try parsing using base network params
510 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
514 // try parsing using p2wpkh params
517 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
522 // try parsing using p2wpkh-in-p2sh network params
523 if ("p2wpkhInP2sh" in n
) {
525 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
531 // try the network params as currently specified
532 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
535 function calcBip32ExtendedKey(path
) {
536 // Check there's a root key to derive from
540 var extendedKey
= bip32RootKey
;
541 // Derive the key from the path
542 var pathBits
= path
.split("/");
543 for (var i
=0; i
<pathBits
.length
; i
++) {
544 var bit
= pathBits
[i
];
545 var index
= parseInt(bit
);
549 var hardened
= bit
[bit
.length
-1] == "'";
550 var isPriv
= !(extendedKey
.isNeutered());
551 var invalidDerivationPath
= hardened
&& !isPriv
;
552 if (invalidDerivationPath
) {
556 extendedKey
= extendedKey
.deriveHardened(index
);
559 extendedKey
= extendedKey
.derive(index
);
565 function showValidationError(errorText
) {
571 function hideValidationError() {
577 function findPhraseErrors(phrase
) {
578 // Preprocess the words
579 phrase
= mnemonic
.normalizeString(phrase
);
580 var words
= phraseToWordArray(phrase
);
581 // Detect blank phrase
582 if (words
.length
== 0) {
583 return "Blank mnemonic";
586 for (var i
=0; i
<words
.length
; i
++) {
588 var language
= getLanguage();
589 if (WORDLISTS
[language
].indexOf(word
) == -1) {
590 console
.log("Finding closest match to " + word
);
591 var nearestWord
= findNearestWord(word
);
592 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
595 // Check the words are valid
596 var properPhrase
= wordArrayToPhrase(words
);
597 var isValid
= mnemonic
.check(properPhrase
);
599 return "Invalid mnemonic";
604 function validateRootKey(rootKeyBase58
) {
605 // try various segwit network params since this extended key may be from
607 if (networkHasSegwit()) {
609 if ("baseNetwork" in n
) {
610 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
612 // try parsing using base network params
614 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
618 // try parsing using p2wpkh params
621 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
626 // try parsing using p2wpkh-in-p2sh network params
627 if ("p2wpkhInP2sh" in n
) {
629 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
635 // try the network params as currently specified
637 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
640 return "Invalid root key";
645 function getDerivationPath() {
646 if (bip44TabSelected()) {
647 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
648 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
649 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
650 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
652 path
+= purpose
+ "'/";
654 path
+= account
+ "'/";
656 DOM
.bip44path
.val(path
);
657 var derivationPath
= DOM
.bip44path
.val();
658 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
659 return derivationPath
;
661 else if (bip49TabSelected()) {
662 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
663 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
664 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
665 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
667 path
+= purpose
+ "'/";
669 path
+= account
+ "'/";
671 DOM
.bip49path
.val(path
);
672 var derivationPath
= DOM
.bip49path
.val();
673 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
674 return derivationPath
;
676 else if (bip84TabSelected()) {
677 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
678 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
679 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
680 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
682 path
+= purpose
+ "'/";
684 path
+= account
+ "'/";
686 DOM
.bip84path
.val(path
);
687 var derivationPath
= DOM
.bip84path
.val();
688 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
689 return derivationPath
;
691 else if (bip32TabSelected()) {
692 var derivationPath
= DOM
.bip32path
.val();
693 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
694 return derivationPath
;
696 else if (bip141TabSelected()) {
697 var derivationPath
= DOM
.bip141path
.val();
698 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
699 return derivationPath
;
702 console
.log("Unknown derivation path");
706 function findDerivationPathErrors(path
) {
707 // TODO is not perfect but is better than nothing
709 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
711 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
712 var maxDepth
= 255; // TODO verify this!!
713 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
714 if (path
[0] != "m") {
715 return "First character must be 'm'";
717 if (path
.length
> 1) {
718 if (path
[1] != "/") {
719 return "Separator must be '/'";
721 var indexes
= path
.split("/");
722 if (indexes
.length
> maxDepth
) {
723 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
725 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
726 var index
= indexes
[depth
];
727 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
728 if (invalidChars
.length
> 0) {
729 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
731 var indexValue
= parseInt(index
.replace("'", ""));
733 return "Invalid number at depth " + depth
;
735 if (indexValue
> maxIndexValue
) {
736 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
740 // Check root key exists or else derivation path is useless!
742 return "No root key";
744 // Check no hardened derivation path when using xpub keys
745 var hardenedPath
= path
.indexOf("'") > -1;
746 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
747 var hardened
= hardenedPath
|| hardenedAddresses
;
748 var isXpubkey
= bip32RootKey
.isNeutered();
749 if (hardened
&& isXpubkey
) {
750 return "Hardened derivation path is invalid with xpub key";
755 function displayBip44Info() {
756 // Get the derivation path for the account
757 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
758 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
759 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
761 path
+= purpose
+ "'/";
763 path
+= account
+ "'/";
764 // Calculate the account extended keys
765 var accountExtendedKey
= calcBip32ExtendedKey(path
);
766 var accountXprv
= accountExtendedKey
.toBase58();
767 var accountXpub
= accountExtendedKey
.neutered().toBase58();
768 // Display the extended keys
769 DOM
.bip44accountXprv
.val(accountXprv
);
770 DOM
.bip44accountXpub
.val(accountXpub
);
773 function displayBip49Info() {
774 // Get the derivation path for the account
775 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
776 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
777 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
779 path
+= purpose
+ "'/";
781 path
+= account
+ "'/";
782 // Calculate the account extended keys
783 var accountExtendedKey
= calcBip32ExtendedKey(path
);
784 var accountXprv
= accountExtendedKey
.toBase58();
785 var accountXpub
= accountExtendedKey
.neutered().toBase58();
786 // Display the extended keys
787 DOM
.bip49accountXprv
.val(accountXprv
);
788 DOM
.bip49accountXpub
.val(accountXpub
);
791 function displayBip84Info() {
792 // Get the derivation path for the account
793 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
794 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
795 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
797 path
+= purpose
+ "'/";
799 path
+= account
+ "'/";
800 // Calculate the account extended keys
801 var accountExtendedKey
= calcBip32ExtendedKey(path
);
802 var accountXprv
= accountExtendedKey
.toBase58();
803 var accountXpub
= accountExtendedKey
.neutered().toBase58();
804 // Display the extended keys
805 DOM
.bip84accountXprv
.val(accountXprv
);
806 DOM
.bip84accountXpub
.val(accountXpub
);
809 function displayBip32Info() {
812 var rootKey
= bip32RootKey
.toBase58();
813 DOM
.rootKey
.val(rootKey
);
814 var xprvkeyB58
= "NA";
815 if (!bip32ExtendedKey
.isNeutered()) {
816 xprvkeyB58
= bip32ExtendedKey
.toBase58();
818 var extendedPrivKey
= xprvkeyB58
;
819 DOM
.extendedPrivKey
.val(extendedPrivKey
);
820 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
821 DOM
.extendedPubKey
.val(extendedPubKey
);
822 // Display the addresses and privkeys
823 clearAddressesList();
824 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
825 displayAddresses(0, initialAddressCount
);
828 function displayAddresses(start
, total
) {
829 generationProcesses
.push(new (function() {
833 this.stop = function() {
834 for (var i
=0; i
<rows
.length
; i
++) {
835 rows
[i
].shouldGenerate
= false;
840 for (var i
=0; i
<total
; i
++) {
841 var index
= i
+ start
;
842 var isLast
= i
== total
- 1;
843 rows
.push(new TableRow(index
, isLast
));
849 function segwitSelected() {
850 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
853 function p2wpkhSelected() {
854 return bip84TabSelected() ||
855 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
858 function p2wpkhInP2shSelected() {
859 return bip49TabSelected() ||
860 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
863 function TableRow(index
, isLast
) {
866 this.shouldGenerate
= true;
867 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
868 var useBip38
= DOM
.useBip38
.prop("checked");
869 var bip38password
= DOM
.bip38Password
.val();
870 var isSegwit
= segwitSelected();
871 var segwitAvailable
= networkHasSegwit();
872 var isP2wpkh
= p2wpkhSelected();
873 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
879 function calculateValues() {
880 setTimeout(function() {
881 if (!self
.shouldGenerate
) {
884 // derive HDkey for this row of the table
886 if (useHardenedAddresses
) {
887 key
= bip32ExtendedKey
.deriveHardened(index
);
890 key
= bip32ExtendedKey
.derive(index
);
892 // bip38 requires uncompressed keys
893 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
894 var keyPair
= key
.keyPair
;
895 var useUncompressed
= useBip38
;
896 if (useUncompressed
) {
897 keyPair
= new bitcoinjs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
900 var address
= keyPair
.getAddress().toString();
902 var hasPrivkey
= !key
.isNeutered();
905 privkey
= keyPair
.toWIF();
906 // BIP38 encode private key if required
908 privkey
= bitcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
909 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
914 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
915 var indexText
= getDerivationPath() + "/" + index
;
916 if (useHardenedAddresses
) {
917 indexText
= indexText
+ "'";
919 // Ethereum values are different
920 if ((networks
[DOM
.network
.val()].name
== "ETH - Ethereum")
921 || (networks
[DOM
.network
.val()].name
== "ETC - Ethereum Classic")
922 || (networks
[DOM
.network
.val()].name
== "PIRL - Pirl")
923 || (networks
[DOM
.network
.val()].name
== "MIX - MIX")
924 || (networks
[DOM
.network
.val()].name
== "MUSIC - Musicoin")
925 || (networks
[DOM
.network
.val()].name
== "POA - Poa")
926 || (networks
[DOM
.network
.val()].name
== "EXP - Expanse")
927 || (networks
[DOM
.network
.val()].name
== "CLO - Callisto")) {
928 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
929 privkey
= privKeyBuffer
.toString('hex');
930 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
931 var hexAddress
= addressBuffer
.toString('hex');
932 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
933 address
= ethUtil
.addHexPrefix(checksumAddress
);
934 privkey
= ethUtil
.addHexPrefix(privkey
);
935 pubkey
= ethUtil
.addHexPrefix(pubkey
);
937 // Ripple values are different
938 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
939 privkey
= convertRipplePriv(privkey
);
940 address
= convertRippleAdrr(address
);
942 // Bitcoin Cash address format may vary
943 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
944 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
945 if (bchAddrType
== "cashaddr") {
946 address
= bchaddr
.toCashAddress(address
);
948 else if (bchAddrType
== "bitpay") {
949 address
= bchaddr
.toBitpayAddress(address
);
952 // Segwit addresses are different
954 if (!segwitAvailable
) {
958 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
959 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
960 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
962 else if (isP2wpkhInP2sh
) {
963 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
964 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
965 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
966 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
967 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
970 addAddressToList(indexText
, address
, pubkey
, privkey
);
982 function showMore() {
983 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
984 if (isNaN(rowsToAdd
)) {
986 DOM
.rowsToAdd
.val("20");
988 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
990 start
= lastIndexInTable() + 1;
993 var newStart
= start
+ rowsToAdd
;
994 DOM
.moreRowsStartIndex
.val(newStart
);
996 if (rowsToAdd
> 200) {
997 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
998 msg
+= "Do you want to continue?";
1003 displayAddresses(start
, rowsToAdd
);
1006 function clearDisplay() {
1007 clearAddressesList();
1009 hideValidationError();
1012 function clearAddressesList() {
1013 DOM
.addresses
.empty();
1018 function stopGenerating() {
1019 while (generationProcesses
.length
> 0) {
1020 var generation
= generationProcesses
.shift();
1025 function clearKeys() {
1030 function clearRootKey() {
1031 DOM
.rootKey
.val("");
1034 function clearDerivedKeys() {
1035 DOM
.extendedPrivKey
.val("");
1036 DOM
.extendedPubKey
.val("");
1037 DOM
.bip44accountXprv
.val("");
1038 DOM
.bip44accountXpub
.val("");
1041 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1042 var row
= $(addressRowTemplate
.html());
1044 var indexCell
= row
.find(".index span");
1045 var addressCell
= row
.find(".address span");
1046 var pubkeyCell
= row
.find(".pubkey span");
1047 var privkeyCell
= row
.find(".privkey span");
1049 indexCell
.text(indexText
);
1050 addressCell
.text(address
);
1051 pubkeyCell
.text(pubkey
);
1052 privkeyCell
.text(privkey
);
1055 indexCell
.addClass("invisible");
1058 addressCell
.addClass("invisible");
1061 pubkeyCell
.addClass("invisible");
1064 privkeyCell
.addClass("invisible");
1066 DOM
.addresses
.append(row
);
1067 var rowShowQrEls
= row
.find("[data-show-qr]");
1068 setQrEvents(rowShowQrEls
);
1071 function hasStrongRandom() {
1072 return 'crypto' in window
&& window
['crypto'] !== null;
1075 function disableForms() {
1076 $("form").on("submit", function(e
) {
1081 function parseIntNoNaN(val
, defaultVal
) {
1082 var v
= parseInt(val
);
1089 function showPending() {
1091 .text("Calculating...")
1095 function findNearestWord(word
) {
1096 var language
= getLanguage();
1097 var words
= WORDLISTS
[language
];
1098 var minDistance
= 99;
1099 var closestWord
= words
[0];
1100 for (var i
=0; i
<words
.length
; i
++) {
1101 var comparedTo
= words
[i
];
1102 if (comparedTo
.indexOf(word
) == 0) {
1105 var distance
= Levenshtein
.get(word
, comparedTo
);
1106 if (distance
< minDistance
) {
1107 closestWord
= comparedTo
;
1108 minDistance
= distance
;
1114 function hidePending() {
1120 function populateNetworkSelect() {
1121 for (var i
=0; i
<networks
.length
; i
++) {
1122 var network
= networks
[i
];
1123 var option
= $("<option>");
1124 option
.attr("value", i
);
1125 option
.text(network
.name
);
1126 if (network
.name
== "BTC - Bitcoin") {
1127 option
.prop("selected", true);
1129 DOM
.phraseNetwork
.append(option
);
1133 function populateClientSelect() {
1134 for (var i
=0; i
<clients
.length
; i
++) {
1135 var client
= clients
[i
];
1136 var option
= $("<option>");
1137 option
.attr("value", i
);
1138 option
.text(client
.name
);
1139 DOM
.bip32Client
.append(option
);
1143 function getLanguage() {
1144 var defaultLanguage
= "english";
1145 // Try to get from existing phrase
1146 var language
= getLanguageFromPhrase();
1147 // Try to get from url if not from phrase
1148 if (language
.length
== 0) {
1149 language
= getLanguageFromUrl();
1151 // Default to English if no other option
1152 if (language
.length
== 0) {
1153 language
= defaultLanguage
;
1158 function getLanguageFromPhrase(phrase
) {
1159 // Check if how many words from existing phrase match a language.
1162 phrase
= DOM
.phrase
.val();
1164 if (phrase
.length
> 0) {
1165 var words
= phraseToWordArray(phrase
);
1166 var languageMatches
= {};
1167 for (l
in WORDLISTS
) {
1168 // Track how many words match in this language
1169 languageMatches
[l
] = 0;
1170 for (var i
=0; i
<words
.length
; i
++) {
1171 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1172 if (wordInLanguage
) {
1173 languageMatches
[l
]++;
1176 // Find languages with most word matches.
1177 // This is made difficult due to commonalities between Chinese
1178 // simplified vs traditional.
1179 var mostMatches
= 0;
1180 var mostMatchedLanguages
= [];
1181 for (var l
in languageMatches
) {
1182 var numMatches
= languageMatches
[l
];
1183 if (numMatches
> mostMatches
) {
1184 mostMatches
= numMatches
;
1185 mostMatchedLanguages
= [l
];
1187 else if (numMatches
== mostMatches
) {
1188 mostMatchedLanguages
.push(l
);
1192 if (mostMatchedLanguages
.length
> 0) {
1193 // Use first language and warn if multiple detected
1194 language
= mostMatchedLanguages
[0];
1195 if (mostMatchedLanguages
.length
> 1) {
1196 console
.warn("Multiple possible languages");
1197 console
.warn(mostMatchedLanguages
);
1204 function getLanguageFromUrl() {
1205 for (var language
in WORDLISTS
) {
1206 if (window
.location
.hash
.indexOf(language
) > -1) {
1213 function setMnemonicLanguage() {
1214 var language
= getLanguage();
1215 // Load the bip39 mnemonic generator for this language if required
1216 if (!(language
in mnemonics
)) {
1217 mnemonics
[language
] = new Mnemonic(language
);
1219 mnemonic
= mnemonics
[language
];
1222 function convertPhraseToNewLanguage() {
1223 var oldLanguage
= getLanguageFromPhrase();
1224 var newLanguage
= getLanguageFromUrl();
1225 var oldPhrase
= DOM
.phrase
.val();
1226 var oldWords
= phraseToWordArray(oldPhrase
);
1228 for (var i
=0; i
<oldWords
.length
; i
++) {
1229 var oldWord
= oldWords
[i
];
1230 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1231 var newWord
= WORDLISTS
[newLanguage
][index
];
1232 newWords
.push(newWord
);
1234 newPhrase
= wordArrayToPhrase(newWords
);
1238 // TODO look at jsbip39 - mnemonic.splitWords
1239 function phraseToWordArray(phrase
) {
1240 var words
= phrase
.split(/\s/g);
1242 for (var i
=0; i
<words
.length
; i
++) {
1243 var word
= words
[i
];
1244 if (word
.length
> 0) {
1245 noBlanks
.push(word
);
1251 // TODO look at jsbip39 - mnemonic.joinWords
1252 function wordArrayToPhrase(words
) {
1253 var phrase
= words
.join(" ");
1254 var language
= getLanguageFromPhrase(phrase
);
1255 if (language
== "japanese") {
1256 phrase
= words
.join("\u3000");
1261 function isUsingOwnEntropy() {
1262 return DOM
.useEntropy
.prop("checked");
1265 function setMnemonicFromEntropy() {
1266 clearEntropyFeedback();
1267 // Get entropy value
1268 var entropyStr
= DOM
.entropy
.val();
1269 // Work out minimum base for entropy
1270 var entropy
= Entropy
.fromString(entropyStr
);
1271 if (entropy
.binaryStr
.length
== 0) {
1274 // Show entropy details
1275 showEntropyFeedback(entropy
);
1276 // Use entropy hash if not using raw entropy
1277 var bits
= entropy
.binaryStr
;
1278 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1279 if (mnemonicLength
!= "raw") {
1280 // Get bits by hashing entropy with SHA256
1281 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1282 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1283 bits
= BigInteger
.parse(hex
, 16).toString(2);
1284 while (bits
.length
% 256 != 0) {
1287 // Truncate hash to suit number of words
1288 mnemonicLength
= parseInt(mnemonicLength
);
1289 var numberOfBits
= 32 * mnemonicLength
/ 3;
1290 bits
= bits
.substring(0, numberOfBits
);
1291 // show warning for weak entropy override
1292 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1293 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1296 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1300 // hide warning for weak entropy override
1301 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1303 // Discard trailing entropy
1304 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1305 var start
= bits
.length
- bitsToUse
;
1306 var binaryStr
= bits
.substring(start
);
1307 // Convert entropy string to numeric array
1308 var entropyArr
= [];
1309 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1310 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1311 var entropyByte
= parseInt(byteAsBits
, 2);
1312 entropyArr
.push(entropyByte
)
1314 // Convert entropy array to mnemonic
1315 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1316 // Set the mnemonic in the UI
1317 DOM
.phrase
.val(phrase
);
1318 // Show the word indexes
1320 // Show the checksum
1324 function clearEntropyFeedback() {
1325 DOM
.entropyCrackTime
.text("...");
1326 DOM
.entropyType
.text("");
1327 DOM
.entropyWordCount
.text("0");
1328 DOM
.entropyEventCount
.text("0");
1329 DOM
.entropyBitsPerEvent
.text("0");
1330 DOM
.entropyBits
.text("0");
1331 DOM
.entropyFiltered
.html(" ");
1332 DOM
.entropyBinary
.html(" ");
1335 function showEntropyFeedback(entropy
) {
1336 var numberOfBits
= entropy
.binaryStr
.length
;
1337 var timeToCrack
= "unknown";
1339 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1340 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1341 if (z
.feedback
.warning
!= "") {
1342 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1346 console
.log("Error detecting entropy strength with zxcvbn:");
1349 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1350 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1351 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1352 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1353 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1354 DOM
.entropyType
.text(entropyTypeStr
);
1355 DOM
.entropyCrackTime
.text(timeToCrack
);
1356 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1357 DOM
.entropyBits
.text(numberOfBits
);
1358 DOM
.entropyWordCount
.text(wordCount
);
1359 DOM
.entropyBinary
.text(spacedBinaryStr
);
1360 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1361 // detect and warn of filtering
1362 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1363 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1364 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1366 DOM
.entropyFilterWarning
.removeClass('hidden');
1369 DOM
.entropyFilterWarning
.addClass('hidden');
1373 function getEntropyTypeStr(entropy
) {
1374 var typeStr
= entropy
.base
.str
;
1375 // Add some detail if these are cards
1376 if (entropy
.base
.asInt
== 52) {
1377 var cardDetail
= []; // array of message strings
1378 // Detect duplicates
1380 var dupeTracker
= {};
1381 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1382 var card
= entropy
.base
.parts
[i
];
1383 var cardUpper
= card
.toUpperCase();
1384 if (cardUpper
in dupeTracker
) {
1387 dupeTracker
[cardUpper
] = true;
1389 if (dupes
.length
> 0) {
1390 var dupeWord
= "duplicates";
1391 if (dupes
.length
== 1) {
1392 dupeWord
= "duplicate";
1394 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1395 if (dupes
.length
> 3) {
1398 cardDetail
.push(msg
);
1401 var uniqueCards
= [];
1402 for (var uniqueCard
in dupeTracker
) {
1403 uniqueCards
.push(uniqueCard
);
1405 if (uniqueCards
.length
== 52) {
1406 cardDetail
.unshift("full deck");
1408 // Detect missing cards
1409 var values
= "A23456789TJQK";
1411 var missingCards
= [];
1412 for (var i
=0; i
<suits
.length
; i
++) {
1413 for (var j
=0; j
<values
.length
; j
++) {
1414 var card
= values
[j
] + suits
[i
];
1415 if (!(card
in dupeTracker
)) {
1416 missingCards
.push(card
);
1420 // Display missing cards if six or less, ie clearly going for full deck
1421 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1422 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1423 if (missingCards
.length
> 3) {
1426 cardDetail
.push(msg
);
1428 // Add card details to typeStr
1429 if (cardDetail
.length
> 0) {
1430 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1436 function setQrEvents(els
) {
1437 els
.on("mouseenter", createQr
);
1438 els
.on("mouseleave", destroyQr
);
1439 els
.on("click", toggleQr
);
1442 function createQr(e
) {
1443 var content
= e
.target
.textContent
|| e
.target
.value
;
1451 DOM
.qrImage
.append(qrEl
);
1453 DOM
.qrHider
.addClass("hidden");
1456 DOM
.qrHider
.removeClass("hidden");
1458 DOM
.qrContainer
.removeClass("hidden");
1462 function destroyQr() {
1463 DOM
.qrImage
.text("");
1464 DOM
.qrContainer
.addClass("hidden");
1467 function toggleQr() {
1469 DOM
.qrHider
.toggleClass("hidden");
1470 DOM
.qrHint
.toggleClass("hidden");
1473 function bip44TabSelected() {
1474 return DOM
.bip44tab
.hasClass("active");
1477 function bip32TabSelected() {
1478 return DOM
.bip32tab
.hasClass("active");
1481 function networkHasSegwit() {
1483 if ("baseNetwork" in network
) {
1484 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1486 // check if only p2wpkh params are required
1487 if (p2wpkhSelected()) {
1488 return "p2wpkh" in n
;
1490 // check if only p2wpkh-in-p2sh params are required
1491 else if (p2wpkhInP2shSelected()) {
1492 return "p2wpkhInP2sh" in n
;
1494 // require both if it's unclear which params are required
1495 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1498 function bip49TabSelected() {
1499 return DOM
.bip49tab
.hasClass("active");
1502 function bip84TabSelected() {
1503 return DOM
.bip84tab
.hasClass("active");
1506 function bip141TabSelected() {
1507 return DOM
.bip141tab
.hasClass("active");
1510 function setHdCoin(coinValue
) {
1511 DOM
.bip44coin
.val(coinValue
);
1512 DOM
.bip49coin
.val(coinValue
);
1513 DOM
.bip84coin
.val(coinValue
);
1516 function showSegwitAvailable() {
1517 DOM
.bip49unavailable
.addClass("hidden");
1518 DOM
.bip49available
.removeClass("hidden");
1519 DOM
.bip84unavailable
.addClass("hidden");
1520 DOM
.bip84available
.removeClass("hidden");
1521 DOM
.bip141unavailable
.addClass("hidden");
1522 DOM
.bip141available
.removeClass("hidden");
1525 function showSegwitUnavailable() {
1526 DOM
.bip49available
.addClass("hidden");
1527 DOM
.bip49unavailable
.removeClass("hidden");
1528 DOM
.bip84available
.addClass("hidden");
1529 DOM
.bip84unavailable
.removeClass("hidden");
1530 DOM
.bip141available
.addClass("hidden");
1531 DOM
.bip141unavailable
.removeClass("hidden");
1534 function adjustNetworkForSegwit() {
1535 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1536 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1538 // See https://github.com/iancoleman/bip39/issues/125
1539 var segwitNetworks
= null;
1540 // if a segwit network is alread selected, need to use base network to
1541 // look up new parameters
1542 if ("baseNetwork" in network
) {
1543 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1545 // choose the right segwit params
1546 if (p2wpkhSelected() && "p2wpkh" in network
) {
1547 network
= network
.p2wpkh
;
1549 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1550 network
= network
.p2wpkhInP2sh
;
1554 function lastIndexInTable() {
1555 var pathText
= DOM
.addresses
.find(".index").last().text();
1556 var pathBits
= pathText
.split("/");
1557 var lastBit
= pathBits
[pathBits
.length
-1];
1558 var lastBitClean
= lastBit
.replace("'", "");
1559 return parseInt(lastBitClean
);
1562 function uint8ArrayToHex(a
) {
1564 for (var i
=0; i
<a
.length
; i
++) {
1565 var h
= a
[i
].toString(16);
1566 while (h
.length
< 2) {
1574 function showWordIndexes() {
1575 var phrase
= DOM
.phrase
.val();
1576 var words
= phraseToWordArray(phrase
);
1577 var wordIndexes
= [];
1578 var language
= getLanguage();
1579 for (var i
=0; i
<words
.length
; i
++) {
1580 var word
= words
[i
];
1581 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1582 wordIndexes
.push(wordIndex
);
1584 var wordIndexesStr
= wordIndexes
.join(", ");
1585 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1588 function showChecksum() {
1589 var phrase
= DOM
.phrase
.val();
1590 var words
= phraseToWordArray(phrase
);
1591 var checksumBitlength
= words
.length
/ 3;
1594 var language
= getLanguage();
1595 for (var i
=words
.length
-1; i
>=0; i
--) {
1596 var word
= words
[i
];
1597 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1598 var wordBinary
= wordIndex
.toString(2);
1599 while (wordBinary
.length
< 11) {
1600 wordBinary
= "0" + wordBinary
;
1602 var binaryStr
= wordBinary
+ binaryStr
;
1603 if (binaryStr
.length
>= checksumBitlength
) {
1604 var start
= binaryStr
.length
- checksumBitlength
;
1605 var end
= binaryStr
.length
;
1606 checksum
= binaryStr
.substring(start
, end
);
1607 // add spaces so the last group is 11 bits, not the first
1608 checksum
= checksum
.split("").reverse().join("")
1609 checksum
= addSpacesEveryElevenBits(checksum
);
1610 checksum
= checksum
.split("").reverse().join("")
1614 DOM
.entropyChecksum
.text(checksum
);
1617 function updateCsv() {
1618 var tableCsv
= "path,address,public key,private key\n";
1619 var rows
= DOM
.addresses
.find("tr");
1620 for (var i
=0; i
<rows
.length
; i
++) {
1621 var row
= $(rows
[i
]);
1622 var cells
= row
.find("td");
1623 for (var j
=0; j
<cells
.length
; j
++) {
1624 var cell
= $(cells
[j
]);
1625 if (!cell
.children().hasClass("invisible")) {
1626 tableCsv
= tableCsv
+ cell
.text();
1628 if (j
!= cells
.length
- 1) {
1629 tableCsv
= tableCsv
+ ",";
1632 tableCsv
= tableCsv
+ "\n";
1634 DOM
.csv
.val(tableCsv
);
1637 function addSpacesEveryElevenBits(binaryStr
) {
1638 return binaryStr
.match(/.{1,11}/g).join(" ");
1643 name: "AC - Asiacoin",
1644 onSelect: function() {
1645 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1650 name: "ACC - Adcoin",
1651 onSelect: function() {
1652 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1657 name: "AUR - Auroracoin",
1658 onSelect: function() {
1659 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1665 onSelect: function() {
1666 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1671 name: "ANON - ANON",
1672 onSelect: function() {
1673 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1678 name: "BCA - Bitcoin Atom",
1679 onSelect: function() {
1680 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1685 name: "BCH - Bitcoin Cash",
1686 onSelect: function() {
1687 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1692 name: "BEET - Beetlecoin",
1693 onSelect: function() {
1694 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1699 name: "BELA - Belacoin",
1700 onSelect: function() {
1701 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1706 name: "BLK - BlackCoin",
1707 onSelect: function() {
1708 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1713 name: "BRIT - Britcoin",
1714 onSelect: function() {
1715 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
1720 name: "BSD - Bitsend",
1721 onSelect: function() {
1722 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
1728 onSelect: function() {
1729 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1734 name: "BTC - Bitcoin",
1735 onSelect: function() {
1736 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1741 name: "BTC - Bitcoin Testnet",
1742 onSelect: function() {
1743 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1748 name: "BITG - Bitcoin Green",
1749 onSelect: function() {
1750 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1755 name: "BTCP - Bitcoin Private",
1756 onSelect: function() {
1757 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
1762 name: "BTCZ - Bitcoinz",
1763 onSelect: function() {
1764 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
1769 name: "BTDX - BitCloud",
1770 onSelect: function() {
1771 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
1776 name: "BTG - Bitcoin Gold",
1777 onSelect: function() {
1778 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
1783 name: "BTX - Bitcore",
1784 onSelect: function() {
1785 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
1790 name: "CCN - Cannacoin",
1791 onSelect: function() {
1792 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1797 name: "CESC - Cryptoescudo",
1798 onSelect: function() {
1799 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1804 name: "CDN - Canadaecoin",
1805 onSelect: function() {
1806 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
1811 name: "CLAM - Clams",
1812 onSelect: function() {
1813 network
= bitcoinjs
.bitcoin
.networks
.clam
;
1818 name: "CLO - Callisto",
1819 segwitAvailable: false,
1820 onSelect: function() {
1821 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1826 name: "CLUB - Clubcoin",
1827 onSelect: function() {
1828 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
1833 name: "CMP - Compcoin",
1834 onSelect: function() {
1835 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
1840 name: "CRAVE - Crave",
1841 onSelect: function() {
1842 network
= bitcoinjs
.bitcoin
.networks
.crave
;
1847 name: "CRW - Crown",
1848 onSelect: function() {
1849 network
= bitcoinjs
.bitcoin
.networks
.crown
;
1854 name: "DASH - Dash",
1855 onSelect: function() {
1856 network
= bitcoinjs
.bitcoin
.networks
.dash
;
1861 name: "DASH - Dash Testnet",
1862 onSelect: function() {
1863 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
1868 name: "DFC - Defcoin",
1869 onSelect: function() {
1870 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
1875 name: "DGB - Digibyte",
1876 onSelect: function() {
1877 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
1882 name: "DGC - Digitalcoin",
1883 onSelect: function() {
1884 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
1889 name: "DMD - Diamond",
1890 onSelect: function() {
1891 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
1896 name: "DNR - Denarius",
1897 onSelect: function() {
1898 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
1903 name: "DOGE - Dogecoin",
1904 onSelect: function() {
1905 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
1910 name: "ECN - Ecoin",
1911 onSelect: function() {
1912 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
1917 name: "EDRC - Edrcoin",
1918 onSelect: function() {
1919 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
1924 name: "EFL - Egulden",
1925 onSelect: function() {
1926 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
1931 name: "EMC2 - Einsteinium",
1932 onSelect: function() {
1933 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
1938 name: "ERC - Europecoin",
1939 onSelect: function() {
1940 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
1945 name: "ETC - Ethereum Classic",
1946 segwitAvailable: false,
1947 onSelect: function() {
1948 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1953 name: "ETH - Ethereum",
1954 onSelect: function() {
1955 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1960 name: "EXCL - Exclusivecoin",
1961 onSelect: function() {
1962 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
1967 name: "EXCC - ExchangeCoin",
1968 onSelect: function() {
1969 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
1974 name: "EXP - Expanse",
1975 segwitAvailable: false,
1976 onSelect: function() {
1977 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1982 name: "FJC - Fujicoin",
1983 onSelect: function() {
1984 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
1989 name: "FLASH - Flashcoin",
1990 onSelect: function() {
1991 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
1996 name: "FRST - Firstcoin",
1997 onSelect: function() {
1998 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2003 name: "FTC - Feathercoin",
2004 onSelect: function() {
2005 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2010 name: "GAME - GameCredits",
2011 onSelect: function() {
2012 network
= bitcoinjs
.bitcoin
.networks
.game
;
2017 name: "GBX - Gobyte",
2018 onSelect: function() {
2019 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2024 name: "GCR - GCRCoin",
2025 onSelect: function() {
2026 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2031 name: "GRC - Gridcoin",
2032 onSelect: function() {
2033 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2038 name: "HNC - Helleniccoin",
2039 onSelect: function() {
2040 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2045 name: "HUSH - Hush",
2046 onSelect: function() {
2047 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2052 name: "INSN - Insane",
2053 onSelect: function() {
2054 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2060 onSelect: function() {
2061 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2066 name: "IXC - Ixcoin",
2067 onSelect: function() {
2068 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2073 name: "JBS - Jumbucks",
2074 onSelect: function() {
2075 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2080 name: "KMD - Komodo",
2081 bip49available: false,
2082 onSelect: function() {
2083 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2088 name: "KOBO - Kobocoin",
2089 bip49available: false,
2090 onSelect: function() {
2091 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2096 name: "LBC - Library Credits",
2097 onSelect: function() {
2098 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2103 name: "LCC - Litecoincash",
2104 onSelect: function() {
2105 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2110 name: "LDCN - Landcoin",
2111 onSelect: function() {
2112 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2117 name: "LINX - Linx",
2118 onSelect: function() {
2119 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2124 name: "LTC - Litecoin",
2125 onSelect: function() {
2126 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2128 DOM
.litecoinLtubContainer
.removeClass("hidden");
2132 name: "LYNX - Lynx",
2133 onSelect: function() {
2134 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2139 name: "MAZA - Maza",
2140 onSelect: function() {
2141 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2146 name: "MEC - Megacoin",
2147 onSelect: function() {
2148 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2154 segwitAvailable: false,
2155 onSelect: function() {
2156 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2161 name: "MNX - Minexcoin",
2162 onSelect: function() {
2163 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2168 name: "MONA - Monacoin",
2169 onSelect: function() {
2170 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2175 name: "MUSIC - Musicoin",
2176 segwitAvailable: false,
2177 onSelect: function() {
2178 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2183 name: "NAV - Navcoin",
2184 onSelect: function() {
2185 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2190 name: "NEBL - Neblio",
2191 onSelect: function() {
2192 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2197 name: "NEOS - Neoscoin",
2198 onSelect: function() {
2199 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2204 name: "NLG - Gulden",
2205 onSelect: function() {
2206 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2211 name: "NMC - Namecoin",
2212 onSelect: function() {
2213 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2218 name: "NRG - Energi",
2219 onSelect: function() {
2220 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2225 name: "NRO - Neurocoin",
2226 onSelect: function() {
2227 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2232 name: "NSR - Nushares",
2233 onSelect: function() {
2234 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2239 name: "NYC - Newyorkc",
2240 onSelect: function() {
2241 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2246 name: "NVC - Novacoin",
2247 onSelect: function() {
2248 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2253 name: "OK - Okcash",
2254 onSelect: function() {
2255 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2260 name: "OMNI - Omnicore",
2261 onSelect: function() {
2262 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2267 name: "ONX - Onixcoin",
2268 onSelect: function() {
2269 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2274 name: "PINK - Pinkcoin",
2275 onSelect: function() {
2276 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2281 name: "PIRL - Pirl",
2282 segwitAvailable: false,
2283 onSelect: function() {
2284 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2289 name: "PIVX - PIVX",
2290 onSelect: function() {
2291 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2296 name: "PIVX - PIVX Testnet",
2297 onSelect: function() {
2298 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2304 segwitAvailable: false,
2305 onSelect: function() {
2306 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2311 name: "POSW - POSWcoin",
2312 onSelect: function() {
2313 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2318 name: "POT - Potcoin",
2319 onSelect: function() {
2320 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2325 name: "PPC - Peercoin",
2326 onSelect: function() {
2327 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2332 name: "PRJ - ProjectCoin",
2333 onSelect: function() {
2334 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2339 name: "PSB - Pesobit",
2340 onSelect: function() {
2341 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2346 name: "PUT - Putincoin",
2347 onSelect: function() {
2348 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2353 name: "RBY - Rubycoin",
2354 onSelect: function() {
2355 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2360 name: "RDD - Reddcoin",
2361 onSelect: function() {
2362 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2367 name: "RVR - RevolutionVR",
2368 onSelect: function() {
2369 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2374 name: "SLS - Salus",
2375 onSelect: function() {
2376 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2381 name: "SDC - ShadowCash",
2382 onSelect: function() {
2383 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2388 name: "SDC - ShadowCash Testnet",
2389 onSelect: function() {
2390 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2395 name: "SLM - Slimcoin",
2396 onSelect: function() {
2397 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2402 name: "SLM - Slimcoin Testnet",
2403 onSelect: function() {
2404 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2409 name: "SLR - Solarcoin",
2410 onSelect: function() {
2411 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2416 name: "SMLY - Smileycoin",
2417 onSelect: function() {
2418 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2423 name: "STASH - Stash",
2424 onSelect: function() {
2425 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2430 name: "STASH - Stash Testnet",
2431 onSelect: function() {
2432 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2437 name: "STRAT - Stratis",
2438 onSelect: function() {
2439 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2444 name: "TSTRAT - Stratis Testnet",
2445 onSelect: function() {
2446 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2451 name: "SYS - Syscoin",
2452 onSelect: function() {
2453 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2458 name: "THC - Hempcoin",
2459 onSelect: function() {
2460 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2466 onSelect: function() {
2467 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2472 name: "USC - Ultimatesecurecash",
2473 onSelect: function() {
2474 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2479 name: "USNBT - NuBits",
2480 onSelect: function() {
2481 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2486 name: "UNO - Unobtanium",
2487 onSelect: function() {
2488 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2493 name: "VASH - Vpncoin",
2494 onSelect: function() {
2495 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2500 name: "VIA - Viacoin",
2501 onSelect: function() {
2502 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2507 name: "VIA - Viacoin Testnet",
2508 onSelect: function() {
2509 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2514 name: "VIVO - Vivo",
2515 onSelect: function() {
2516 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2521 name: "VTC - Vertcoin",
2522 onSelect: function() {
2523 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2528 name: "WC - Wincoin",
2529 onSelect: function() {
2530 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2535 name: "XAX - Artax",
2536 onSelect: function() {
2537 network
= bitcoinjs
.bitcoin
.networks
.artax
;
2542 name: "XBC - Bitcoinplus",
2543 onSelect: function() {
2544 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
2549 name: "XMY - Myriadcoin",
2550 onSelect: function() {
2551 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
2556 name: "XRP - Ripple",
2557 onSelect: function() {
2558 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2563 name: "XVC - Vcash",
2564 onSelect: function() {
2565 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
2570 name: "XVG - Verge",
2571 onSelect: function() {
2572 network
= bitcoinjs
.bitcoin
.networks
.verge
;
2577 name: "XUEZ - Xuez",
2578 segwitAvailable: false,
2579 onSelect: function() {
2580 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
2585 name: "XWC - Whitecoin",
2586 onSelect: function() {
2587 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
2592 name: "XZC - Zcoin",
2593 onSelect: function() {
2594 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
2599 name: "ZCL - Zclassic",
2600 onSelect: function() {
2601 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
2606 name: "ZEC - Zcash",
2607 onSelect: function() {
2608 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
2613 name: "ZEN - Zencash",
2614 onSelect: function() {
2615 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
2623 name: "Bitcoin Core",
2624 onSelect: function() {
2625 DOM
.bip32path
.val("m/0'/0'");
2626 DOM
.hardenedAddresses
.prop('checked', true);
2630 name: "blockchain.info",
2631 onSelect: function() {
2632 DOM
.bip32path
.val("m/44'/0'/0'");
2633 DOM
.hardenedAddresses
.prop('checked', false);
2637 name: "MultiBit HD",
2638 onSelect: function() {
2639 DOM
.bip32path
.val("m/0'/0");
2640 DOM
.hardenedAddresses
.prop('checked', false);
2644 name: "Coinomi, Ledger",
2645 onSelect: function() {
2646 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
2647 DOM
.hardenedAddresses
.prop('checked', false);