3 // mnemonics is populated as required by getLanguage
4 var mnemonics
= { "english": new Mnemonic("english") };
5 var mnemonic
= mnemonics
["english"];
7 var bip32RootKey
= null;
8 var bip32ExtendedKey
= null;
9 var network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
10 var addressRowTemplate
= $("#address-row-template");
13 var showAddress
= true;
14 var showPubKey
= true;
15 var showPrivKey
= true;
17 var litecoinUseLtub
= true;
18 var isDefaultBip44ChangeValue
= true;
20 var entropyChangeTimeoutEvent
= null;
21 var phraseChangeTimeoutEvent
= null;
22 var rootKeyChangedTimeoutEvent
= null;
24 var generationProcesses
= [];
27 DOM
.privacyScreenToggle
= $(".privacy-screen-toggle");
28 DOM
.network
= $(".network");
29 DOM
.bip32Client
= $("#bip32-client");
30 DOM
.phraseNetwork
= $("#network-phrase");
31 DOM
.useEntropy
= $(".use-entropy");
32 DOM
.entropyContainer
= $(".entropy-container");
33 DOM
.entropy
= $(".entropy");
34 DOM
.entropyFiltered
= DOM
.entropyContainer
.find(".filtered");
35 DOM
.entropyType
= DOM
.entropyContainer
.find(".type");
36 DOM
.entropyCrackTime
= DOM
.entropyContainer
.find(".crack-time");
37 DOM
.entropyEventCount
= DOM
.entropyContainer
.find(".event-count");
38 DOM
.entropyBits
= DOM
.entropyContainer
.find(".bits");
39 DOM
.entropyBitsPerEvent
= DOM
.entropyContainer
.find(".bits-per-event");
40 DOM
.entropyWordCount
= DOM
.entropyContainer
.find(".word-count");
41 DOM
.entropyBinary
= DOM
.entropyContainer
.find(".binary");
42 DOM
.entropyWordIndexes
= DOM
.entropyContainer
.find(".word-indexes");
43 DOM
.entropyChecksum
= DOM
.entropyContainer
.find(".checksum");
44 DOM
.entropyMnemonicLength
= DOM
.entropyContainer
.find(".mnemonic-length");
45 DOM
.entropyWeakEntropyOverrideWarning
= DOM
.entropyContainer
.find(".weak-entropy-override-warning");
46 DOM
.entropyFilterWarning
= DOM
.entropyContainer
.find(".filter-warning");
47 DOM
.phrase
= $(".phrase");
48 DOM
.passphrase
= $(".passphrase");
49 DOM
.generateContainer
= $(".generate-container");
50 DOM
.generate
= $(".generate");
51 DOM
.seed
= $(".seed");
52 DOM
.rootKey
= $(".root-key");
53 DOM
.litecoinLtubContainer
= $(".litecoin-ltub-container");
54 DOM
.litecoinUseLtub
= $(".litecoin-use-ltub");
55 DOM
.extendedPrivKey
= $(".extended-priv-key");
56 DOM
.extendedPubKey
= $(".extended-pub-key");
57 DOM
.bip32tab
= $("#bip32-tab");
58 DOM
.bip44tab
= $("#bip44-tab");
59 DOM
.bip49tab
= $("#bip49-tab");
60 DOM
.bip84tab
= $("#bip84-tab");
61 DOM
.bip141tab
= $("#bip141-tab");
62 DOM
.bip32panel
= $("#bip32");
63 DOM
.bip44panel
= $("#bip44");
64 DOM
.bip49panel
= $("#bip49");
65 DOM
.bip32path
= $("#bip32-path");
66 DOM
.bip44path
= $("#bip44-path");
67 DOM
.bip44purpose
= $("#bip44 .purpose");
68 DOM
.bip44coin
= $("#bip44 .coin");
69 DOM
.bip44account
= $("#bip44 .account");
70 DOM
.bip44accountXprv
= $("#bip44 .account-xprv");
71 DOM
.bip44accountXpub
= $("#bip44 .account-xpub");
72 DOM
.bip44change
= $("#bip44 .change");
73 DOM
.defaultBip44ChangeValue
= $("#bip44 .default-bip44-change-value");
74 DOM
.bip49unavailable
= $("#bip49 .unavailable");
75 DOM
.bip49available
= $("#bip49 .available");
76 DOM
.bip49path
= $("#bip49-path");
77 DOM
.bip49purpose
= $("#bip49 .purpose");
78 DOM
.bip49coin
= $("#bip49 .coin");
79 DOM
.bip49account
= $("#bip49 .account");
80 DOM
.bip49accountXprv
= $("#bip49 .account-xprv");
81 DOM
.bip49accountXpub
= $("#bip49 .account-xpub");
82 DOM
.bip49change
= $("#bip49 .change");
83 DOM
.bip84unavailable
= $("#bip84 .unavailable");
84 DOM
.bip84available
= $("#bip84 .available");
85 DOM
.bip84path
= $("#bip84-path");
86 DOM
.bip84purpose
= $("#bip84 .purpose");
87 DOM
.bip84coin
= $("#bip84 .coin");
88 DOM
.bip84account
= $("#bip84 .account");
89 DOM
.bip84accountXprv
= $("#bip84 .account-xprv");
90 DOM
.bip84accountXpub
= $("#bip84 .account-xpub");
91 DOM
.bip84change
= $("#bip84 .change");
92 DOM
.bip141unavailable
= $("#bip141 .unavailable");
93 DOM
.bip141available
= $("#bip141 .available");
94 DOM
.bip141path
= $("#bip141-path");
95 DOM
.bip141semantics
= $(".bip141-semantics");
96 DOM
.generatedStrength
= $(".generate-container .strength");
97 DOM
.generatedStrengthWarning
= $(".generate-container .warning");
98 DOM
.hardenedAddresses
= $(".hardened-addresses");
99 DOM
.bitcoinCashAddressTypeContainer
= $(".bch-addr-type-container");
100 DOM
.bitcoinCashAddressType
= $("[name=bch-addr-type]")
101 DOM
.useBip38
= $(".use-bip38");
102 DOM
.bip38Password
= $(".bip38-password");
103 DOM
.addresses
= $(".addresses");
104 DOM
.csvTab
= $("#csv-tab a");
106 DOM
.rowsToAdd
= $(".rows-to-add");
107 DOM
.more
= $(".more");
108 DOM
.moreRowsStartIndex
= $(".more-rows-start-index");
109 DOM
.feedback
= $(".feedback");
110 DOM
.tab
= $(".derivation-type a");
111 DOM
.indexToggle
= $(".index-toggle");
112 DOM
.addressToggle
= $(".address-toggle");
113 DOM
.publicKeyToggle
= $(".public-key-toggle");
114 DOM
.privateKeyToggle
= $(".private-key-toggle");
115 DOM
.languages
= $(".languages a");
116 DOM
.qrContainer
= $(".qr-container");
117 DOM
.qrHider
= DOM
.qrContainer
.find(".qr-hider");
118 DOM
.qrImage
= DOM
.qrContainer
.find(".qr-image");
119 DOM
.qrHint
= DOM
.qrContainer
.find(".qr-hint");
120 DOM
.showQrEls
= $("[data-show-qr]");
124 DOM
.privacyScreenToggle
.on("change", privacyScreenToggled
);
125 DOM
.generatedStrength
.on("change", generatedStrengthChanged
);
126 DOM
.network
.on("change", networkChanged
);
127 DOM
.bip32Client
.on("change", bip32ClientChanged
);
128 DOM
.useEntropy
.on("change", setEntropyVisibility
);
129 DOM
.entropy
.on("input", delayedEntropyChanged
);
130 DOM
.entropyMnemonicLength
.on("change", entropyChanged
);
131 DOM
.phrase
.on("input", delayedPhraseChanged
);
132 DOM
.passphrase
.on("input", delayedPhraseChanged
);
133 DOM
.generate
.on("click", generateClicked
);
134 DOM
.more
.on("click", showMore
);
135 DOM
.rootKey
.on("input", delayedRootKeyChanged
);
136 DOM
.litecoinUseLtub
.on("change", litecoinUseLtubChanged
);
137 DOM
.bip32path
.on("input", calcForDerivationPath
);
138 DOM
.bip44account
.on("input", calcForDerivationPath
);
139 DOM
.bip44change
.on("input", modifiedDefaultBip44ChangeValue
);
140 DOM
.bip44change
.on("input", calcForDerivationPath
);
141 DOM
.defaultBip44ChangeValue
.on("click", resetDefaultBip44ChangeValue
);
142 DOM
.bip49account
.on("input", calcForDerivationPath
);
143 DOM
.bip49change
.on("input", calcForDerivationPath
);
144 DOM
.bip84account
.on("input", calcForDerivationPath
);
145 DOM
.bip84change
.on("input", calcForDerivationPath
);
146 DOM
.bip141path
.on("input", calcForDerivationPath
);
147 DOM
.bip141semantics
.on("change", tabChanged
);
148 DOM
.tab
.on("shown.bs.tab", tabChanged
);
149 DOM
.hardenedAddresses
.on("change", calcForDerivationPath
);
150 DOM
.useBip38
.on("change", calcForDerivationPath
);
151 DOM
.bip38Password
.on("change", calcForDerivationPath
);
152 DOM
.indexToggle
.on("click", toggleIndexes
);
153 DOM
.addressToggle
.on("click", toggleAddresses
);
154 DOM
.publicKeyToggle
.on("click", togglePublicKeys
);
155 DOM
.privateKeyToggle
.on("click", togglePrivateKeys
);
156 DOM
.csvTab
.on("click", updateCsv
);
157 DOM
.languages
.on("click", languageChanged
);
158 DOM
.bitcoinCashAddressType
.on("change", bitcoinCashAddressTypeChange
);
159 setQrEvents(DOM
.showQrEls
);
162 hideValidationError();
163 populateNetworkSelect();
164 populateClientSelect();
169 function generatedStrengthChanged() {
170 var strength
= parseInt(DOM
.generatedStrength
.val());
172 DOM
.generatedStrengthWarning
.removeClass("hidden");
175 DOM
.generatedStrengthWarning
.addClass("hidden");
179 function networkChanged(e
) {
181 clearAddressesList();
182 DOM
.litecoinLtubContainer
.addClass("hidden");
183 DOM
.bitcoinCashAddressTypeContainer
.addClass("hidden");
184 var networkIndex
= e
.target
.value
;
185 var network
= networks
[networkIndex
];
187 adjustNetworkForSegwit();
196 function bip32ClientChanged(e
) {
197 var clientIndex
= DOM
.bip32Client
.val();
198 if (clientIndex
== "custom") {
199 DOM
.bip32path
.prop("readonly", false);
202 DOM
.bip32path
.prop("readonly", true);
203 clients
[clientIndex
].onSelect();
213 function setEntropyVisibility() {
214 if (isUsingOwnEntropy()) {
215 DOM
.entropyContainer
.removeClass("hidden");
216 DOM
.generateContainer
.addClass("hidden");
217 DOM
.phrase
.prop("readonly", true);
222 DOM
.entropyContainer
.addClass("hidden");
223 DOM
.generateContainer
.removeClass("hidden");
224 DOM
.phrase
.prop("readonly", false);
229 function delayedPhraseChanged() {
230 hideValidationError();
233 bip32ExtendedKey
= null;
234 clearAddressesList();
236 if (phraseChangeTimeoutEvent
!= null) {
237 clearTimeout(phraseChangeTimeoutEvent
);
239 phraseChangeTimeoutEvent
= setTimeout(phraseChanged
, 400);
242 function phraseChanged() {
244 setMnemonicLanguage();
245 // Get the mnemonic phrase
246 var phrase
= DOM
.phrase
.val();
247 var errorText
= findPhraseErrors(phrase
);
249 showValidationError(errorText
);
252 // Calculate and display
253 var passphrase
= DOM
.passphrase
.val();
254 calcBip32RootKeyFromSeed(phrase
, passphrase
);
255 calcForDerivationPath();
256 // Show the word indexes
260 function tabChanged() {
262 adjustNetworkForSegwit();
263 var phrase
= DOM
.phrase
.val();
265 // Calculate and display for mnemonic
266 var errorText
= findPhraseErrors(phrase
);
268 showValidationError(errorText
);
271 // Calculate and display
272 var passphrase
= DOM
.passphrase
.val();
273 calcBip32RootKeyFromSeed(phrase
, passphrase
);
276 // Calculate and display for root key
277 var rootKeyBase58
= DOM
.rootKey
.val();
278 var errorText
= validateRootKey(rootKeyBase58
);
280 showValidationError(errorText
);
283 // Calculate and display
284 calcBip32RootKeyFromBase58(rootKeyBase58
);
286 calcForDerivationPath();
289 function delayedEntropyChanged() {
290 hideValidationError();
292 if (entropyChangeTimeoutEvent
!= null) {
293 clearTimeout(entropyChangeTimeoutEvent
);
295 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
298 function entropyChanged() {
299 // If blank entropy, clear mnemonic, addresses, errors
300 if (DOM
.entropy
.val().trim().length
== 0) {
302 clearEntropyFeedback();
304 showValidationError("Blank entropy");
307 // Get the current phrase to detect changes
308 var phrase
= DOM
.phrase
.val();
309 // Set the phrase from the entropy
310 setMnemonicFromEntropy();
311 // Recalc addresses if the phrase has changed
312 var newPhrase
= DOM
.phrase
.val();
313 if (newPhrase
!= phrase
) {
314 if (newPhrase
.length
== 0) {
326 function delayedRootKeyChanged() {
327 // Warn if there is an existing mnemonic or passphrase.
328 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
329 if (!confirm("This will clear existing mnemonic and passphrase")) {
330 DOM
.rootKey
.val(bip32RootKey
);
334 hideValidationError();
336 // Clear existing mnemonic and passphrase
338 DOM
.passphrase
.val("");
340 if (rootKeyChangedTimeoutEvent
!= null) {
341 clearTimeout(rootKeyChangedTimeoutEvent
);
343 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
346 function rootKeyChanged() {
348 hideValidationError();
349 var rootKeyBase58
= DOM
.rootKey
.val();
350 var errorText
= validateRootKey(rootKeyBase58
);
352 showValidationError(errorText
);
355 // Calculate and display
356 calcBip32RootKeyFromBase58(rootKeyBase58
);
357 calcForDerivationPath();
360 function litecoinUseLtubChanged() {
361 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
362 if (litecoinUseLtub
) {
363 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
366 network
= bitcoinjs
.bitcoin
.networks
.litecoinXprv
;
371 function calcForDerivationPath() {
373 clearAddressesList();
375 // Don't show segwit if it's selected but network doesn't support it
376 if (segwitSelected() && !networkHasSegwit()) {
377 showSegwitUnavailable();
381 showSegwitAvailable();
382 // Get the derivation path
383 var derivationPath
= getDerivationPath();
384 var errorText
= findDerivationPathErrors(derivationPath
);
386 showValidationError(errorText
);
389 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
390 if (bip44TabSelected()) {
393 else if (bip49TabSelected()) {
396 else if (bip84TabSelected()) {
402 function generateClicked() {
403 if (isUsingOwnEntropy()) {
408 setTimeout(function() {
409 setMnemonicLanguage();
410 var phrase
= generateRandomPhrase();
418 function languageChanged() {
419 setTimeout(function() {
420 setMnemonicLanguage();
421 if (DOM
.phrase
.val().length
> 0) {
422 var newPhrase
= convertPhraseToNewLanguage();
423 DOM
.phrase
.val(newPhrase
);
427 DOM
.generate
.trigger("click");
432 function bitcoinCashAddressTypeChange() {
436 function toggleIndexes() {
437 showIndex
= !showIndex
;
438 $("td.index span").toggleClass("invisible");
441 function toggleAddresses() {
442 showAddress
= !showAddress
;
443 $("td.address span").toggleClass("invisible");
446 function togglePublicKeys() {
447 showPubKey
= !showPubKey
;
448 $("td.pubkey span").toggleClass("invisible");
451 function togglePrivateKeys() {
452 showPrivKey
= !showPrivKey
;
453 $("td.privkey span").toggleClass("invisible");
456 function privacyScreenToggled() {
457 // private-data contains elements added to DOM at runtime
458 // so catch all by adding visual privacy class to the root of the DOM
459 if (DOM
.privacyScreenToggle
.prop("checked")) {
460 $("body").addClass("visual-privacy");
463 $("body").removeClass("visual-privacy");
469 function generateRandomPhrase() {
470 if (!hasStrongRandom()) {
471 var errorText
= "This browser does not support strong randomness";
472 showValidationError(errorText
);
475 // get the amount of entropy to use
476 var numWords
= parseInt(DOM
.generatedStrength
.val());
477 var strength
= numWords
/ 3 * 32;
478 var buffer
= new Uint8Array(strength
/ 8);
479 // create secure entropy
480 var data
= crypto
.getRandomValues(buffer
);
482 var words
= mnemonic
.toMnemonic(data
);
483 DOM
.phrase
.val(words
);
485 var entropyHex
= uint8ArrayToHex(data
);
486 DOM
.entropy
.val(entropyHex
);
487 // ensure entropy fields are consistent with what is being displayed
488 DOM
.entropyMnemonicLength
.val("raw");
492 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
493 seed
= mnemonic
.toSeed(phrase
, passphrase
);
494 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
497 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
498 // try parsing with various segwit network params since this extended
499 // key may be from any one of them.
500 if (networkHasSegwit()) {
502 if ("baseNetwork" in n
) {
503 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
505 // try parsing using base network params
507 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
511 // try parsing using p2wpkh params
514 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
519 // try parsing using p2wpkh-in-p2sh network params
520 if ("p2wpkhInP2sh" in n
) {
522 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
528 // try the network params as currently specified
529 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
532 function calcBip32ExtendedKey(path
) {
533 // Check there's a root key to derive from
537 var extendedKey
= bip32RootKey
;
538 // Derive the key from the path
539 var pathBits
= path
.split("/");
540 for (var i
=0; i
<pathBits
.length
; i
++) {
541 var bit
= pathBits
[i
];
542 var index
= parseInt(bit
);
546 var hardened
= bit
[bit
.length
-1] == "'";
547 var isPriv
= !(extendedKey
.isNeutered());
548 var invalidDerivationPath
= hardened
&& !isPriv
;
549 if (invalidDerivationPath
) {
553 extendedKey
= extendedKey
.deriveHardened(index
);
556 extendedKey
= extendedKey
.derive(index
);
562 function showValidationError(errorText
) {
568 function hideValidationError() {
574 function findPhraseErrors(phrase
) {
575 // Preprocess the words
576 phrase
= mnemonic
.normalizeString(phrase
);
577 var words
= phraseToWordArray(phrase
);
578 // Detect blank phrase
579 if (words
.length
== 0) {
580 return "Blank mnemonic";
583 for (var i
=0; i
<words
.length
; i
++) {
585 var language
= getLanguage();
586 if (WORDLISTS
[language
].indexOf(word
) == -1) {
587 console
.log("Finding closest match to " + word
);
588 var nearestWord
= findNearestWord(word
);
589 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
592 // Check the words are valid
593 var properPhrase
= wordArrayToPhrase(words
);
594 var isValid
= mnemonic
.check(properPhrase
);
596 return "Invalid mnemonic";
601 function validateRootKey(rootKeyBase58
) {
602 // try various segwit network params since this extended key may be from
604 if (networkHasSegwit()) {
606 if ("baseNetwork" in n
) {
607 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
609 // try parsing using base network params
611 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
615 // try parsing using p2wpkh params
618 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
623 // try parsing using p2wpkh-in-p2sh network params
624 if ("p2wpkhInP2sh" in n
) {
626 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
632 // try the network params as currently specified
634 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
637 return "Invalid root key";
642 function getDerivationPath() {
643 if (bip44TabSelected()) {
644 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
645 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
646 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
647 var change
= parseIntNoNaN(DOM
.bip44change
.val(), "");
649 path
+= "/" + purpose
+ "'";
650 path
+= "/" + coin
+ "'";
651 path
+= "/" + account
+ "'";
653 path
+= "/" + change
;
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 (networkIsEthereum()) {
920 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
921 privkey
= privKeyBuffer
.toString('hex');
922 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
923 var hexAddress
= addressBuffer
.toString('hex');
924 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
925 address
= ethUtil
.addHexPrefix(checksumAddress
);
926 privkey
= ethUtil
.addHexPrefix(privkey
);
927 pubkey
= ethUtil
.addHexPrefix(pubkey
);
929 // Ripple values are different
930 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
931 privkey
= convertRipplePriv(privkey
);
932 address
= convertRippleAdrr(address
);
934 // Bitcoin Cash address format may vary
935 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
936 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
937 if (bchAddrType
== "cashaddr") {
938 address
= bchaddr
.toCashAddress(address
);
940 else if (bchAddrType
== "bitpay") {
941 address
= bchaddr
.toBitpayAddress(address
);
944 // Segwit addresses are different
946 if (!segwitAvailable
) {
950 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
951 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
952 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
954 else if (isP2wpkhInP2sh
) {
955 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
956 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
957 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
958 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
959 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
962 addAddressToList(indexText
, address
, pubkey
, privkey
);
974 function showMore() {
975 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
976 if (isNaN(rowsToAdd
)) {
978 DOM
.rowsToAdd
.val("20");
980 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
982 start
= lastIndexInTable() + 1;
985 var newStart
= start
+ rowsToAdd
;
986 DOM
.moreRowsStartIndex
.val(newStart
);
988 if (rowsToAdd
> 200) {
989 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
990 msg
+= "Do you want to continue?";
995 displayAddresses(start
, rowsToAdd
);
998 function clearDisplay() {
999 clearAddressesList();
1001 hideValidationError();
1004 function clearAddressesList() {
1005 DOM
.addresses
.empty();
1010 function stopGenerating() {
1011 while (generationProcesses
.length
> 0) {
1012 var generation
= generationProcesses
.shift();
1017 function clearKeys() {
1022 function clearRootKey() {
1023 DOM
.rootKey
.val("");
1026 function clearDerivedKeys() {
1027 DOM
.extendedPrivKey
.val("");
1028 DOM
.extendedPubKey
.val("");
1029 DOM
.bip44accountXprv
.val("");
1030 DOM
.bip44accountXpub
.val("");
1033 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1034 var row
= $(addressRowTemplate
.html());
1036 var indexCell
= row
.find(".index span");
1037 var addressCell
= row
.find(".address span");
1038 var pubkeyCell
= row
.find(".pubkey span");
1039 var privkeyCell
= row
.find(".privkey span");
1041 indexCell
.text(indexText
);
1042 addressCell
.text(address
);
1043 pubkeyCell
.text(pubkey
);
1044 privkeyCell
.text(privkey
);
1047 indexCell
.addClass("invisible");
1050 addressCell
.addClass("invisible");
1053 pubkeyCell
.addClass("invisible");
1056 privkeyCell
.addClass("invisible");
1058 DOM
.addresses
.append(row
);
1059 var rowShowQrEls
= row
.find("[data-show-qr]");
1060 setQrEvents(rowShowQrEls
);
1063 function hasStrongRandom() {
1064 return 'crypto' in window
&& window
['crypto'] !== null;
1067 function disableForms() {
1068 $("form").on("submit", function(e
) {
1073 function parseIntNoNaN(val
, defaultVal
) {
1074 var v
= parseInt(val
);
1081 function showPending() {
1083 .text("Calculating...")
1087 function findNearestWord(word
) {
1088 var language
= getLanguage();
1089 var words
= WORDLISTS
[language
];
1090 var minDistance
= 99;
1091 var closestWord
= words
[0];
1092 for (var i
=0; i
<words
.length
; i
++) {
1093 var comparedTo
= words
[i
];
1094 if (comparedTo
.indexOf(word
) == 0) {
1097 var distance
= Levenshtein
.get(word
, comparedTo
);
1098 if (distance
< minDistance
) {
1099 closestWord
= comparedTo
;
1100 minDistance
= distance
;
1106 function hidePending() {
1112 function populateNetworkSelect() {
1113 for (var i
=0; i
<networks
.length
; i
++) {
1114 var network
= networks
[i
];
1115 var option
= $("<option>");
1116 option
.attr("value", i
);
1117 option
.text(network
.name
);
1118 if (network
.name
== "BTC - Bitcoin") {
1119 option
.prop("selected", true);
1121 DOM
.phraseNetwork
.append(option
);
1125 function populateClientSelect() {
1126 for (var i
=0; i
<clients
.length
; i
++) {
1127 var client
= clients
[i
];
1128 var option
= $("<option>");
1129 option
.attr("value", i
);
1130 option
.text(client
.name
);
1131 DOM
.bip32Client
.append(option
);
1135 function getLanguage() {
1136 var defaultLanguage
= "english";
1137 // Try to get from existing phrase
1138 var language
= getLanguageFromPhrase();
1139 // Try to get from url if not from phrase
1140 if (language
.length
== 0) {
1141 language
= getLanguageFromUrl();
1143 // Default to English if no other option
1144 if (language
.length
== 0) {
1145 language
= defaultLanguage
;
1150 function getLanguageFromPhrase(phrase
) {
1151 // Check if how many words from existing phrase match a language.
1154 phrase
= DOM
.phrase
.val();
1156 if (phrase
.length
> 0) {
1157 var words
= phraseToWordArray(phrase
);
1158 var languageMatches
= {};
1159 for (l
in WORDLISTS
) {
1160 // Track how many words match in this language
1161 languageMatches
[l
] = 0;
1162 for (var i
=0; i
<words
.length
; i
++) {
1163 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1164 if (wordInLanguage
) {
1165 languageMatches
[l
]++;
1168 // Find languages with most word matches.
1169 // This is made difficult due to commonalities between Chinese
1170 // simplified vs traditional.
1171 var mostMatches
= 0;
1172 var mostMatchedLanguages
= [];
1173 for (var l
in languageMatches
) {
1174 var numMatches
= languageMatches
[l
];
1175 if (numMatches
> mostMatches
) {
1176 mostMatches
= numMatches
;
1177 mostMatchedLanguages
= [l
];
1179 else if (numMatches
== mostMatches
) {
1180 mostMatchedLanguages
.push(l
);
1184 if (mostMatchedLanguages
.length
> 0) {
1185 // Use first language and warn if multiple detected
1186 language
= mostMatchedLanguages
[0];
1187 if (mostMatchedLanguages
.length
> 1) {
1188 console
.warn("Multiple possible languages");
1189 console
.warn(mostMatchedLanguages
);
1196 function getLanguageFromUrl() {
1197 for (var language
in WORDLISTS
) {
1198 if (window
.location
.hash
.indexOf(language
) > -1) {
1205 function setMnemonicLanguage() {
1206 var language
= getLanguage();
1207 // Load the bip39 mnemonic generator for this language if required
1208 if (!(language
in mnemonics
)) {
1209 mnemonics
[language
] = new Mnemonic(language
);
1211 mnemonic
= mnemonics
[language
];
1214 function convertPhraseToNewLanguage() {
1215 var oldLanguage
= getLanguageFromPhrase();
1216 var newLanguage
= getLanguageFromUrl();
1217 var oldPhrase
= DOM
.phrase
.val();
1218 var oldWords
= phraseToWordArray(oldPhrase
);
1220 for (var i
=0; i
<oldWords
.length
; i
++) {
1221 var oldWord
= oldWords
[i
];
1222 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1223 var newWord
= WORDLISTS
[newLanguage
][index
];
1224 newWords
.push(newWord
);
1226 newPhrase
= wordArrayToPhrase(newWords
);
1230 // TODO look at jsbip39 - mnemonic.splitWords
1231 function phraseToWordArray(phrase
) {
1232 var words
= phrase
.split(/\s/g);
1234 for (var i
=0; i
<words
.length
; i
++) {
1235 var word
= words
[i
];
1236 if (word
.length
> 0) {
1237 noBlanks
.push(word
);
1243 // TODO look at jsbip39 - mnemonic.joinWords
1244 function wordArrayToPhrase(words
) {
1245 var phrase
= words
.join(" ");
1246 var language
= getLanguageFromPhrase(phrase
);
1247 if (language
== "japanese") {
1248 phrase
= words
.join("\u3000");
1253 function isUsingOwnEntropy() {
1254 return DOM
.useEntropy
.prop("checked");
1257 function setMnemonicFromEntropy() {
1258 clearEntropyFeedback();
1259 // Get entropy value
1260 var entropyStr
= DOM
.entropy
.val();
1261 // Work out minimum base for entropy
1262 var entropy
= Entropy
.fromString(entropyStr
);
1263 if (entropy
.binaryStr
.length
== 0) {
1266 // Show entropy details
1267 showEntropyFeedback(entropy
);
1268 // Use entropy hash if not using raw entropy
1269 var bits
= entropy
.binaryStr
;
1270 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1271 if (mnemonicLength
!= "raw") {
1272 // Get bits by hashing entropy with SHA256
1273 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1274 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1275 bits
= BigInteger
.parse(hex
, 16).toString(2);
1276 while (bits
.length
% 256 != 0) {
1279 // Truncate hash to suit number of words
1280 mnemonicLength
= parseInt(mnemonicLength
);
1281 var numberOfBits
= 32 * mnemonicLength
/ 3;
1282 bits
= bits
.substring(0, numberOfBits
);
1283 // show warning for weak entropy override
1284 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1285 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1288 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1292 // hide warning for weak entropy override
1293 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1295 // Discard trailing entropy
1296 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1297 var start
= bits
.length
- bitsToUse
;
1298 var binaryStr
= bits
.substring(start
);
1299 // Convert entropy string to numeric array
1300 var entropyArr
= [];
1301 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1302 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1303 var entropyByte
= parseInt(byteAsBits
, 2);
1304 entropyArr
.push(entropyByte
)
1306 // Convert entropy array to mnemonic
1307 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1308 // Set the mnemonic in the UI
1309 DOM
.phrase
.val(phrase
);
1310 // Show the word indexes
1312 // Show the checksum
1316 function clearEntropyFeedback() {
1317 DOM
.entropyCrackTime
.text("...");
1318 DOM
.entropyType
.text("");
1319 DOM
.entropyWordCount
.text("0");
1320 DOM
.entropyEventCount
.text("0");
1321 DOM
.entropyBitsPerEvent
.text("0");
1322 DOM
.entropyBits
.text("0");
1323 DOM
.entropyFiltered
.html(" ");
1324 DOM
.entropyBinary
.html(" ");
1327 function showEntropyFeedback(entropy
) {
1328 var numberOfBits
= entropy
.binaryStr
.length
;
1329 var timeToCrack
= "unknown";
1331 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1332 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1333 if (z
.feedback
.warning
!= "") {
1334 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1338 console
.log("Error detecting entropy strength with zxcvbn:");
1341 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1342 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1343 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1344 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1345 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1346 DOM
.entropyType
.text(entropyTypeStr
);
1347 DOM
.entropyCrackTime
.text(timeToCrack
);
1348 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1349 DOM
.entropyBits
.text(numberOfBits
);
1350 DOM
.entropyWordCount
.text(wordCount
);
1351 DOM
.entropyBinary
.text(spacedBinaryStr
);
1352 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1353 // detect and warn of filtering
1354 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1355 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1356 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1358 DOM
.entropyFilterWarning
.removeClass('hidden');
1361 DOM
.entropyFilterWarning
.addClass('hidden');
1365 function getEntropyTypeStr(entropy
) {
1366 var typeStr
= entropy
.base
.str
;
1367 // Add some detail if these are cards
1368 if (entropy
.base
.asInt
== 52) {
1369 var cardDetail
= []; // array of message strings
1370 // Detect duplicates
1372 var dupeTracker
= {};
1373 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1374 var card
= entropy
.base
.parts
[i
];
1375 var cardUpper
= card
.toUpperCase();
1376 if (cardUpper
in dupeTracker
) {
1379 dupeTracker
[cardUpper
] = true;
1381 if (dupes
.length
> 0) {
1382 var dupeWord
= "duplicates";
1383 if (dupes
.length
== 1) {
1384 dupeWord
= "duplicate";
1386 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1387 if (dupes
.length
> 3) {
1390 cardDetail
.push(msg
);
1393 var uniqueCards
= [];
1394 for (var uniqueCard
in dupeTracker
) {
1395 uniqueCards
.push(uniqueCard
);
1397 if (uniqueCards
.length
== 52) {
1398 cardDetail
.unshift("full deck");
1400 // Detect missing cards
1401 var values
= "A23456789TJQK";
1403 var missingCards
= [];
1404 for (var i
=0; i
<suits
.length
; i
++) {
1405 for (var j
=0; j
<values
.length
; j
++) {
1406 var card
= values
[j
] + suits
[i
];
1407 if (!(card
in dupeTracker
)) {
1408 missingCards
.push(card
);
1412 // Display missing cards if six or less, ie clearly going for full deck
1413 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1414 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1415 if (missingCards
.length
> 3) {
1418 cardDetail
.push(msg
);
1420 // Add card details to typeStr
1421 if (cardDetail
.length
> 0) {
1422 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1428 function setQrEvents(els
) {
1429 els
.on("mouseenter", createQr
);
1430 els
.on("mouseleave", destroyQr
);
1431 els
.on("click", toggleQr
);
1434 function createQr(e
) {
1435 var content
= e
.target
.textContent
|| e
.target
.value
;
1443 DOM
.qrImage
.append(qrEl
);
1445 DOM
.qrHider
.addClass("hidden");
1448 DOM
.qrHider
.removeClass("hidden");
1450 DOM
.qrContainer
.removeClass("hidden");
1454 function destroyQr() {
1455 DOM
.qrImage
.text("");
1456 DOM
.qrContainer
.addClass("hidden");
1459 function toggleQr() {
1461 DOM
.qrHider
.toggleClass("hidden");
1462 DOM
.qrHint
.toggleClass("hidden");
1465 function bip44TabSelected() {
1466 return DOM
.bip44tab
.hasClass("active");
1469 function bip32TabSelected() {
1470 return DOM
.bip32tab
.hasClass("active");
1473 function networkIsEthereum() {
1474 var name
= networks
[DOM
.network
.val()].name
;
1475 return (name
== "ETH - Ethereum")
1476 || (name
== "ETC - Ethereum Classic")
1477 || (name
== "PIRL - Pirl")
1478 || (name
== "MIX - MIX")
1479 || (name
== "MUSIC - Musicoin")
1480 || (name
== "POA - Poa")
1481 || (name
== "EXP - Expanse")
1482 || (name
== "CLO - Callisto");
1485 function networkHasSegwit() {
1487 if ("baseNetwork" in network
) {
1488 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1490 // check if only p2wpkh params are required
1491 if (p2wpkhSelected()) {
1492 return "p2wpkh" in n
;
1494 // check if only p2wpkh-in-p2sh params are required
1495 else if (p2wpkhInP2shSelected()) {
1496 return "p2wpkhInP2sh" in n
;
1498 // require both if it's unclear which params are required
1499 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1502 function bip49TabSelected() {
1503 return DOM
.bip49tab
.hasClass("active");
1506 function bip84TabSelected() {
1507 return DOM
.bip84tab
.hasClass("active");
1510 function bip141TabSelected() {
1511 return DOM
.bip141tab
.hasClass("active");
1514 function setBip44ChangeValue() {
1515 if (isDefaultBip44ChangeValue
) {
1516 if (networkIsEthereum()) {
1517 DOM
.bip44change
.val("");
1519 DOM
.bip44change
.val(0);
1524 function modifiedDefaultBip44ChangeValue() {
1525 isDefaultBip44ChangeValue
= false;
1528 function resetDefaultBip44ChangeValue() {
1529 isDefaultBip44ChangeValue
= true;
1530 setBip44ChangeValue();
1533 function setHdCoin(coinValue
) {
1534 DOM
.bip44coin
.val(coinValue
);
1535 DOM
.bip49coin
.val(coinValue
);
1536 DOM
.bip84coin
.val(coinValue
);
1537 setBip44ChangeValue();
1540 function showSegwitAvailable() {
1541 DOM
.bip49unavailable
.addClass("hidden");
1542 DOM
.bip49available
.removeClass("hidden");
1543 DOM
.bip84unavailable
.addClass("hidden");
1544 DOM
.bip84available
.removeClass("hidden");
1545 DOM
.bip141unavailable
.addClass("hidden");
1546 DOM
.bip141available
.removeClass("hidden");
1549 function showSegwitUnavailable() {
1550 DOM
.bip49available
.addClass("hidden");
1551 DOM
.bip49unavailable
.removeClass("hidden");
1552 DOM
.bip84available
.addClass("hidden");
1553 DOM
.bip84unavailable
.removeClass("hidden");
1554 DOM
.bip141available
.addClass("hidden");
1555 DOM
.bip141unavailable
.removeClass("hidden");
1558 function adjustNetworkForSegwit() {
1559 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1560 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1562 // See https://github.com/iancoleman/bip39/issues/125
1563 var segwitNetworks
= null;
1564 // if a segwit network is alread selected, need to use base network to
1565 // look up new parameters
1566 if ("baseNetwork" in network
) {
1567 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1569 // choose the right segwit params
1570 if (p2wpkhSelected() && "p2wpkh" in network
) {
1571 network
= network
.p2wpkh
;
1573 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1574 network
= network
.p2wpkhInP2sh
;
1578 function lastIndexInTable() {
1579 var pathText
= DOM
.addresses
.find(".index").last().text();
1580 var pathBits
= pathText
.split("/");
1581 var lastBit
= pathBits
[pathBits
.length
-1];
1582 var lastBitClean
= lastBit
.replace("'", "");
1583 return parseInt(lastBitClean
);
1586 function uint8ArrayToHex(a
) {
1588 for (var i
=0; i
<a
.length
; i
++) {
1589 var h
= a
[i
].toString(16);
1590 while (h
.length
< 2) {
1598 function showWordIndexes() {
1599 var phrase
= DOM
.phrase
.val();
1600 var words
= phraseToWordArray(phrase
);
1601 var wordIndexes
= [];
1602 var language
= getLanguage();
1603 for (var i
=0; i
<words
.length
; i
++) {
1604 var word
= words
[i
];
1605 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1606 wordIndexes
.push(wordIndex
);
1608 var wordIndexesStr
= wordIndexes
.join(", ");
1609 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1612 function showChecksum() {
1613 var phrase
= DOM
.phrase
.val();
1614 var words
= phraseToWordArray(phrase
);
1615 var checksumBitlength
= words
.length
/ 3;
1618 var language
= getLanguage();
1619 for (var i
=words
.length
-1; i
>=0; i
--) {
1620 var word
= words
[i
];
1621 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1622 var wordBinary
= wordIndex
.toString(2);
1623 while (wordBinary
.length
< 11) {
1624 wordBinary
= "0" + wordBinary
;
1626 var binaryStr
= wordBinary
+ binaryStr
;
1627 if (binaryStr
.length
>= checksumBitlength
) {
1628 var start
= binaryStr
.length
- checksumBitlength
;
1629 var end
= binaryStr
.length
;
1630 checksum
= binaryStr
.substring(start
, end
);
1631 // add spaces so the last group is 11 bits, not the first
1632 checksum
= checksum
.split("").reverse().join("")
1633 checksum
= addSpacesEveryElevenBits(checksum
);
1634 checksum
= checksum
.split("").reverse().join("")
1638 DOM
.entropyChecksum
.text(checksum
);
1641 function updateCsv() {
1642 var tableCsv
= "path,address,public key,private key\n";
1643 var rows
= DOM
.addresses
.find("tr");
1644 for (var i
=0; i
<rows
.length
; i
++) {
1645 var row
= $(rows
[i
]);
1646 var cells
= row
.find("td");
1647 for (var j
=0; j
<cells
.length
; j
++) {
1648 var cell
= $(cells
[j
]);
1649 if (!cell
.children().hasClass("invisible")) {
1650 tableCsv
= tableCsv
+ cell
.text();
1652 if (j
!= cells
.length
- 1) {
1653 tableCsv
= tableCsv
+ ",";
1656 tableCsv
= tableCsv
+ "\n";
1658 DOM
.csv
.val(tableCsv
);
1661 function addSpacesEveryElevenBits(binaryStr
) {
1662 return binaryStr
.match(/.{1,11}/g).join(" ");
1667 name: "AC - Asiacoin",
1668 onSelect: function() {
1669 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1674 name: "ACC - Adcoin",
1675 onSelect: function() {
1676 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1681 name: "AUR - Auroracoin",
1682 onSelect: function() {
1683 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1689 onSelect: function() {
1690 network
= bitcoinjs
.bitcoin
.networks
.axe
;
1695 name: "ANON - ANON",
1696 onSelect: function() {
1697 network
= bitcoinjs
.bitcoin
.networks
.anon
;
1702 name: "BCA - Bitcoin Atom",
1703 onSelect: function() {
1704 network
= bitcoinjs
.bitcoin
.networks
.atom
;
1709 name: "BCH - Bitcoin Cash",
1710 onSelect: function() {
1711 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
1716 name: "BEET - Beetlecoin",
1717 onSelect: function() {
1718 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
1723 name: "BELA - Belacoin",
1724 onSelect: function() {
1725 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
1730 name: "BLK - BlackCoin",
1731 onSelect: function() {
1732 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
1737 name: "BND - Blocknode",
1738 onSelect: function() {
1739 network
= bitcoinjs
.bitcoin
.networks
.blocknode
;
1744 name: "tBND - Blocknode Testnet",
1745 onSelect: function() {
1746 network
= bitcoinjs
.bitcoin
.networks
.blocknode_testnet
;
1751 name: "BRIT - Britcoin",
1752 onSelect: function() {
1753 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
1758 name: "BSD - Bitsend",
1759 onSelect: function() {
1760 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
1766 onSelect: function() {
1767 network
= bitcoinjs
.bitcoin
.networks
.bata
;
1772 name: "BTC - Bitcoin",
1773 onSelect: function() {
1774 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1779 name: "BTC - Bitcoin Testnet",
1780 onSelect: function() {
1781 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
1786 name: "BITG - Bitcoin Green",
1787 onSelect: function() {
1788 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
1793 name: "BTCP - Bitcoin Private",
1794 onSelect: function() {
1795 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
1800 name: "BTCZ - Bitcoinz",
1801 onSelect: function() {
1802 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
1807 name: "BTDX - BitCloud",
1808 onSelect: function() {
1809 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
1814 name: "BTG - Bitcoin Gold",
1815 onSelect: function() {
1816 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
1821 name: "BTX - Bitcore",
1822 onSelect: function() {
1823 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
1828 name: "CCN - Cannacoin",
1829 onSelect: function() {
1830 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1835 name: "CESC - Cryptoescudo",
1836 onSelect: function() {
1837 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
1842 name: "CDN - Canadaecoin",
1843 onSelect: function() {
1844 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
1849 name: "CLAM - Clams",
1850 onSelect: function() {
1851 network
= bitcoinjs
.bitcoin
.networks
.clam
;
1856 name: "CLO - Callisto",
1857 segwitAvailable: false,
1858 onSelect: function() {
1859 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1864 name: "CLUB - Clubcoin",
1865 onSelect: function() {
1866 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
1871 name: "CMP - Compcoin",
1872 onSelect: function() {
1873 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
1878 name: "CRAVE - Crave",
1879 onSelect: function() {
1880 network
= bitcoinjs
.bitcoin
.networks
.crave
;
1885 name: "CRW - Crown",
1886 onSelect: function() {
1887 network
= bitcoinjs
.bitcoin
.networks
.crown
;
1892 name: "DASH - Dash",
1893 onSelect: function() {
1894 network
= bitcoinjs
.bitcoin
.networks
.dash
;
1899 name: "DASH - Dash Testnet",
1900 onSelect: function() {
1901 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
1906 name: "DFC - Defcoin",
1907 onSelect: function() {
1908 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
1913 name: "DGB - Digibyte",
1914 onSelect: function() {
1915 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
1920 name: "DGC - Digitalcoin",
1921 onSelect: function() {
1922 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
1927 name: "DMD - Diamond",
1928 onSelect: function() {
1929 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
1934 name: "DNR - Denarius",
1935 onSelect: function() {
1936 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
1941 name: "DOGE - Dogecoin",
1942 onSelect: function() {
1943 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
1948 name: "ECN - Ecoin",
1949 onSelect: function() {
1950 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
1955 name: "EDRC - Edrcoin",
1956 onSelect: function() {
1957 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
1962 name: "EFL - Egulden",
1963 onSelect: function() {
1964 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
1969 name: "EMC2 - Einsteinium",
1970 onSelect: function() {
1971 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
1976 name: "ERC - Europecoin",
1977 onSelect: function() {
1978 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
1983 name: "ETC - Ethereum Classic",
1984 segwitAvailable: false,
1985 onSelect: function() {
1986 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1991 name: "ETH - Ethereum",
1992 onSelect: function() {
1993 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
1998 name: "EXCL - Exclusivecoin",
1999 onSelect: function() {
2000 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
2005 name: "EXCC - ExchangeCoin",
2006 onSelect: function() {
2007 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
2012 name: "EXP - Expanse",
2013 segwitAvailable: false,
2014 onSelect: function() {
2015 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2020 name: "FJC - Fujicoin",
2021 onSelect: function() {
2022 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2027 name: "FLASH - Flashcoin",
2028 onSelect: function() {
2029 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2034 name: "FRST - Firstcoin",
2035 onSelect: function() {
2036 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2041 name: "FTC - Feathercoin",
2042 onSelect: function() {
2043 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2048 name: "GAME - GameCredits",
2049 onSelect: function() {
2050 network
= bitcoinjs
.bitcoin
.networks
.game
;
2055 name: "GBX - Gobyte",
2056 onSelect: function() {
2057 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2062 name: "GCR - GCRCoin",
2063 onSelect: function() {
2064 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2069 name: "GRC - Gridcoin",
2070 onSelect: function() {
2071 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2076 name: "HNC - Helleniccoin",
2077 onSelect: function() {
2078 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2083 name: "HUSH - Hush",
2084 onSelect: function() {
2085 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2090 name: "INSN - Insane",
2091 onSelect: function() {
2092 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2098 onSelect: function() {
2099 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2104 name: "IXC - Ixcoin",
2105 onSelect: function() {
2106 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2111 name: "JBS - Jumbucks",
2112 onSelect: function() {
2113 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2118 name: "KMD - Komodo",
2119 bip49available: false,
2120 onSelect: function() {
2121 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2126 name: "KOBO - Kobocoin",
2127 bip49available: false,
2128 onSelect: function() {
2129 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2134 name: "LBC - Library Credits",
2135 onSelect: function() {
2136 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2141 name: "LCC - Litecoincash",
2142 onSelect: function() {
2143 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2148 name: "LDCN - Landcoin",
2149 onSelect: function() {
2150 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2155 name: "LINX - Linx",
2156 onSelect: function() {
2157 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2162 name: "LKR - Lkrcoin",
2163 segwitAvailable: false,
2164 onSelect: function() {
2165 network
= bitcoinjs
.bitcoin
.networks
.lkrcoin
;
2170 name: "LTC - Litecoin",
2171 onSelect: function() {
2172 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2174 DOM
.litecoinLtubContainer
.removeClass("hidden");
2178 name: "LTZ - LitecoinZ",
2179 onSelect: function() {
2180 network
= bitcoinjs
.bitcoin
.networks
.litecoinz
;
2185 name: "LYNX - Lynx",
2186 onSelect: function() {
2187 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2192 name: "MAZA - Maza",
2193 onSelect: function() {
2194 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2199 name: "MEC - Megacoin",
2200 onSelect: function() {
2201 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2207 segwitAvailable: false,
2208 onSelect: function() {
2209 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2214 name: "MNX - Minexcoin",
2215 onSelect: function() {
2216 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2221 name: "MONA - Monacoin",
2222 onSelect: function() {
2223 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2228 name: "MUSIC - Musicoin",
2229 segwitAvailable: false,
2230 onSelect: function() {
2231 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2236 name: "NAV - Navcoin",
2237 onSelect: function() {
2238 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2243 name: "NEBL - Neblio",
2244 onSelect: function() {
2245 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2250 name: "NEOS - Neoscoin",
2251 onSelect: function() {
2252 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2257 name: "NLG - Gulden",
2258 onSelect: function() {
2259 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2264 name: "NMC - Namecoin",
2265 onSelect: function() {
2266 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2271 name: "NRG - Energi",
2272 onSelect: function() {
2273 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2278 name: "NRO - Neurocoin",
2279 onSelect: function() {
2280 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2285 name: "NSR - Nushares",
2286 onSelect: function() {
2287 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2292 name: "NYC - Newyorkc",
2293 onSelect: function() {
2294 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2299 name: "NVC - Novacoin",
2300 onSelect: function() {
2301 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2306 name: "OK - Okcash",
2307 onSelect: function() {
2308 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2313 name: "OMNI - Omnicore",
2314 onSelect: function() {
2315 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2320 name: "ONX - Onixcoin",
2321 onSelect: function() {
2322 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2327 name: "PHR - Phore",
2328 onSelect: function() {
2329 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2334 name: "PINK - Pinkcoin",
2335 onSelect: function() {
2336 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2341 name: "PIRL - Pirl",
2342 segwitAvailable: false,
2343 onSelect: function() {
2344 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2349 name: "PIVX - PIVX",
2350 onSelect: function() {
2351 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2356 name: "PIVX - PIVX Testnet",
2357 onSelect: function() {
2358 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2364 segwitAvailable: false,
2365 onSelect: function() {
2366 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2371 name: "POSW - POSWcoin",
2372 onSelect: function() {
2373 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2378 name: "POT - Potcoin",
2379 onSelect: function() {
2380 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2385 name: "PPC - Peercoin",
2386 onSelect: function() {
2387 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2392 name: "PRJ - ProjectCoin",
2393 onSelect: function() {
2394 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2399 name: "PSB - Pesobit",
2400 onSelect: function() {
2401 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2406 name: "PUT - Putincoin",
2407 onSelect: function() {
2408 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2413 name: "RVN - Ravencoin",
2414 onSelect: function() {
2415 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2420 name: "RBY - Rubycoin",
2421 onSelect: function() {
2422 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2427 name: "RDD - Reddcoin",
2428 onSelect: function() {
2429 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2434 name: "RVR - RevolutionVR",
2435 onSelect: function() {
2436 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2441 name: "SAFE - Safecoin",
2442 onSelect: function() {
2443 network
= bitcoinjs
.bitcoin
.networks
.safecoin
;
2448 name: "SLS - Salus",
2449 onSelect: function() {
2450 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2455 name: "SDC - ShadowCash",
2456 onSelect: function() {
2457 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2462 name: "SDC - ShadowCash Testnet",
2463 onSelect: function() {
2464 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2469 name: "SLM - Slimcoin",
2470 onSelect: function() {
2471 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2476 name: "SLM - Slimcoin Testnet",
2477 onSelect: function() {
2478 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2483 name: "SLR - Solarcoin",
2484 onSelect: function() {
2485 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2490 name: "SMLY - Smileycoin",
2491 onSelect: function() {
2492 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2497 name: "STASH - Stash",
2498 onSelect: function() {
2499 network
= bitcoinjs
.bitcoin
.networks
.stash
;
2504 name: "STASH - Stash Testnet",
2505 onSelect: function() {
2506 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
2511 name: "STRAT - Stratis",
2512 onSelect: function() {
2513 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
2518 name: "TSTRAT - Stratis Testnet",
2519 onSelect: function() {
2520 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
2525 name: "SYS - Syscoin",
2526 onSelect: function() {
2527 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
2532 name: "THC - Hempcoin",
2533 onSelect: function() {
2534 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
2540 onSelect: function() {
2541 network
= bitcoinjs
.bitcoin
.networks
.toa
;
2546 name: "USC - Ultimatesecurecash",
2547 onSelect: function() {
2548 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
2553 name: "USNBT - NuBits",
2554 onSelect: function() {
2555 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
2560 name: "UNO - Unobtanium",
2561 onSelect: function() {
2562 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
2567 name: "VASH - Vpncoin",
2568 onSelect: function() {
2569 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
2574 name: "VIA - Viacoin",
2575 onSelect: function() {
2576 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
2581 name: "VIA - Viacoin Testnet",
2582 onSelect: function() {
2583 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
2588 name: "VIVO - Vivo",
2589 onSelect: function() {
2590 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
2595 name: "VTC - Vertcoin",
2596 onSelect: function() {
2597 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
2602 name: "WC - Wincoin",
2603 onSelect: function() {
2604 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
2609 name: "XAX - Artax",
2610 onSelect: function() {
2611 network
= bitcoinjs
.bitcoin
.networks
.artax
;
2616 name: "XBC - Bitcoinplus",
2617 onSelect: function() {
2618 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
2623 name: "XMY - Myriadcoin",
2624 onSelect: function() {
2625 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
2630 name: "XRP - Ripple",
2631 onSelect: function() {
2632 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2637 name: "XVC - Vcash",
2638 onSelect: function() {
2639 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
2644 name: "XVG - Verge",
2645 onSelect: function() {
2646 network
= bitcoinjs
.bitcoin
.networks
.verge
;
2651 name: "XUEZ - Xuez",
2652 segwitAvailable: false,
2653 onSelect: function() {
2654 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
2659 name: "XWC - Whitecoin",
2660 onSelect: function() {
2661 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
2666 name: "XZC - Zcoin",
2667 onSelect: function() {
2668 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
2673 name: "ZCL - Zclassic",
2674 onSelect: function() {
2675 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
2680 name: "ZEC - Zcash",
2681 onSelect: function() {
2682 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
2687 name: "ZEN - Zencash",
2688 onSelect: function() {
2689 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
2697 name: "Bitcoin Core",
2698 onSelect: function() {
2699 DOM
.bip32path
.val("m/0'/0'");
2700 DOM
.hardenedAddresses
.prop('checked', true);
2704 name: "blockchain.info",
2705 onSelect: function() {
2706 DOM
.bip32path
.val("m/44'/0'/0'");
2707 DOM
.hardenedAddresses
.prop('checked', false);
2711 name: "MultiBit HD",
2712 onSelect: function() {
2713 DOM
.bip32path
.val("m/0'/0");
2714 DOM
.hardenedAddresses
.prop('checked', false);
2718 name: "Coinomi, Ledger",
2719 onSelect: function() {
2720 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
2721 DOM
.hardenedAddresses
.prop('checked', false);