3 // mnemonics is populated as required by getLanguage
4 var mnemonics
= { "english": new Mnemonic("english") };
5 var mnemonic
= mnemonics
["english"];
7 var bip32RootKey
= null;
8 var bip32ExtendedKey
= null;
9 var network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
10 var addressRowTemplate
= $("#address-row-template");
13 var showAddress
= true;
14 var showPubKey
= true;
15 var showPrivKey
= true;
17 var litecoinUseLtub
= true;
19 var entropyTypeAutoDetect
= true;
20 var entropyChangeTimeoutEvent
= null;
21 var phraseChangeTimeoutEvent
= null;
22 var rootKeyChangedTimeoutEvent
= null;
24 var generationProcesses
= [];
27 DOM
.privacyScreenToggle
= $(".privacy-screen-toggle");
28 DOM
.network
= $(".network");
29 DOM
.bip32Client
= $("#bip32-client");
30 DOM
.phraseNetwork
= $("#network-phrase");
31 DOM
.useEntropy
= $(".use-entropy");
32 DOM
.entropyContainer
= $(".entropy-container");
33 DOM
.entropy
= $(".entropy");
34 DOM
.entropyFiltered
= DOM
.entropyContainer
.find(".filtered");
35 DOM
.entropyType
= DOM
.entropyContainer
.find(".type");
36 DOM
.entropyTypeInputs
= DOM
.entropyContainer
.find("input[name='entropy-type']");
37 DOM
.entropyCrackTime
= DOM
.entropyContainer
.find(".crack-time");
38 DOM
.entropyEventCount
= DOM
.entropyContainer
.find(".event-count");
39 DOM
.entropyBits
= DOM
.entropyContainer
.find(".bits");
40 DOM
.entropyBitsPerEvent
= DOM
.entropyContainer
.find(".bits-per-event");
41 DOM
.entropyWordCount
= DOM
.entropyContainer
.find(".word-count");
42 DOM
.entropyBinary
= DOM
.entropyContainer
.find(".binary");
43 DOM
.entropyWordIndexes
= DOM
.entropyContainer
.find(".word-indexes");
44 DOM
.entropyChecksum
= DOM
.entropyContainer
.find(".checksum");
45 DOM
.entropyMnemonicLength
= DOM
.entropyContainer
.find(".mnemonic-length");
46 DOM
.entropyWeakEntropyOverrideWarning
= DOM
.entropyContainer
.find(".weak-entropy-override-warning");
47 DOM
.entropyFilterWarning
= DOM
.entropyContainer
.find(".filter-warning");
48 DOM
.phrase
= $(".phrase");
49 DOM
.phraseSplit
= $(".phraseSplit");
50 DOM
.phraseSplitWarn
= $(".phraseSplitWarn");
51 DOM
.passphrase
= $(".passphrase");
52 DOM
.generateContainer
= $(".generate-container");
53 DOM
.generate
= $(".generate");
54 DOM
.seed
= $(".seed");
55 DOM
.rootKey
= $(".root-key");
56 DOM
.litecoinLtubContainer
= $(".litecoin-ltub-container");
57 DOM
.litecoinUseLtub
= $(".litecoin-use-ltub");
58 DOM
.extendedPrivKey
= $(".extended-priv-key");
59 DOM
.extendedPubKey
= $(".extended-pub-key");
60 DOM
.bip32tab
= $("#bip32-tab");
61 DOM
.bip44tab
= $("#bip44-tab");
62 DOM
.bip49tab
= $("#bip49-tab");
63 DOM
.bip84tab
= $("#bip84-tab");
64 DOM
.bip141tab
= $("#bip141-tab");
65 DOM
.bip32panel
= $("#bip32");
66 DOM
.bip44panel
= $("#bip44");
67 DOM
.bip49panel
= $("#bip49");
68 DOM
.bip32path
= $("#bip32-path");
69 DOM
.bip44path
= $("#bip44-path");
70 DOM
.bip44purpose
= $("#bip44 .purpose");
71 DOM
.bip44coin
= $("#bip44 .coin");
72 DOM
.bip44account
= $("#bip44 .account");
73 DOM
.bip44accountXprv
= $("#bip44 .account-xprv");
74 DOM
.bip44accountXpub
= $("#bip44 .account-xpub");
75 DOM
.bip44change
= $("#bip44 .change");
76 DOM
.bip49unavailable
= $("#bip49 .unavailable");
77 DOM
.bip49available
= $("#bip49 .available");
78 DOM
.bip49path
= $("#bip49-path");
79 DOM
.bip49purpose
= $("#bip49 .purpose");
80 DOM
.bip49coin
= $("#bip49 .coin");
81 DOM
.bip49account
= $("#bip49 .account");
82 DOM
.bip49accountXprv
= $("#bip49 .account-xprv");
83 DOM
.bip49accountXpub
= $("#bip49 .account-xpub");
84 DOM
.bip49change
= $("#bip49 .change");
85 DOM
.bip84unavailable
= $("#bip84 .unavailable");
86 DOM
.bip84available
= $("#bip84 .available");
87 DOM
.bip84path
= $("#bip84-path");
88 DOM
.bip84purpose
= $("#bip84 .purpose");
89 DOM
.bip84coin
= $("#bip84 .coin");
90 DOM
.bip84account
= $("#bip84 .account");
91 DOM
.bip84accountXprv
= $("#bip84 .account-xprv");
92 DOM
.bip84accountXpub
= $("#bip84 .account-xpub");
93 DOM
.bip84change
= $("#bip84 .change");
94 DOM
.bip141unavailable
= $("#bip141 .unavailable");
95 DOM
.bip141available
= $("#bip141 .available");
96 DOM
.bip141path
= $("#bip141-path");
97 DOM
.bip141semantics
= $(".bip141-semantics");
98 DOM
.generatedStrength
= $(".generate-container .strength");
99 DOM
.generatedStrengthWarning
= $(".generate-container .warning");
100 DOM
.hardenedAddresses
= $(".hardened-addresses");
101 DOM
.bitcoinCashAddressTypeContainer
= $(".bch-addr-type-container");
102 DOM
.bitcoinCashAddressType
= $("[name=bch-addr-type]")
103 DOM
.useBip38
= $(".use-bip38");
104 DOM
.bip38Password
= $(".bip38-password");
105 DOM
.addresses
= $(".addresses");
106 DOM
.csvTab
= $("#csv-tab a");
108 DOM
.rowsToAdd
= $(".rows-to-add");
109 DOM
.more
= $(".more");
110 DOM
.moreRowsStartIndex
= $(".more-rows-start-index");
111 DOM
.feedback
= $(".feedback");
112 DOM
.tab
= $(".derivation-type a");
113 DOM
.indexToggle
= $(".index-toggle");
114 DOM
.addressToggle
= $(".address-toggle");
115 DOM
.publicKeyToggle
= $(".public-key-toggle");
116 DOM
.privateKeyToggle
= $(".private-key-toggle");
117 DOM
.languages
= $(".languages a");
118 DOM
.qrContainer
= $(".qr-container");
119 DOM
.qrHider
= DOM
.qrContainer
.find(".qr-hider");
120 DOM
.qrImage
= DOM
.qrContainer
.find(".qr-image");
121 DOM
.qrHint
= DOM
.qrContainer
.find(".qr-hint");
122 DOM
.showQrEls
= $("[data-show-qr]");
126 DOM
.privacyScreenToggle
.on("change", privacyScreenToggled
);
127 DOM
.generatedStrength
.on("change", generatedStrengthChanged
);
128 DOM
.network
.on("change", networkChanged
);
129 DOM
.bip32Client
.on("change", bip32ClientChanged
);
130 DOM
.useEntropy
.on("change", setEntropyVisibility
);
131 DOM
.entropy
.on("input", delayedEntropyChanged
);
132 DOM
.entropyMnemonicLength
.on("change", entropyChanged
);
133 DOM
.entropyTypeInputs
.on("change", entropyTypeChanged
);
134 DOM
.phrase
.on("input", delayedPhraseChanged
);
135 DOM
.passphrase
.on("input", delayedPhraseChanged
);
136 DOM
.generate
.on("click", generateClicked
);
137 DOM
.more
.on("click", showMore
);
138 DOM
.rootKey
.on("input", delayedRootKeyChanged
);
139 DOM
.litecoinUseLtub
.on("change", litecoinUseLtubChanged
);
140 DOM
.bip32path
.on("input", calcForDerivationPath
);
141 DOM
.bip44account
.on("input", calcForDerivationPath
);
142 DOM
.bip44change
.on("input", calcForDerivationPath
);
143 DOM
.bip49account
.on("input", calcForDerivationPath
);
144 DOM
.bip49change
.on("input", calcForDerivationPath
);
145 DOM
.bip84account
.on("input", calcForDerivationPath
);
146 DOM
.bip84change
.on("input", calcForDerivationPath
);
147 DOM
.bip141path
.on("input", calcForDerivationPath
);
148 DOM
.bip141semantics
.on("change", tabChanged
);
149 DOM
.tab
.on("shown.bs.tab", tabChanged
);
150 DOM
.hardenedAddresses
.on("change", calcForDerivationPath
);
151 DOM
.useBip38
.on("change", calcForDerivationPath
);
152 DOM
.bip38Password
.on("change", calcForDerivationPath
);
153 DOM
.indexToggle
.on("click", toggleIndexes
);
154 DOM
.addressToggle
.on("click", toggleAddresses
);
155 DOM
.publicKeyToggle
.on("click", togglePublicKeys
);
156 DOM
.privateKeyToggle
.on("click", togglePrivateKeys
);
157 DOM
.csvTab
.on("click", updateCsv
);
158 DOM
.languages
.on("click", languageChanged
);
159 DOM
.bitcoinCashAddressType
.on("change", bitcoinCashAddressTypeChange
);
160 setQrEvents(DOM
.showQrEls
);
163 hideValidationError();
164 populateNetworkSelect();
165 populateClientSelect();
170 function generatedStrengthChanged() {
171 var strength
= parseInt(DOM
.generatedStrength
.val());
173 DOM
.generatedStrengthWarning
.removeClass("hidden");
176 DOM
.generatedStrengthWarning
.addClass("hidden");
180 function networkChanged(e
) {
182 clearAddressesList();
183 DOM
.litecoinLtubContainer
.addClass("hidden");
184 DOM
.bitcoinCashAddressTypeContainer
.addClass("hidden");
185 var networkIndex
= e
.target
.value
;
186 var network
= networks
[networkIndex
];
188 adjustNetworkForSegwit();
197 function bip32ClientChanged(e
) {
198 var clientIndex
= DOM
.bip32Client
.val();
199 if (clientIndex
== "custom") {
200 DOM
.bip32path
.prop("readonly", false);
203 DOM
.bip32path
.prop("readonly", true);
204 clients
[clientIndex
].onSelect();
214 function setEntropyVisibility() {
215 if (isUsingOwnEntropy()) {
216 DOM
.entropyContainer
.removeClass("hidden");
217 DOM
.generateContainer
.addClass("hidden");
218 DOM
.phrase
.prop("readonly", true);
223 DOM
.entropyContainer
.addClass("hidden");
224 DOM
.generateContainer
.removeClass("hidden");
225 DOM
.phrase
.prop("readonly", false);
230 function delayedPhraseChanged() {
231 hideValidationError();
234 bip32ExtendedKey
= null;
235 clearAddressesList();
237 if (phraseChangeTimeoutEvent
!= null) {
238 clearTimeout(phraseChangeTimeoutEvent
);
240 phraseChangeTimeoutEvent
= setTimeout(function() {
242 var entropy
= mnemonic
.toRawEntropyHex(DOM
.phrase
.val());
243 if (entropy
!== null) {
244 DOM
.entropyMnemonicLength
.val("raw");
245 DOM
.entropy
.val(entropy
);
246 DOM
.entropyTypeInputs
.filter("[value='hexadecimal']").prop("checked", true);
247 entropyTypeAutoDetect
= false;
252 function phraseChanged() {
254 setMnemonicLanguage();
255 // Get the mnemonic phrase
256 var phrase
= DOM
.phrase
.val();
257 var errorText
= findPhraseErrors(phrase
);
259 showValidationError(errorText
);
262 // Calculate and display
263 var passphrase
= DOM
.passphrase
.val();
264 calcBip32RootKeyFromSeed(phrase
, passphrase
);
265 calcForDerivationPath();
266 // Show the word indexes
268 writeSplitPhrase(phrase
);
271 function tabChanged() {
273 adjustNetworkForSegwit();
274 var phrase
= DOM
.phrase
.val();
276 // Calculate and display for mnemonic
277 var errorText
= findPhraseErrors(phrase
);
279 showValidationError(errorText
);
282 // Calculate and display
283 var passphrase
= DOM
.passphrase
.val();
284 calcBip32RootKeyFromSeed(phrase
, passphrase
);
287 // Calculate and display for root key
288 var rootKeyBase58
= DOM
.rootKey
.val();
289 var errorText
= validateRootKey(rootKeyBase58
);
291 showValidationError(errorText
);
294 // Calculate and display
295 calcBip32RootKeyFromBase58(rootKeyBase58
);
297 calcForDerivationPath();
300 function delayedEntropyChanged() {
301 hideValidationError();
303 if (entropyChangeTimeoutEvent
!= null) {
304 clearTimeout(entropyChangeTimeoutEvent
);
306 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
309 function entropyChanged() {
310 // If blank entropy, clear mnemonic, addresses, errors
311 if (DOM
.entropy
.val().trim().length
== 0) {
313 clearEntropyFeedback();
315 DOM
.phraseSplit
.val("");
316 showValidationError("Blank entropy");
319 // Get the current phrase to detect changes
320 var phrase
= DOM
.phrase
.val();
321 // Set the phrase from the entropy
322 setMnemonicFromEntropy();
323 // Recalc addresses if the phrase has changed
324 var newPhrase
= DOM
.phrase
.val();
325 if (newPhrase
!= phrase
) {
326 if (newPhrase
.length
== 0) {
338 function entropyTypeChanged() {
339 entropyTypeAutoDetect
= false;
343 function delayedRootKeyChanged() {
344 // Warn if there is an existing mnemonic or passphrase.
345 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
346 if (!confirm("This will clear existing mnemonic and passphrase")) {
347 DOM
.rootKey
.val(bip32RootKey
);
351 hideValidationError();
353 // Clear existing mnemonic and passphrase
355 DOM
.phraseSplit
.val("");
356 DOM
.passphrase
.val("");
358 if (rootKeyChangedTimeoutEvent
!= null) {
359 clearTimeout(rootKeyChangedTimeoutEvent
);
361 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
364 function rootKeyChanged() {
366 hideValidationError();
367 var rootKeyBase58
= DOM
.rootKey
.val();
368 var errorText
= validateRootKey(rootKeyBase58
);
370 showValidationError(errorText
);
373 // Calculate and display
374 calcBip32RootKeyFromBase58(rootKeyBase58
);
375 calcForDerivationPath();
378 function litecoinUseLtubChanged() {
379 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
380 if (litecoinUseLtub
) {
381 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
384 network
= bitcoinjs
.bitcoin
.networks
.litecoinXprv
;
389 function calcForDerivationPath() {
391 clearAddressesList();
393 // Don't show segwit if it's selected but network doesn't support it
394 if (segwitSelected() && !networkHasSegwit()) {
395 showSegwitUnavailable();
399 showSegwitAvailable();
400 // Get the derivation path
401 var derivationPath
= getDerivationPath();
402 var errorText
= findDerivationPathErrors(derivationPath
);
404 showValidationError(errorText
);
407 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
408 if (bip44TabSelected()) {
411 else if (bip49TabSelected()) {
414 else if (bip84TabSelected()) {
420 function generateClicked() {
421 if (isUsingOwnEntropy()) {
426 setTimeout(function() {
427 setMnemonicLanguage();
428 var phrase
= generateRandomPhrase();
436 function languageChanged() {
437 setTimeout(function() {
438 setMnemonicLanguage();
439 if (DOM
.phrase
.val().length
> 0) {
440 var newPhrase
= convertPhraseToNewLanguage();
441 DOM
.phrase
.val(newPhrase
);
445 DOM
.generate
.trigger("click");
450 function bitcoinCashAddressTypeChange() {
454 function toggleIndexes() {
455 showIndex
= !showIndex
;
456 $("td.index span").toggleClass("invisible");
459 function toggleAddresses() {
460 showAddress
= !showAddress
;
461 $("td.address span").toggleClass("invisible");
464 function togglePublicKeys() {
465 showPubKey
= !showPubKey
;
466 $("td.pubkey span").toggleClass("invisible");
469 function togglePrivateKeys() {
470 showPrivKey
= !showPrivKey
;
471 $("td.privkey span").toggleClass("invisible");
474 function privacyScreenToggled() {
475 // private-data contains elements added to DOM at runtime
476 // so catch all by adding visual privacy class to the root of the DOM
477 if (DOM
.privacyScreenToggle
.prop("checked")) {
478 $("body").addClass("visual-privacy");
481 $("body").removeClass("visual-privacy");
487 function generateRandomPhrase() {
488 if (!hasStrongRandom()) {
489 var errorText
= "This browser does not support strong randomness";
490 showValidationError(errorText
);
493 // get the amount of entropy to use
494 var numWords
= parseInt(DOM
.generatedStrength
.val());
495 var strength
= numWords
/ 3 * 32;
496 var buffer
= new Uint8Array(strength
/ 8);
497 // create secure entropy
498 var data
= crypto
.getRandomValues(buffer
);
500 var words
= mnemonic
.toMnemonic(data
);
501 DOM
.phrase
.val(words
);
503 var entropyHex
= uint8ArrayToHex(data
);
504 DOM
.entropy
.val(entropyHex
);
505 // ensure entropy fields are consistent with what is being displayed
506 DOM
.entropyMnemonicLength
.val("raw");
510 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
511 seed
= mnemonic
.toSeed(phrase
, passphrase
);
512 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
514 bip32RootKey
= groestlcoinjs
.HDNode
.fromSeedHex(seed
, network
);
518 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
520 calcBip32RootKeyFromBase58GRS(rootKeyBase58
);
523 // try parsing with various segwit network params since this extended
524 // key may be from any one of them.
525 if (networkHasSegwit()) {
527 if ("baseNetwork" in n
) {
528 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
530 // try parsing using base network params
532 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
536 // try parsing using p2wpkh params
539 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
544 // try parsing using p2wpkh-in-p2sh network params
545 if ("p2wpkhInP2sh" in n
) {
547 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
552 // try parsing using p2wsh network params
555 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wsh
);
560 // try parsing using p2wsh-in-p2sh network params
561 if ("p2wshInP2sh" in n
) {
563 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wshInP2sh
);
569 // try the network params as currently specified
570 bip32RootKey
= bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
573 function calcBip32RootKeyFromBase58GRS(rootKeyBase58
) {
574 // try parsing with various segwit network params since this extended
575 // key may be from any one of them.
576 if (networkHasSegwit()) {
578 if ("baseNetwork" in n
) {
579 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
581 // try parsing using base network params
583 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
587 // try parsing using p2wpkh params
590 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
595 // try parsing using p2wpkh-in-p2sh network params
596 if ("p2wpkhInP2sh" in n
) {
598 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
604 // try the network params as currently specified
605 bip32RootKey
= groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
608 function calcBip32ExtendedKey(path
) {
609 // Check there's a root key to derive from
613 var extendedKey
= bip32RootKey
;
614 // Derive the key from the path
615 var pathBits
= path
.split("/");
616 for (var i
=0; i
<pathBits
.length
; i
++) {
617 var bit
= pathBits
[i
];
618 var index
= parseInt(bit
);
622 var hardened
= bit
[bit
.length
-1] == "'";
623 var isPriv
= !(extendedKey
.isNeutered());
624 var invalidDerivationPath
= hardened
&& !isPriv
;
625 if (invalidDerivationPath
) {
629 extendedKey
= extendedKey
.deriveHardened(index
);
632 extendedKey
= extendedKey
.derive(index
);
638 function showValidationError(errorText
) {
644 function hideValidationError() {
650 function findPhraseErrors(phrase
) {
651 // Preprocess the words
652 phrase
= mnemonic
.normalizeString(phrase
);
653 var words
= phraseToWordArray(phrase
);
654 // Detect blank phrase
655 if (words
.length
== 0) {
656 return "Blank mnemonic";
659 for (var i
=0; i
<words
.length
; i
++) {
661 var language
= getLanguage();
662 if (WORDLISTS
[language
].indexOf(word
) == -1) {
663 console
.log("Finding closest match to " + word
);
664 var nearestWord
= findNearestWord(word
);
665 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
668 // Check the words are valid
669 var properPhrase
= wordArrayToPhrase(words
);
670 var isValid
= mnemonic
.check(properPhrase
);
672 return "Invalid mnemonic";
677 function validateRootKey(rootKeyBase58
) {
679 return validateRootKeyGRS(rootKeyBase58
);
681 // try various segwit network params since this extended key may be from
683 if (networkHasSegwit()) {
685 if ("baseNetwork" in n
) {
686 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
688 // try parsing using base network params
690 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
694 // try parsing using p2wpkh params
697 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
702 // try parsing using p2wpkh-in-p2sh network params
703 if ("p2wpkhInP2sh" in n
) {
705 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
710 // try parsing using p2wsh network params
713 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wsh
);
718 // try parsing using p2wsh-in-p2sh network params
719 if ("p2wshInP2sh" in n
) {
721 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wshInP2sh
);
727 // try the network params as currently specified
729 bitcoinjs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
732 return "Invalid root key";
737 function validateRootKeyGRS(rootKeyBase58
) {
738 // try various segwit network params since this extended key may be from
740 if (networkHasSegwit()) {
742 if ("baseNetwork" in n
) {
743 n
= bitcoinjs
.bitcoin
.networks
[n
.baseNetwork
];
745 // try parsing using base network params
747 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
751 // try parsing using p2wpkh params
754 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
759 // try parsing using p2wpkh-in-p2sh network params
760 if ("p2wpkhInP2sh" in n
) {
762 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
768 // try the network params as currently specified
770 groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
773 return "Invalid root key";
778 function getDerivationPath() {
779 if (bip44TabSelected()) {
780 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
781 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
782 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
783 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
785 path
+= purpose
+ "'/";
787 path
+= account
+ "'/";
789 DOM
.bip44path
.val(path
);
790 var derivationPath
= DOM
.bip44path
.val();
791 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
792 return derivationPath
;
794 else if (bip49TabSelected()) {
795 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
796 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
797 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
798 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
800 path
+= purpose
+ "'/";
802 path
+= account
+ "'/";
804 DOM
.bip49path
.val(path
);
805 var derivationPath
= DOM
.bip49path
.val();
806 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
807 return derivationPath
;
809 else if (bip84TabSelected()) {
810 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
811 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
812 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
813 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
815 path
+= purpose
+ "'/";
817 path
+= account
+ "'/";
819 DOM
.bip84path
.val(path
);
820 var derivationPath
= DOM
.bip84path
.val();
821 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
822 return derivationPath
;
824 else if (bip32TabSelected()) {
825 var derivationPath
= DOM
.bip32path
.val();
826 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
827 return derivationPath
;
829 else if (bip141TabSelected()) {
830 var derivationPath
= DOM
.bip141path
.val();
831 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
832 return derivationPath
;
835 console
.log("Unknown derivation path");
839 function findDerivationPathErrors(path
) {
840 // TODO is not perfect but is better than nothing
842 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
844 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
845 var maxDepth
= 255; // TODO verify this!!
846 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
847 if (path
[0] != "m") {
848 return "First character must be 'm'";
850 if (path
.length
> 1) {
851 if (path
[1] != "/") {
852 return "Separator must be '/'";
854 var indexes
= path
.split("/");
855 if (indexes
.length
> maxDepth
) {
856 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
858 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
859 var index
= indexes
[depth
];
860 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
861 if (invalidChars
.length
> 0) {
862 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
864 var indexValue
= parseInt(index
.replace("'", ""));
866 return "Invalid number at depth " + depth
;
868 if (indexValue
> maxIndexValue
) {
869 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
873 // Check root key exists or else derivation path is useless!
875 return "No root key";
877 // Check no hardened derivation path when using xpub keys
878 var hardenedPath
= path
.indexOf("'") > -1;
879 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
880 var hardened
= hardenedPath
|| hardenedAddresses
;
881 var isXpubkey
= bip32RootKey
.isNeutered();
882 if (hardened
&& isXpubkey
) {
883 return "Hardened derivation path is invalid with xpub key";
889 return networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin" || networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin Testnet";
893 return networks
[DOM
.network
.val()].name
== "ELA - Elastos"
896 function displayBip44Info() {
897 // Get the derivation path for the account
898 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
899 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
900 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
902 path
+= purpose
+ "'/";
904 path
+= account
+ "'/";
905 // Calculate the account extended keys
906 var accountExtendedKey
= calcBip32ExtendedKey(path
);
907 var accountXprv
= accountExtendedKey
.toBase58();
908 var accountXpub
= accountExtendedKey
.neutered().toBase58();
910 // Display the extended keys
911 DOM
.bip44accountXprv
.val(accountXprv
);
912 DOM
.bip44accountXpub
.val(accountXpub
);
915 displayBip44InfoForELA();
919 function displayBip49Info() {
920 // Get the derivation path for the account
921 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
922 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
923 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
925 path
+= purpose
+ "'/";
927 path
+= account
+ "'/";
928 // Calculate the account extended keys
929 var accountExtendedKey
= calcBip32ExtendedKey(path
);
930 var accountXprv
= accountExtendedKey
.toBase58();
931 var accountXpub
= accountExtendedKey
.neutered().toBase58();
932 // Display the extended keys
933 DOM
.bip49accountXprv
.val(accountXprv
);
934 DOM
.bip49accountXpub
.val(accountXpub
);
937 function displayBip84Info() {
938 // Get the derivation path for the account
939 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
940 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
941 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
943 path
+= purpose
+ "'/";
945 path
+= account
+ "'/";
946 // Calculate the account extended keys
947 var accountExtendedKey
= calcBip32ExtendedKey(path
);
948 var accountXprv
= accountExtendedKey
.toBase58();
949 var accountXpub
= accountExtendedKey
.neutered().toBase58();
950 // Display the extended keys
951 DOM
.bip84accountXprv
.val(accountXprv
);
952 DOM
.bip84accountXpub
.val(accountXpub
);
955 function displayBip32Info() {
958 var rootKey
= bip32RootKey
.toBase58();
959 DOM
.rootKey
.val(rootKey
);
960 var xprvkeyB58
= "NA";
961 if (!bip32ExtendedKey
.isNeutered()) {
962 xprvkeyB58
= bip32ExtendedKey
.toBase58();
964 var extendedPrivKey
= xprvkeyB58
;
965 DOM
.extendedPrivKey
.val(extendedPrivKey
);
966 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
967 DOM
.extendedPubKey
.val(extendedPubKey
);
968 // Display the addresses and privkeys
969 clearAddressesList();
970 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
971 displayAddresses(0, initialAddressCount
);
974 displayBip32InfoForELA();
978 function displayAddresses(start
, total
) {
979 generationProcesses
.push(new (function() {
983 this.stop = function() {
984 for (var i
=0; i
<rows
.length
; i
++) {
985 rows
[i
].shouldGenerate
= false;
990 for (var i
=0; i
<total
; i
++) {
991 var index
= i
+ start
;
992 var isLast
= i
== total
- 1;
993 rows
.push(new TableRow(index
, isLast
));
999 function segwitSelected() {
1000 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
1003 function p2wpkhSelected() {
1004 return bip84TabSelected() ||
1005 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
1008 function p2wpkhInP2shSelected() {
1009 return bip49TabSelected() ||
1010 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
1013 function p2wshSelected() {
1014 return bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wsh";
1017 function p2wshInP2shSelected() {
1018 return (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wsh-p2sh");
1021 function TableRow(index
, isLast
) {
1024 this.shouldGenerate
= true;
1025 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
1026 var useBip38
= DOM
.useBip38
.prop("checked");
1027 var bip38password
= DOM
.bip38Password
.val();
1028 var isSegwit
= segwitSelected();
1029 var segwitAvailable
= networkHasSegwit();
1030 var isP2wpkh
= p2wpkhSelected();
1031 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
1032 var isP2wsh
= p2wshSelected();
1033 var isP2wshInP2sh
= p2wshInP2shSelected();
1039 function calculateValues() {
1040 setTimeout(function() {
1041 if (!self
.shouldGenerate
) {
1044 // derive HDkey for this row of the table
1046 if (useHardenedAddresses
) {
1047 key
= bip32ExtendedKey
.deriveHardened(index
);
1050 key
= bip32ExtendedKey
.derive(index
);
1052 // bip38 requires uncompressed keys
1053 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
1054 var keyPair
= key
.keyPair
;
1055 var useUncompressed
= useBip38
;
1056 if (useUncompressed
) {
1057 keyPair
= new bitcoinjs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
1059 keyPair
= new groestlcoinjs
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
1063 var address
= keyPair
.getAddress().toString();
1065 var hasPrivkey
= !key
.isNeutered();
1068 privkey
= keyPair
.toWIF();
1069 // BIP38 encode private key if required
1072 privkey
= groestlcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1073 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1074 }, null, networks
[DOM
.network
.val()].name
.includes("Testnet"));
1076 privkey
= bitcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1077 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1082 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
1083 var indexText
= getDerivationPath() + "/" + index
;
1084 if (useHardenedAddresses
) {
1085 indexText
= indexText
+ "'";
1087 // Ethereum values are different
1088 if (networkIsEthereum()) {
1089 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1090 privkey
= privKeyBuffer
.toString('hex');
1091 var addressBuffer
= ethUtil
.privateToAddress(privKeyBuffer
);
1092 var hexAddress
= addressBuffer
.toString('hex');
1093 var checksumAddress
= ethUtil
.toChecksumAddress(hexAddress
);
1094 address
= ethUtil
.addHexPrefix(checksumAddress
);
1095 privkey
= ethUtil
.addHexPrefix(privkey
);
1096 pubkey
= ethUtil
.addHexPrefix(pubkey
);
1099 // Stellar is different
1100 if (networks
[DOM
.network
.val()].name
== "XLM - Stellar") {
1101 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
1102 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
1104 path
+= purpose
+ "'/";
1105 path
+= coin
+ "'/" + index
+ "'";
1106 var keypair
= stellarUtil
.getKeypair(path
, seed
);
1108 privkey
= keypair
.secret();
1109 pubkey
= address
= keypair
.publicKey();
1111 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
1112 var NasAccount
= require("nebulas-account");
1113 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1114 var nebulasAccount
= new NasAccount();
1115 nebulasAccount
.setPrivateKey(privKeyBuffer
);
1116 address
= nebulasAccount
.getAddressString();
1117 privkey
= nebulasAccount
.getPrivateKeyString();
1118 pubkey
= nebulasAccount
.getPublicKeyString();
1120 // Ripple values are different
1121 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
1122 privkey
= convertRipplePriv(privkey
);
1123 address
= convertRippleAdrr(address
);
1125 // CasinoCoin values are different
1126 if (networks
[DOM
.network
.val()].name
== "CSC - CasinoCoin") {
1127 privkey
= convertCasinoCoinPriv(privkey
);
1128 address
= convertCasinoCoinAdrr(address
);
1130 // Bitcoin Cash address format may vary
1131 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
1132 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1133 if (bchAddrType
== "cashaddr") {
1134 address
= bchaddr
.toCashAddress(address
);
1136 else if (bchAddrType
== "bitpay") {
1137 address
= bchaddr
.toBitpayAddress(address
);
1140 // Bitcoin Cash address format may vary
1141 if (networks
[DOM
.network
.val()].name
== "SLP - Simple Ledger Protocol") {
1142 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1143 if (bchAddrType
== "cashaddr") {
1144 address
= bchaddr
.toSlpAddress(address
);
1147 // Segwit addresses are different
1149 if (!segwitAvailable
) {
1153 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1154 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1155 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1157 else if (isP2wpkhInP2sh
) {
1158 var keyhash
= bitcoinjs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1159 var scriptsig
= bitcoinjs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1160 var addressbytes
= bitcoinjs
.bitcoin
.crypto
.hash160(scriptsig
);
1161 var scriptpubkey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
1162 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1165 // https://github.com/bitcoinjs/bitcoinjs-lib/blob/v3.3.2/test/integration/addresses.js#L71
1167 var witnessScript
= bitcoinjs
.bitcoin
.script
.multisig
.output
.encode(1, [key
.getPublicKeyBuffer()]);
1168 var scriptPubKey
= bitcoinjs
.bitcoin
.script
.witnessScriptHash
.output
.encode(bitcoinjs
.bitcoin
.crypto
.sha256(witnessScript
));
1169 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptPubKey
, network
);
1171 else if (isP2wshInP2sh
) {
1172 // https://github.com/bitcoinjs/bitcoinjs-lib/blob/v3.3.2/test/integration/transactions.js#L183
1174 var witnessScript
= bitcoinjs
.bitcoin
.script
.multisig
.output
.encode(1, [key
.getPublicKeyBuffer()]);
1175 var redeemScript
= bitcoinjs
.bitcoin
.script
.witnessScriptHash
.output
.encode(bitcoinjs
.bitcoin
.crypto
.sha256(witnessScript
));
1176 var scriptPubKey
= bitcoinjs
.bitcoin
.script
.scriptHash
.output
.encode(bitcoinjs
.bitcoin
.crypto
.hash160(redeemScript
));
1177 address
= bitcoinjs
.bitcoin
.address
.fromOutputScript(scriptPubKey
, network
)
1181 if ((networks
[DOM
.network
.val()].name
== "CRW - Crown")) {
1182 address
= bitcoinjs
.bitcoin
.networks
.crown
.toNewAddress(address
);
1185 if (networks
[DOM
.network
.val()].name
== "EOS - EOSIO") {
1187 pubkey
= eosUtil
.bufferToPublic(keyPair
.getPublicKeyBuffer());
1188 privkey
= eosUtil
.bufferToPrivate(keyPair
.d
.toBuffer(32));
1191 //Groestlcoin Addresses are different
1195 if (!segwitAvailable
) {
1199 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1201 else if (isP2wpkhInP2sh
) {
1202 address
= groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1205 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1209 let elaAddress
= calcAddressForELA(
1211 parseIntNoNaN(DOM
.bip44coin
.val(), 0),
1212 parseIntNoNaN(DOM
.bip44account
.val(), 0),
1213 parseIntNoNaN(DOM
.bip44change
.val(), 0),
1216 address
= elaAddress
.address
;
1217 privkey
= elaAddress
.privateKey
;
1218 pubkey
= elaAddress
.publicKey
;
1221 addAddressToList(indexText
, address
, pubkey
, privkey
);
1233 function showMore() {
1234 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
1235 if (isNaN(rowsToAdd
)) {
1237 DOM
.rowsToAdd
.val("20");
1239 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
1241 start
= lastIndexInTable() + 1;
1244 var newStart
= start
+ rowsToAdd
;
1245 DOM
.moreRowsStartIndex
.val(newStart
);
1247 if (rowsToAdd
> 200) {
1248 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1249 msg
+= "Do you want to continue?";
1250 if (!confirm(msg
)) {
1254 displayAddresses(start
, rowsToAdd
);
1257 function clearDisplay() {
1258 clearAddressesList();
1260 hideValidationError();
1263 function clearAddressesList() {
1264 DOM
.addresses
.empty();
1269 function stopGenerating() {
1270 while (generationProcesses
.length
> 0) {
1271 var generation
= generationProcesses
.shift();
1276 function clearKeys() {
1281 function clearRootKey() {
1282 DOM
.rootKey
.val("");
1285 function clearDerivedKeys() {
1286 DOM
.extendedPrivKey
.val("");
1287 DOM
.extendedPubKey
.val("");
1288 DOM
.bip44accountXprv
.val("");
1289 DOM
.bip44accountXpub
.val("");
1292 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1293 var row
= $(addressRowTemplate
.html());
1295 var indexCell
= row
.find(".index span");
1296 var addressCell
= row
.find(".address span");
1297 var pubkeyCell
= row
.find(".pubkey span");
1298 var privkeyCell
= row
.find(".privkey span");
1300 indexCell
.text(indexText
);
1301 addressCell
.text(address
);
1302 pubkeyCell
.text(pubkey
);
1303 privkeyCell
.text(privkey
);
1306 indexCell
.addClass("invisible");
1309 addressCell
.addClass("invisible");
1312 pubkeyCell
.addClass("invisible");
1315 privkeyCell
.addClass("invisible");
1317 DOM
.addresses
.append(row
);
1318 var rowShowQrEls
= row
.find("[data-show-qr]");
1319 setQrEvents(rowShowQrEls
);
1322 function hasStrongRandom() {
1323 return 'crypto' in window
&& window
['crypto'] !== null;
1326 function disableForms() {
1327 $("form").on("submit", function(e
) {
1332 function parseIntNoNaN(val
, defaultVal
) {
1333 var v
= parseInt(val
);
1340 function showPending() {
1342 .text("Calculating...")
1346 function findNearestWord(word
) {
1347 var language
= getLanguage();
1348 var words
= WORDLISTS
[language
];
1349 var minDistance
= 99;
1350 var closestWord
= words
[0];
1351 for (var i
=0; i
<words
.length
; i
++) {
1352 var comparedTo
= words
[i
];
1353 if (comparedTo
.indexOf(word
) == 0) {
1356 var distance
= Levenshtein
.get(word
, comparedTo
);
1357 if (distance
< minDistance
) {
1358 closestWord
= comparedTo
;
1359 minDistance
= distance
;
1365 function hidePending() {
1371 function populateNetworkSelect() {
1372 for (var i
=0; i
<networks
.length
; i
++) {
1373 var network
= networks
[i
];
1374 var option
= $("<option>");
1375 option
.attr("value", i
);
1376 option
.text(network
.name
);
1377 if (network
.name
== "BTC - Bitcoin") {
1378 option
.prop("selected", true);
1380 DOM
.phraseNetwork
.append(option
);
1384 function populateClientSelect() {
1385 for (var i
=0; i
<clients
.length
; i
++) {
1386 var client
= clients
[i
];
1387 var option
= $("<option>");
1388 option
.attr("value", i
);
1389 option
.text(client
.name
);
1390 DOM
.bip32Client
.append(option
);
1394 function getLanguage() {
1395 var defaultLanguage
= "english";
1396 // Try to get from existing phrase
1397 var language
= getLanguageFromPhrase();
1398 // Try to get from url if not from phrase
1399 if (language
.length
== 0) {
1400 language
= getLanguageFromUrl();
1402 // Default to English if no other option
1403 if (language
.length
== 0) {
1404 language
= defaultLanguage
;
1409 function getLanguageFromPhrase(phrase
) {
1410 // Check if how many words from existing phrase match a language.
1413 phrase
= DOM
.phrase
.val();
1415 if (phrase
.length
> 0) {
1416 var words
= phraseToWordArray(phrase
);
1417 var languageMatches
= {};
1418 for (l
in WORDLISTS
) {
1419 // Track how many words match in this language
1420 languageMatches
[l
] = 0;
1421 for (var i
=0; i
<words
.length
; i
++) {
1422 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1423 if (wordInLanguage
) {
1424 languageMatches
[l
]++;
1427 // Find languages with most word matches.
1428 // This is made difficult due to commonalities between Chinese
1429 // simplified vs traditional.
1430 var mostMatches
= 0;
1431 var mostMatchedLanguages
= [];
1432 for (var l
in languageMatches
) {
1433 var numMatches
= languageMatches
[l
];
1434 if (numMatches
> mostMatches
) {
1435 mostMatches
= numMatches
;
1436 mostMatchedLanguages
= [l
];
1438 else if (numMatches
== mostMatches
) {
1439 mostMatchedLanguages
.push(l
);
1443 if (mostMatchedLanguages
.length
> 0) {
1444 // Use first language and warn if multiple detected
1445 language
= mostMatchedLanguages
[0];
1446 if (mostMatchedLanguages
.length
> 1) {
1447 console
.warn("Multiple possible languages");
1448 console
.warn(mostMatchedLanguages
);
1455 function getLanguageFromUrl() {
1456 for (var language
in WORDLISTS
) {
1457 if (window
.location
.hash
.indexOf(language
) > -1) {
1464 function setMnemonicLanguage() {
1465 var language
= getLanguage();
1466 // Load the bip39 mnemonic generator for this language if required
1467 if (!(language
in mnemonics
)) {
1468 mnemonics
[language
] = new Mnemonic(language
);
1470 mnemonic
= mnemonics
[language
];
1473 function convertPhraseToNewLanguage() {
1474 var oldLanguage
= getLanguageFromPhrase();
1475 var newLanguage
= getLanguageFromUrl();
1476 var oldPhrase
= DOM
.phrase
.val();
1477 var oldWords
= phraseToWordArray(oldPhrase
);
1479 for (var i
=0; i
<oldWords
.length
; i
++) {
1480 var oldWord
= oldWords
[i
];
1481 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1482 var newWord
= WORDLISTS
[newLanguage
][index
];
1483 newWords
.push(newWord
);
1485 newPhrase
= wordArrayToPhrase(newWords
);
1489 // TODO look at jsbip39 - mnemonic.splitWords
1490 function phraseToWordArray(phrase
) {
1491 var words
= phrase
.split(/\s/g);
1493 for (var i
=0; i
<words
.length
; i
++) {
1494 var word
= words
[i
];
1495 if (word
.length
> 0) {
1496 noBlanks
.push(word
);
1502 // TODO look at jsbip39 - mnemonic.joinWords
1503 function wordArrayToPhrase(words
) {
1504 var phrase
= words
.join(" ");
1505 var language
= getLanguageFromPhrase(phrase
);
1506 if (language
== "japanese") {
1507 phrase
= words
.join("\u3000");
1512 function writeSplitPhrase(phrase
) {
1513 var wordCount
= phrase
.split(/\s/g).length
;
1515 for (var i
=0;i
<wordCount
;i
++) left
.push(i
);
1516 var group
=[[],[],[]],
1518 var seed
= Math
.abs(sjcl
.hash
.sha256
.hash(phrase
)[0])% 2147483647;
1519 while (left
.length
>0) {
1520 groupI
=(groupI
+1)%3;
1521 seed
= seed
* 16807 % 2147483647;
1522 var selected
=Math
.floor(left
.length
*(seed
- 1) / 2147483646);
1523 group
[groupI
].push(left
[selected
]);
1524 left
.splice(selected
,1);
1526 var cards
=[phrase
.split(/\s/g),phrase
.split(/\s/g),phrase
.split(/\s/g)];
1527 for (var i
=0;i
<3;i
++) {
1528 for (var ii
=0;ii
<wordCount
/3;ii
++) cards
[i
][group
[i
][ii
]]='XXXX';
1529 cards
[i
]='Card '+(i
+1)+': '+wordArrayToPhrase(cards
[i
]);
1531 DOM
.phraseSplit
.val(cards
.join("\r\n"));
1532 var triesPerSecond
=10000000000;
1533 var hackTime
=Math
.pow(2,wordCount
*10/3)/triesPerSecond
;
1534 var displayRedText
= false;
1536 hackTime
="<1 second";
1537 displayRedText
= true;
1538 } else if (hackTime
<86400) {
1539 hackTime
=Math
.floor(hackTime
)+" seconds";
1540 displayRedText
= true;
1541 } else if(hackTime
<31557600) {
1542 hackTime
=Math
.floor(hackTime
/86400)+" days";
1543 displayRedText
= true;
1545 hackTime
=Math
.floor(hackTime
/31557600)+" years";
1547 DOM
.phraseSplitWarn
.html("Time to hack with only one card: "+hackTime
);
1548 if (displayRedText
) {
1549 DOM
.phraseSplitWarn
.addClass("text-danger");
1551 DOM
.phraseSplitWarn
.removeClass("text-danger");
1555 function isUsingOwnEntropy() {
1556 return DOM
.useEntropy
.prop("checked");
1559 function setMnemonicFromEntropy() {
1560 clearEntropyFeedback();
1561 // Get entropy value
1562 var entropyStr
= DOM
.entropy
.val();
1563 // Work out minimum base for entropy
1565 if (entropyTypeAutoDetect
) {
1566 entropy
= Entropy
.fromString(entropyStr
);
1569 let base
= DOM
.entropyTypeInputs
.filter(":checked").val();
1570 entropy
= Entropy
.fromString(entropyStr
, base
);
1572 if (entropy
.binaryStr
.length
== 0) {
1575 // Show entropy details
1576 showEntropyFeedback(entropy
);
1577 // Use entropy hash if not using raw entropy
1578 var bits
= entropy
.binaryStr
;
1579 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1580 if (mnemonicLength
!= "raw") {
1581 // Get bits by hashing entropy with SHA256
1582 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1583 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1584 bits
= BigInteger
.parse(hex
, 16).toString(2);
1585 while (bits
.length
% 256 != 0) {
1588 // Truncate hash to suit number of words
1589 mnemonicLength
= parseInt(mnemonicLength
);
1590 var numberOfBits
= 32 * mnemonicLength
/ 3;
1591 bits
= bits
.substring(0, numberOfBits
);
1592 // show warning for weak entropy override
1593 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1594 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1597 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1601 // hide warning for weak entropy override
1602 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1604 // Discard trailing entropy
1605 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1606 var start
= bits
.length
- bitsToUse
;
1607 var binaryStr
= bits
.substring(start
);
1608 // Convert entropy string to numeric array
1609 var entropyArr
= [];
1610 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1611 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1612 var entropyByte
= parseInt(byteAsBits
, 2);
1613 entropyArr
.push(entropyByte
)
1615 // Convert entropy array to mnemonic
1616 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1617 // Set the mnemonic in the UI
1618 DOM
.phrase
.val(phrase
);
1619 writeSplitPhrase(phrase
);
1620 // Show the word indexes
1622 // Show the checksum
1626 function clearEntropyFeedback() {
1627 DOM
.entropyCrackTime
.text("...");
1628 DOM
.entropyType
.text("");
1629 DOM
.entropyWordCount
.text("0");
1630 DOM
.entropyEventCount
.text("0");
1631 DOM
.entropyBitsPerEvent
.text("0");
1632 DOM
.entropyBits
.text("0");
1633 DOM
.entropyFiltered
.html(" ");
1634 DOM
.entropyBinary
.html(" ");
1637 function showEntropyFeedback(entropy
) {
1638 var numberOfBits
= entropy
.binaryStr
.length
;
1639 var timeToCrack
= "unknown";
1641 var z
= zxcvbn(entropy
.base
.parts
.join(""));
1642 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1643 if (z
.feedback
.warning
!= "") {
1644 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1648 console
.log("Error detecting entropy strength with zxcvbn:");
1651 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1652 DOM
.entropyTypeInputs
.attr("checked", false);
1653 DOM
.entropyTypeInputs
.filter("[value='" + entropyTypeStr
+ "']").attr("checked", true);
1654 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1655 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1656 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1657 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1658 DOM
.entropyType
.text(entropyTypeStr
);
1659 DOM
.entropyCrackTime
.text(timeToCrack
);
1660 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1661 DOM
.entropyBits
.text(numberOfBits
);
1662 DOM
.entropyWordCount
.text(wordCount
);
1663 DOM
.entropyBinary
.text(spacedBinaryStr
);
1664 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1665 // detect and warn of filtering
1666 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1667 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1668 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1670 DOM
.entropyFilterWarning
.removeClass('hidden');
1673 DOM
.entropyFilterWarning
.addClass('hidden');
1677 function getEntropyTypeStr(entropy
) {
1678 var typeStr
= entropy
.base
.str
;
1679 // Add some detail if these are cards
1680 if (entropy
.base
.asInt
== 52) {
1681 var cardDetail
= []; // array of message strings
1682 // Detect duplicates
1684 var dupeTracker
= {};
1685 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1686 var card
= entropy
.base
.parts
[i
];
1687 var cardUpper
= card
.toUpperCase();
1688 if (cardUpper
in dupeTracker
) {
1691 dupeTracker
[cardUpper
] = true;
1693 if (dupes
.length
> 0) {
1694 var dupeWord
= "duplicates";
1695 if (dupes
.length
== 1) {
1696 dupeWord
= "duplicate";
1698 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1699 if (dupes
.length
> 3) {
1702 cardDetail
.push(msg
);
1705 var uniqueCards
= [];
1706 for (var uniqueCard
in dupeTracker
) {
1707 uniqueCards
.push(uniqueCard
);
1709 if (uniqueCards
.length
== 52) {
1710 cardDetail
.unshift("full deck");
1712 // Detect missing cards
1713 var values
= "A23456789TJQK";
1715 var missingCards
= [];
1716 for (var i
=0; i
<suits
.length
; i
++) {
1717 for (var j
=0; j
<values
.length
; j
++) {
1718 var card
= values
[j
] + suits
[i
];
1719 if (!(card
in dupeTracker
)) {
1720 missingCards
.push(card
);
1724 // Display missing cards if six or less, ie clearly going for full deck
1725 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1726 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1727 if (missingCards
.length
> 3) {
1730 cardDetail
.push(msg
);
1732 // Add card details to typeStr
1733 if (cardDetail
.length
> 0) {
1734 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1740 function setQrEvents(els
) {
1741 els
.on("mouseenter", createQr
);
1742 els
.on("mouseleave", destroyQr
);
1743 els
.on("click", toggleQr
);
1746 function createQr(e
) {
1747 var content
= e
.target
.textContent
|| e
.target
.value
;
1755 DOM
.qrImage
.append(qrEl
);
1757 DOM
.qrHider
.addClass("hidden");
1760 DOM
.qrHider
.removeClass("hidden");
1762 DOM
.qrContainer
.removeClass("hidden");
1766 function destroyQr() {
1767 DOM
.qrImage
.text("");
1768 DOM
.qrContainer
.addClass("hidden");
1771 function toggleQr() {
1773 DOM
.qrHider
.toggleClass("hidden");
1774 DOM
.qrHint
.toggleClass("hidden");
1777 function bip44TabSelected() {
1778 return DOM
.bip44tab
.hasClass("active");
1781 function bip32TabSelected() {
1782 return DOM
.bip32tab
.hasClass("active");
1785 function networkIsEthereum() {
1786 var name
= networks
[DOM
.network
.val()].name
;
1787 return (name
== "ETH - Ethereum")
1788 || (name
== "ETC - Ethereum Classic")
1789 || (name
== "EWT - EnergyWeb")
1790 || (name
== "PIRL - Pirl")
1791 || (name
== "MIX - MIX")
1792 || (name
== "MUSIC - Musicoin")
1793 || (name
== "POA - Poa")
1794 || (name
== "EXP - Expanse")
1795 || (name
== "CLO - Callisto")
1796 || (name
== "DXN - DEXON")
1797 || (name
== "ELLA - Ellaism")
1798 || (name
== "ESN - Ethersocial Network")
1799 || (name
== "VET - VeChain")
1802 function networkHasSegwit() {
1804 if ("baseNetwork" in network
) {
1805 n
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1807 // check if only p2wpkh params are required
1808 if (p2wpkhSelected()) {
1809 return "p2wpkh" in n
;
1811 // check if only p2wpkh-in-p2sh params are required
1812 else if (p2wpkhInP2shSelected()) {
1813 return "p2wpkhInP2sh" in n
;
1815 // require both if it's unclear which params are required
1816 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1819 function bip49TabSelected() {
1820 return DOM
.bip49tab
.hasClass("active");
1823 function bip84TabSelected() {
1824 return DOM
.bip84tab
.hasClass("active");
1827 function bip141TabSelected() {
1828 return DOM
.bip141tab
.hasClass("active");
1831 function setHdCoin(coinValue
) {
1832 DOM
.bip44coin
.val(coinValue
);
1833 DOM
.bip49coin
.val(coinValue
);
1834 DOM
.bip84coin
.val(coinValue
);
1837 function showSegwitAvailable() {
1838 DOM
.bip49unavailable
.addClass("hidden");
1839 DOM
.bip49available
.removeClass("hidden");
1840 DOM
.bip84unavailable
.addClass("hidden");
1841 DOM
.bip84available
.removeClass("hidden");
1842 DOM
.bip141unavailable
.addClass("hidden");
1843 DOM
.bip141available
.removeClass("hidden");
1846 function showSegwitUnavailable() {
1847 DOM
.bip49available
.addClass("hidden");
1848 DOM
.bip49unavailable
.removeClass("hidden");
1849 DOM
.bip84available
.addClass("hidden");
1850 DOM
.bip84unavailable
.removeClass("hidden");
1851 DOM
.bip141available
.addClass("hidden");
1852 DOM
.bip141unavailable
.removeClass("hidden");
1855 function adjustNetworkForSegwit() {
1856 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1857 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1859 // See https://github.com/iancoleman/bip39/issues/125
1860 var segwitNetworks
= null;
1861 // if a segwit network is alread selected, need to use base network to
1862 // look up new parameters
1863 if ("baseNetwork" in network
) {
1864 network
= bitcoinjs
.bitcoin
.networks
[network
.baseNetwork
];
1866 // choose the right segwit params
1867 if (p2wpkhSelected() && "p2wpkh" in network
) {
1868 network
= network
.p2wpkh
;
1870 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1871 network
= network
.p2wpkhInP2sh
;
1873 else if (p2wshSelected() && "p2wsh" in network
) {
1874 network
= network
.p2wsh
;
1876 else if (p2wshInP2shSelected() && "p2wshInP2sh" in network
) {
1877 network
= network
.p2wshInP2sh
;
1881 function lastIndexInTable() {
1882 var pathText
= DOM
.addresses
.find(".index").last().text();
1883 var pathBits
= pathText
.split("/");
1884 var lastBit
= pathBits
[pathBits
.length
-1];
1885 var lastBitClean
= lastBit
.replace("'", "");
1886 return parseInt(lastBitClean
);
1889 function uint8ArrayToHex(a
) {
1891 for (var i
=0; i
<a
.length
; i
++) {
1892 var h
= a
[i
].toString(16);
1893 while (h
.length
< 2) {
1901 function showWordIndexes() {
1902 var phrase
= DOM
.phrase
.val();
1903 var words
= phraseToWordArray(phrase
);
1904 var wordIndexes
= [];
1905 var language
= getLanguage();
1906 for (var i
=0; i
<words
.length
; i
++) {
1907 var word
= words
[i
];
1908 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1909 wordIndexes
.push(wordIndex
);
1911 var wordIndexesStr
= wordIndexes
.join(", ");
1912 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1915 function showChecksum() {
1916 var phrase
= DOM
.phrase
.val();
1917 var words
= phraseToWordArray(phrase
);
1918 var checksumBitlength
= words
.length
/ 3;
1921 var language
= getLanguage();
1922 for (var i
=words
.length
-1; i
>=0; i
--) {
1923 var word
= words
[i
];
1924 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1925 var wordBinary
= wordIndex
.toString(2);
1926 while (wordBinary
.length
< 11) {
1927 wordBinary
= "0" + wordBinary
;
1929 var binaryStr
= wordBinary
+ binaryStr
;
1930 if (binaryStr
.length
>= checksumBitlength
) {
1931 var start
= binaryStr
.length
- checksumBitlength
;
1932 var end
= binaryStr
.length
;
1933 checksum
= binaryStr
.substring(start
, end
);
1934 // add spaces so the last group is 11 bits, not the first
1935 checksum
= checksum
.split("").reverse().join("")
1936 checksum
= addSpacesEveryElevenBits(checksum
);
1937 checksum
= checksum
.split("").reverse().join("")
1941 DOM
.entropyChecksum
.text(checksum
);
1944 function updateCsv() {
1945 var tableCsv
= "path,address,public key,private key\n";
1946 var rows
= DOM
.addresses
.find("tr");
1947 for (var i
=0; i
<rows
.length
; i
++) {
1948 var row
= $(rows
[i
]);
1949 var cells
= row
.find("td");
1950 for (var j
=0; j
<cells
.length
; j
++) {
1951 var cell
= $(cells
[j
]);
1952 if (!cell
.children().hasClass("invisible")) {
1953 tableCsv
= tableCsv
+ cell
.text();
1955 if (j
!= cells
.length
- 1) {
1956 tableCsv
= tableCsv
+ ",";
1959 tableCsv
= tableCsv
+ "\n";
1961 DOM
.csv
.val(tableCsv
);
1964 function addSpacesEveryElevenBits(binaryStr
) {
1965 return binaryStr
.match(/.{1,11}/g).join(" ");
1970 name: "AC - Asiacoin",
1971 onSelect: function() {
1972 network
= bitcoinjs
.bitcoin
.networks
.asiacoin
;
1977 name: "ACC - Adcoin",
1978 onSelect: function() {
1979 network
= bitcoinjs
.bitcoin
.networks
.adcoin
;
1984 name: "ARYA - Aryacoin",
1985 onSelect: function() {
1986 network
= bitcoinjs
.bitcoin
.networks
.aryacoin
;
1991 name: "AUR - Auroracoin",
1992 onSelect: function() {
1993 network
= bitcoinjs
.bitcoin
.networks
.auroracoin
;
1999 onSelect: function() {
2000 network
= bitcoinjs
.bitcoin
.networks
.axe
;
2005 name: "ANON - ANON",
2006 onSelect: function() {
2007 network
= bitcoinjs
.bitcoin
.networks
.anon
;
2012 name: "BOLI - Bolivarcoin",
2013 onSelect: function() {
2014 network
= bitcoinjs
.bitcoin
.networks
.bolivarcoin
;
2019 name: "BCA - Bitcoin Atom",
2020 onSelect: function() {
2021 network
= bitcoinjs
.bitcoin
.networks
.atom
;
2026 name: "BCH - Bitcoin Cash",
2027 onSelect: function() {
2028 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2033 name: "BEET - Beetlecoin",
2034 onSelect: function() {
2035 network
= bitcoinjs
.bitcoin
.networks
.beetlecoin
;
2040 name: "BELA - Belacoin",
2041 onSelect: function() {
2042 network
= bitcoinjs
.bitcoin
.networks
.belacoin
;
2047 name: "BLK - BlackCoin",
2048 onSelect: function() {
2049 network
= bitcoinjs
.bitcoin
.networks
.blackcoin
;
2054 name: "BND - Blocknode",
2055 onSelect: function() {
2056 network
= bitcoinjs
.bitcoin
.networks
.blocknode
;
2061 name: "tBND - Blocknode Testnet",
2062 onSelect: function() {
2063 network
= bitcoinjs
.bitcoin
.networks
.blocknode_testnet
;
2068 name: "BRIT - Britcoin",
2069 onSelect: function() {
2070 network
= bitcoinjs
.bitcoin
.networks
.britcoin
;
2075 name: "BSD - Bitsend",
2076 onSelect: function() {
2077 network
= bitcoinjs
.bitcoin
.networks
.bitsend
;
2082 name: "BST - BlockStamp",
2083 onSelect: function() {
2084 network
= bitcoinjs
.bitcoin
.networks
.blockstamp
;
2090 onSelect: function() {
2091 network
= bitcoinjs
.bitcoin
.networks
.bata
;
2096 name: "BTC - Bitcoin",
2097 onSelect: function() {
2098 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2103 name: "BTC - Bitcoin RegTest",
2104 onSelect: function() {
2105 network
= bitcoinjs
.bitcoin
.networks
.regtest
;
2106 // Using hd coin value 1 based on bip44_coin_type
2107 // https://github.com/chaintope/bitcoinrb/blob/f1014406f6b8f9b4edcecedc18df70c80df06f11/lib/bitcoin/chainparams/regtest.yml
2112 name: "BTC - Bitcoin Testnet",
2113 onSelect: function() {
2114 network
= bitcoinjs
.bitcoin
.networks
.testnet
;
2119 name: "BITG - Bitcoin Green",
2120 onSelect: function() {
2121 network
= bitcoinjs
.bitcoin
.networks
.bitcoingreen
;
2126 name: "BTCP - Bitcoin Private",
2127 onSelect: function() {
2128 network
= bitcoinjs
.bitcoin
.networks
.bitcoinprivate
;
2133 name: "BSV - BitcoinSV",
2134 onSelect: function() {
2135 network
= bitcoinjs
.bitcoin
.networks
.bitcoinsv
;
2140 name: "BTCZ - Bitcoinz",
2141 onSelect: function() {
2142 network
= bitcoinjs
.bitcoin
.networks
.bitcoinz
;
2147 name: "BTDX - BitCloud",
2148 onSelect: function() {
2149 network
= bitcoinjs
.bitcoin
.networks
.bitcloud
;
2154 name: "BTG - Bitcoin Gold",
2155 onSelect: function() {
2156 network
= bitcoinjs
.bitcoin
.networks
.bgold
;
2161 name: "BTX - Bitcore",
2162 onSelect: function() {
2163 network
= bitcoinjs
.bitcoin
.networks
.bitcore
;
2168 name: "CCN - Cannacoin",
2169 onSelect: function() {
2170 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2175 name: "CESC - Cryptoescudo",
2176 onSelect: function() {
2177 network
= bitcoinjs
.bitcoin
.networks
.cannacoin
;
2182 name: "CDN - Canadaecoin",
2183 onSelect: function() {
2184 network
= bitcoinjs
.bitcoin
.networks
.canadaecoin
;
2189 name: "CLAM - Clams",
2190 onSelect: function() {
2191 network
= bitcoinjs
.bitcoin
.networks
.clam
;
2196 name: "CLO - Callisto",
2197 segwitAvailable: false,
2198 onSelect: function() {
2199 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2204 name: "CLUB - Clubcoin",
2205 onSelect: function() {
2206 network
= bitcoinjs
.bitcoin
.networks
.clubcoin
;
2211 name: "CMP - Compcoin",
2212 onSelect: function() {
2213 network
= bitcoinjs
.bitcoin
.networks
.compcoin
;
2218 name: "CPU - CPUchain",
2219 onSelect: function() {
2220 network
= bitcoinjs
.bitcoin
.networks
.cpuchain
;
2225 name: "CRAVE - Crave",
2226 onSelect: function() {
2227 network
= bitcoinjs
.bitcoin
.networks
.crave
;
2232 name: "CRW - Crown (Legacy)",
2233 onSelect: function() {
2234 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2239 name: "CRW - Crown",
2240 onSelect: function() {
2241 network
= bitcoinjs
.bitcoin
.networks
.crown
;
2246 name: "CSC - CasinoCoin",
2247 onSelect: function() {
2248 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2253 name: "DASH - Dash",
2254 onSelect: function() {
2255 network
= bitcoinjs
.bitcoin
.networks
.dash
;
2260 name: "DASH - Dash Testnet",
2261 onSelect: function() {
2262 network
= bitcoinjs
.bitcoin
.networks
.dashtn
;
2267 name: "DFC - Defcoin",
2268 onSelect: function() {
2269 network
= bitcoinjs
.bitcoin
.networks
.defcoin
;
2274 name: "DGB - Digibyte",
2275 onSelect: function() {
2276 network
= bitcoinjs
.bitcoin
.networks
.digibyte
;
2281 name: "DGC - Digitalcoin",
2282 onSelect: function() {
2283 network
= bitcoinjs
.bitcoin
.networks
.digitalcoin
;
2288 name: "DMD - Diamond",
2289 onSelect: function() {
2290 network
= bitcoinjs
.bitcoin
.networks
.diamond
;
2295 name: "DNR - Denarius",
2296 onSelect: function() {
2297 network
= bitcoinjs
.bitcoin
.networks
.denarius
;
2302 name: "DOGE - Dogecoin",
2303 onSelect: function() {
2304 network
= bitcoinjs
.bitcoin
.networks
.dogecoin
;
2309 name: "DOGEt - Dogecoin Testnet",
2310 onSelect: function() {
2311 network
= bitcoinjs
.bitcoin
.networks
.dogecointestnet
;
2316 name: "DXN - DEXON",
2317 onSelect: function() {
2318 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2323 name: "ECN - Ecoin",
2324 onSelect: function() {
2325 network
= bitcoinjs
.bitcoin
.networks
.ecoin
;
2330 name: "EDRC - Edrcoin",
2331 onSelect: function() {
2332 network
= bitcoinjs
.bitcoin
.networks
.edrcoin
;
2337 name: "EFL - Egulden",
2338 onSelect: function() {
2339 network
= bitcoinjs
.bitcoin
.networks
.egulden
;
2344 name: "ELA - Elastos",
2345 onSelect: function () {
2346 network
= bitcoinjs
.bitcoin
.networks
.elastos
;
2351 name: "ELLA - Ellaism",
2352 segwitAvailable: false,
2353 onSelect: function() {
2354 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2359 name: "EMC2 - Einsteinium",
2360 onSelect: function() {
2361 network
= bitcoinjs
.bitcoin
.networks
.einsteinium
;
2366 name: "ERC - Europecoin",
2367 onSelect: function() {
2368 network
= bitcoinjs
.bitcoin
.networks
.europecoin
;
2373 name: "EOS - EOSIO",
2374 onSelect: function() {
2375 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2380 name: "ESN - Ethersocial Network",
2381 segwitAvailable: false,
2382 onSelect: function() {
2383 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2388 name: "ETC - Ethereum Classic",
2389 segwitAvailable: false,
2390 onSelect: function() {
2391 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2396 name: "ETH - Ethereum",
2397 onSelect: function() {
2398 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2403 name: "EWT - EnergyWeb",
2404 onSelect: function() {
2405 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2410 name: "EXCL - Exclusivecoin",
2411 onSelect: function() {
2412 network
= bitcoinjs
.bitcoin
.networks
.exclusivecoin
;
2417 name: "EXCC - ExchangeCoin",
2418 onSelect: function() {
2419 network
= bitcoinjs
.bitcoin
.networks
.exchangecoin
;
2424 name: "EXP - Expanse",
2425 segwitAvailable: false,
2426 onSelect: function() {
2427 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2433 onSelect: function() {
2434 network
= bitcoinjs
.bitcoin
.networks
.fix
;
2439 name: "FIX - FIX Testnet",
2440 onSelect: function() {
2441 network
= bitcoinjs
.bitcoin
.networks
.fixtestnet
;
2446 name: "FJC - Fujicoin",
2447 onSelect: function() {
2448 network
= bitcoinjs
.bitcoin
.networks
.fujicoin
;
2453 name: "FLASH - Flashcoin",
2454 onSelect: function() {
2455 network
= bitcoinjs
.bitcoin
.networks
.flashcoin
;
2460 name: "FRST - Firstcoin",
2461 onSelect: function() {
2462 network
= bitcoinjs
.bitcoin
.networks
.firstcoin
;
2467 name: "FTC - Feathercoin",
2468 onSelect: function() {
2469 network
= bitcoinjs
.bitcoin
.networks
.feathercoin
;
2474 name: "GAME - GameCredits",
2475 onSelect: function() {
2476 network
= bitcoinjs
.bitcoin
.networks
.game
;
2481 name: "GBX - Gobyte",
2482 onSelect: function() {
2483 network
= bitcoinjs
.bitcoin
.networks
.gobyte
;
2488 name: "GCR - GCRCoin",
2489 onSelect: function() {
2490 network
= bitcoinjs
.bitcoin
.networks
.gcr
;
2495 name: "GRC - Gridcoin",
2496 onSelect: function() {
2497 network
= bitcoinjs
.bitcoin
.networks
.gridcoin
;
2502 name: "GRS - Groestlcoin",
2503 onSelect: function() {
2504 network
= bitcoinjs
.bitcoin
.networks
.groestlcoin
;
2509 name: "GRS - Groestlcoin Testnet",
2510 onSelect: function() {
2511 network
= bitcoinjs
.bitcoin
.networks
.groestlcointestnet
;
2516 name: "HNC - Helleniccoin",
2517 onSelect: function() {
2518 network
= bitcoinjs
.bitcoin
.networks
.helleniccoin
;
2523 name: "HUSH - Hush (Legacy)",
2524 onSelect: function() {
2525 network
= bitcoinjs
.bitcoin
.networks
.hush
;
2530 name: "HUSH - Hush3",
2531 onSelect: function() {
2532 network
= bitcoinjs
.bitcoin
.networks
.hush3
;
2537 name: "INSN - Insane",
2538 onSelect: function() {
2539 network
= bitcoinjs
.bitcoin
.networks
.insane
;
2545 onSelect: function() {
2546 network
= bitcoinjs
.bitcoin
.networks
.iop
;
2551 name: "IXC - Ixcoin",
2552 onSelect: function() {
2553 network
= bitcoinjs
.bitcoin
.networks
.ixcoin
;
2558 name: "JBS - Jumbucks",
2559 onSelect: function() {
2560 network
= bitcoinjs
.bitcoin
.networks
.jumbucks
;
2565 name: "KMD - Komodo",
2566 bip49available: false,
2567 onSelect: function() {
2568 network
= bitcoinjs
.bitcoin
.networks
.komodo
;
2573 name: "KOBO - Kobocoin",
2574 bip49available: false,
2575 onSelect: function() {
2576 network
= bitcoinjs
.bitcoin
.networks
.kobocoin
;
2581 name: "LBC - Library Credits",
2582 onSelect: function() {
2583 network
= bitcoinjs
.bitcoin
.networks
.lbry
;
2588 name: "LCC - Litecoincash",
2589 onSelect: function() {
2590 network
= bitcoinjs
.bitcoin
.networks
.litecoincash
;
2595 name: "LDCN - Landcoin",
2596 onSelect: function() {
2597 network
= bitcoinjs
.bitcoin
.networks
.landcoin
;
2602 name: "LINX - Linx",
2603 onSelect: function() {
2604 network
= bitcoinjs
.bitcoin
.networks
.linx
;
2609 name: "LKR - Lkrcoin",
2610 segwitAvailable: false,
2611 onSelect: function() {
2612 network
= bitcoinjs
.bitcoin
.networks
.lkrcoin
;
2617 name: "LTC - Litecoin",
2618 onSelect: function() {
2619 network
= bitcoinjs
.bitcoin
.networks
.litecoin
;
2621 DOM
.litecoinLtubContainer
.removeClass("hidden");
2625 name: "LTCt - Litecoin Testnet",
2626 onSelect: function() {
2627 network
= bitcoinjs
.bitcoin
.networks
.litecointestnet
;
2629 DOM
.litecoinLtubContainer
.removeClass("hidden");
2633 name: "LTZ - LitecoinZ",
2634 onSelect: function() {
2635 network
= bitcoinjs
.bitcoin
.networks
.litecoinz
;
2640 name: "LYNX - Lynx",
2641 onSelect: function() {
2642 network
= bitcoinjs
.bitcoin
.networks
.lynx
;
2647 name: "MAZA - Maza",
2648 onSelect: function() {
2649 network
= bitcoinjs
.bitcoin
.networks
.maza
;
2654 name: "MEC - Megacoin",
2655 onSelect: function() {
2656 network
= bitcoinjs
.bitcoin
.networks
.megacoin
;
2662 segwitAvailable: false,
2663 onSelect: function() {
2664 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2669 name: "MNX - Minexcoin",
2670 onSelect: function() {
2671 network
= bitcoinjs
.bitcoin
.networks
.minexcoin
;
2676 name: "MONA - Monacoin",
2677 onSelect: function() {
2678 network
= bitcoinjs
.bitcoin
.networks
.monacoin
,
2683 name: "MONK - Monkey Project",
2684 onSelect: function() {
2685 network
= bitcoinjs
.bitcoin
.networks
.monkeyproject
,
2690 name: "MUSIC - Musicoin",
2691 segwitAvailable: false,
2692 onSelect: function() {
2693 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2698 name: "NAV - Navcoin",
2699 onSelect: function() {
2700 network
= bitcoinjs
.bitcoin
.networks
.navcoin
;
2705 name: "NAS - Nebulas",
2706 onSelect: function() {
2707 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2712 name: "NEBL - Neblio",
2713 onSelect: function() {
2714 network
= bitcoinjs
.bitcoin
.networks
.neblio
;
2719 name: "NEOS - Neoscoin",
2720 onSelect: function() {
2721 network
= bitcoinjs
.bitcoin
.networks
.neoscoin
;
2726 name: "NIX - NIX Platform",
2727 onSelect: function() {
2728 network
= bitcoinjs
.bitcoin
.networks
.nix
;
2733 name: "NLG - Gulden",
2734 onSelect: function() {
2735 network
= bitcoinjs
.bitcoin
.networks
.gulden
;
2740 name: "NMC - Namecoin",
2741 onSelect: function() {
2742 network
= bitcoinjs
.bitcoin
.networks
.namecoin
;
2747 name: "NRG - Energi",
2748 onSelect: function() {
2749 network
= bitcoinjs
.bitcoin
.networks
.energi
;
2754 name: "NRO - Neurocoin",
2755 onSelect: function() {
2756 network
= bitcoinjs
.bitcoin
.networks
.neurocoin
;
2761 name: "NSR - Nushares",
2762 onSelect: function() {
2763 network
= bitcoinjs
.bitcoin
.networks
.nushares
;
2768 name: "NYC - Newyorkc",
2769 onSelect: function() {
2770 network
= bitcoinjs
.bitcoin
.networks
.newyorkc
;
2775 name: "NVC - Novacoin",
2776 onSelect: function() {
2777 network
= bitcoinjs
.bitcoin
.networks
.novacoin
;
2782 name: "OK - Okcash",
2783 onSelect: function() {
2784 network
= bitcoinjs
.bitcoin
.networks
.okcash
;
2789 name: "OMNI - Omnicore",
2790 onSelect: function() {
2791 network
= bitcoinjs
.bitcoin
.networks
.omnicore
;
2796 name: "ONION - DeepOnion",
2797 onSelect: function() {
2798 network
= bitcoinjs
.bitcoin
.networks
.deeponion
;
2803 name: "ONX - Onixcoin",
2804 onSelect: function() {
2805 network
= bitcoinjs
.bitcoin
.networks
.onixcoin
;
2810 name: "PHR - Phore",
2811 onSelect: function() {
2812 network
= bitcoinjs
.bitcoin
.networks
.phore
;
2817 name: "PINK - Pinkcoin",
2818 onSelect: function() {
2819 network
= bitcoinjs
.bitcoin
.networks
.pinkcoin
;
2824 name: "PIRL - Pirl",
2825 segwitAvailable: false,
2826 onSelect: function() {
2827 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2832 name: "PIVX - PIVX",
2833 onSelect: function() {
2834 network
= bitcoinjs
.bitcoin
.networks
.pivx
;
2839 name: "PIVX - PIVX Testnet",
2840 onSelect: function() {
2841 network
= bitcoinjs
.bitcoin
.networks
.pivxtestnet
;
2847 segwitAvailable: false,
2848 onSelect: function() {
2849 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
2854 name: "POSW - POSWcoin",
2855 onSelect: function() {
2856 network
= bitcoinjs
.bitcoin
.networks
.poswcoin
;
2861 name: "POT - Potcoin",
2862 onSelect: function() {
2863 network
= bitcoinjs
.bitcoin
.networks
.potcoin
;
2868 name: "PPC - Peercoin",
2869 onSelect: function() {
2870 network
= bitcoinjs
.bitcoin
.networks
.peercoin
;
2875 name: "PRJ - ProjectCoin",
2876 onSelect: function() {
2877 network
= bitcoinjs
.bitcoin
.networks
.projectcoin
;
2882 name: "PSB - Pesobit",
2883 onSelect: function() {
2884 network
= bitcoinjs
.bitcoin
.networks
.pesobit
;
2889 name: "PUT - Putincoin",
2890 onSelect: function() {
2891 network
= bitcoinjs
.bitcoin
.networks
.putincoin
;
2896 name: "RPD - Rapids",
2897 onSelect: function() {
2898 network
= bitcoinjs
.bitcoin
.networks
.rapids
;
2903 name: "RVN - Ravencoin",
2904 onSelect: function() {
2905 network
= bitcoinjs
.bitcoin
.networks
.ravencoin
;
2910 name: "RBY - Rubycoin",
2911 onSelect: function() {
2912 network
= bitcoinjs
.bitcoin
.networks
.rubycoin
;
2917 name: "RDD - Reddcoin",
2918 onSelect: function() {
2919 network
= bitcoinjs
.bitcoin
.networks
.reddcoin
;
2924 name: "RVR - RevolutionVR",
2925 onSelect: function() {
2926 network
= bitcoinjs
.bitcoin
.networks
.revolutionvr
;
2931 name: "SAFE - Safecoin",
2932 onSelect: function() {
2933 network
= bitcoinjs
.bitcoin
.networks
.safecoin
;
2938 name: "SLS - Salus",
2939 onSelect: function() {
2940 network
= bitcoinjs
.bitcoin
.networks
.salus
;
2945 name: "SDC - ShadowCash",
2946 onSelect: function() {
2947 network
= bitcoinjs
.bitcoin
.networks
.shadow
;
2952 name: "SDC - ShadowCash Testnet",
2953 onSelect: function() {
2954 network
= bitcoinjs
.bitcoin
.networks
.shadowtn
;
2959 name: "SLM - Slimcoin",
2960 onSelect: function() {
2961 network
= bitcoinjs
.bitcoin
.networks
.slimcoin
;
2966 name: "SLM - Slimcoin Testnet",
2967 onSelect: function() {
2968 network
= bitcoinjs
.bitcoin
.networks
.slimcointn
;
2973 name: "SLP - Simple Ledger Protocol",
2974 onSelect: function() {
2975 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2980 name: "SLR - Solarcoin",
2981 onSelect: function() {
2982 network
= bitcoinjs
.bitcoin
.networks
.solarcoin
;
2987 name: "SMLY - Smileycoin",
2988 onSelect: function() {
2989 network
= bitcoinjs
.bitcoin
.networks
.smileycoin
;
2994 name: "STASH - Stash",
2995 onSelect: function() {
2996 network
= bitcoinjs
.bitcoin
.networks
.stash
;
3001 name: "STASH - Stash Testnet",
3002 onSelect: function() {
3003 network
= bitcoinjs
.bitcoin
.networks
.stashtn
;
3008 name: "STRAT - Stratis",
3009 onSelect: function() {
3010 network
= bitcoinjs
.bitcoin
.networks
.stratis
;
3015 name: "TSTRAT - Stratis Testnet",
3016 onSelect: function() {
3017 network
= bitcoinjs
.bitcoin
.networks
.stratistest
;
3022 name: "SYS - Syscoin",
3023 onSelect: function() {
3024 network
= bitcoinjs
.bitcoin
.networks
.syscoin
;
3029 name: "THC - Hempcoin",
3030 onSelect: function() {
3031 network
= bitcoinjs
.bitcoin
.networks
.hempcoin
;
3036 name: "THT - Thought",
3037 onSelect: function() {
3038 network
= bitcoinjs
.bitcoin
.networks
.thought
;
3044 onSelect: function() {
3045 network
= bitcoinjs
.bitcoin
.networks
.toa
;
3050 name: "TWINS - TWINS",
3051 onSelect: function() {
3052 network
= bitcoinjs
.bitcoin
.networks
.twins
;
3057 name: "TWINS - TWINS Testnet",
3058 onSelect: function() {
3059 network
= bitcoinjs
.bitcoin
.networks
.twinstestnet
;
3064 name: "USC - Ultimatesecurecash",
3065 onSelect: function() {
3066 network
= bitcoinjs
.bitcoin
.networks
.ultimatesecurecash
;
3071 name: "USNBT - NuBits",
3072 onSelect: function() {
3073 network
= bitcoinjs
.bitcoin
.networks
.nubits
;
3078 name: "UNO - Unobtanium",
3079 onSelect: function() {
3080 network
= bitcoinjs
.bitcoin
.networks
.unobtanium
;
3085 name: "VASH - Vpncoin",
3086 onSelect: function() {
3087 network
= bitcoinjs
.bitcoin
.networks
.vpncoin
;
3092 name: "VET - VeChain",
3093 onSelect: function() {
3094 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
3099 name: "VIA - Viacoin",
3100 onSelect: function() {
3101 network
= bitcoinjs
.bitcoin
.networks
.viacoin
;
3106 name: "VIA - Viacoin Testnet",
3107 onSelect: function() {
3108 network
= bitcoinjs
.bitcoin
.networks
.viacointestnet
;
3113 name: "VIVO - Vivo",
3114 onSelect: function() {
3115 network
= bitcoinjs
.bitcoin
.networks
.vivo
;
3120 name: "VTC - Vertcoin",
3121 onSelect: function() {
3122 network
= bitcoinjs
.bitcoin
.networks
.vertcoin
;
3127 name: "WGR - Wagerr",
3128 onSelect: function() {
3129 network
= bitcoinjs
.bitcoin
.networks
.wagerr
;
3134 name: "WC - Wincoin",
3135 onSelect: function() {
3136 network
= bitcoinjs
.bitcoin
.networks
.wincoin
;
3141 name: "XAX - Artax",
3142 onSelect: function() {
3143 network
= bitcoinjs
.bitcoin
.networks
.artax
;
3148 name: "XBC - Bitcoinplus",
3149 onSelect: function() {
3150 network
= bitcoinjs
.bitcoin
.networks
.bitcoinplus
;
3155 name: "XLM - Stellar",
3156 onSelect: function() {
3157 network
= stellarUtil
.dummyNetwork
;
3162 name: "XMY - Myriadcoin",
3163 onSelect: function() {
3164 network
= bitcoinjs
.bitcoin
.networks
.myriadcoin
;
3169 name: "XRP - Ripple",
3170 onSelect: function() {
3171 network
= bitcoinjs
.bitcoin
.networks
.bitcoin
;
3176 name: "XVC - Vcash",
3177 onSelect: function() {
3178 network
= bitcoinjs
.bitcoin
.networks
.vcash
;
3183 name: "XVG - Verge",
3184 onSelect: function() {
3185 network
= bitcoinjs
.bitcoin
.networks
.verge
;
3190 name: "XUEZ - Xuez",
3191 segwitAvailable: false,
3192 onSelect: function() {
3193 network
= bitcoinjs
.bitcoin
.networks
.xuez
;
3198 name: "XWC - Whitecoin",
3199 onSelect: function() {
3200 network
= bitcoinjs
.bitcoin
.networks
.whitecoin
;
3205 name: "XZC - Zcoin",
3206 onSelect: function() {
3207 network
= bitcoinjs
.bitcoin
.networks
.zcoin
;
3212 name: "ZCL - Zclassic",
3213 onSelect: function() {
3214 network
= bitcoinjs
.bitcoin
.networks
.zclassic
;
3219 name: "ZEC - Zcash",
3220 onSelect: function() {
3221 network
= bitcoinjs
.bitcoin
.networks
.zcash
;
3226 name: "ZEN - Horizen",
3227 onSelect: function() {
3228 network
= bitcoinjs
.bitcoin
.networks
.zencash
;
3236 name: "Bitcoin Core",
3237 onSelect: function() {
3238 DOM
.bip32path
.val("m/0'/0'");
3239 DOM
.hardenedAddresses
.prop('checked', true);
3243 name: "blockchain.info",
3244 onSelect: function() {
3245 DOM
.bip32path
.val("m/44'/0'/0'");
3246 DOM
.hardenedAddresses
.prop('checked', false);
3250 name: "MultiBit HD",
3251 onSelect: function() {
3252 DOM
.bip32path
.val("m/0'/0");
3253 DOM
.hardenedAddresses
.prop('checked', false);
3257 name: "Coinomi, Ledger",
3258 onSelect: function() {
3259 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
3260 DOM
.hardenedAddresses
.prop('checked', false);
3265 // ELA - Elastos functions - begin
3266 function displayBip44InfoForELA() {
3271 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
3272 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
3274 // Calculate the account extended keys
3275 var accountXprv
= elastosjs
.getAccountExtendedPrivateKey(seed
, coin
, account
);
3276 var accountXpub
= elastosjs
.getAccountExtendedPublicKey(seed
, coin
, account
);
3278 // Display the extended keys
3279 DOM
.bip44accountXprv
.val(accountXprv
);
3280 DOM
.bip44accountXpub
.val(accountXpub
);
3283 function displayBip32InfoForELA() {
3288 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
3289 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
3290 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
3292 DOM
.extendedPrivKey
.val(elastosjs
.getBip32ExtendedPrivateKey(seed
, coin
, account
, change
));
3293 DOM
.extendedPubKey
.val(elastosjs
.getBip32ExtendedPublicKey(seed
, coin
, account
, change
));
3295 // Display the addresses and privkeys
3296 clearAddressesList();
3297 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
3298 displayAddresses(0, initialAddressCount
);
3301 function calcAddressForELA(seed
, coin
, account
, change
, index
) {
3306 var publicKey
= elastosjs
.getDerivedPublicKey(elastosjs
.getMasterPublicKey(seed
), change
, index
);
3308 privateKey: elastosjs
.getDerivedPrivateKey(seed
, coin
, account
, change
, index
),
3309 publicKey: publicKey
,
3310 address: elastosjs
.getAddress(publicKey
.toString('hex'))
3313 // ELA - Elastos functions - end