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 // Stellar is different
1144 if (networks
[DOM
.network
.val()].name
== "XLM - Stellar") {
1145 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
1146 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
1148 path
+= purpose
+ "'/";
1149 path
+= coin
+ "'/" + index
+ "'";
1150 var keypair
= libs
.stellarUtil
.getKeypair(path
, seed
);
1152 privkey
= keypair
.secret();
1153 pubkey
= address
= keypair
.publicKey();
1155 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
1156 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1157 var nebulasAccount
= libs
.nebulas
.Account
.NewAccount();
1158 nebulasAccount
.setPrivateKey(privKeyBuffer
);
1159 address
= nebulasAccount
.getAddressString();
1160 privkey
= nebulasAccount
.getPrivateKeyString();
1161 pubkey
= nebulasAccount
.getPublicKeyString();
1163 // Ripple values are different
1164 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
1165 privkey
= convertRipplePriv(privkey
);
1166 address
= convertRippleAdrr(address
);
1168 // Jingtum values are different
1169 if (networks
[DOM
.network
.val()].name
== "SWTC - Jingtum") {
1170 privkey
= convertJingtumPriv(privkey
);
1171 address
= convertJingtumAdrr(address
);
1173 // CasinoCoin values are different
1174 if (networks
[DOM
.network
.val()].name
== "CSC - CasinoCoin") {
1175 privkey
= convertCasinoCoinPriv(privkey
);
1176 address
= convertCasinoCoinAdrr(address
);
1178 // Bitcoin Cash address format may vary
1179 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
1180 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1181 if (bchAddrType
== "cashaddr") {
1182 address
= libs
.bchaddr
.toCashAddress(address
);
1184 else if (bchAddrType
== "bitpay") {
1185 address
= libs
.bchaddr
.toBitpayAddress(address
);
1188 // Bitcoin Cash address format may vary
1189 if (networks
[DOM
.network
.val()].name
== "SLP - Simple Ledger Protocol") {
1190 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1191 if (bchAddrType
== "cashaddr") {
1192 address
= libs
.bchaddrSlp
.toSlpAddress(address
);
1195 // Segwit addresses are different
1197 if (!segwitAvailable
) {
1201 var keyhash
= libs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1202 var scriptpubkey
= libs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1203 address
= libs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1205 else if (isP2wpkhInP2sh
) {
1206 var keyhash
= libs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1207 var scriptsig
= libs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1208 var addressbytes
= libs
.bitcoin
.crypto
.hash160(scriptsig
);
1209 var scriptpubkey
= libs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
1210 address
= libs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1213 // https://github.com/libs.bitcoinjs-lib/blob/v3.3.2/test/integration/addresses.js#L71
1215 var witnessScript
= libs
.bitcoin
.script
.multisig
.output
.encode(1, [key
.getPublicKeyBuffer()]);
1216 var scriptPubKey
= libs
.bitcoin
.script
.witnessScriptHash
.output
.encode(libs
.bitcoin
.crypto
.sha256(witnessScript
));
1217 address
= libs
.bitcoin
.address
.fromOutputScript(scriptPubKey
, network
);
1219 else if (isP2wshInP2sh
) {
1220 // https://github.com/libs.bitcoinjs-lib/blob/v3.3.2/test/integration/transactions.js#L183
1222 var witnessScript
= libs
.bitcoin
.script
.multisig
.output
.encode(1, [key
.getPublicKeyBuffer()]);
1223 var redeemScript
= libs
.bitcoin
.script
.witnessScriptHash
.output
.encode(libs
.bitcoin
.crypto
.sha256(witnessScript
));
1224 var scriptPubKey
= libs
.bitcoin
.script
.scriptHash
.output
.encode(libs
.bitcoin
.crypto
.hash160(redeemScript
));
1225 address
= libs
.bitcoin
.address
.fromOutputScript(scriptPubKey
, network
)
1229 if ((networks
[DOM
.network
.val()].name
== "CRW - Crown")) {
1230 address
= libs
.bitcoin
.networks
.crown
.toNewAddress(address
);
1233 if (networks
[DOM
.network
.val()].name
== "EOS - EOSIO") {
1235 pubkey
= eosUtil
.bufferToPublic(keyPair
.getPublicKeyBuffer());
1236 privkey
= eosUtil
.bufferToPrivate(keyPair
.d
.toBuffer(32));
1239 //Groestlcoin Addresses are different
1243 if (!segwitAvailable
) {
1247 address
= libs
.groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1249 else if (isP2wpkhInP2sh
) {
1250 address
= libs
.groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1253 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1257 let elaAddress
= calcAddressForELA(
1259 parseIntNoNaN(DOM
.bip44coin
.val(), 0),
1260 parseIntNoNaN(DOM
.bip44account
.val(), 0),
1261 parseIntNoNaN(DOM
.bip44change
.val(), 0),
1264 address
= elaAddress
.address
;
1265 privkey
= elaAddress
.privateKey
;
1266 pubkey
= elaAddress
.publicKey
;
1269 addAddressToList(indexText
, address
, pubkey
, privkey
);
1281 function showMore() {
1282 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
1283 if (isNaN(rowsToAdd
)) {
1285 DOM
.rowsToAdd
.val("20");
1287 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
1289 start
= lastIndexInTable() + 1;
1292 var newStart
= start
+ rowsToAdd
;
1293 DOM
.moreRowsStartIndex
.val(newStart
);
1295 if (rowsToAdd
> 200) {
1296 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1297 msg
+= "Do you want to continue?";
1298 if (!confirm(msg
)) {
1302 displayAddresses(start
, rowsToAdd
);
1305 function clearDisplay() {
1306 clearAddressesList();
1308 hideValidationError();
1311 function clearAddressesList() {
1312 DOM
.addresses
.empty();
1317 function stopGenerating() {
1318 while (generationProcesses
.length
> 0) {
1319 var generation
= generationProcesses
.shift();
1324 function clearKeys() {
1329 function clearRootKey() {
1330 DOM
.rootKey
.val("");
1333 function clearDerivedKeys() {
1334 DOM
.extendedPrivKey
.val("");
1335 DOM
.extendedPubKey
.val("");
1336 DOM
.bip44accountXprv
.val("");
1337 DOM
.bip44accountXpub
.val("");
1340 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1341 var row
= $(addressRowTemplate
.html());
1343 var indexCell
= row
.find(".index span");
1344 var addressCell
= row
.find(".address span");
1345 var pubkeyCell
= row
.find(".pubkey span");
1346 var privkeyCell
= row
.find(".privkey span");
1348 indexCell
.text(indexText
);
1349 addressCell
.text(address
);
1350 pubkeyCell
.text(pubkey
);
1351 privkeyCell
.text(privkey
);
1354 indexCell
.addClass("invisible");
1357 addressCell
.addClass("invisible");
1360 pubkeyCell
.addClass("invisible");
1363 privkeyCell
.addClass("invisible");
1365 DOM
.addresses
.append(row
);
1366 var rowShowQrEls
= row
.find("[data-show-qr]");
1367 setQrEvents(rowShowQrEls
);
1370 function hasStrongRandom() {
1371 return 'crypto' in window
&& window
['crypto'] !== null;
1374 function disableForms() {
1375 $("form").on("submit", function(e
) {
1380 function parseIntNoNaN(val
, defaultVal
) {
1381 var v
= parseInt(val
);
1388 function showPending() {
1390 .text("Calculating...")
1394 function findNearestWord(word
) {
1395 var language
= getLanguage();
1396 var words
= WORDLISTS
[language
];
1397 var minDistance
= 99;
1398 var closestWord
= words
[0];
1399 for (var i
=0; i
<words
.length
; i
++) {
1400 var comparedTo
= words
[i
];
1401 if (comparedTo
.indexOf(word
) == 0) {
1404 var distance
= libs
.levenshtein
.get(word
, comparedTo
);
1405 if (distance
< minDistance
) {
1406 closestWord
= comparedTo
;
1407 minDistance
= distance
;
1413 function hidePending() {
1419 function populateNetworkSelect() {
1420 for (var i
=0; i
<networks
.length
; i
++) {
1421 var network
= networks
[i
];
1422 var option
= $("<option>");
1423 option
.attr("value", i
);
1424 option
.text(network
.name
);
1425 if (network
.name
== "BTC - Bitcoin") {
1426 option
.prop("selected", true);
1428 DOM
.phraseNetwork
.append(option
);
1432 function populateClientSelect() {
1433 for (var i
=0; i
<clients
.length
; i
++) {
1434 var client
= clients
[i
];
1435 var option
= $("<option>");
1436 option
.attr("value", i
);
1437 option
.text(client
.name
);
1438 DOM
.bip32Client
.append(option
);
1442 function getLanguage() {
1443 var defaultLanguage
= "english";
1444 // Try to get from existing phrase
1445 var language
= getLanguageFromPhrase();
1446 // Try to get from url if not from phrase
1447 if (language
.length
== 0) {
1448 language
= getLanguageFromUrl();
1450 // Default to English if no other option
1451 if (language
.length
== 0) {
1452 language
= defaultLanguage
;
1457 function getLanguageFromPhrase(phrase
) {
1458 // Check if how many words from existing phrase match a language.
1461 phrase
= DOM
.phrase
.val();
1463 if (phrase
.length
> 0) {
1464 var words
= phraseToWordArray(phrase
);
1465 var languageMatches
= {};
1466 for (l
in WORDLISTS
) {
1467 // Track how many words match in this language
1468 languageMatches
[l
] = 0;
1469 for (var i
=0; i
<words
.length
; i
++) {
1470 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1471 if (wordInLanguage
) {
1472 languageMatches
[l
]++;
1475 // Find languages with most word matches.
1476 // This is made difficult due to commonalities between Chinese
1477 // simplified vs traditional.
1478 var mostMatches
= 0;
1479 var mostMatchedLanguages
= [];
1480 for (var l
in languageMatches
) {
1481 var numMatches
= languageMatches
[l
];
1482 if (numMatches
> mostMatches
) {
1483 mostMatches
= numMatches
;
1484 mostMatchedLanguages
= [l
];
1486 else if (numMatches
== mostMatches
) {
1487 mostMatchedLanguages
.push(l
);
1491 if (mostMatchedLanguages
.length
> 0) {
1492 // Use first language and warn if multiple detected
1493 language
= mostMatchedLanguages
[0];
1494 if (mostMatchedLanguages
.length
> 1) {
1495 console
.warn("Multiple possible languages");
1496 console
.warn(mostMatchedLanguages
);
1503 function getLanguageFromUrl() {
1504 for (var language
in WORDLISTS
) {
1505 if (window
.location
.hash
.indexOf(language
) > -1) {
1512 function setMnemonicLanguage() {
1513 var language
= getLanguage();
1514 // Load the bip39 mnemonic generator for this language if required
1515 if (!(language
in mnemonics
)) {
1516 mnemonics
[language
] = new Mnemonic(language
);
1518 mnemonic
= mnemonics
[language
];
1521 function convertPhraseToNewLanguage() {
1522 var oldLanguage
= getLanguageFromPhrase();
1523 var newLanguage
= getLanguageFromUrl();
1524 var oldPhrase
= DOM
.phrase
.val();
1525 var oldWords
= phraseToWordArray(oldPhrase
);
1527 for (var i
=0; i
<oldWords
.length
; i
++) {
1528 var oldWord
= oldWords
[i
];
1529 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1530 var newWord
= WORDLISTS
[newLanguage
][index
];
1531 newWords
.push(newWord
);
1533 newPhrase
= wordArrayToPhrase(newWords
);
1537 // TODO look at jsbip39 - mnemonic.splitWords
1538 function phraseToWordArray(phrase
) {
1539 var words
= phrase
.split(/\s/g);
1541 for (var i
=0; i
<words
.length
; i
++) {
1542 var word
= words
[i
];
1543 if (word
.length
> 0) {
1544 noBlanks
.push(word
);
1550 // TODO look at jsbip39 - mnemonic.joinWords
1551 function wordArrayToPhrase(words
) {
1552 var phrase
= words
.join(" ");
1553 var language
= getLanguageFromPhrase(phrase
);
1554 if (language
== "japanese") {
1555 phrase
= words
.join("\u3000");
1560 function writeSplitPhrase(phrase
) {
1561 var wordCount
= phrase
.split(/\s/g).length
;
1563 for (var i
=0;i
<wordCount
;i
++) left
.push(i
);
1564 var group
=[[],[],[]],
1566 var seed
= Math
.abs(sjcl
.hash
.sha256
.hash(phrase
)[0])% 2147483647;
1567 while (left
.length
>0) {
1568 groupI
=(groupI
+1)%3;
1569 seed
= seed
* 16807 % 2147483647;
1570 var selected
=Math
.floor(left
.length
*(seed
- 1) / 2147483646);
1571 group
[groupI
].push(left
[selected
]);
1572 left
.splice(selected
,1);
1574 var cards
=[phrase
.split(/\s/g),phrase
.split(/\s/g),phrase
.split(/\s/g)];
1575 for (var i
=0;i
<3;i
++) {
1576 for (var ii
=0;ii
<wordCount
/3;ii
++) cards
[i
][group
[i
][ii
]]='XXXX';
1577 cards
[i
]='Card '+(i
+1)+': '+wordArrayToPhrase(cards
[i
]);
1579 DOM
.phraseSplit
.val(cards
.join("\r\n"));
1580 var triesPerSecond
=10000000000;
1581 var hackTime
=Math
.pow(2,wordCount
*10/3)/triesPerSecond
;
1582 var displayRedText
= false;
1584 hackTime
="<1 second";
1585 displayRedText
= true;
1586 } else if (hackTime
<86400) {
1587 hackTime
=Math
.floor(hackTime
)+" seconds";
1588 displayRedText
= true;
1589 } else if(hackTime
<31557600) {
1590 hackTime
=Math
.floor(hackTime
/86400)+" days";
1591 displayRedText
= true;
1593 hackTime
=Math
.floor(hackTime
/31557600)+" years";
1595 DOM
.phraseSplitWarn
.html("Time to hack with only one card: "+hackTime
);
1596 if (displayRedText
) {
1597 DOM
.phraseSplitWarn
.addClass("text-danger");
1599 DOM
.phraseSplitWarn
.removeClass("text-danger");
1603 function isUsingOwnEntropy() {
1604 return DOM
.useEntropy
.prop("checked");
1607 function setMnemonicFromEntropy() {
1608 clearEntropyFeedback();
1609 // Get entropy value
1610 var entropyStr
= DOM
.entropy
.val();
1611 // Work out minimum base for entropy
1613 if (entropyTypeAutoDetect
) {
1614 entropy
= Entropy
.fromString(entropyStr
);
1617 let base
= DOM
.entropyTypeInputs
.filter(":checked").val();
1618 entropy
= Entropy
.fromString(entropyStr
, base
);
1620 if (entropy
.binaryStr
.length
== 0) {
1623 // Show entropy details
1624 showEntropyFeedback(entropy
);
1625 // Use entropy hash if not using raw entropy
1626 var bits
= entropy
.binaryStr
;
1627 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1628 if (mnemonicLength
!= "raw") {
1629 // Get bits by hashing entropy with SHA256
1630 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1631 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1632 bits
= libs
.BigInteger
.BigInteger
.parse(hex
, 16).toString(2);
1633 while (bits
.length
% 256 != 0) {
1636 // Truncate hash to suit number of words
1637 mnemonicLength
= parseInt(mnemonicLength
);
1638 var numberOfBits
= 32 * mnemonicLength
/ 3;
1639 bits
= bits
.substring(0, numberOfBits
);
1640 // show warning for weak entropy override
1641 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1642 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1645 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1649 // hide warning for weak entropy override
1650 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1652 // Discard trailing entropy
1653 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1654 var start
= bits
.length
- bitsToUse
;
1655 var binaryStr
= bits
.substring(start
);
1656 // Convert entropy string to numeric array
1657 var entropyArr
= [];
1658 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1659 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1660 var entropyByte
= parseInt(byteAsBits
, 2);
1661 entropyArr
.push(entropyByte
)
1663 // Convert entropy array to mnemonic
1664 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1665 // Set the mnemonic in the UI
1666 DOM
.phrase
.val(phrase
);
1667 writeSplitPhrase(phrase
);
1668 // Show the word indexes
1670 // Show the checksum
1674 function clearEntropyFeedback() {
1675 DOM
.entropyCrackTime
.text("...");
1676 DOM
.entropyType
.text("");
1677 DOM
.entropyWordCount
.text("0");
1678 DOM
.entropyEventCount
.text("0");
1679 DOM
.entropyBitsPerEvent
.text("0");
1680 DOM
.entropyBits
.text("0");
1681 DOM
.entropyFiltered
.html(" ");
1682 DOM
.entropyBinary
.html(" ");
1685 function showEntropyFeedback(entropy
) {
1686 var numberOfBits
= entropy
.binaryStr
.length
;
1687 var timeToCrack
= "unknown";
1689 var z
= libs
.zxcvbn(entropy
.base
.parts
.join(""));
1690 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1691 if (z
.feedback
.warning
!= "") {
1692 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1696 console
.log("Error detecting entropy strength with zxcvbn:");
1699 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1700 DOM
.entropyTypeInputs
.attr("checked", false);
1701 DOM
.entropyTypeInputs
.filter("[value='" + entropyTypeStr
+ "']").attr("checked", true);
1702 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1703 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1704 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1705 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1706 DOM
.entropyType
.text(entropyTypeStr
);
1707 DOM
.entropyCrackTime
.text(timeToCrack
);
1708 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1709 DOM
.entropyBits
.text(numberOfBits
);
1710 DOM
.entropyWordCount
.text(wordCount
);
1711 DOM
.entropyBinary
.text(spacedBinaryStr
);
1712 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1713 // detect and warn of filtering
1714 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1715 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1716 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1718 DOM
.entropyFilterWarning
.removeClass('hidden');
1721 DOM
.entropyFilterWarning
.addClass('hidden');
1725 function getEntropyTypeStr(entropy
) {
1726 var typeStr
= entropy
.base
.str
;
1727 // Add some detail if these are cards
1728 if (entropy
.base
.asInt
== 52) {
1729 var cardDetail
= []; // array of message strings
1730 // Detect duplicates
1732 var dupeTracker
= {};
1733 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1734 var card
= entropy
.base
.parts
[i
];
1735 var cardUpper
= card
.toUpperCase();
1736 if (cardUpper
in dupeTracker
) {
1739 dupeTracker
[cardUpper
] = true;
1741 if (dupes
.length
> 0) {
1742 var dupeWord
= "duplicates";
1743 if (dupes
.length
== 1) {
1744 dupeWord
= "duplicate";
1746 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1747 if (dupes
.length
> 3) {
1750 cardDetail
.push(msg
);
1753 var uniqueCards
= [];
1754 for (var uniqueCard
in dupeTracker
) {
1755 uniqueCards
.push(uniqueCard
);
1757 if (uniqueCards
.length
== 52) {
1758 cardDetail
.unshift("full deck");
1760 // Detect missing cards
1761 var values
= "A23456789TJQK";
1763 var missingCards
= [];
1764 for (var i
=0; i
<suits
.length
; i
++) {
1765 for (var j
=0; j
<values
.length
; j
++) {
1766 var card
= values
[j
] + suits
[i
];
1767 if (!(card
in dupeTracker
)) {
1768 missingCards
.push(card
);
1772 // Display missing cards if six or less, ie clearly going for full deck
1773 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1774 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1775 if (missingCards
.length
> 3) {
1778 cardDetail
.push(msg
);
1780 // Add card details to typeStr
1781 if (cardDetail
.length
> 0) {
1782 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1788 function setQrEvents(els
) {
1789 els
.on("mouseenter", createQr
);
1790 els
.on("mouseleave", destroyQr
);
1791 els
.on("click", toggleQr
);
1794 function createQr(e
) {
1795 var content
= e
.target
.textContent
|| e
.target
.value
;
1797 var qrEl
= libs
.kjua({
1803 DOM
.qrImage
.append(qrEl
);
1805 DOM
.qrHider
.addClass("hidden");
1808 DOM
.qrHider
.removeClass("hidden");
1810 DOM
.qrContainer
.removeClass("hidden");
1814 function destroyQr() {
1815 DOM
.qrImage
.text("");
1816 DOM
.qrContainer
.addClass("hidden");
1819 function toggleQr() {
1821 DOM
.qrHider
.toggleClass("hidden");
1822 DOM
.qrHint
.toggleClass("hidden");
1825 function bip44TabSelected() {
1826 return DOM
.bip44tab
.hasClass("active");
1829 function bip32TabSelected() {
1830 return DOM
.bip32tab
.hasClass("active");
1833 function networkIsEthereum() {
1834 var name
= networks
[DOM
.network
.val()].name
;
1835 return (name
== "ETH - Ethereum")
1836 || (name
== "ETC - Ethereum Classic")
1837 || (name
== "EWT - EnergyWeb")
1838 || (name
== "PIRL - Pirl")
1839 || (name
== "MIX - MIX")
1840 || (name
== "MOAC - MOAC")
1841 || (name
== "MUSIC - Musicoin")
1842 || (name
== "POA - Poa")
1843 || (name
== "EXP - Expanse")
1844 || (name
== "CLO - Callisto")
1845 || (name
== "DXN - DEXON")
1846 || (name
== "ELLA - Ellaism")
1847 || (name
== "ESN - Ethersocial Network")
1848 || (name
== "VET - VeChain")
1849 || (name
== "ERE - EtherCore")
1852 function networkHasSegwit() {
1854 if ("baseNetwork" in network
) {
1855 n
= libs
.bitcoin
.networks
[network
.baseNetwork
];
1857 // check if only p2wpkh params are required
1858 if (p2wpkhSelected()) {
1859 return "p2wpkh" in n
;
1861 // check if only p2wpkh-in-p2sh params are required
1862 else if (p2wpkhInP2shSelected()) {
1863 return "p2wpkhInP2sh" in n
;
1865 // require both if it's unclear which params are required
1866 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1869 function bip49TabSelected() {
1870 return DOM
.bip49tab
.hasClass("active");
1873 function bip84TabSelected() {
1874 return DOM
.bip84tab
.hasClass("active");
1877 function bip141TabSelected() {
1878 return DOM
.bip141tab
.hasClass("active");
1881 function setHdCoin(coinValue
) {
1882 DOM
.bip44coin
.val(coinValue
);
1883 DOM
.bip49coin
.val(coinValue
);
1884 DOM
.bip84coin
.val(coinValue
);
1887 function showSegwitAvailable() {
1888 DOM
.bip49unavailable
.addClass("hidden");
1889 DOM
.bip49available
.removeClass("hidden");
1890 DOM
.bip84unavailable
.addClass("hidden");
1891 DOM
.bip84available
.removeClass("hidden");
1892 DOM
.bip141unavailable
.addClass("hidden");
1893 DOM
.bip141available
.removeClass("hidden");
1896 function showSegwitUnavailable() {
1897 DOM
.bip49available
.addClass("hidden");
1898 DOM
.bip49unavailable
.removeClass("hidden");
1899 DOM
.bip84available
.addClass("hidden");
1900 DOM
.bip84unavailable
.removeClass("hidden");
1901 DOM
.bip141available
.addClass("hidden");
1902 DOM
.bip141unavailable
.removeClass("hidden");
1905 function adjustNetworkForSegwit() {
1906 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1907 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1909 // See https://github.com/iancoleman/bip39/issues/125
1910 var segwitNetworks
= null;
1911 // if a segwit network is alread selected, need to use base network to
1912 // look up new parameters
1913 if ("baseNetwork" in network
) {
1914 network
= libs
.bitcoin
.networks
[network
.baseNetwork
];
1916 // choose the right segwit params
1917 if (p2wpkhSelected() && "p2wpkh" in network
) {
1918 network
= network
.p2wpkh
;
1920 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1921 network
= network
.p2wpkhInP2sh
;
1923 else if (p2wshSelected() && "p2wsh" in network
) {
1924 network
= network
.p2wsh
;
1926 else if (p2wshInP2shSelected() && "p2wshInP2sh" in network
) {
1927 network
= network
.p2wshInP2sh
;
1931 function lastIndexInTable() {
1932 var pathText
= DOM
.addresses
.find(".index").last().text();
1933 var pathBits
= pathText
.split("/");
1934 var lastBit
= pathBits
[pathBits
.length
-1];
1935 var lastBitClean
= lastBit
.replace("'", "");
1936 return parseInt(lastBitClean
);
1939 function uint8ArrayToHex(a
) {
1941 for (var i
=0; i
<a
.length
; i
++) {
1942 var h
= a
[i
].toString(16);
1943 while (h
.length
< 2) {
1951 function showWordIndexes() {
1952 var phrase
= DOM
.phrase
.val();
1953 var words
= phraseToWordArray(phrase
);
1954 var wordIndexes
= [];
1955 var language
= getLanguage();
1956 for (var i
=0; i
<words
.length
; i
++) {
1957 var word
= words
[i
];
1958 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1959 wordIndexes
.push(wordIndex
);
1961 var wordIndexesStr
= wordIndexes
.join(", ");
1962 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1965 function showChecksum() {
1966 var phrase
= DOM
.phrase
.val();
1967 var words
= phraseToWordArray(phrase
);
1968 var checksumBitlength
= words
.length
/ 3;
1971 var language
= getLanguage();
1972 for (var i
=words
.length
-1; i
>=0; i
--) {
1973 var word
= words
[i
];
1974 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1975 var wordBinary
= wordIndex
.toString(2);
1976 while (wordBinary
.length
< 11) {
1977 wordBinary
= "0" + wordBinary
;
1979 var binaryStr
= wordBinary
+ binaryStr
;
1980 if (binaryStr
.length
>= checksumBitlength
) {
1981 var start
= binaryStr
.length
- checksumBitlength
;
1982 var end
= binaryStr
.length
;
1983 checksum
= binaryStr
.substring(start
, end
);
1984 // add spaces so the last group is 11 bits, not the first
1985 checksum
= checksum
.split("").reverse().join("")
1986 checksum
= addSpacesEveryElevenBits(checksum
);
1987 checksum
= checksum
.split("").reverse().join("")
1991 DOM
.entropyChecksum
.text(checksum
);
1994 function updateCsv() {
1995 var tableCsv
= "path,address,public key,private key\n";
1996 var rows
= DOM
.addresses
.find("tr");
1997 for (var i
=0; i
<rows
.length
; i
++) {
1998 var row
= $(rows
[i
]);
1999 var cells
= row
.find("td");
2000 for (var j
=0; j
<cells
.length
; j
++) {
2001 var cell
= $(cells
[j
]);
2002 if (!cell
.children().hasClass("invisible")) {
2003 tableCsv
= tableCsv
+ cell
.text();
2005 if (j
!= cells
.length
- 1) {
2006 tableCsv
= tableCsv
+ ",";
2009 tableCsv
= tableCsv
+ "\n";
2011 DOM
.csv
.val(tableCsv
);
2014 function addSpacesEveryElevenBits(binaryStr
) {
2015 return binaryStr
.match(/.{1,11}/g).join(" ");
2020 name: "AC - Asiacoin",
2021 onSelect: function() {
2022 network
= libs
.bitcoin
.networks
.asiacoin
;
2027 name: "ACC - Adcoin",
2028 onSelect: function() {
2029 network
= libs
.bitcoin
.networks
.adcoin
;
2034 name: "ARYA - Aryacoin",
2035 onSelect: function() {
2036 network
= libs
.bitcoin
.networks
.aryacoin
;
2041 name: "AUR - Auroracoin",
2042 onSelect: function() {
2043 network
= libs
.bitcoin
.networks
.auroracoin
;
2049 onSelect: function() {
2050 network
= libs
.bitcoin
.networks
.axe
;
2055 name: "ANON - ANON",
2056 onSelect: function() {
2057 network
= libs
.bitcoin
.networks
.anon
;
2062 name: "BOLI - Bolivarcoin",
2063 onSelect: function() {
2064 network
= libs
.bitcoin
.networks
.bolivarcoin
;
2069 name: "BCA - Bitcoin Atom",
2070 onSelect: function() {
2071 network
= libs
.bitcoin
.networks
.atom
;
2076 name: "BCH - Bitcoin Cash",
2077 onSelect: function() {
2078 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2083 name: "BEET - Beetlecoin",
2084 onSelect: function() {
2085 network
= libs
.bitcoin
.networks
.beetlecoin
;
2090 name: "BELA - Belacoin",
2091 onSelect: function() {
2092 network
= libs
.bitcoin
.networks
.belacoin
;
2097 name: "BLK - BlackCoin",
2098 onSelect: function() {
2099 network
= libs
.bitcoin
.networks
.blackcoin
;
2104 name: "BND - Blocknode",
2105 onSelect: function() {
2106 network
= libs
.bitcoin
.networks
.blocknode
;
2111 name: "tBND - Blocknode Testnet",
2112 onSelect: function() {
2113 network
= libs
.bitcoin
.networks
.blocknode_testnet
;
2118 name: "BRIT - Britcoin",
2119 onSelect: function() {
2120 network
= libs
.bitcoin
.networks
.britcoin
;
2125 name: "BSD - Bitsend",
2126 onSelect: function() {
2127 network
= libs
.bitcoin
.networks
.bitsend
;
2132 name: "BST - BlockStamp",
2133 onSelect: function() {
2134 network
= libs
.bitcoin
.networks
.blockstamp
;
2140 onSelect: function() {
2141 network
= libs
.bitcoin
.networks
.bata
;
2146 name: "BTC - Bitcoin",
2147 onSelect: function() {
2148 network
= libs
.bitcoin
.networks
.bitcoin
;
2153 name: "BTC - Bitcoin RegTest",
2154 onSelect: function() {
2155 network
= libs
.bitcoin
.networks
.regtest
;
2156 // Using hd coin value 1 based on bip44_coin_type
2157 // https://github.com/chaintope/bitcoinrb/blob/f1014406f6b8f9b4edcecedc18df70c80df06f11/lib/bitcoin/chainparams/regtest.yml
2162 name: "BTC - Bitcoin Testnet",
2163 onSelect: function() {
2164 network
= libs
.bitcoin
.networks
.testnet
;
2169 name: "BITG - Bitcoin Green",
2170 onSelect: function() {
2171 network
= libs
.bitcoin
.networks
.bitcoingreen
;
2176 name: "BTCP - Bitcoin Private",
2177 onSelect: function() {
2178 network
= libs
.bitcoin
.networks
.bitcoinprivate
;
2183 name: "BSV - BitcoinSV",
2184 onSelect: function() {
2185 network
= libs
.bitcoin
.networks
.bitcoinsv
;
2190 name: "BTCZ - Bitcoinz",
2191 onSelect: function() {
2192 network
= libs
.bitcoin
.networks
.bitcoinz
;
2197 name: "BTDX - BitCloud",
2198 onSelect: function() {
2199 network
= libs
.bitcoin
.networks
.bitcloud
;
2204 name: "BTG - Bitcoin Gold",
2205 onSelect: function() {
2206 network
= libs
.bitcoin
.networks
.bgold
;
2211 name: "BTX - Bitcore",
2212 onSelect: function() {
2213 network
= libs
.bitcoin
.networks
.bitcore
;
2218 name: "CCN - Cannacoin",
2219 onSelect: function() {
2220 network
= libs
.bitcoin
.networks
.cannacoin
;
2225 name: "CESC - Cryptoescudo",
2226 onSelect: function() {
2227 network
= libs
.bitcoin
.networks
.cannacoin
;
2232 name: "CDN - Canadaecoin",
2233 onSelect: function() {
2234 network
= libs
.bitcoin
.networks
.canadaecoin
;
2239 name: "CLAM - Clams",
2240 onSelect: function() {
2241 network
= libs
.bitcoin
.networks
.clam
;
2246 name: "CLO - Callisto",
2247 segwitAvailable: false,
2248 onSelect: function() {
2249 network
= libs
.bitcoin
.networks
.bitcoin
;
2254 name: "CLUB - Clubcoin",
2255 onSelect: function() {
2256 network
= libs
.bitcoin
.networks
.clubcoin
;
2261 name: "CMP - Compcoin",
2262 onSelect: function() {
2263 network
= libs
.bitcoin
.networks
.compcoin
;
2268 name: "CPU - CPUchain",
2269 onSelect: function() {
2270 network
= libs
.bitcoin
.networks
.cpuchain
;
2275 name: "CRAVE - Crave",
2276 onSelect: function() {
2277 network
= libs
.bitcoin
.networks
.crave
;
2282 name: "CRW - Crown (Legacy)",
2283 onSelect: function() {
2284 network
= libs
.bitcoin
.networks
.crown
;
2289 name: "CRW - Crown",
2290 onSelect: function() {
2291 network
= libs
.bitcoin
.networks
.crown
;
2296 name: "CSC - CasinoCoin",
2297 onSelect: function() {
2298 network
= libs
.bitcoin
.networks
.bitcoin
;
2303 name: "DASH - Dash",
2304 onSelect: function() {
2305 network
= libs
.bitcoin
.networks
.dash
;
2310 name: "DASH - Dash Testnet",
2311 onSelect: function() {
2312 network
= libs
.bitcoin
.networks
.dashtn
;
2317 name: "DFC - Defcoin",
2318 onSelect: function() {
2319 network
= libs
.bitcoin
.networks
.defcoin
;
2324 name: "DGB - Digibyte",
2325 onSelect: function() {
2326 network
= libs
.bitcoin
.networks
.digibyte
;
2331 name: "DGC - Digitalcoin",
2332 onSelect: function() {
2333 network
= libs
.bitcoin
.networks
.digitalcoin
;
2338 name: "DMD - Diamond",
2339 onSelect: function() {
2340 network
= libs
.bitcoin
.networks
.diamond
;
2345 name: "DNR - Denarius",
2346 onSelect: function() {
2347 network
= libs
.bitcoin
.networks
.denarius
;
2352 name: "DOGE - Dogecoin",
2353 onSelect: function() {
2354 network
= libs
.bitcoin
.networks
.dogecoin
;
2359 name: "DOGEt - Dogecoin Testnet",
2360 onSelect: function() {
2361 network
= libs
.bitcoin
.networks
.dogecointestnet
;
2366 name: "DXN - DEXON",
2367 onSelect: function() {
2368 network
= libs
.bitcoin
.networks
.bitcoin
;
2373 name: "ECN - Ecoin",
2374 onSelect: function() {
2375 network
= libs
.bitcoin
.networks
.ecoin
;
2380 name: "EDRC - Edrcoin",
2381 onSelect: function() {
2382 network
= libs
.bitcoin
.networks
.edrcoin
;
2387 name: "EFL - Egulden",
2388 onSelect: function() {
2389 network
= libs
.bitcoin
.networks
.egulden
;
2394 name: "ELA - Elastos",
2395 onSelect: function () {
2396 network
= libs
.bitcoin
.networks
.elastos
;
2401 name: "ELLA - Ellaism",
2402 segwitAvailable: false,
2403 onSelect: function() {
2404 network
= libs
.bitcoin
.networks
.bitcoin
;
2409 name: "EMC2 - Einsteinium",
2410 onSelect: function() {
2411 network
= libs
.bitcoin
.networks
.einsteinium
;
2416 name: "ERC - Europecoin",
2417 onSelect: function() {
2418 network
= libs
.bitcoin
.networks
.europecoin
;
2423 name: "EOS - EOSIO",
2424 onSelect: function() {
2425 network
= libs
.bitcoin
.networks
.bitcoin
;
2430 name: "ERE - EtherCore",
2431 segwitAvailable: false,
2432 onSelect: function() {
2433 network
= libs
.bitcoin
.networks
.bitcoin
;
2438 name: "ESN - Ethersocial Network",
2439 segwitAvailable: false,
2440 onSelect: function() {
2441 network
= libs
.bitcoin
.networks
.bitcoin
;
2446 name: "ETC - Ethereum Classic",
2447 segwitAvailable: false,
2448 onSelect: function() {
2449 network
= libs
.bitcoin
.networks
.bitcoin
;
2454 name: "ETH - Ethereum",
2455 onSelect: function() {
2456 network
= libs
.bitcoin
.networks
.bitcoin
;
2461 name: "EWT - EnergyWeb",
2462 onSelect: function() {
2463 network
= libs
.bitcoin
.networks
.bitcoin
;
2468 name: "EXCL - Exclusivecoin",
2469 onSelect: function() {
2470 network
= libs
.bitcoin
.networks
.exclusivecoin
;
2475 name: "EXCC - ExchangeCoin",
2476 onSelect: function() {
2477 network
= libs
.bitcoin
.networks
.exchangecoin
;
2482 name: "EXP - Expanse",
2483 segwitAvailable: false,
2484 onSelect: function() {
2485 network
= libs
.bitcoin
.networks
.bitcoin
;
2491 onSelect: function() {
2492 network
= libs
.bitcoin
.networks
.fix
;
2497 name: "FIX - FIX Testnet",
2498 onSelect: function() {
2499 network
= libs
.bitcoin
.networks
.fixtestnet
;
2504 name: "FJC - Fujicoin",
2505 onSelect: function() {
2506 network
= libs
.bitcoin
.networks
.fujicoin
;
2511 name: "FLASH - Flashcoin",
2512 onSelect: function() {
2513 network
= libs
.bitcoin
.networks
.flashcoin
;
2518 name: "FRST - Firstcoin",
2519 onSelect: function() {
2520 network
= libs
.bitcoin
.networks
.firstcoin
;
2525 name: "FTC - Feathercoin",
2526 onSelect: function() {
2527 network
= libs
.bitcoin
.networks
.feathercoin
;
2532 name: "GAME - GameCredits",
2533 onSelect: function() {
2534 network
= libs
.bitcoin
.networks
.game
;
2539 name: "GBX - Gobyte",
2540 onSelect: function() {
2541 network
= libs
.bitcoin
.networks
.gobyte
;
2546 name: "GCR - GCRCoin",
2547 onSelect: function() {
2548 network
= libs
.bitcoin
.networks
.gcr
;
2553 name: "GRC - Gridcoin",
2554 onSelect: function() {
2555 network
= libs
.bitcoin
.networks
.gridcoin
;
2560 name: "GRS - Groestlcoin",
2561 onSelect: function() {
2562 network
= libs
.bitcoin
.networks
.groestlcoin
;
2567 name: "GRS - Groestlcoin Testnet",
2568 onSelect: function() {
2569 network
= libs
.bitcoin
.networks
.groestlcointestnet
;
2574 name: "HNC - Helleniccoin",
2575 onSelect: function() {
2576 network
= libs
.bitcoin
.networks
.helleniccoin
;
2581 name: "HUSH - Hush (Legacy)",
2582 onSelect: function() {
2583 network
= libs
.bitcoin
.networks
.hush
;
2588 name: "HUSH - Hush3",
2589 onSelect: function() {
2590 network
= libs
.bitcoin
.networks
.hush3
;
2595 name: "INSN - Insane",
2596 onSelect: function() {
2597 network
= libs
.bitcoin
.networks
.insane
;
2603 onSelect: function() {
2604 network
= libs
.bitcoin
.networks
.iop
;
2609 name: "IXC - Ixcoin",
2610 onSelect: function() {
2611 network
= libs
.bitcoin
.networks
.ixcoin
;
2616 name: "JBS - Jumbucks",
2617 onSelect: function() {
2618 network
= libs
.bitcoin
.networks
.jumbucks
;
2623 name: "KMD - Komodo",
2624 bip49available: false,
2625 onSelect: function() {
2626 network
= libs
.bitcoin
.networks
.komodo
;
2631 name: "KOBO - Kobocoin",
2632 bip49available: false,
2633 onSelect: function() {
2634 network
= libs
.bitcoin
.networks
.kobocoin
;
2639 name: "LBC - Library Credits",
2640 onSelect: function() {
2641 network
= libs
.bitcoin
.networks
.lbry
;
2646 name: "LCC - Litecoincash",
2647 onSelect: function() {
2648 network
= libs
.bitcoin
.networks
.litecoincash
;
2653 name: "LDCN - Landcoin",
2654 onSelect: function() {
2655 network
= libs
.bitcoin
.networks
.landcoin
;
2660 name: "LINX - Linx",
2661 onSelect: function() {
2662 network
= libs
.bitcoin
.networks
.linx
;
2667 name: "LKR - Lkrcoin",
2668 segwitAvailable: false,
2669 onSelect: function() {
2670 network
= libs
.bitcoin
.networks
.lkrcoin
;
2675 name: "LTC - Litecoin",
2676 onSelect: function() {
2677 network
= libs
.bitcoin
.networks
.litecoin
;
2679 DOM
.litecoinLtubContainer
.removeClass("hidden");
2683 name: "LTCt - Litecoin Testnet",
2684 onSelect: function() {
2685 network
= libs
.bitcoin
.networks
.litecointestnet
;
2687 DOM
.litecoinLtubContainer
.removeClass("hidden");
2691 name: "LTZ - LitecoinZ",
2692 onSelect: function() {
2693 network
= libs
.bitcoin
.networks
.litecoinz
;
2698 name: "LYNX - Lynx",
2699 onSelect: function() {
2700 network
= libs
.bitcoin
.networks
.lynx
;
2705 name: "MAZA - Maza",
2706 onSelect: function() {
2707 network
= libs
.bitcoin
.networks
.maza
;
2712 name: "MEC - Megacoin",
2713 onSelect: function() {
2714 network
= libs
.bitcoin
.networks
.megacoin
;
2720 segwitAvailable: false,
2721 onSelect: function() {
2722 network
= libs
.bitcoin
.networks
.bitcoin
;
2727 name: "MNX - Minexcoin",
2728 onSelect: function() {
2729 network
= libs
.bitcoin
.networks
.minexcoin
;
2734 name: "MONA - Monacoin",
2735 onSelect: function() {
2736 network
= libs
.bitcoin
.networks
.monacoin
,
2741 name: "MONK - Monkey Project",
2742 onSelect: function() {
2743 network
= libs
.bitcoin
.networks
.monkeyproject
,
2748 name: "MOAC - MOAC",
2749 segwitAvailable: false,
2750 onSelect: function() {
2751 network
= libs
.bitcoin
.networks
.bitcoin
;
2756 name: "MUSIC - Musicoin",
2757 segwitAvailable: false,
2758 onSelect: function() {
2759 network
= libs
.bitcoin
.networks
.bitcoin
;
2764 name: "NAV - Navcoin",
2765 onSelect: function() {
2766 network
= libs
.bitcoin
.networks
.navcoin
;
2771 name: "NAS - Nebulas",
2772 onSelect: function() {
2773 network
= libs
.bitcoin
.networks
.bitcoin
;
2778 name: "NEBL - Neblio",
2779 onSelect: function() {
2780 network
= libs
.bitcoin
.networks
.neblio
;
2785 name: "NEOS - Neoscoin",
2786 onSelect: function() {
2787 network
= libs
.bitcoin
.networks
.neoscoin
;
2792 name: "NIX - NIX Platform",
2793 onSelect: function() {
2794 network
= libs
.bitcoin
.networks
.nix
;
2799 name: "NLG - Gulden",
2800 onSelect: function() {
2801 network
= libs
.bitcoin
.networks
.gulden
;
2806 name: "NMC - Namecoin",
2807 onSelect: function() {
2808 network
= libs
.bitcoin
.networks
.namecoin
;
2813 name: "NRG - Energi",
2814 onSelect: function() {
2815 network
= libs
.bitcoin
.networks
.energi
;
2820 name: "NRO - Neurocoin",
2821 onSelect: function() {
2822 network
= libs
.bitcoin
.networks
.neurocoin
;
2827 name: "NSR - Nushares",
2828 onSelect: function() {
2829 network
= libs
.bitcoin
.networks
.nushares
;
2834 name: "NYC - Newyorkc",
2835 onSelect: function() {
2836 network
= libs
.bitcoin
.networks
.newyorkc
;
2841 name: "NVC - Novacoin",
2842 onSelect: function() {
2843 network
= libs
.bitcoin
.networks
.novacoin
;
2848 name: "OK - Okcash",
2849 onSelect: function() {
2850 network
= libs
.bitcoin
.networks
.okcash
;
2855 name: "OMNI - Omnicore",
2856 onSelect: function() {
2857 network
= libs
.bitcoin
.networks
.omnicore
;
2862 name: "ONION - DeepOnion",
2863 onSelect: function() {
2864 network
= libs
.bitcoin
.networks
.deeponion
;
2869 name: "ONX - Onixcoin",
2870 onSelect: function() {
2871 network
= libs
.bitcoin
.networks
.onixcoin
;
2876 name: "PHR - Phore",
2877 onSelect: function() {
2878 network
= libs
.bitcoin
.networks
.phore
;
2883 name: "PINK - Pinkcoin",
2884 onSelect: function() {
2885 network
= libs
.bitcoin
.networks
.pinkcoin
;
2890 name: "PIRL - Pirl",
2891 segwitAvailable: false,
2892 onSelect: function() {
2893 network
= libs
.bitcoin
.networks
.bitcoin
;
2898 name: "PIVX - PIVX",
2899 onSelect: function() {
2900 network
= libs
.bitcoin
.networks
.pivx
;
2905 name: "PIVX - PIVX Testnet",
2906 onSelect: function() {
2907 network
= libs
.bitcoin
.networks
.pivxtestnet
;
2913 segwitAvailable: false,
2914 onSelect: function() {
2915 network
= libs
.bitcoin
.networks
.bitcoin
;
2920 name: "POSW - POSWcoin",
2921 onSelect: function() {
2922 network
= libs
.bitcoin
.networks
.poswcoin
;
2927 name: "POT - Potcoin",
2928 onSelect: function() {
2929 network
= libs
.bitcoin
.networks
.potcoin
;
2934 name: "PPC - Peercoin",
2935 onSelect: function() {
2936 network
= libs
.bitcoin
.networks
.peercoin
;
2941 name: "PRJ - ProjectCoin",
2942 onSelect: function() {
2943 network
= libs
.bitcoin
.networks
.projectcoin
;
2948 name: "PSB - Pesobit",
2949 onSelect: function() {
2950 network
= libs
.bitcoin
.networks
.pesobit
;
2955 name: "PUT - Putincoin",
2956 onSelect: function() {
2957 network
= libs
.bitcoin
.networks
.putincoin
;
2962 name: "RPD - Rapids",
2963 onSelect: function() {
2964 network
= libs
.bitcoin
.networks
.rapids
;
2969 name: "RVN - Ravencoin",
2970 onSelect: function() {
2971 network
= libs
.bitcoin
.networks
.ravencoin
;
2977 onSelect: function() {
2978 network
= libs
.bitcoin
.networks
.rubycoin
;
2983 name: "tRBTC - RSK Testnet",
2984 onSelect: function() {
2985 network
= libs
.bitcoin
.networks
.rubycoin
;
2990 name: "RBY - Rubycoin",
2991 onSelect: function() {
2992 network
= libs
.bitcoin
.networks
.rubycoin
;
2997 name: "RDD - Reddcoin",
2998 onSelect: function() {
2999 network
= libs
.bitcoin
.networks
.reddcoin
;
3004 name: "RVR - RevolutionVR",
3005 onSelect: function() {
3006 network
= libs
.bitcoin
.networks
.revolutionvr
;
3011 name: "SAFE - Safecoin",
3012 onSelect: function() {
3013 network
= libs
.bitcoin
.networks
.safecoin
;
3018 name: "SLS - Salus",
3019 onSelect: function() {
3020 network
= libs
.bitcoin
.networks
.salus
;
3025 name: "SDC - ShadowCash",
3026 onSelect: function() {
3027 network
= libs
.bitcoin
.networks
.shadow
;
3032 name: "SDC - ShadowCash Testnet",
3033 onSelect: function() {
3034 network
= libs
.bitcoin
.networks
.shadowtn
;
3039 name: "SLM - Slimcoin",
3040 onSelect: function() {
3041 network
= libs
.bitcoin
.networks
.slimcoin
;
3046 name: "SLM - Slimcoin Testnet",
3047 onSelect: function() {
3048 network
= libs
.bitcoin
.networks
.slimcointn
;
3053 name: "SLP - Simple Ledger Protocol",
3054 onSelect: function() {
3055 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
3060 name: "SLR - Solarcoin",
3061 onSelect: function() {
3062 network
= libs
.bitcoin
.networks
.solarcoin
;
3067 name: "SMLY - Smileycoin",
3068 onSelect: function() {
3069 network
= libs
.bitcoin
.networks
.smileycoin
;
3074 name: "STASH - Stash",
3075 onSelect: function() {
3076 network
= libs
.bitcoin
.networks
.stash
;
3081 name: "STASH - Stash Testnet",
3082 onSelect: function() {
3083 network
= libs
.bitcoin
.networks
.stashtn
;
3088 name: "STRAT - Stratis",
3089 onSelect: function() {
3090 network
= libs
.bitcoin
.networks
.stratis
;
3095 name: "SWTC - Jingtum",
3096 onSelect: function() {
3097 network
= libs
.bitcoin
.networks
.bitcoin
;
3102 name: "TSTRAT - Stratis Testnet",
3103 onSelect: function() {
3104 network
= libs
.bitcoin
.networks
.stratistest
;
3109 name: "SYS - Syscoin",
3110 onSelect: function() {
3111 network
= libs
.bitcoin
.networks
.syscoin
;
3116 name: "THC - Hempcoin",
3117 onSelect: function() {
3118 network
= libs
.bitcoin
.networks
.hempcoin
;
3123 name: "THT - Thought",
3124 onSelect: function() {
3125 network
= libs
.bitcoin
.networks
.thought
;
3131 onSelect: function() {
3132 network
= libs
.bitcoin
.networks
.toa
;
3137 name: "TWINS - TWINS",
3138 onSelect: function() {
3139 network
= libs
.bitcoin
.networks
.twins
;
3144 name: "TWINS - TWINS Testnet",
3145 onSelect: function() {
3146 network
= libs
.bitcoin
.networks
.twinstestnet
;
3151 name: "USC - Ultimatesecurecash",
3152 onSelect: function() {
3153 network
= libs
.bitcoin
.networks
.ultimatesecurecash
;
3158 name: "USNBT - NuBits",
3159 onSelect: function() {
3160 network
= libs
.bitcoin
.networks
.nubits
;
3165 name: "UNO - Unobtanium",
3166 onSelect: function() {
3167 network
= libs
.bitcoin
.networks
.unobtanium
;
3172 name: "VASH - Vpncoin",
3173 onSelect: function() {
3174 network
= libs
.bitcoin
.networks
.vpncoin
;
3179 name: "VET - VeChain",
3180 onSelect: function() {
3181 network
= libs
.bitcoin
.networks
.bitcoin
;
3186 name: "VIA - Viacoin",
3187 onSelect: function() {
3188 network
= libs
.bitcoin
.networks
.viacoin
;
3193 name: "VIA - Viacoin Testnet",
3194 onSelect: function() {
3195 network
= libs
.bitcoin
.networks
.viacointestnet
;
3200 name: "VIVO - Vivo",
3201 onSelect: function() {
3202 network
= libs
.bitcoin
.networks
.vivo
;
3207 name: "VTC - Vertcoin",
3208 onSelect: function() {
3209 network
= libs
.bitcoin
.networks
.vertcoin
;
3214 name: "WGR - Wagerr",
3215 onSelect: function() {
3216 network
= libs
.bitcoin
.networks
.wagerr
;
3221 name: "WC - Wincoin",
3222 onSelect: function() {
3223 network
= libs
.bitcoin
.networks
.wincoin
;
3228 name: "XAX - Artax",
3229 onSelect: function() {
3230 network
= libs
.bitcoin
.networks
.artax
;
3235 name: "XBC - Bitcoinplus",
3236 onSelect: function() {
3237 network
= libs
.bitcoin
.networks
.bitcoinplus
;
3242 name: "XLM - Stellar",
3243 onSelect: function() {
3244 network
= libs
.stellarUtil
.dummyNetwork
;
3249 name: "XMY - Myriadcoin",
3250 onSelect: function() {
3251 network
= libs
.bitcoin
.networks
.myriadcoin
;
3256 name: "XRP - Ripple",
3257 onSelect: function() {
3258 network
= libs
.bitcoin
.networks
.bitcoin
;
3263 name: "XVC - Vcash",
3264 onSelect: function() {
3265 network
= libs
.bitcoin
.networks
.vcash
;
3270 name: "XVG - Verge",
3271 onSelect: function() {
3272 network
= libs
.bitcoin
.networks
.verge
;
3277 name: "XUEZ - Xuez",
3278 segwitAvailable: false,
3279 onSelect: function() {
3280 network
= libs
.bitcoin
.networks
.xuez
;
3285 name: "XWC - Whitecoin",
3286 onSelect: function() {
3287 network
= libs
.bitcoin
.networks
.whitecoin
;
3292 name: "XZC - Zcoin",
3293 onSelect: function() {
3294 network
= libs
.bitcoin
.networks
.zcoin
;
3299 name: "ZCL - Zclassic",
3300 onSelect: function() {
3301 network
= libs
.bitcoin
.networks
.zclassic
;
3306 name: "ZEC - Zcash",
3307 onSelect: function() {
3308 network
= libs
.bitcoin
.networks
.zcash
;
3313 name: "ZEN - Horizen",
3314 onSelect: function() {
3315 network
= libs
.bitcoin
.networks
.zencash
;
3323 name: "Bitcoin Core",
3324 onSelect: function() {
3325 DOM
.bip32path
.val("m/0'/0'");
3326 DOM
.hardenedAddresses
.prop('checked', true);
3330 name: "blockchain.info",
3331 onSelect: function() {
3332 DOM
.bip32path
.val("m/44'/0'/0'");
3333 DOM
.hardenedAddresses
.prop('checked', false);
3337 name: "MultiBit HD",
3338 onSelect: function() {
3339 DOM
.bip32path
.val("m/0'/0");
3340 DOM
.hardenedAddresses
.prop('checked', false);
3344 name: "Coinomi, Ledger",
3345 onSelect: function() {
3346 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
3347 DOM
.hardenedAddresses
.prop('checked', false);
3352 // ELA - Elastos functions - begin
3353 function displayBip44InfoForELA() {
3358 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
3359 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
3361 // Calculate the account extended keys
3362 var accountXprv
= libs
.elastosjs
.getAccountExtendedPrivateKey(seed
, coin
, account
);
3363 var accountXpub
= libs
.elastosjs
.getAccountExtendedPublicKey(seed
, coin
, account
);
3365 // Display the extended keys
3366 DOM
.bip44accountXprv
.val(accountXprv
);
3367 DOM
.bip44accountXpub
.val(accountXpub
);
3370 function displayBip32InfoForELA() {
3375 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
3376 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
3377 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
3379 DOM
.extendedPrivKey
.val(libs
.elastosjs
.getBip32ExtendedPrivateKey(seed
, coin
, account
, change
));
3380 DOM
.extendedPubKey
.val(libs
.elastosjs
.getBip32ExtendedPublicKey(seed
, coin
, account
, change
));
3382 // Display the addresses and privkeys
3383 clearAddressesList();
3384 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
3385 displayAddresses(0, initialAddressCount
);
3388 function calcAddressForELA(seed
, coin
, account
, change
, index
) {
3393 var publicKey
= libs
.elastosjs
.getDerivedPublicKey(libs
.elastosjs
.getMasterPublicKey(seed
), change
, index
);
3395 privateKey: libs
.elastosjs
.getDerivedPrivateKey(seed
, coin
, account
, change
, index
),
3396 publicKey: publicKey
,
3397 address: libs
.elastosjs
.getAddress(publicKey
.toString('hex'))
3400 // ELA - Elastos functions - end