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
= libs
.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 entropyTypeAutoDetect
= true;
20 var entropyChangeTimeoutEvent
= null;
21 var phraseChangeTimeoutEvent
= null;
22 var seedChangedTimeoutEvent
= null;
23 var rootKeyChangedTimeoutEvent
= null;
25 var generationProcesses
= [];
28 DOM
.privacyScreenToggle
= $(".privacy-screen-toggle");
29 DOM
.network
= $(".network");
30 DOM
.bip32Client
= $("#bip32-client");
31 DOM
.phraseNetwork
= $("#network-phrase");
32 DOM
.useEntropy
= $(".use-entropy");
33 DOM
.entropyContainer
= $(".entropy-container");
34 DOM
.entropy
= $(".entropy");
35 DOM
.entropyFiltered
= DOM
.entropyContainer
.find(".filtered");
36 DOM
.entropyType
= DOM
.entropyContainer
.find(".type");
37 DOM
.entropyTypeInputs
= DOM
.entropyContainer
.find("input[name='entropy-type']");
38 DOM
.entropyCrackTime
= DOM
.entropyContainer
.find(".crack-time");
39 DOM
.entropyEventCount
= DOM
.entropyContainer
.find(".event-count");
40 DOM
.entropyBits
= DOM
.entropyContainer
.find(".bits");
41 DOM
.entropyBitsPerEvent
= DOM
.entropyContainer
.find(".bits-per-event");
42 DOM
.entropyWordCount
= DOM
.entropyContainer
.find(".word-count");
43 DOM
.entropyBinary
= DOM
.entropyContainer
.find(".binary");
44 DOM
.entropyWordIndexes
= DOM
.entropyContainer
.find(".word-indexes");
45 DOM
.entropyChecksum
= DOM
.entropyContainer
.find(".checksum");
46 DOM
.entropyMnemonicLength
= DOM
.entropyContainer
.find(".mnemonic-length");
47 DOM
.entropyWeakEntropyOverrideWarning
= DOM
.entropyContainer
.find(".weak-entropy-override-warning");
48 DOM
.entropyFilterWarning
= DOM
.entropyContainer
.find(".filter-warning");
49 DOM
.phrase
= $(".phrase");
50 DOM
.phraseSplit
= $(".phraseSplit");
51 DOM
.phraseSplitWarn
= $(".phraseSplitWarn");
52 DOM
.passphrase
= $(".passphrase");
53 DOM
.generateContainer
= $(".generate-container");
54 DOM
.generate
= $(".generate");
55 DOM
.seed
= $(".seed");
56 DOM
.rootKey
= $(".root-key");
57 DOM
.litecoinLtubContainer
= $(".litecoin-ltub-container");
58 DOM
.litecoinUseLtub
= $(".litecoin-use-ltub");
59 DOM
.extendedPrivKey
= $(".extended-priv-key");
60 DOM
.extendedPubKey
= $(".extended-pub-key");
61 DOM
.bip32tab
= $("#bip32-tab");
62 DOM
.bip44tab
= $("#bip44-tab");
63 DOM
.bip49tab
= $("#bip49-tab");
64 DOM
.bip84tab
= $("#bip84-tab");
65 DOM
.bip141tab
= $("#bip141-tab");
66 DOM
.bip32panel
= $("#bip32");
67 DOM
.bip44panel
= $("#bip44");
68 DOM
.bip49panel
= $("#bip49");
69 DOM
.bip32path
= $("#bip32-path");
70 DOM
.bip44path
= $("#bip44-path");
71 DOM
.bip44purpose
= $("#bip44 .purpose");
72 DOM
.bip44coin
= $("#bip44 .coin");
73 DOM
.bip44account
= $("#bip44 .account");
74 DOM
.bip44accountXprv
= $("#bip44 .account-xprv");
75 DOM
.bip44accountXpub
= $("#bip44 .account-xpub");
76 DOM
.bip44change
= $("#bip44 .change");
77 DOM
.bip49unavailable
= $("#bip49 .unavailable");
78 DOM
.bip49available
= $("#bip49 .available");
79 DOM
.bip49path
= $("#bip49-path");
80 DOM
.bip49purpose
= $("#bip49 .purpose");
81 DOM
.bip49coin
= $("#bip49 .coin");
82 DOM
.bip49account
= $("#bip49 .account");
83 DOM
.bip49accountXprv
= $("#bip49 .account-xprv");
84 DOM
.bip49accountXpub
= $("#bip49 .account-xpub");
85 DOM
.bip49change
= $("#bip49 .change");
86 DOM
.bip84unavailable
= $("#bip84 .unavailable");
87 DOM
.bip84available
= $("#bip84 .available");
88 DOM
.bip84path
= $("#bip84-path");
89 DOM
.bip84purpose
= $("#bip84 .purpose");
90 DOM
.bip84coin
= $("#bip84 .coin");
91 DOM
.bip84account
= $("#bip84 .account");
92 DOM
.bip84accountXprv
= $("#bip84 .account-xprv");
93 DOM
.bip84accountXpub
= $("#bip84 .account-xpub");
94 DOM
.bip84change
= $("#bip84 .change");
95 DOM
.bip141unavailable
= $("#bip141 .unavailable");
96 DOM
.bip141available
= $("#bip141 .available");
97 DOM
.bip141path
= $("#bip141-path");
98 DOM
.bip141semantics
= $(".bip141-semantics");
99 DOM
.generatedStrength
= $(".generate-container .strength");
100 DOM
.generatedStrengthWarning
= $(".generate-container .warning");
101 DOM
.hardenedAddresses
= $(".hardened-addresses");
102 DOM
.bitcoinCashAddressTypeContainer
= $(".bch-addr-type-container");
103 DOM
.bitcoinCashAddressType
= $("[name=bch-addr-type]")
104 DOM
.useBip38
= $(".use-bip38");
105 DOM
.bip38Password
= $(".bip38-password");
106 DOM
.addresses
= $(".addresses");
107 DOM
.csvTab
= $("#csv-tab a");
109 DOM
.rowsToAdd
= $(".rows-to-add");
110 DOM
.more
= $(".more");
111 DOM
.moreRowsStartIndex
= $(".more-rows-start-index");
112 DOM
.feedback
= $(".feedback");
113 DOM
.tab
= $(".derivation-type a");
114 DOM
.indexToggle
= $(".index-toggle");
115 DOM
.addressToggle
= $(".address-toggle");
116 DOM
.publicKeyToggle
= $(".public-key-toggle");
117 DOM
.privateKeyToggle
= $(".private-key-toggle");
118 DOM
.languages
= $(".languages a");
119 DOM
.qrContainer
= $(".qr-container");
120 DOM
.qrHider
= DOM
.qrContainer
.find(".qr-hider");
121 DOM
.qrImage
= DOM
.qrContainer
.find(".qr-image");
122 DOM
.qrHint
= DOM
.qrContainer
.find(".qr-hint");
123 DOM
.showQrEls
= $("[data-show-qr]");
127 DOM
.privacyScreenToggle
.on("change", privacyScreenToggled
);
128 DOM
.generatedStrength
.on("change", generatedStrengthChanged
);
129 DOM
.network
.on("change", networkChanged
);
130 DOM
.bip32Client
.on("change", bip32ClientChanged
);
131 DOM
.useEntropy
.on("change", setEntropyVisibility
);
132 DOM
.entropy
.on("input", delayedEntropyChanged
);
133 DOM
.entropyMnemonicLength
.on("change", entropyChanged
);
134 DOM
.entropyTypeInputs
.on("change", entropyTypeChanged
);
135 DOM
.phrase
.on("input", delayedPhraseChanged
);
136 DOM
.passphrase
.on("input", delayedPhraseChanged
);
137 DOM
.generate
.on("click", generateClicked
);
138 DOM
.more
.on("click", showMore
);
139 DOM
.seed
.on("input", delayedSeedChanged
);
140 DOM
.rootKey
.on("input", delayedRootKeyChanged
);
141 DOM
.litecoinUseLtub
.on("change", litecoinUseLtubChanged
);
142 DOM
.bip32path
.on("input", calcForDerivationPath
);
143 DOM
.bip44account
.on("input", calcForDerivationPath
);
144 DOM
.bip44change
.on("input", calcForDerivationPath
);
145 DOM
.bip49account
.on("input", calcForDerivationPath
);
146 DOM
.bip49change
.on("input", calcForDerivationPath
);
147 DOM
.bip84account
.on("input", calcForDerivationPath
);
148 DOM
.bip84change
.on("input", calcForDerivationPath
);
149 DOM
.bip141path
.on("input", calcForDerivationPath
);
150 DOM
.bip141semantics
.on("change", tabChanged
);
151 DOM
.tab
.on("shown.bs.tab", tabChanged
);
152 DOM
.hardenedAddresses
.on("change", calcForDerivationPath
);
153 DOM
.useBip38
.on("change", calcForDerivationPath
);
154 DOM
.bip38Password
.on("change", calcForDerivationPath
);
155 DOM
.indexToggle
.on("click", toggleIndexes
);
156 DOM
.addressToggle
.on("click", toggleAddresses
);
157 DOM
.publicKeyToggle
.on("click", togglePublicKeys
);
158 DOM
.privateKeyToggle
.on("click", togglePrivateKeys
);
159 DOM
.csvTab
.on("click", updateCsv
);
160 DOM
.languages
.on("click", languageChanged
);
161 DOM
.bitcoinCashAddressType
.on("change", bitcoinCashAddressTypeChange
);
162 setQrEvents(DOM
.showQrEls
);
165 hideValidationError();
166 populateNetworkSelect();
167 populateClientSelect();
172 function generatedStrengthChanged() {
173 var strength
= parseInt(DOM
.generatedStrength
.val());
175 DOM
.generatedStrengthWarning
.removeClass("hidden");
178 DOM
.generatedStrengthWarning
.addClass("hidden");
182 function networkChanged(e
) {
184 clearAddressesList();
185 DOM
.litecoinLtubContainer
.addClass("hidden");
186 DOM
.bitcoinCashAddressTypeContainer
.addClass("hidden");
187 var networkIndex
= e
.target
.value
;
188 var network
= networks
[networkIndex
];
190 adjustNetworkForSegwit();
199 function bip32ClientChanged(e
) {
200 var clientIndex
= DOM
.bip32Client
.val();
201 if (clientIndex
== "custom") {
202 DOM
.bip32path
.prop("readonly", false);
205 DOM
.bip32path
.prop("readonly", true);
206 clients
[clientIndex
].onSelect();
216 function setEntropyVisibility() {
217 if (isUsingOwnEntropy()) {
218 DOM
.entropyContainer
.removeClass("hidden");
219 DOM
.generateContainer
.addClass("hidden");
220 DOM
.phrase
.prop("readonly", true);
225 DOM
.entropyContainer
.addClass("hidden");
226 DOM
.generateContainer
.removeClass("hidden");
227 DOM
.phrase
.prop("readonly", false);
232 function delayedPhraseChanged() {
233 hideValidationError();
236 bip32ExtendedKey
= null;
237 clearAddressesList();
239 if (phraseChangeTimeoutEvent
!= null) {
240 clearTimeout(phraseChangeTimeoutEvent
);
242 phraseChangeTimeoutEvent
= setTimeout(function() {
244 var entropy
= mnemonic
.toRawEntropyHex(DOM
.phrase
.val());
245 if (entropy
!== null) {
246 DOM
.entropyMnemonicLength
.val("raw");
247 DOM
.entropy
.val(entropy
);
248 DOM
.entropyTypeInputs
.filter("[value='hexadecimal']").prop("checked", true);
249 entropyTypeAutoDetect
= false;
254 function phraseChanged() {
256 setMnemonicLanguage();
257 // Get the mnemonic phrase
258 var phrase
= DOM
.phrase
.val();
259 var errorText
= findPhraseErrors(phrase
);
261 showValidationError(errorText
);
264 // Calculate and display
265 var passphrase
= DOM
.passphrase
.val();
266 calcBip32RootKeyFromSeed(phrase
, passphrase
);
267 calcForDerivationPath();
268 // Show the word indexes
270 writeSplitPhrase(phrase
);
273 function tabChanged() {
275 adjustNetworkForSegwit();
276 var phrase
= DOM
.phrase
.val();
278 // Calculate and display for mnemonic
279 var errorText
= findPhraseErrors(phrase
);
281 showValidationError(errorText
);
284 // Calculate and display
285 var passphrase
= DOM
.passphrase
.val();
286 calcBip32RootKeyFromSeed(phrase
, passphrase
);
289 // Calculate and display for root key
290 var rootKeyBase58
= DOM
.rootKey
.val();
291 var errorText
= validateRootKey(rootKeyBase58
);
293 showValidationError(errorText
);
296 // Calculate and display
297 calcBip32RootKeyFromBase58(rootKeyBase58
);
299 calcForDerivationPath();
302 function delayedEntropyChanged() {
303 hideValidationError();
305 if (entropyChangeTimeoutEvent
!= null) {
306 clearTimeout(entropyChangeTimeoutEvent
);
308 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
311 function entropyChanged() {
312 // If blank entropy, clear mnemonic, addresses, errors
313 if (DOM
.entropy
.val().trim().length
== 0) {
315 clearEntropyFeedback();
317 DOM
.phraseSplit
.val("");
318 showValidationError("Blank entropy");
321 // Get the current phrase to detect changes
322 var phrase
= DOM
.phrase
.val();
323 // Set the phrase from the entropy
324 setMnemonicFromEntropy();
325 // Recalc addresses if the phrase has changed
326 var newPhrase
= DOM
.phrase
.val();
327 if (newPhrase
!= phrase
) {
328 if (newPhrase
.length
== 0) {
340 function entropyTypeChanged() {
341 entropyTypeAutoDetect
= false;
345 function delayedSeedChanged() {
346 // Warn if there is an existing mnemonic or passphrase.
347 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
348 if (!confirm("This will clear existing mnemonic and passphrase")) {
353 hideValidationError();
355 // Clear existing mnemonic and passphrase
357 DOM
.phraseSplit
.val("");
358 DOM
.passphrase
.val("");
360 clearAddressesList();
363 if (seedChangedTimeoutEvent
!= null) {
364 clearTimeout(seedChangedTimeoutEvent
);
366 seedChangedTimeoutEvent
= setTimeout(seedChanged
, 400);
369 function delayedRootKeyChanged() {
370 // Warn if there is an existing mnemonic or passphrase.
371 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
372 if (!confirm("This will clear existing mnemonic and passphrase")) {
373 DOM
.rootKey
.val(bip32RootKey
);
377 hideValidationError();
379 // Clear existing mnemonic and passphrase
381 DOM
.phraseSplit
.val("");
382 DOM
.passphrase
.val("");
384 if (rootKeyChangedTimeoutEvent
!= null) {
385 clearTimeout(rootKeyChangedTimeoutEvent
);
387 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
390 function seedChanged() {
392 hideValidationError();
393 seed
= DOM
.seed
.val();
394 bip32RootKey
= libs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
395 var rootKeyBase58
= bip32RootKey
.toBase58();
396 DOM
.rootKey
.val(rootKeyBase58
);
397 var errorText
= validateRootKey(rootKeyBase58
);
399 showValidationError(errorText
);
402 // Calculate and display
403 calcForDerivationPath();
406 function rootKeyChanged() {
408 hideValidationError();
409 var rootKeyBase58
= DOM
.rootKey
.val();
410 var errorText
= validateRootKey(rootKeyBase58
);
412 showValidationError(errorText
);
415 // Calculate and display
416 calcBip32RootKeyFromBase58(rootKeyBase58
);
417 calcForDerivationPath();
420 function litecoinUseLtubChanged() {
421 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
422 if (litecoinUseLtub
) {
423 network
= libs
.bitcoin
.networks
.litecoin
;
426 network
= libs
.bitcoin
.networks
.litecoinXprv
;
431 function calcForDerivationPath() {
433 clearAddressesList();
435 // Don't show segwit if it's selected but network doesn't support it
436 if (segwitSelected() && !networkHasSegwit()) {
437 showSegwitUnavailable();
441 showSegwitAvailable();
442 // Get the derivation path
443 var derivationPath
= getDerivationPath();
444 var errorText
= findDerivationPathErrors(derivationPath
);
446 showValidationError(errorText
);
449 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
450 if (bip44TabSelected()) {
453 else if (bip49TabSelected()) {
456 else if (bip84TabSelected()) {
462 function generateClicked() {
463 if (isUsingOwnEntropy()) {
468 setTimeout(function() {
469 setMnemonicLanguage();
470 var phrase
= generateRandomPhrase();
478 function languageChanged() {
479 setTimeout(function() {
480 setMnemonicLanguage();
481 if (DOM
.phrase
.val().length
> 0) {
482 var newPhrase
= convertPhraseToNewLanguage();
483 DOM
.phrase
.val(newPhrase
);
487 DOM
.generate
.trigger("click");
492 function bitcoinCashAddressTypeChange() {
496 function toggleIndexes() {
497 showIndex
= !showIndex
;
498 $("td.index span").toggleClass("invisible");
501 function toggleAddresses() {
502 showAddress
= !showAddress
;
503 $("td.address span").toggleClass("invisible");
506 function togglePublicKeys() {
507 showPubKey
= !showPubKey
;
508 $("td.pubkey span").toggleClass("invisible");
511 function togglePrivateKeys() {
512 showPrivKey
= !showPrivKey
;
513 $("td.privkey span").toggleClass("invisible");
516 function privacyScreenToggled() {
517 // private-data contains elements added to DOM at runtime
518 // so catch all by adding visual privacy class to the root of the DOM
519 if (DOM
.privacyScreenToggle
.prop("checked")) {
520 $("body").addClass("visual-privacy");
523 $("body").removeClass("visual-privacy");
529 function generateRandomPhrase() {
530 if (!hasStrongRandom()) {
531 var errorText
= "This browser does not support strong randomness";
532 showValidationError(errorText
);
535 // get the amount of entropy to use
536 var numWords
= parseInt(DOM
.generatedStrength
.val());
537 var strength
= numWords
/ 3 * 32;
538 var buffer
= new Uint8Array(strength
/ 8);
539 // create secure entropy
540 var data
= crypto
.getRandomValues(buffer
);
542 var words
= mnemonic
.toMnemonic(data
);
543 DOM
.phrase
.val(words
);
545 var entropyHex
= uint8ArrayToHex(data
);
546 DOM
.entropy
.val(entropyHex
);
547 // ensure entropy fields are consistent with what is being displayed
548 DOM
.entropyMnemonicLength
.val("raw");
552 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
553 seed
= mnemonic
.toSeed(phrase
, passphrase
);
554 bip32RootKey
= libs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
556 bip32RootKey
= libs
.groestlcoinjs
.HDNode
.fromSeedHex(seed
, network
);
560 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
562 calcBip32RootKeyFromBase58GRS(rootKeyBase58
);
565 // try parsing with various segwit network params since this extended
566 // key may be from any one of them.
567 if (networkHasSegwit()) {
569 if ("baseNetwork" in n
) {
570 n
= libs
.bitcoin
.networks
[n
.baseNetwork
];
572 // try parsing using base network params
574 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
578 // try parsing using p2wpkh params
581 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
586 // try parsing using p2wpkh-in-p2sh network params
587 if ("p2wpkhInP2sh" in n
) {
589 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
594 // try parsing using p2wsh network params
597 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wsh
);
602 // try parsing using p2wsh-in-p2sh network params
603 if ("p2wshInP2sh" in n
) {
605 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wshInP2sh
);
611 // try the network params as currently specified
612 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
615 function calcBip32RootKeyFromBase58GRS(rootKeyBase58
) {
616 // try parsing with various segwit network params since this extended
617 // key may be from any one of them.
618 if (networkHasSegwit()) {
620 if ("baseNetwork" in n
) {
621 n
= libs
.bitcoin
.networks
[n
.baseNetwork
];
623 // try parsing using base network params
625 bip32RootKey
= libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
629 // try parsing using p2wpkh params
632 bip32RootKey
= libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
637 // try parsing using p2wpkh-in-p2sh network params
638 if ("p2wpkhInP2sh" in n
) {
640 bip32RootKey
= libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
646 // try the network params as currently specified
647 bip32RootKey
= libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
650 function calcBip32ExtendedKey(path
) {
651 // Check there's a root key to derive from
655 var extendedKey
= bip32RootKey
;
656 // Derive the key from the path
657 var pathBits
= path
.split("/");
658 for (var i
=0; i
<pathBits
.length
; i
++) {
659 var bit
= pathBits
[i
];
660 var index
= parseInt(bit
);
664 var hardened
= bit
[bit
.length
-1] == "'";
665 var isPriv
= !(extendedKey
.isNeutered());
666 var invalidDerivationPath
= hardened
&& !isPriv
;
667 if (invalidDerivationPath
) {
671 extendedKey
= extendedKey
.deriveHardened(index
);
674 extendedKey
= extendedKey
.derive(index
);
680 function showValidationError(errorText
) {
686 function hideValidationError() {
692 function findPhraseErrors(phrase
) {
693 // Preprocess the words
694 phrase
= mnemonic
.normalizeString(phrase
);
695 var words
= phraseToWordArray(phrase
);
696 // Detect blank phrase
697 if (words
.length
== 0) {
698 return "Blank mnemonic";
701 for (var i
=0; i
<words
.length
; i
++) {
703 var language
= getLanguage();
704 if (WORDLISTS
[language
].indexOf(word
) == -1) {
705 console
.log("Finding closest match to " + word
);
706 var nearestWord
= findNearestWord(word
);
707 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
710 // Check the words are valid
711 var properPhrase
= wordArrayToPhrase(words
);
712 var isValid
= mnemonic
.check(properPhrase
);
714 return "Invalid mnemonic";
719 function validateRootKey(rootKeyBase58
) {
721 return validateRootKeyGRS(rootKeyBase58
);
723 // try various segwit network params since this extended key may be from
725 if (networkHasSegwit()) {
727 if ("baseNetwork" in n
) {
728 n
= libs
.bitcoin
.networks
[n
.baseNetwork
];
730 // try parsing using base network params
732 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
736 // try parsing using p2wpkh params
739 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
744 // try parsing using p2wpkh-in-p2sh network params
745 if ("p2wpkhInP2sh" in n
) {
747 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
752 // try parsing using p2wsh network params
755 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wsh
);
760 // try parsing using p2wsh-in-p2sh network params
761 if ("p2wshInP2sh" in n
) {
763 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wshInP2sh
);
769 // try the network params as currently specified
771 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
774 return "Invalid root key";
779 function validateRootKeyGRS(rootKeyBase58
) {
780 // try various segwit network params since this extended key may be from
782 if (networkHasSegwit()) {
784 if ("baseNetwork" in n
) {
785 n
= libs
.bitcoin
.networks
[n
.baseNetwork
];
787 // try parsing using base network params
789 libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
793 // try parsing using p2wpkh params
796 libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
801 // try parsing using p2wpkh-in-p2sh network params
802 if ("p2wpkhInP2sh" in n
) {
804 libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
810 // try the network params as currently specified
812 libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
815 return "Invalid root key";
820 function getDerivationPath() {
821 if (bip44TabSelected()) {
822 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
823 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
824 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
825 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
827 path
+= purpose
+ "'/";
829 path
+= account
+ "'/";
831 DOM
.bip44path
.val(path
);
832 var derivationPath
= DOM
.bip44path
.val();
833 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
834 return derivationPath
;
836 else if (bip49TabSelected()) {
837 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
838 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
839 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
840 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
842 path
+= purpose
+ "'/";
844 path
+= account
+ "'/";
846 DOM
.bip49path
.val(path
);
847 var derivationPath
= DOM
.bip49path
.val();
848 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
849 return derivationPath
;
851 else if (bip84TabSelected()) {
852 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
853 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
854 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
855 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
857 path
+= purpose
+ "'/";
859 path
+= account
+ "'/";
861 DOM
.bip84path
.val(path
);
862 var derivationPath
= DOM
.bip84path
.val();
863 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
864 return derivationPath
;
866 else if (bip32TabSelected()) {
867 var derivationPath
= DOM
.bip32path
.val();
868 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
869 return derivationPath
;
871 else if (bip141TabSelected()) {
872 var derivationPath
= DOM
.bip141path
.val();
873 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
874 return derivationPath
;
877 console
.log("Unknown derivation path");
881 function findDerivationPathErrors(path
) {
882 // TODO is not perfect but is better than nothing
884 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
886 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
887 var maxDepth
= 255; // TODO verify this!!
888 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
889 if (path
[0] != "m") {
890 return "First character must be 'm'";
892 if (path
.length
> 1) {
893 if (path
[1] != "/") {
894 return "Separator must be '/'";
896 var indexes
= path
.split("/");
897 if (indexes
.length
> maxDepth
) {
898 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
900 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
901 var index
= indexes
[depth
];
902 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
903 if (invalidChars
.length
> 0) {
904 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
906 var indexValue
= parseInt(index
.replace("'", ""));
908 return "Invalid number at depth " + depth
;
910 if (indexValue
> maxIndexValue
) {
911 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
915 // Check root key exists or else derivation path is useless!
917 return "No root key";
919 // Check no hardened derivation path when using xpub keys
920 var hardenedPath
= path
.indexOf("'") > -1;
921 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
922 var hardened
= hardenedPath
|| hardenedAddresses
;
923 var isXpubkey
= bip32RootKey
.isNeutered();
924 if (hardened
&& isXpubkey
) {
925 return "Hardened derivation path is invalid with xpub key";
931 return networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin" || networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin Testnet";
935 return networks
[DOM
.network
.val()].name
== "ELA - Elastos"
938 function displayBip44Info() {
939 // Get the derivation path for the account
940 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
941 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
942 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
944 path
+= purpose
+ "'/";
946 path
+= account
+ "'/";
947 // Calculate the account extended keys
948 var accountExtendedKey
= calcBip32ExtendedKey(path
);
949 var accountXprv
= accountExtendedKey
.toBase58();
950 var accountXpub
= accountExtendedKey
.neutered().toBase58();
952 // Display the extended keys
953 DOM
.bip44accountXprv
.val(accountXprv
);
954 DOM
.bip44accountXpub
.val(accountXpub
);
957 displayBip44InfoForELA();
961 function displayBip49Info() {
962 // Get the derivation path for the account
963 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
964 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
965 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
967 path
+= purpose
+ "'/";
969 path
+= account
+ "'/";
970 // Calculate the account extended keys
971 var accountExtendedKey
= calcBip32ExtendedKey(path
);
972 var accountXprv
= accountExtendedKey
.toBase58();
973 var accountXpub
= accountExtendedKey
.neutered().toBase58();
974 // Display the extended keys
975 DOM
.bip49accountXprv
.val(accountXprv
);
976 DOM
.bip49accountXpub
.val(accountXpub
);
979 function displayBip84Info() {
980 // Get the derivation path for the account
981 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
982 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
983 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
985 path
+= purpose
+ "'/";
987 path
+= account
+ "'/";
988 // Calculate the account extended keys
989 var accountExtendedKey
= calcBip32ExtendedKey(path
);
990 var accountXprv
= accountExtendedKey
.toBase58();
991 var accountXpub
= accountExtendedKey
.neutered().toBase58();
992 // Display the extended keys
993 DOM
.bip84accountXprv
.val(accountXprv
);
994 DOM
.bip84accountXpub
.val(accountXpub
);
997 function displayBip32Info() {
1000 var rootKey
= bip32RootKey
.toBase58();
1001 DOM
.rootKey
.val(rootKey
);
1002 var xprvkeyB58
= "NA";
1003 if (!bip32ExtendedKey
.isNeutered()) {
1004 xprvkeyB58
= bip32ExtendedKey
.toBase58();
1006 var extendedPrivKey
= xprvkeyB58
;
1007 DOM
.extendedPrivKey
.val(extendedPrivKey
);
1008 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
1009 DOM
.extendedPubKey
.val(extendedPubKey
);
1010 // Display the addresses and privkeys
1011 clearAddressesList();
1012 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
1013 displayAddresses(0, initialAddressCount
);
1016 displayBip32InfoForELA();
1020 function displayAddresses(start
, total
) {
1021 generationProcesses
.push(new (function() {
1025 this.stop = function() {
1026 for (var i
=0; i
<rows
.length
; i
++) {
1027 rows
[i
].shouldGenerate
= false;
1032 for (var i
=0; i
<total
; i
++) {
1033 var index
= i
+ start
;
1034 var isLast
= i
== total
- 1;
1035 rows
.push(new TableRow(index
, isLast
));
1041 function segwitSelected() {
1042 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
1045 function p2wpkhSelected() {
1046 return bip84TabSelected() ||
1047 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
1050 function p2wpkhInP2shSelected() {
1051 return bip49TabSelected() ||
1052 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
1055 function p2wshSelected() {
1056 return bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wsh";
1059 function p2wshInP2shSelected() {
1060 return (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wsh-p2sh");
1063 function TableRow(index
, isLast
) {
1066 this.shouldGenerate
= true;
1067 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
1068 var useBip38
= DOM
.useBip38
.prop("checked");
1069 var bip38password
= DOM
.bip38Password
.val();
1070 var isSegwit
= segwitSelected();
1071 var segwitAvailable
= networkHasSegwit();
1072 var isP2wpkh
= p2wpkhSelected();
1073 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
1074 var isP2wsh
= p2wshSelected();
1075 var isP2wshInP2sh
= p2wshInP2shSelected();
1081 function calculateValues() {
1082 setTimeout(function() {
1083 if (!self
.shouldGenerate
) {
1086 // derive HDkey for this row of the table
1088 if (useHardenedAddresses
) {
1089 key
= bip32ExtendedKey
.deriveHardened(index
);
1092 key
= bip32ExtendedKey
.derive(index
);
1094 // bip38 requires uncompressed keys
1095 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
1096 var keyPair
= key
.keyPair
;
1097 var useUncompressed
= useBip38
;
1098 if (useUncompressed
) {
1099 keyPair
= new libs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
1101 keyPair
= new libs
.groestlcoinjs
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
1105 var address
= keyPair
.getAddress().toString();
1107 var hasPrivkey
= !key
.isNeutered();
1110 privkey
= keyPair
.toWIF();
1111 // BIP38 encode private key if required
1114 privkey
= libs
.groestlcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1115 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1116 }, null, networks
[DOM
.network
.val()].name
.includes("Testnet"));
1118 privkey
= libs
.bip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1119 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1124 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
1125 var indexText
= getDerivationPath() + "/" + index
;
1126 if (useHardenedAddresses
) {
1127 indexText
= indexText
+ "'";
1129 // Ethereum values are different
1130 if (networkIsEthereum()) {
1131 var pubkeyBuffer
= keyPair
.getPublicKeyBuffer();
1132 var ethPubkey
= libs
.ethUtil
.importPublic(pubkeyBuffer
);
1133 var addressBuffer
= libs
.ethUtil
.publicToAddress(ethPubkey
);
1134 var hexAddress
= addressBuffer
.toString('hex');
1135 var checksumAddress
= libs
.ethUtil
.toChecksumAddress(hexAddress
);
1136 address
= libs
.ethUtil
.addHexPrefix(checksumAddress
);
1137 pubkey
= libs
.ethUtil
.addHexPrefix(pubkey
);
1139 privkey
= libs
.ethUtil
.bufferToHex(keyPair
.d
.toBuffer());
1143 // Handshake values are different
1144 if (networks
[DOM
.network
.val()].name
== "HNS - Handshake") {
1145 var ring
= libs
.handshake
.KeyRing
.fromPublic(keyPair
.getPublicKeyBuffer())
1146 address
= ring
.getAddress().toString();
1148 // Stellar is different
1149 if (networks
[DOM
.network
.val()].name
== "XLM - Stellar") {
1150 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
1151 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
1153 path
+= purpose
+ "'/";
1154 path
+= coin
+ "'/" + index
+ "'";
1155 var keypair
= libs
.stellarUtil
.getKeypair(path
, seed
);
1157 privkey
= keypair
.secret();
1158 pubkey
= address
= keypair
.publicKey();
1160 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
1161 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1162 var nebulasAccount
= libs
.nebulas
.Account
.NewAccount();
1163 nebulasAccount
.setPrivateKey(privKeyBuffer
);
1164 address
= nebulasAccount
.getAddressString();
1165 privkey
= nebulasAccount
.getPrivateKeyString();
1166 pubkey
= nebulasAccount
.getPublicKeyString();
1168 // Ripple values are different
1169 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
1170 privkey
= convertRipplePriv(privkey
);
1171 address
= convertRippleAdrr(address
);
1173 // Jingtum values are different
1174 if (networks
[DOM
.network
.val()].name
== "SWTC - Jingtum") {
1175 privkey
= convertJingtumPriv(privkey
);
1176 address
= convertJingtumAdrr(address
);
1178 // CasinoCoin values are different
1179 if (networks
[DOM
.network
.val()].name
== "CSC - CasinoCoin") {
1180 privkey
= convertCasinoCoinPriv(privkey
);
1181 address
= convertCasinoCoinAdrr(address
);
1183 // Bitcoin Cash address format may vary
1184 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
1185 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1186 if (bchAddrType
== "cashaddr") {
1187 address
= libs
.bchaddr
.toCashAddress(address
);
1189 else if (bchAddrType
== "bitpay") {
1190 address
= libs
.bchaddr
.toBitpayAddress(address
);
1193 // Bitcoin Cash address format may vary
1194 if (networks
[DOM
.network
.val()].name
== "SLP - Simple Ledger Protocol") {
1195 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1196 if (bchAddrType
== "cashaddr") {
1197 address
= libs
.bchaddrSlp
.toSlpAddress(address
);
1200 // Segwit addresses are different
1202 if (!segwitAvailable
) {
1206 var keyhash
= libs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1207 var scriptpubkey
= libs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1208 address
= libs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1210 else if (isP2wpkhInP2sh
) {
1211 var keyhash
= libs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1212 var scriptsig
= libs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1213 var addressbytes
= libs
.bitcoin
.crypto
.hash160(scriptsig
);
1214 var scriptpubkey
= libs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
1215 address
= libs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1218 // https://github.com/libs.bitcoinjs-lib/blob/v3.3.2/test/integration/addresses.js#L71
1220 var witnessScript
= libs
.bitcoin
.script
.multisig
.output
.encode(1, [key
.getPublicKeyBuffer()]);
1221 var scriptPubKey
= libs
.bitcoin
.script
.witnessScriptHash
.output
.encode(libs
.bitcoin
.crypto
.sha256(witnessScript
));
1222 address
= libs
.bitcoin
.address
.fromOutputScript(scriptPubKey
, network
);
1224 else if (isP2wshInP2sh
) {
1225 // https://github.com/libs.bitcoinjs-lib/blob/v3.3.2/test/integration/transactions.js#L183
1227 var witnessScript
= libs
.bitcoin
.script
.multisig
.output
.encode(1, [key
.getPublicKeyBuffer()]);
1228 var redeemScript
= libs
.bitcoin
.script
.witnessScriptHash
.output
.encode(libs
.bitcoin
.crypto
.sha256(witnessScript
));
1229 var scriptPubKey
= libs
.bitcoin
.script
.scriptHash
.output
.encode(libs
.bitcoin
.crypto
.hash160(redeemScript
));
1230 address
= libs
.bitcoin
.address
.fromOutputScript(scriptPubKey
, network
)
1234 if ((networks
[DOM
.network
.val()].name
== "CRW - Crown")) {
1235 address
= libs
.bitcoin
.networks
.crown
.toNewAddress(address
);
1238 if (networks
[DOM
.network
.val()].name
== "EOS - EOSIO") {
1240 pubkey
= eosUtil
.bufferToPublic(keyPair
.getPublicKeyBuffer());
1241 privkey
= eosUtil
.bufferToPrivate(keyPair
.d
.toBuffer(32));
1244 //Groestlcoin Addresses are different
1248 if (!segwitAvailable
) {
1252 address
= libs
.groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1254 else if (isP2wpkhInP2sh
) {
1255 address
= libs
.groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1258 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1262 let elaAddress
= calcAddressForELA(
1264 parseIntNoNaN(DOM
.bip44coin
.val(), 0),
1265 parseIntNoNaN(DOM
.bip44account
.val(), 0),
1266 parseIntNoNaN(DOM
.bip44change
.val(), 0),
1269 address
= elaAddress
.address
;
1270 privkey
= elaAddress
.privateKey
;
1271 pubkey
= elaAddress
.publicKey
;
1274 addAddressToList(indexText
, address
, pubkey
, privkey
);
1286 function showMore() {
1287 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
1288 if (isNaN(rowsToAdd
)) {
1290 DOM
.rowsToAdd
.val("20");
1292 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
1294 start
= lastIndexInTable() + 1;
1297 var newStart
= start
+ rowsToAdd
;
1298 DOM
.moreRowsStartIndex
.val(newStart
);
1300 if (rowsToAdd
> 200) {
1301 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1302 msg
+= "Do you want to continue?";
1303 if (!confirm(msg
)) {
1307 displayAddresses(start
, rowsToAdd
);
1310 function clearDisplay() {
1311 clearAddressesList();
1313 hideValidationError();
1316 function clearAddressesList() {
1317 DOM
.addresses
.empty();
1322 function stopGenerating() {
1323 while (generationProcesses
.length
> 0) {
1324 var generation
= generationProcesses
.shift();
1329 function clearKeys() {
1334 function clearRootKey() {
1335 DOM
.rootKey
.val("");
1338 function clearDerivedKeys() {
1339 DOM
.extendedPrivKey
.val("");
1340 DOM
.extendedPubKey
.val("");
1341 DOM
.bip44accountXprv
.val("");
1342 DOM
.bip44accountXpub
.val("");
1345 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1346 var row
= $(addressRowTemplate
.html());
1348 var indexCell
= row
.find(".index span");
1349 var addressCell
= row
.find(".address span");
1350 var pubkeyCell
= row
.find(".pubkey span");
1351 var privkeyCell
= row
.find(".privkey span");
1353 indexCell
.text(indexText
);
1354 addressCell
.text(address
);
1355 pubkeyCell
.text(pubkey
);
1356 privkeyCell
.text(privkey
);
1359 indexCell
.addClass("invisible");
1362 addressCell
.addClass("invisible");
1365 pubkeyCell
.addClass("invisible");
1368 privkeyCell
.addClass("invisible");
1370 DOM
.addresses
.append(row
);
1371 var rowShowQrEls
= row
.find("[data-show-qr]");
1372 setQrEvents(rowShowQrEls
);
1375 function hasStrongRandom() {
1376 return 'crypto' in window
&& window
['crypto'] !== null;
1379 function disableForms() {
1380 $("form").on("submit", function(e
) {
1385 function parseIntNoNaN(val
, defaultVal
) {
1386 var v
= parseInt(val
);
1393 function showPending() {
1395 .text("Calculating...")
1399 function findNearestWord(word
) {
1400 var language
= getLanguage();
1401 var words
= WORDLISTS
[language
];
1402 var minDistance
= 99;
1403 var closestWord
= words
[0];
1404 for (var i
=0; i
<words
.length
; i
++) {
1405 var comparedTo
= words
[i
];
1406 if (comparedTo
.indexOf(word
) == 0) {
1409 var distance
= libs
.levenshtein
.get(word
, comparedTo
);
1410 if (distance
< minDistance
) {
1411 closestWord
= comparedTo
;
1412 minDistance
= distance
;
1418 function hidePending() {
1424 function populateNetworkSelect() {
1425 for (var i
=0; i
<networks
.length
; i
++) {
1426 var network
= networks
[i
];
1427 var option
= $("<option>");
1428 option
.attr("value", i
);
1429 option
.text(network
.name
);
1430 if (network
.name
== "BTC - Bitcoin") {
1431 option
.prop("selected", true);
1433 DOM
.phraseNetwork
.append(option
);
1437 function populateClientSelect() {
1438 for (var i
=0; i
<clients
.length
; i
++) {
1439 var client
= clients
[i
];
1440 var option
= $("<option>");
1441 option
.attr("value", i
);
1442 option
.text(client
.name
);
1443 DOM
.bip32Client
.append(option
);
1447 function getLanguage() {
1448 var defaultLanguage
= "english";
1449 // Try to get from existing phrase
1450 var language
= getLanguageFromPhrase();
1451 // Try to get from url if not from phrase
1452 if (language
.length
== 0) {
1453 language
= getLanguageFromUrl();
1455 // Default to English if no other option
1456 if (language
.length
== 0) {
1457 language
= defaultLanguage
;
1462 function getLanguageFromPhrase(phrase
) {
1463 // Check if how many words from existing phrase match a language.
1466 phrase
= DOM
.phrase
.val();
1468 if (phrase
.length
> 0) {
1469 var words
= phraseToWordArray(phrase
);
1470 var languageMatches
= {};
1471 for (l
in WORDLISTS
) {
1472 // Track how many words match in this language
1473 languageMatches
[l
] = 0;
1474 for (var i
=0; i
<words
.length
; i
++) {
1475 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1476 if (wordInLanguage
) {
1477 languageMatches
[l
]++;
1480 // Find languages with most word matches.
1481 // This is made difficult due to commonalities between Chinese
1482 // simplified vs traditional.
1483 var mostMatches
= 0;
1484 var mostMatchedLanguages
= [];
1485 for (var l
in languageMatches
) {
1486 var numMatches
= languageMatches
[l
];
1487 if (numMatches
> mostMatches
) {
1488 mostMatches
= numMatches
;
1489 mostMatchedLanguages
= [l
];
1491 else if (numMatches
== mostMatches
) {
1492 mostMatchedLanguages
.push(l
);
1496 if (mostMatchedLanguages
.length
> 0) {
1497 // Use first language and warn if multiple detected
1498 language
= mostMatchedLanguages
[0];
1499 if (mostMatchedLanguages
.length
> 1) {
1500 console
.warn("Multiple possible languages");
1501 console
.warn(mostMatchedLanguages
);
1508 function getLanguageFromUrl() {
1509 for (var language
in WORDLISTS
) {
1510 if (window
.location
.hash
.indexOf(language
) > -1) {
1517 function setMnemonicLanguage() {
1518 var language
= getLanguage();
1519 // Load the bip39 mnemonic generator for this language if required
1520 if (!(language
in mnemonics
)) {
1521 mnemonics
[language
] = new Mnemonic(language
);
1523 mnemonic
= mnemonics
[language
];
1526 function convertPhraseToNewLanguage() {
1527 var oldLanguage
= getLanguageFromPhrase();
1528 var newLanguage
= getLanguageFromUrl();
1529 var oldPhrase
= DOM
.phrase
.val();
1530 var oldWords
= phraseToWordArray(oldPhrase
);
1532 for (var i
=0; i
<oldWords
.length
; i
++) {
1533 var oldWord
= oldWords
[i
];
1534 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1535 var newWord
= WORDLISTS
[newLanguage
][index
];
1536 newWords
.push(newWord
);
1538 newPhrase
= wordArrayToPhrase(newWords
);
1542 // TODO look at jsbip39 - mnemonic.splitWords
1543 function phraseToWordArray(phrase
) {
1544 var words
= phrase
.split(/\s/g);
1546 for (var i
=0; i
<words
.length
; i
++) {
1547 var word
= words
[i
];
1548 if (word
.length
> 0) {
1549 noBlanks
.push(word
);
1555 // TODO look at jsbip39 - mnemonic.joinWords
1556 function wordArrayToPhrase(words
) {
1557 var phrase
= words
.join(" ");
1558 var language
= getLanguageFromPhrase(phrase
);
1559 if (language
== "japanese") {
1560 phrase
= words
.join("\u3000");
1565 function writeSplitPhrase(phrase
) {
1566 var wordCount
= phrase
.split(/\s/g).length
;
1568 for (var i
=0;i
<wordCount
;i
++) left
.push(i
);
1569 var group
=[[],[],[]],
1571 var seed
= Math
.abs(sjcl
.hash
.sha256
.hash(phrase
)[0])% 2147483647;
1572 while (left
.length
>0) {
1573 groupI
=(groupI
+1)%3;
1574 seed
= seed
* 16807 % 2147483647;
1575 var selected
=Math
.floor(left
.length
*(seed
- 1) / 2147483646);
1576 group
[groupI
].push(left
[selected
]);
1577 left
.splice(selected
,1);
1579 var cards
=[phrase
.split(/\s/g),phrase
.split(/\s/g),phrase
.split(/\s/g)];
1580 for (var i
=0;i
<3;i
++) {
1581 for (var ii
=0;ii
<wordCount
/3;ii
++) cards
[i
][group
[i
][ii
]]='XXXX';
1582 cards
[i
]='Card '+(i
+1)+': '+wordArrayToPhrase(cards
[i
]);
1584 DOM
.phraseSplit
.val(cards
.join("\r\n"));
1585 var triesPerSecond
=10000000000;
1586 var hackTime
=Math
.pow(2,wordCount
*10/3)/triesPerSecond
;
1587 var displayRedText
= false;
1589 hackTime
="<1 second";
1590 displayRedText
= true;
1591 } else if (hackTime
<86400) {
1592 hackTime
=Math
.floor(hackTime
)+" seconds";
1593 displayRedText
= true;
1594 } else if(hackTime
<31557600) {
1595 hackTime
=Math
.floor(hackTime
/86400)+" days";
1596 displayRedText
= true;
1598 hackTime
=Math
.floor(hackTime
/31557600)+" years";
1600 DOM
.phraseSplitWarn
.html("Time to hack with only one card: "+hackTime
);
1601 if (displayRedText
) {
1602 DOM
.phraseSplitWarn
.addClass("text-danger");
1604 DOM
.phraseSplitWarn
.removeClass("text-danger");
1608 function isUsingOwnEntropy() {
1609 return DOM
.useEntropy
.prop("checked");
1612 function setMnemonicFromEntropy() {
1613 clearEntropyFeedback();
1614 // Get entropy value
1615 var entropyStr
= DOM
.entropy
.val();
1616 // Work out minimum base for entropy
1618 if (entropyTypeAutoDetect
) {
1619 entropy
= Entropy
.fromString(entropyStr
);
1622 let base
= DOM
.entropyTypeInputs
.filter(":checked").val();
1623 entropy
= Entropy
.fromString(entropyStr
, base
);
1625 if (entropy
.binaryStr
.length
== 0) {
1628 // Show entropy details
1629 showEntropyFeedback(entropy
);
1630 // Use entropy hash if not using raw entropy
1631 var bits
= entropy
.binaryStr
;
1632 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1633 if (mnemonicLength
!= "raw") {
1634 // Get bits by hashing entropy with SHA256
1635 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1636 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1637 bits
= libs
.BigInteger
.BigInteger
.parse(hex
, 16).toString(2);
1638 while (bits
.length
% 256 != 0) {
1641 // Truncate hash to suit number of words
1642 mnemonicLength
= parseInt(mnemonicLength
);
1643 var numberOfBits
= 32 * mnemonicLength
/ 3;
1644 bits
= bits
.substring(0, numberOfBits
);
1645 // show warning for weak entropy override
1646 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1647 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1650 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1654 // hide warning for weak entropy override
1655 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1657 // Discard trailing entropy
1658 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1659 var start
= bits
.length
- bitsToUse
;
1660 var binaryStr
= bits
.substring(start
);
1661 // Convert entropy string to numeric array
1662 var entropyArr
= [];
1663 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1664 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1665 var entropyByte
= parseInt(byteAsBits
, 2);
1666 entropyArr
.push(entropyByte
)
1668 // Convert entropy array to mnemonic
1669 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1670 // Set the mnemonic in the UI
1671 DOM
.phrase
.val(phrase
);
1672 writeSplitPhrase(phrase
);
1673 // Show the word indexes
1675 // Show the checksum
1679 function clearEntropyFeedback() {
1680 DOM
.entropyCrackTime
.text("...");
1681 DOM
.entropyType
.text("");
1682 DOM
.entropyWordCount
.text("0");
1683 DOM
.entropyEventCount
.text("0");
1684 DOM
.entropyBitsPerEvent
.text("0");
1685 DOM
.entropyBits
.text("0");
1686 DOM
.entropyFiltered
.html(" ");
1687 DOM
.entropyBinary
.html(" ");
1690 function showEntropyFeedback(entropy
) {
1691 var numberOfBits
= entropy
.binaryStr
.length
;
1692 var timeToCrack
= "unknown";
1694 var z
= libs
.zxcvbn(entropy
.base
.parts
.join(""));
1695 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1696 if (z
.feedback
.warning
!= "") {
1697 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1701 console
.log("Error detecting entropy strength with zxcvbn:");
1704 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1705 DOM
.entropyTypeInputs
.attr("checked", false);
1706 DOM
.entropyTypeInputs
.filter("[value='" + entropyTypeStr
+ "']").attr("checked", true);
1707 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1708 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1709 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1710 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1711 DOM
.entropyType
.text(entropyTypeStr
);
1712 DOM
.entropyCrackTime
.text(timeToCrack
);
1713 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1714 DOM
.entropyBits
.text(numberOfBits
);
1715 DOM
.entropyWordCount
.text(wordCount
);
1716 DOM
.entropyBinary
.text(spacedBinaryStr
);
1717 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1718 // detect and warn of filtering
1719 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1720 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1721 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1723 DOM
.entropyFilterWarning
.removeClass('hidden');
1726 DOM
.entropyFilterWarning
.addClass('hidden');
1730 function getEntropyTypeStr(entropy
) {
1731 var typeStr
= entropy
.base
.str
;
1732 // Add some detail if these are cards
1733 if (entropy
.base
.asInt
== 52) {
1734 var cardDetail
= []; // array of message strings
1735 // Detect duplicates
1737 var dupeTracker
= {};
1738 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1739 var card
= entropy
.base
.parts
[i
];
1740 var cardUpper
= card
.toUpperCase();
1741 if (cardUpper
in dupeTracker
) {
1744 dupeTracker
[cardUpper
] = true;
1746 if (dupes
.length
> 0) {
1747 var dupeWord
= "duplicates";
1748 if (dupes
.length
== 1) {
1749 dupeWord
= "duplicate";
1751 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1752 if (dupes
.length
> 3) {
1755 cardDetail
.push(msg
);
1758 var uniqueCards
= [];
1759 for (var uniqueCard
in dupeTracker
) {
1760 uniqueCards
.push(uniqueCard
);
1762 if (uniqueCards
.length
== 52) {
1763 cardDetail
.unshift("full deck");
1765 // Detect missing cards
1766 var values
= "A23456789TJQK";
1768 var missingCards
= [];
1769 for (var i
=0; i
<suits
.length
; i
++) {
1770 for (var j
=0; j
<values
.length
; j
++) {
1771 var card
= values
[j
] + suits
[i
];
1772 if (!(card
in dupeTracker
)) {
1773 missingCards
.push(card
);
1777 // Display missing cards if six or less, ie clearly going for full deck
1778 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1779 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1780 if (missingCards
.length
> 3) {
1783 cardDetail
.push(msg
);
1785 // Add card details to typeStr
1786 if (cardDetail
.length
> 0) {
1787 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1793 function setQrEvents(els
) {
1794 els
.on("mouseenter", createQr
);
1795 els
.on("mouseleave", destroyQr
);
1796 els
.on("click", toggleQr
);
1799 function createQr(e
) {
1800 var content
= e
.target
.textContent
|| e
.target
.value
;
1802 var qrEl
= libs
.kjua({
1808 DOM
.qrImage
.append(qrEl
);
1810 DOM
.qrHider
.addClass("hidden");
1813 DOM
.qrHider
.removeClass("hidden");
1815 DOM
.qrContainer
.removeClass("hidden");
1819 function destroyQr() {
1820 DOM
.qrImage
.text("");
1821 DOM
.qrContainer
.addClass("hidden");
1824 function toggleQr() {
1826 DOM
.qrHider
.toggleClass("hidden");
1827 DOM
.qrHint
.toggleClass("hidden");
1830 function bip44TabSelected() {
1831 return DOM
.bip44tab
.hasClass("active");
1834 function bip32TabSelected() {
1835 return DOM
.bip32tab
.hasClass("active");
1838 function networkIsEthereum() {
1839 var name
= networks
[DOM
.network
.val()].name
;
1840 return (name
== "ETH - Ethereum")
1841 || (name
== "ETC - Ethereum Classic")
1842 || (name
== "EWT - EnergyWeb")
1843 || (name
== "PIRL - Pirl")
1844 || (name
== "MIX - MIX")
1845 || (name
== "MOAC - MOAC")
1846 || (name
== "MUSIC - Musicoin")
1847 || (name
== "POA - Poa")
1848 || (name
== "EXP - Expanse")
1849 || (name
== "CLO - Callisto")
1850 || (name
== "DXN - DEXON")
1851 || (name
== "ELLA - Ellaism")
1852 || (name
== "ESN - Ethersocial Network")
1853 || (name
== "VET - VeChain")
1854 || (name
== "ERE - EtherCore")
1857 function networkHasSegwit() {
1859 if ("baseNetwork" in network
) {
1860 n
= libs
.bitcoin
.networks
[network
.baseNetwork
];
1862 // check if only p2wpkh params are required
1863 if (p2wpkhSelected()) {
1864 return "p2wpkh" in n
;
1866 // check if only p2wpkh-in-p2sh params are required
1867 else if (p2wpkhInP2shSelected()) {
1868 return "p2wpkhInP2sh" in n
;
1870 // require both if it's unclear which params are required
1871 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1874 function bip49TabSelected() {
1875 return DOM
.bip49tab
.hasClass("active");
1878 function bip84TabSelected() {
1879 return DOM
.bip84tab
.hasClass("active");
1882 function bip141TabSelected() {
1883 return DOM
.bip141tab
.hasClass("active");
1886 function setHdCoin(coinValue
) {
1887 DOM
.bip44coin
.val(coinValue
);
1888 DOM
.bip49coin
.val(coinValue
);
1889 DOM
.bip84coin
.val(coinValue
);
1892 function showSegwitAvailable() {
1893 DOM
.bip49unavailable
.addClass("hidden");
1894 DOM
.bip49available
.removeClass("hidden");
1895 DOM
.bip84unavailable
.addClass("hidden");
1896 DOM
.bip84available
.removeClass("hidden");
1897 DOM
.bip141unavailable
.addClass("hidden");
1898 DOM
.bip141available
.removeClass("hidden");
1901 function showSegwitUnavailable() {
1902 DOM
.bip49available
.addClass("hidden");
1903 DOM
.bip49unavailable
.removeClass("hidden");
1904 DOM
.bip84available
.addClass("hidden");
1905 DOM
.bip84unavailable
.removeClass("hidden");
1906 DOM
.bip141available
.addClass("hidden");
1907 DOM
.bip141unavailable
.removeClass("hidden");
1910 function adjustNetworkForSegwit() {
1911 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1912 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1914 // See https://github.com/iancoleman/bip39/issues/125
1915 var segwitNetworks
= null;
1916 // if a segwit network is alread selected, need to use base network to
1917 // look up new parameters
1918 if ("baseNetwork" in network
) {
1919 network
= libs
.bitcoin
.networks
[network
.baseNetwork
];
1921 // choose the right segwit params
1922 if (p2wpkhSelected() && "p2wpkh" in network
) {
1923 network
= network
.p2wpkh
;
1925 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1926 network
= network
.p2wpkhInP2sh
;
1928 else if (p2wshSelected() && "p2wsh" in network
) {
1929 network
= network
.p2wsh
;
1931 else if (p2wshInP2shSelected() && "p2wshInP2sh" in network
) {
1932 network
= network
.p2wshInP2sh
;
1936 function lastIndexInTable() {
1937 var pathText
= DOM
.addresses
.find(".index").last().text();
1938 var pathBits
= pathText
.split("/");
1939 var lastBit
= pathBits
[pathBits
.length
-1];
1940 var lastBitClean
= lastBit
.replace("'", "");
1941 return parseInt(lastBitClean
);
1944 function uint8ArrayToHex(a
) {
1946 for (var i
=0; i
<a
.length
; i
++) {
1947 var h
= a
[i
].toString(16);
1948 while (h
.length
< 2) {
1956 function showWordIndexes() {
1957 var phrase
= DOM
.phrase
.val();
1958 var words
= phraseToWordArray(phrase
);
1959 var wordIndexes
= [];
1960 var language
= getLanguage();
1961 for (var i
=0; i
<words
.length
; i
++) {
1962 var word
= words
[i
];
1963 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1964 wordIndexes
.push(wordIndex
);
1966 var wordIndexesStr
= wordIndexes
.join(", ");
1967 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1970 function showChecksum() {
1971 var phrase
= DOM
.phrase
.val();
1972 var words
= phraseToWordArray(phrase
);
1973 var checksumBitlength
= words
.length
/ 3;
1976 var language
= getLanguage();
1977 for (var i
=words
.length
-1; i
>=0; i
--) {
1978 var word
= words
[i
];
1979 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1980 var wordBinary
= wordIndex
.toString(2);
1981 while (wordBinary
.length
< 11) {
1982 wordBinary
= "0" + wordBinary
;
1984 var binaryStr
= wordBinary
+ binaryStr
;
1985 if (binaryStr
.length
>= checksumBitlength
) {
1986 var start
= binaryStr
.length
- checksumBitlength
;
1987 var end
= binaryStr
.length
;
1988 checksum
= binaryStr
.substring(start
, end
);
1989 // add spaces so the last group is 11 bits, not the first
1990 checksum
= checksum
.split("").reverse().join("")
1991 checksum
= addSpacesEveryElevenBits(checksum
);
1992 checksum
= checksum
.split("").reverse().join("")
1996 DOM
.entropyChecksum
.text(checksum
);
1999 function updateCsv() {
2000 var tableCsv
= "path,address,public key,private key\n";
2001 var rows
= DOM
.addresses
.find("tr");
2002 for (var i
=0; i
<rows
.length
; i
++) {
2003 var row
= $(rows
[i
]);
2004 var cells
= row
.find("td");
2005 for (var j
=0; j
<cells
.length
; j
++) {
2006 var cell
= $(cells
[j
]);
2007 if (!cell
.children().hasClass("invisible")) {
2008 tableCsv
= tableCsv
+ cell
.text();
2010 if (j
!= cells
.length
- 1) {
2011 tableCsv
= tableCsv
+ ",";
2014 tableCsv
= tableCsv
+ "\n";
2016 DOM
.csv
.val(tableCsv
);
2019 function addSpacesEveryElevenBits(binaryStr
) {
2020 return binaryStr
.match(/.{1,11}/g).join(" ");
2025 name: "AC - Asiacoin",
2026 onSelect: function() {
2027 network
= libs
.bitcoin
.networks
.asiacoin
;
2032 name: "ACC - Adcoin",
2033 onSelect: function() {
2034 network
= libs
.bitcoin
.networks
.adcoin
;
2039 name: "AGM - Argoneum",
2040 onSelect: function() {
2041 network
= libs
.bitcoin
.networks
.argoneum
;
2046 name: "ARYA - Aryacoin",
2047 onSelect: function() {
2048 network
= libs
.bitcoin
.networks
.aryacoin
;
2053 name: "AUR - Auroracoin",
2054 onSelect: function() {
2055 network
= libs
.bitcoin
.networks
.auroracoin
;
2061 onSelect: function() {
2062 network
= libs
.bitcoin
.networks
.axe
;
2067 name: "ANON - ANON",
2068 onSelect: function() {
2069 network
= libs
.bitcoin
.networks
.anon
;
2074 name: "BOLI - Bolivarcoin",
2075 onSelect: function() {
2076 network
= libs
.bitcoin
.networks
.bolivarcoin
;
2081 name: "BCA - Bitcoin Atom",
2082 onSelect: function() {
2083 network
= libs
.bitcoin
.networks
.atom
;
2088 name: "BCH - Bitcoin Cash",
2089 onSelect: function() {
2090 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2095 name: "BEET - Beetlecoin",
2096 onSelect: function() {
2097 network
= libs
.bitcoin
.networks
.beetlecoin
;
2102 name: "BELA - Belacoin",
2103 onSelect: function() {
2104 network
= libs
.bitcoin
.networks
.belacoin
;
2109 name: "BLK - BlackCoin",
2110 onSelect: function() {
2111 network
= libs
.bitcoin
.networks
.blackcoin
;
2116 name: "BND - Blocknode",
2117 onSelect: function() {
2118 network
= libs
.bitcoin
.networks
.blocknode
;
2123 name: "tBND - Blocknode Testnet",
2124 onSelect: function() {
2125 network
= libs
.bitcoin
.networks
.blocknode_testnet
;
2130 name: "BRIT - Britcoin",
2131 onSelect: function() {
2132 network
= libs
.bitcoin
.networks
.britcoin
;
2137 name: "BSD - Bitsend",
2138 onSelect: function() {
2139 network
= libs
.bitcoin
.networks
.bitsend
;
2144 name: "BST - BlockStamp",
2145 onSelect: function() {
2146 network
= libs
.bitcoin
.networks
.blockstamp
;
2152 onSelect: function() {
2153 network
= libs
.bitcoin
.networks
.bata
;
2158 name: "BTC - Bitcoin",
2159 onSelect: function() {
2160 network
= libs
.bitcoin
.networks
.bitcoin
;
2165 name: "BTC - Bitcoin RegTest",
2166 onSelect: function() {
2167 network
= libs
.bitcoin
.networks
.regtest
;
2168 // Using hd coin value 1 based on bip44_coin_type
2169 // https://github.com/chaintope/bitcoinrb/blob/f1014406f6b8f9b4edcecedc18df70c80df06f11/lib/bitcoin/chainparams/regtest.yml
2174 name: "BTC - Bitcoin Testnet",
2175 onSelect: function() {
2176 network
= libs
.bitcoin
.networks
.testnet
;
2181 name: "BITG - Bitcoin Green",
2182 onSelect: function() {
2183 network
= libs
.bitcoin
.networks
.bitcoingreen
;
2188 name: "BTCP - Bitcoin Private",
2189 onSelect: function() {
2190 network
= libs
.bitcoin
.networks
.bitcoinprivate
;
2195 name: "BSV - BitcoinSV",
2196 onSelect: function() {
2197 network
= libs
.bitcoin
.networks
.bitcoinsv
;
2202 name: "BTCZ - Bitcoinz",
2203 onSelect: function() {
2204 network
= libs
.bitcoin
.networks
.bitcoinz
;
2209 name: "BTDX - BitCloud",
2210 onSelect: function() {
2211 network
= libs
.bitcoin
.networks
.bitcloud
;
2216 name: "BTG - Bitcoin Gold",
2217 onSelect: function() {
2218 network
= libs
.bitcoin
.networks
.bgold
;
2223 name: "BTX - Bitcore",
2224 onSelect: function() {
2225 network
= libs
.bitcoin
.networks
.bitcore
;
2230 name: "CCN - Cannacoin",
2231 onSelect: function() {
2232 network
= libs
.bitcoin
.networks
.cannacoin
;
2237 name: "CESC - Cryptoescudo",
2238 onSelect: function() {
2239 network
= libs
.bitcoin
.networks
.cannacoin
;
2244 name: "CDN - Canadaecoin",
2245 onSelect: function() {
2246 network
= libs
.bitcoin
.networks
.canadaecoin
;
2251 name: "CLAM - Clams",
2252 onSelect: function() {
2253 network
= libs
.bitcoin
.networks
.clam
;
2258 name: "CLO - Callisto",
2259 segwitAvailable: false,
2260 onSelect: function() {
2261 network
= libs
.bitcoin
.networks
.bitcoin
;
2266 name: "CLUB - Clubcoin",
2267 onSelect: function() {
2268 network
= libs
.bitcoin
.networks
.clubcoin
;
2273 name: "CMP - Compcoin",
2274 onSelect: function() {
2275 network
= libs
.bitcoin
.networks
.compcoin
;
2280 name: "CPU - CPUchain",
2281 onSelect: function() {
2282 network
= libs
.bitcoin
.networks
.cpuchain
;
2287 name: "CRAVE - Crave",
2288 onSelect: function() {
2289 network
= libs
.bitcoin
.networks
.crave
;
2294 name: "CRW - Crown (Legacy)",
2295 onSelect: function() {
2296 network
= libs
.bitcoin
.networks
.crown
;
2301 name: "CRW - Crown",
2302 onSelect: function() {
2303 network
= libs
.bitcoin
.networks
.crown
;
2308 name: "CSC - CasinoCoin",
2309 onSelect: function() {
2310 network
= libs
.bitcoin
.networks
.bitcoin
;
2315 name: "DASH - Dash",
2316 onSelect: function() {
2317 network
= libs
.bitcoin
.networks
.dash
;
2322 name: "DASH - Dash Testnet",
2323 onSelect: function() {
2324 network
= libs
.bitcoin
.networks
.dashtn
;
2329 name: "DFC - Defcoin",
2330 onSelect: function() {
2331 network
= libs
.bitcoin
.networks
.defcoin
;
2336 name: "DGB - Digibyte",
2337 onSelect: function() {
2338 network
= libs
.bitcoin
.networks
.digibyte
;
2343 name: "DGC - Digitalcoin",
2344 onSelect: function() {
2345 network
= libs
.bitcoin
.networks
.digitalcoin
;
2350 name: "DMD - Diamond",
2351 onSelect: function() {
2352 network
= libs
.bitcoin
.networks
.diamond
;
2357 name: "DNR - Denarius",
2358 onSelect: function() {
2359 network
= libs
.bitcoin
.networks
.denarius
;
2364 name: "DOGE - Dogecoin",
2365 onSelect: function() {
2366 network
= libs
.bitcoin
.networks
.dogecoin
;
2371 name: "DOGEt - Dogecoin Testnet",
2372 onSelect: function() {
2373 network
= libs
.bitcoin
.networks
.dogecointestnet
;
2378 name: "DXN - DEXON",
2379 onSelect: function() {
2380 network
= libs
.bitcoin
.networks
.bitcoin
;
2385 name: "ECN - Ecoin",
2386 onSelect: function() {
2387 network
= libs
.bitcoin
.networks
.ecoin
;
2392 name: "EDRC - Edrcoin",
2393 onSelect: function() {
2394 network
= libs
.bitcoin
.networks
.edrcoin
;
2399 name: "EFL - Egulden",
2400 onSelect: function() {
2401 network
= libs
.bitcoin
.networks
.egulden
;
2406 name: "ELA - Elastos",
2407 onSelect: function () {
2408 network
= libs
.bitcoin
.networks
.elastos
;
2413 name: "ELLA - Ellaism",
2414 segwitAvailable: false,
2415 onSelect: function() {
2416 network
= libs
.bitcoin
.networks
.bitcoin
;
2421 name: "EMC2 - Einsteinium",
2422 onSelect: function() {
2423 network
= libs
.bitcoin
.networks
.einsteinium
;
2428 name: "ERC - Europecoin",
2429 onSelect: function() {
2430 network
= libs
.bitcoin
.networks
.europecoin
;
2435 name: "EOS - EOSIO",
2436 onSelect: function() {
2437 network
= libs
.bitcoin
.networks
.bitcoin
;
2442 name: "ERE - EtherCore",
2443 segwitAvailable: false,
2444 onSelect: function() {
2445 network
= libs
.bitcoin
.networks
.bitcoin
;
2450 name: "ESN - Ethersocial Network",
2451 segwitAvailable: false,
2452 onSelect: function() {
2453 network
= libs
.bitcoin
.networks
.bitcoin
;
2458 name: "ETC - Ethereum Classic",
2459 segwitAvailable: false,
2460 onSelect: function() {
2461 network
= libs
.bitcoin
.networks
.bitcoin
;
2466 name: "ETH - Ethereum",
2467 onSelect: function() {
2468 network
= libs
.bitcoin
.networks
.bitcoin
;
2473 name: "EWT - EnergyWeb",
2474 onSelect: function() {
2475 network
= libs
.bitcoin
.networks
.bitcoin
;
2480 name: "EXCL - Exclusivecoin",
2481 onSelect: function() {
2482 network
= libs
.bitcoin
.networks
.exclusivecoin
;
2487 name: "EXCC - ExchangeCoin",
2488 onSelect: function() {
2489 network
= libs
.bitcoin
.networks
.exchangecoin
;
2494 name: "EXP - Expanse",
2495 segwitAvailable: false,
2496 onSelect: function() {
2497 network
= libs
.bitcoin
.networks
.bitcoin
;
2503 onSelect: function() {
2504 network
= libs
.bitcoin
.networks
.fix
;
2509 name: "FIX - FIX Testnet",
2510 onSelect: function() {
2511 network
= libs
.bitcoin
.networks
.fixtestnet
;
2516 name: "FJC - Fujicoin",
2517 onSelect: function() {
2518 network
= libs
.bitcoin
.networks
.fujicoin
;
2523 name: "FLASH - Flashcoin",
2524 onSelect: function() {
2525 network
= libs
.bitcoin
.networks
.flashcoin
;
2530 name: "FRST - Firstcoin",
2531 onSelect: function() {
2532 network
= libs
.bitcoin
.networks
.firstcoin
;
2537 name: "FTC - Feathercoin",
2538 onSelect: function() {
2539 network
= libs
.bitcoin
.networks
.feathercoin
;
2544 name: "GAME - GameCredits",
2545 onSelect: function() {
2546 network
= libs
.bitcoin
.networks
.game
;
2551 name: "GBX - Gobyte",
2552 onSelect: function() {
2553 network
= libs
.bitcoin
.networks
.gobyte
;
2558 name: "GCR - GCRCoin",
2559 onSelect: function() {
2560 network
= libs
.bitcoin
.networks
.gcr
;
2565 name: "GRC - Gridcoin",
2566 onSelect: function() {
2567 network
= libs
.bitcoin
.networks
.gridcoin
;
2572 name: "GRS - Groestlcoin",
2573 onSelect: function() {
2574 network
= libs
.bitcoin
.networks
.groestlcoin
;
2579 name: "GRS - Groestlcoin Testnet",
2580 onSelect: function() {
2581 network
= libs
.bitcoin
.networks
.groestlcointestnet
;
2586 name: "HNS - Handshake",
2587 onSelect: function() {
2592 name: "HNC - Helleniccoin",
2593 onSelect: function() {
2594 network
= libs
.bitcoin
.networks
.helleniccoin
;
2599 name: "HUSH - Hush (Legacy)",
2600 onSelect: function() {
2601 network
= libs
.bitcoin
.networks
.hush
;
2606 name: "HUSH - Hush3",
2607 onSelect: function() {
2608 network
= libs
.bitcoin
.networks
.hush3
;
2613 name: "INSN - Insane",
2614 onSelect: function() {
2615 network
= libs
.bitcoin
.networks
.insane
;
2621 onSelect: function() {
2622 network
= libs
.bitcoin
.networks
.iop
;
2627 name: "IXC - Ixcoin",
2628 onSelect: function() {
2629 network
= libs
.bitcoin
.networks
.ixcoin
;
2634 name: "JBS - Jumbucks",
2635 onSelect: function() {
2636 network
= libs
.bitcoin
.networks
.jumbucks
;
2641 name: "KMD - Komodo",
2642 bip49available: false,
2643 onSelect: function() {
2644 network
= libs
.bitcoin
.networks
.komodo
;
2649 name: "KOBO - Kobocoin",
2650 bip49available: false,
2651 onSelect: function() {
2652 network
= libs
.bitcoin
.networks
.kobocoin
;
2657 name: "LBC - Library Credits",
2658 onSelect: function() {
2659 network
= libs
.bitcoin
.networks
.lbry
;
2664 name: "LCC - Litecoincash",
2665 onSelect: function() {
2666 network
= libs
.bitcoin
.networks
.litecoincash
;
2671 name: "LDCN - Landcoin",
2672 onSelect: function() {
2673 network
= libs
.bitcoin
.networks
.landcoin
;
2678 name: "LINX - Linx",
2679 onSelect: function() {
2680 network
= libs
.bitcoin
.networks
.linx
;
2685 name: "LKR - Lkrcoin",
2686 segwitAvailable: false,
2687 onSelect: function() {
2688 network
= libs
.bitcoin
.networks
.lkrcoin
;
2693 name: "LTC - Litecoin",
2694 onSelect: function() {
2695 network
= libs
.bitcoin
.networks
.litecoin
;
2697 DOM
.litecoinLtubContainer
.removeClass("hidden");
2701 name: "LTCt - Litecoin Testnet",
2702 onSelect: function() {
2703 network
= libs
.bitcoin
.networks
.litecointestnet
;
2705 DOM
.litecoinLtubContainer
.removeClass("hidden");
2709 name: "LTZ - LitecoinZ",
2710 onSelect: function() {
2711 network
= libs
.bitcoin
.networks
.litecoinz
;
2716 name: "LYNX - Lynx",
2717 onSelect: function() {
2718 network
= libs
.bitcoin
.networks
.lynx
;
2723 name: "MAZA - Maza",
2724 onSelect: function() {
2725 network
= libs
.bitcoin
.networks
.maza
;
2730 name: "MEC - Megacoin",
2731 onSelect: function() {
2732 network
= libs
.bitcoin
.networks
.megacoin
;
2738 segwitAvailable: false,
2739 onSelect: function() {
2740 network
= libs
.bitcoin
.networks
.bitcoin
;
2745 name: "MNX - Minexcoin",
2746 onSelect: function() {
2747 network
= libs
.bitcoin
.networks
.minexcoin
;
2752 name: "MONA - Monacoin",
2753 onSelect: function() {
2754 network
= libs
.bitcoin
.networks
.monacoin
,
2759 name: "MONK - Monkey Project",
2760 onSelect: function() {
2761 network
= libs
.bitcoin
.networks
.monkeyproject
,
2766 name: "MOAC - MOAC",
2767 segwitAvailable: false,
2768 onSelect: function() {
2769 network
= libs
.bitcoin
.networks
.bitcoin
;
2774 name: "MUSIC - Musicoin",
2775 segwitAvailable: false,
2776 onSelect: function() {
2777 network
= libs
.bitcoin
.networks
.bitcoin
;
2782 name: "NAV - Navcoin",
2783 onSelect: function() {
2784 network
= libs
.bitcoin
.networks
.navcoin
;
2789 name: "NAS - Nebulas",
2790 onSelect: function() {
2791 network
= libs
.bitcoin
.networks
.bitcoin
;
2796 name: "NEBL - Neblio",
2797 onSelect: function() {
2798 network
= libs
.bitcoin
.networks
.neblio
;
2803 name: "NEOS - Neoscoin",
2804 onSelect: function() {
2805 network
= libs
.bitcoin
.networks
.neoscoin
;
2810 name: "NIX - NIX Platform",
2811 onSelect: function() {
2812 network
= libs
.bitcoin
.networks
.nix
;
2817 name: "NLG - Gulden",
2818 onSelect: function() {
2819 network
= libs
.bitcoin
.networks
.gulden
;
2824 name: "NMC - Namecoin",
2825 onSelect: function() {
2826 network
= libs
.bitcoin
.networks
.namecoin
;
2831 name: "NRG - Energi",
2832 onSelect: function() {
2833 network
= libs
.bitcoin
.networks
.energi
;
2838 name: "NRO - Neurocoin",
2839 onSelect: function() {
2840 network
= libs
.bitcoin
.networks
.neurocoin
;
2845 name: "NSR - Nushares",
2846 onSelect: function() {
2847 network
= libs
.bitcoin
.networks
.nushares
;
2852 name: "NYC - Newyorkc",
2853 onSelect: function() {
2854 network
= libs
.bitcoin
.networks
.newyorkc
;
2859 name: "NVC - Novacoin",
2860 onSelect: function() {
2861 network
= libs
.bitcoin
.networks
.novacoin
;
2866 name: "OK - Okcash",
2867 onSelect: function() {
2868 network
= libs
.bitcoin
.networks
.okcash
;
2873 name: "OMNI - Omnicore",
2874 onSelect: function() {
2875 network
= libs
.bitcoin
.networks
.omnicore
;
2880 name: "ONION - DeepOnion",
2881 onSelect: function() {
2882 network
= libs
.bitcoin
.networks
.deeponion
;
2887 name: "ONX - Onixcoin",
2888 onSelect: function() {
2889 network
= libs
.bitcoin
.networks
.onixcoin
;
2894 name: "PHR - Phore",
2895 onSelect: function() {
2896 network
= libs
.bitcoin
.networks
.phore
;
2901 name: "PINK - Pinkcoin",
2902 onSelect: function() {
2903 network
= libs
.bitcoin
.networks
.pinkcoin
;
2908 name: "PIRL - Pirl",
2909 segwitAvailable: false,
2910 onSelect: function() {
2911 network
= libs
.bitcoin
.networks
.bitcoin
;
2916 name: "PIVX - PIVX",
2917 onSelect: function() {
2918 network
= libs
.bitcoin
.networks
.pivx
;
2923 name: "PIVX - PIVX Testnet",
2924 onSelect: function() {
2925 network
= libs
.bitcoin
.networks
.pivxtestnet
;
2931 segwitAvailable: false,
2932 onSelect: function() {
2933 network
= libs
.bitcoin
.networks
.bitcoin
;
2938 name: "POSW - POSWcoin",
2939 onSelect: function() {
2940 network
= libs
.bitcoin
.networks
.poswcoin
;
2945 name: "POT - Potcoin",
2946 onSelect: function() {
2947 network
= libs
.bitcoin
.networks
.potcoin
;
2952 name: "PPC - Peercoin",
2953 onSelect: function() {
2954 network
= libs
.bitcoin
.networks
.peercoin
;
2959 name: "PRJ - ProjectCoin",
2960 onSelect: function() {
2961 network
= libs
.bitcoin
.networks
.projectcoin
;
2966 name: "PSB - Pesobit",
2967 onSelect: function() {
2968 network
= libs
.bitcoin
.networks
.pesobit
;
2973 name: "PUT - Putincoin",
2974 onSelect: function() {
2975 network
= libs
.bitcoin
.networks
.putincoin
;
2980 name: "RPD - Rapids",
2981 onSelect: function() {
2982 network
= libs
.bitcoin
.networks
.rapids
;
2987 name: "RVN - Ravencoin",
2988 onSelect: function() {
2989 network
= libs
.bitcoin
.networks
.ravencoin
;
2995 onSelect: function() {
2996 network
= libs
.bitcoin
.networks
.rubycoin
;
3001 name: "tRBTC - RSK Testnet",
3002 onSelect: function() {
3003 network
= libs
.bitcoin
.networks
.rubycoin
;
3008 name: "RBY - Rubycoin",
3009 onSelect: function() {
3010 network
= libs
.bitcoin
.networks
.rubycoin
;
3015 name: "RDD - Reddcoin",
3016 onSelect: function() {
3017 network
= libs
.bitcoin
.networks
.reddcoin
;
3022 name: "RVR - RevolutionVR",
3023 onSelect: function() {
3024 network
= libs
.bitcoin
.networks
.revolutionvr
;
3029 name: "SAFE - Safecoin",
3030 onSelect: function() {
3031 network
= libs
.bitcoin
.networks
.safecoin
;
3036 name: "SLS - Salus",
3037 onSelect: function() {
3038 network
= libs
.bitcoin
.networks
.salus
;
3043 name: "SDC - ShadowCash",
3044 onSelect: function() {
3045 network
= libs
.bitcoin
.networks
.shadow
;
3050 name: "SDC - ShadowCash Testnet",
3051 onSelect: function() {
3052 network
= libs
.bitcoin
.networks
.shadowtn
;
3057 name: "SLM - Slimcoin",
3058 onSelect: function() {
3059 network
= libs
.bitcoin
.networks
.slimcoin
;
3064 name: "SLM - Slimcoin Testnet",
3065 onSelect: function() {
3066 network
= libs
.bitcoin
.networks
.slimcointn
;
3071 name: "SLP - Simple Ledger Protocol",
3072 onSelect: function() {
3073 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
3078 name: "SLR - Solarcoin",
3079 onSelect: function() {
3080 network
= libs
.bitcoin
.networks
.solarcoin
;
3085 name: "SMLY - Smileycoin",
3086 onSelect: function() {
3087 network
= libs
.bitcoin
.networks
.smileycoin
;
3092 name: "STASH - Stash",
3093 onSelect: function() {
3094 network
= libs
.bitcoin
.networks
.stash
;
3099 name: "STASH - Stash Testnet",
3100 onSelect: function() {
3101 network
= libs
.bitcoin
.networks
.stashtn
;
3106 name: "STRAT - Stratis",
3107 onSelect: function() {
3108 network
= libs
.bitcoin
.networks
.stratis
;
3113 name: "SUGAR - Sugarchain",
3114 onSelect: function() {
3115 network
= libs
.bitcoin
.networks
.sugarchain
;
3120 name: "TUGAR - Sugarchain Testnet",
3121 onSelect: function() {
3122 network
= libs
.bitcoin
.networks
.sugarchaintestnet
;
3127 name: "SWTC - Jingtum",
3128 onSelect: function() {
3129 network
= libs
.bitcoin
.networks
.bitcoin
;
3134 name: "TSTRAT - Stratis Testnet",
3135 onSelect: function() {
3136 network
= libs
.bitcoin
.networks
.stratistest
;
3141 name: "SYS - Syscoin",
3142 onSelect: function() {
3143 network
= libs
.bitcoin
.networks
.syscoin
;
3148 name: "THC - Hempcoin",
3149 onSelect: function() {
3150 network
= libs
.bitcoin
.networks
.hempcoin
;
3155 name: "THT - Thought",
3156 onSelect: function() {
3157 network
= libs
.bitcoin
.networks
.thought
;
3163 onSelect: function() {
3164 network
= libs
.bitcoin
.networks
.toa
;
3169 name: "TWINS - TWINS",
3170 onSelect: function() {
3171 network
= libs
.bitcoin
.networks
.twins
;
3176 name: "TWINS - TWINS Testnet",
3177 onSelect: function() {
3178 network
= libs
.bitcoin
.networks
.twinstestnet
;
3183 name: "USC - Ultimatesecurecash",
3184 onSelect: function() {
3185 network
= libs
.bitcoin
.networks
.ultimatesecurecash
;
3190 name: "USNBT - NuBits",
3191 onSelect: function() {
3192 network
= libs
.bitcoin
.networks
.nubits
;
3197 name: "UNO - Unobtanium",
3198 onSelect: function() {
3199 network
= libs
.bitcoin
.networks
.unobtanium
;
3204 name: "VASH - Vpncoin",
3205 onSelect: function() {
3206 network
= libs
.bitcoin
.networks
.vpncoin
;
3211 name: "VET - VeChain",
3212 onSelect: function() {
3213 network
= libs
.bitcoin
.networks
.bitcoin
;
3218 name: "VIA - Viacoin",
3219 onSelect: function() {
3220 network
= libs
.bitcoin
.networks
.viacoin
;
3225 name: "VIA - Viacoin Testnet",
3226 onSelect: function() {
3227 network
= libs
.bitcoin
.networks
.viacointestnet
;
3232 name: "VIVO - Vivo",
3233 onSelect: function() {
3234 network
= libs
.bitcoin
.networks
.vivo
;
3239 name: "VTC - Vertcoin",
3240 onSelect: function() {
3241 network
= libs
.bitcoin
.networks
.vertcoin
;
3246 name: "WGR - Wagerr",
3247 onSelect: function() {
3248 network
= libs
.bitcoin
.networks
.wagerr
;
3253 name: "WC - Wincoin",
3254 onSelect: function() {
3255 network
= libs
.bitcoin
.networks
.wincoin
;
3260 name: "XAX - Artax",
3261 onSelect: function() {
3262 network
= libs
.bitcoin
.networks
.artax
;
3267 name: "XBC - Bitcoinplus",
3268 onSelect: function() {
3269 network
= libs
.bitcoin
.networks
.bitcoinplus
;
3274 name: "XLM - Stellar",
3275 onSelect: function() {
3276 network
= libs
.stellarUtil
.dummyNetwork
;
3281 name: "XMY - Myriadcoin",
3282 onSelect: function() {
3283 network
= libs
.bitcoin
.networks
.myriadcoin
;
3288 name: "XRP - Ripple",
3289 onSelect: function() {
3290 network
= libs
.bitcoin
.networks
.bitcoin
;
3295 name: "XVC - Vcash",
3296 onSelect: function() {
3297 network
= libs
.bitcoin
.networks
.vcash
;
3302 name: "XVG - Verge",
3303 onSelect: function() {
3304 network
= libs
.bitcoin
.networks
.verge
;
3309 name: "XUEZ - Xuez",
3310 segwitAvailable: false,
3311 onSelect: function() {
3312 network
= libs
.bitcoin
.networks
.xuez
;
3317 name: "XWC - Whitecoin",
3318 onSelect: function() {
3319 network
= libs
.bitcoin
.networks
.whitecoin
;
3324 name: "XZC - Zcoin",
3325 onSelect: function() {
3326 network
= libs
.bitcoin
.networks
.zcoin
;
3331 name: "ZCL - Zclassic",
3332 onSelect: function() {
3333 network
= libs
.bitcoin
.networks
.zclassic
;
3338 name: "ZEC - Zcash",
3339 onSelect: function() {
3340 network
= libs
.bitcoin
.networks
.zcash
;
3345 name: "ZEN - Horizen",
3346 onSelect: function() {
3347 network
= libs
.bitcoin
.networks
.zencash
;
3355 name: "Bitcoin Core",
3356 onSelect: function() {
3357 DOM
.bip32path
.val("m/0'/0'");
3358 DOM
.hardenedAddresses
.prop('checked', true);
3362 name: "blockchain.info",
3363 onSelect: function() {
3364 DOM
.bip32path
.val("m/44'/0'/0'");
3365 DOM
.hardenedAddresses
.prop('checked', false);
3369 name: "MultiBit HD",
3370 onSelect: function() {
3371 DOM
.bip32path
.val("m/0'/0");
3372 DOM
.hardenedAddresses
.prop('checked', false);
3376 name: "Coinomi, Ledger",
3377 onSelect: function() {
3378 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
3379 DOM
.hardenedAddresses
.prop('checked', false);
3384 // ELA - Elastos functions - begin
3385 function displayBip44InfoForELA() {
3390 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
3391 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
3393 // Calculate the account extended keys
3394 var accountXprv
= libs
.elastosjs
.getAccountExtendedPrivateKey(seed
, coin
, account
);
3395 var accountXpub
= libs
.elastosjs
.getAccountExtendedPublicKey(seed
, coin
, account
);
3397 // Display the extended keys
3398 DOM
.bip44accountXprv
.val(accountXprv
);
3399 DOM
.bip44accountXpub
.val(accountXpub
);
3402 function displayBip32InfoForELA() {
3407 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
3408 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
3409 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
3411 DOM
.extendedPrivKey
.val(libs
.elastosjs
.getBip32ExtendedPrivateKey(seed
, coin
, account
, change
));
3412 DOM
.extendedPubKey
.val(libs
.elastosjs
.getBip32ExtendedPublicKey(seed
, coin
, account
, change
));
3414 // Display the addresses and privkeys
3415 clearAddressesList();
3416 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
3417 displayAddresses(0, initialAddressCount
);
3420 function calcAddressForELA(seed
, coin
, account
, change
, index
) {
3425 var publicKey
= libs
.elastosjs
.getDerivedPublicKey(libs
.elastosjs
.getMasterPublicKey(seed
), change
, index
);
3427 privateKey: libs
.elastosjs
.getDerivedPrivateKey(seed
, coin
, account
, change
, index
),
3428 publicKey: publicKey
,
3429 address: libs
.elastosjs
.getAddress(publicKey
.toString('hex'))
3432 // ELA - Elastos functions - end