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;
18 var isDefaultBip44ChangeValue
= true;
20 var entropyTypeAutoDetect
= true;
21 var entropyChangeTimeoutEvent
= null;
22 var phraseChangeTimeoutEvent
= null;
23 var seedChangedTimeoutEvent
= null;
24 var rootKeyChangedTimeoutEvent
= null;
26 var generationProcesses
= [];
29 DOM
.privacyScreenToggle
= $(".privacy-screen-toggle");
30 DOM
.network
= $(".network");
31 DOM
.bip32Client
= $("#bip32-client");
32 DOM
.phraseNetwork
= $("#network-phrase");
33 DOM
.useEntropy
= $(".use-entropy");
34 DOM
.entropyContainer
= $(".entropy-container");
35 DOM
.entropy
= $(".entropy");
36 DOM
.entropyFiltered
= DOM
.entropyContainer
.find(".filtered");
37 DOM
.entropyType
= DOM
.entropyContainer
.find(".type");
38 DOM
.entropyTypeInputs
= DOM
.entropyContainer
.find("input[name='entropy-type']");
39 DOM
.entropyCrackTime
= DOM
.entropyContainer
.find(".crack-time");
40 DOM
.entropyEventCount
= DOM
.entropyContainer
.find(".event-count");
41 DOM
.entropyBits
= DOM
.entropyContainer
.find(".bits");
42 DOM
.entropyBitsPerEvent
= DOM
.entropyContainer
.find(".bits-per-event");
43 DOM
.entropyWordCount
= DOM
.entropyContainer
.find(".word-count");
44 DOM
.entropyBinary
= DOM
.entropyContainer
.find(".binary");
45 DOM
.entropyWordIndexes
= DOM
.entropyContainer
.find(".word-indexes");
46 DOM
.entropyChecksum
= DOM
.entropyContainer
.find(".checksum");
47 DOM
.entropyMnemonicLength
= DOM
.entropyContainer
.find(".mnemonic-length");
48 DOM
.entropyWeakEntropyOverrideWarning
= DOM
.entropyContainer
.find(".weak-entropy-override-warning");
49 DOM
.entropyFilterWarning
= DOM
.entropyContainer
.find(".filter-warning");
50 DOM
.phrase
= $(".phrase");
51 DOM
.phraseSplit
= $(".phraseSplit");
52 DOM
.phraseSplitWarn
= $(".phraseSplitWarn");
53 DOM
.passphrase
= $(".passphrase");
54 DOM
.generateContainer
= $(".generate-container");
55 DOM
.generate
= $(".generate");
56 DOM
.seed
= $(".seed");
57 DOM
.rootKey
= $(".root-key");
58 DOM
.litecoinLtubContainer
= $(".litecoin-ltub-container");
59 DOM
.litecoinUseLtub
= $(".litecoin-use-ltub");
60 DOM
.extendedPrivKey
= $(".extended-priv-key");
61 DOM
.extendedPubKey
= $(".extended-pub-key");
62 DOM
.bip32tab
= $("#bip32-tab");
63 DOM
.bip44tab
= $("#bip44-tab");
64 DOM
.bip49tab
= $("#bip49-tab");
65 DOM
.bip84tab
= $("#bip84-tab");
66 DOM
.bip141tab
= $("#bip141-tab");
67 DOM
.bip32panel
= $("#bip32");
68 DOM
.bip44panel
= $("#bip44");
69 DOM
.bip49panel
= $("#bip49");
70 DOM
.bip32path
= $("#bip32-path");
71 DOM
.bip44path
= $("#bip44-path");
72 DOM
.bip44purpose
= $("#bip44 .purpose");
73 DOM
.bip44coin
= $("#bip44 .coin");
74 DOM
.bip44account
= $("#bip44 .account");
75 DOM
.bip44accountXprv
= $("#bip44 .account-xprv");
76 DOM
.bip44accountXpub
= $("#bip44 .account-xpub");
77 DOM
.bip44change
= $("#bip44 .change");
78 DOM
.defaultBip44ChangeValue
= $("#bip44 .default-bip44-change-value");
79 DOM
.bip49unavailable
= $("#bip49 .unavailable");
80 DOM
.bip49available
= $("#bip49 .available");
81 DOM
.bip49path
= $("#bip49-path");
82 DOM
.bip49purpose
= $("#bip49 .purpose");
83 DOM
.bip49coin
= $("#bip49 .coin");
84 DOM
.bip49account
= $("#bip49 .account");
85 DOM
.bip49accountXprv
= $("#bip49 .account-xprv");
86 DOM
.bip49accountXpub
= $("#bip49 .account-xpub");
87 DOM
.bip49change
= $("#bip49 .change");
88 DOM
.bip84unavailable
= $("#bip84 .unavailable");
89 DOM
.bip84available
= $("#bip84 .available");
90 DOM
.bip84path
= $("#bip84-path");
91 DOM
.bip84purpose
= $("#bip84 .purpose");
92 DOM
.bip84coin
= $("#bip84 .coin");
93 DOM
.bip84account
= $("#bip84 .account");
94 DOM
.bip84accountXprv
= $("#bip84 .account-xprv");
95 DOM
.bip84accountXpub
= $("#bip84 .account-xpub");
96 DOM
.bip84change
= $("#bip84 .change");
97 DOM
.bip141unavailable
= $("#bip141 .unavailable");
98 DOM
.bip141available
= $("#bip141 .available");
99 DOM
.bip141path
= $("#bip141-path");
100 DOM
.bip141semantics
= $(".bip141-semantics");
101 DOM
.generatedStrength
= $(".generate-container .strength");
102 DOM
.generatedStrengthWarning
= $(".generate-container .warning");
103 DOM
.hardenedAddresses
= $(".hardened-addresses");
104 DOM
.bitcoinCashAddressTypeContainer
= $(".bch-addr-type-container");
105 DOM
.bitcoinCashAddressType
= $("[name=bch-addr-type]")
106 DOM
.useBip38
= $(".use-bip38");
107 DOM
.bip38Password
= $(".bip38-password");
108 DOM
.addresses
= $(".addresses");
109 DOM
.csvTab
= $("#csv-tab a");
111 DOM
.rowsToAdd
= $(".rows-to-add");
112 DOM
.more
= $(".more");
113 DOM
.moreRowsStartIndex
= $(".more-rows-start-index");
114 DOM
.feedback
= $(".feedback");
115 DOM
.tab
= $(".derivation-type a");
116 DOM
.indexToggle
= $(".index-toggle");
117 DOM
.addressToggle
= $(".address-toggle");
118 DOM
.publicKeyToggle
= $(".public-key-toggle");
119 DOM
.privateKeyToggle
= $(".private-key-toggle");
120 DOM
.languages
= $(".languages a");
121 DOM
.qrContainer
= $(".qr-container");
122 DOM
.qrHider
= DOM
.qrContainer
.find(".qr-hider");
123 DOM
.qrImage
= DOM
.qrContainer
.find(".qr-image");
124 DOM
.qrHint
= DOM
.qrContainer
.find(".qr-hint");
125 DOM
.showQrEls
= $("[data-show-qr]");
129 DOM
.privacyScreenToggle
.on("change", privacyScreenToggled
);
130 DOM
.generatedStrength
.on("change", generatedStrengthChanged
);
131 DOM
.network
.on("change", networkChanged
);
132 DOM
.bip32Client
.on("change", bip32ClientChanged
);
133 DOM
.useEntropy
.on("change", setEntropyVisibility
);
134 DOM
.entropy
.on("input", delayedEntropyChanged
);
135 DOM
.entropyMnemonicLength
.on("change", entropyChanged
);
136 DOM
.entropyTypeInputs
.on("change", entropyTypeChanged
);
137 DOM
.phrase
.on("input", delayedPhraseChanged
);
138 DOM
.passphrase
.on("input", delayedPhraseChanged
);
139 DOM
.generate
.on("click", generateClicked
);
140 DOM
.more
.on("click", showMore
);
141 DOM
.seed
.on("input", delayedSeedChanged
);
142 DOM
.rootKey
.on("input", delayedRootKeyChanged
);
143 DOM
.litecoinUseLtub
.on("change", litecoinUseLtubChanged
);
144 DOM
.bip32path
.on("input", calcForDerivationPath
);
145 DOM
.bip44account
.on("input", calcForDerivationPath
);
146 DOM
.bip44change
.on("input", modifiedDefaultBip44ChangeValue
);
147 DOM
.bip44change
.on("input", calcForDerivationPath
);
148 DOM
.defaultBip44ChangeValue
.on("click", resetDefaultBip44ChangeValue
);
149 DOM
.bip49account
.on("input", calcForDerivationPath
);
150 DOM
.bip49change
.on("input", calcForDerivationPath
);
151 DOM
.bip84account
.on("input", calcForDerivationPath
);
152 DOM
.bip84change
.on("input", calcForDerivationPath
);
153 DOM
.bip141path
.on("input", calcForDerivationPath
);
154 DOM
.bip141semantics
.on("change", tabChanged
);
155 DOM
.tab
.on("shown.bs.tab", tabChanged
);
156 DOM
.hardenedAddresses
.on("change", calcForDerivationPath
);
157 DOM
.useBip38
.on("change", calcForDerivationPath
);
158 DOM
.bip38Password
.on("change", calcForDerivationPath
);
159 DOM
.indexToggle
.on("click", toggleIndexes
);
160 DOM
.addressToggle
.on("click", toggleAddresses
);
161 DOM
.publicKeyToggle
.on("click", togglePublicKeys
);
162 DOM
.privateKeyToggle
.on("click", togglePrivateKeys
);
163 DOM
.csvTab
.on("click", updateCsv
);
164 DOM
.languages
.on("click", languageChanged
);
165 DOM
.bitcoinCashAddressType
.on("change", bitcoinCashAddressTypeChange
);
166 setQrEvents(DOM
.showQrEls
);
169 hideValidationError();
170 populateNetworkSelect();
171 populateClientSelect();
176 function generatedStrengthChanged() {
177 var strength
= parseInt(DOM
.generatedStrength
.val());
179 DOM
.generatedStrengthWarning
.removeClass("hidden");
182 DOM
.generatedStrengthWarning
.addClass("hidden");
186 function networkChanged(e
) {
188 clearAddressesList();
189 DOM
.litecoinLtubContainer
.addClass("hidden");
190 DOM
.bitcoinCashAddressTypeContainer
.addClass("hidden");
191 var networkIndex
= e
.target
.value
;
192 var network
= networks
[networkIndex
];
194 adjustNetworkForSegwit();
203 function bip32ClientChanged(e
) {
204 var clientIndex
= DOM
.bip32Client
.val();
205 if (clientIndex
== "custom") {
206 DOM
.bip32path
.prop("readonly", false);
209 DOM
.bip32path
.prop("readonly", true);
210 clients
[clientIndex
].onSelect();
220 function setEntropyVisibility() {
221 if (isUsingOwnEntropy()) {
222 DOM
.entropyContainer
.removeClass("hidden");
223 DOM
.generateContainer
.addClass("hidden");
224 DOM
.phrase
.prop("readonly", true);
229 DOM
.entropyContainer
.addClass("hidden");
230 DOM
.generateContainer
.removeClass("hidden");
231 DOM
.phrase
.prop("readonly", false);
236 function delayedPhraseChanged() {
237 hideValidationError();
240 bip32ExtendedKey
= null;
241 clearAddressesList();
243 if (phraseChangeTimeoutEvent
!= null) {
244 clearTimeout(phraseChangeTimeoutEvent
);
246 phraseChangeTimeoutEvent
= setTimeout(function() {
248 var entropy
= mnemonic
.toRawEntropyHex(DOM
.phrase
.val());
249 if (entropy
!== null) {
250 DOM
.entropyMnemonicLength
.val("raw");
251 DOM
.entropy
.val(entropy
);
252 DOM
.entropyTypeInputs
.filter("[value='hexadecimal']").prop("checked", true);
253 entropyTypeAutoDetect
= false;
258 function phraseChanged() {
260 setMnemonicLanguage();
261 // Get the mnemonic phrase
262 var phrase
= DOM
.phrase
.val();
263 var errorText
= findPhraseErrors(phrase
);
265 showValidationError(errorText
);
268 // Calculate and display
269 var passphrase
= DOM
.passphrase
.val();
270 calcBip32RootKeyFromSeed(phrase
, passphrase
);
271 calcForDerivationPath();
272 // Show the word indexes
274 writeSplitPhrase(phrase
);
277 function tabChanged() {
279 adjustNetworkForSegwit();
280 var phrase
= DOM
.phrase
.val();
282 // Calculate and display for mnemonic
283 var errorText
= findPhraseErrors(phrase
);
285 showValidationError(errorText
);
288 // Calculate and display
289 var passphrase
= DOM
.passphrase
.val();
290 calcBip32RootKeyFromSeed(phrase
, passphrase
);
293 // Calculate and display for root key
294 var rootKeyBase58
= DOM
.rootKey
.val();
295 var errorText
= validateRootKey(rootKeyBase58
);
297 showValidationError(errorText
);
300 // Calculate and display
301 calcBip32RootKeyFromBase58(rootKeyBase58
);
303 calcForDerivationPath();
306 function delayedEntropyChanged() {
307 hideValidationError();
309 if (entropyChangeTimeoutEvent
!= null) {
310 clearTimeout(entropyChangeTimeoutEvent
);
312 entropyChangeTimeoutEvent
= setTimeout(entropyChanged
, 400);
315 function entropyChanged() {
316 // If blank entropy, clear mnemonic, addresses, errors
317 if (DOM
.entropy
.val().trim().length
== 0) {
319 clearEntropyFeedback();
321 DOM
.phraseSplit
.val("");
322 showValidationError("Blank entropy");
325 // Get the current phrase to detect changes
326 var phrase
= DOM
.phrase
.val();
327 // Set the phrase from the entropy
328 setMnemonicFromEntropy();
329 // Recalc addresses if the phrase has changed
330 var newPhrase
= DOM
.phrase
.val();
331 if (newPhrase
!= phrase
) {
332 if (newPhrase
.length
== 0) {
344 function entropyTypeChanged() {
345 entropyTypeAutoDetect
= false;
349 function delayedSeedChanged() {
350 // Warn if there is an existing mnemonic or passphrase.
351 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
352 if (!confirm("This will clear existing mnemonic and passphrase")) {
357 hideValidationError();
359 // Clear existing mnemonic and passphrase
361 DOM
.phraseSplit
.val("");
362 DOM
.passphrase
.val("");
364 clearAddressesList();
367 if (seedChangedTimeoutEvent
!= null) {
368 clearTimeout(seedChangedTimeoutEvent
);
370 seedChangedTimeoutEvent
= setTimeout(seedChanged
, 400);
373 function delayedRootKeyChanged() {
374 // Warn if there is an existing mnemonic or passphrase.
375 if (DOM
.phrase
.val().length
> 0 || DOM
.passphrase
.val().length
> 0) {
376 if (!confirm("This will clear existing mnemonic and passphrase")) {
377 DOM
.rootKey
.val(bip32RootKey
);
381 hideValidationError();
383 // Clear existing mnemonic and passphrase
385 DOM
.phraseSplit
.val("");
386 DOM
.passphrase
.val("");
388 if (rootKeyChangedTimeoutEvent
!= null) {
389 clearTimeout(rootKeyChangedTimeoutEvent
);
391 rootKeyChangedTimeoutEvent
= setTimeout(rootKeyChanged
, 400);
394 function seedChanged() {
396 hideValidationError();
397 seed
= DOM
.seed
.val();
398 bip32RootKey
= libs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
399 var rootKeyBase58
= bip32RootKey
.toBase58();
400 DOM
.rootKey
.val(rootKeyBase58
);
401 var errorText
= validateRootKey(rootKeyBase58
);
403 showValidationError(errorText
);
406 // Calculate and display
407 calcForDerivationPath();
410 function rootKeyChanged() {
412 hideValidationError();
413 var rootKeyBase58
= DOM
.rootKey
.val();
414 var errorText
= validateRootKey(rootKeyBase58
);
416 showValidationError(errorText
);
419 // Calculate and display
420 calcBip32RootKeyFromBase58(rootKeyBase58
);
421 calcForDerivationPath();
424 function litecoinUseLtubChanged() {
425 litecoinUseLtub
= DOM
.litecoinUseLtub
.prop("checked");
426 if (litecoinUseLtub
) {
427 network
= libs
.bitcoin
.networks
.litecoin
;
430 network
= libs
.bitcoin
.networks
.litecoinXprv
;
435 function calcForDerivationPath() {
437 clearAddressesList();
439 // Don't show segwit if it's selected but network doesn't support it
440 if (segwitSelected() && !networkHasSegwit()) {
441 showSegwitUnavailable();
445 showSegwitAvailable();
446 // Get the derivation path
447 var derivationPath
= getDerivationPath();
448 var errorText
= findDerivationPathErrors(derivationPath
);
450 showValidationError(errorText
);
453 bip32ExtendedKey
= calcBip32ExtendedKey(derivationPath
);
454 if (bip44TabSelected()) {
457 else if (bip49TabSelected()) {
460 else if (bip84TabSelected()) {
466 function generateClicked() {
467 if (isUsingOwnEntropy()) {
472 setTimeout(function() {
473 setMnemonicLanguage();
474 var phrase
= generateRandomPhrase();
482 function languageChanged() {
483 setTimeout(function() {
484 setMnemonicLanguage();
485 if (DOM
.phrase
.val().length
> 0) {
486 var newPhrase
= convertPhraseToNewLanguage();
487 DOM
.phrase
.val(newPhrase
);
491 DOM
.generate
.trigger("click");
496 function bitcoinCashAddressTypeChange() {
500 function toggleIndexes() {
501 showIndex
= !showIndex
;
502 $("td.index span").toggleClass("invisible");
505 function toggleAddresses() {
506 showAddress
= !showAddress
;
507 $("td.address span").toggleClass("invisible");
510 function togglePublicKeys() {
511 showPubKey
= !showPubKey
;
512 $("td.pubkey span").toggleClass("invisible");
515 function togglePrivateKeys() {
516 showPrivKey
= !showPrivKey
;
517 $("td.privkey span").toggleClass("invisible");
520 function privacyScreenToggled() {
521 // private-data contains elements added to DOM at runtime
522 // so catch all by adding visual privacy class to the root of the DOM
523 if (DOM
.privacyScreenToggle
.prop("checked")) {
524 $("body").addClass("visual-privacy");
527 $("body").removeClass("visual-privacy");
533 function generateRandomPhrase() {
534 if (!hasStrongRandom()) {
535 var errorText
= "This browser does not support strong randomness";
536 showValidationError(errorText
);
539 // get the amount of entropy to use
540 var numWords
= parseInt(DOM
.generatedStrength
.val());
541 var strength
= numWords
/ 3 * 32;
542 var buffer
= new Uint8Array(strength
/ 8);
543 // create secure entropy
544 var data
= crypto
.getRandomValues(buffer
);
546 var words
= mnemonic
.toMnemonic(data
);
547 DOM
.phrase
.val(words
);
549 var entropyHex
= uint8ArrayToHex(data
);
550 DOM
.entropy
.val(entropyHex
);
551 // ensure entropy fields are consistent with what is being displayed
552 DOM
.entropyMnemonicLength
.val("raw");
556 function calcBip32RootKeyFromSeed(phrase
, passphrase
) {
557 seed
= mnemonic
.toSeed(phrase
, passphrase
);
558 bip32RootKey
= libs
.bitcoin
.HDNode
.fromSeedHex(seed
, network
);
560 bip32RootKey
= libs
.groestlcoinjs
.HDNode
.fromSeedHex(seed
, network
);
564 function calcBip32RootKeyFromBase58(rootKeyBase58
) {
566 calcBip32RootKeyFromBase58GRS(rootKeyBase58
);
569 // try parsing with various segwit network params since this extended
570 // key may be from any one of them.
571 if (networkHasSegwit()) {
573 if ("baseNetwork" in n
) {
574 n
= libs
.bitcoin
.networks
[n
.baseNetwork
];
576 // try parsing using base network params
578 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
582 // try parsing using p2wpkh params
585 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
590 // try parsing using p2wpkh-in-p2sh network params
591 if ("p2wpkhInP2sh" in n
) {
593 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
598 // try parsing using p2wsh network params
601 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wsh
);
606 // try parsing using p2wsh-in-p2sh network params
607 if ("p2wshInP2sh" in n
) {
609 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wshInP2sh
);
615 // try the network params as currently specified
616 bip32RootKey
= libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
619 function calcBip32RootKeyFromBase58GRS(rootKeyBase58
) {
620 // try parsing with various segwit network params since this extended
621 // key may be from any one of them.
622 if (networkHasSegwit()) {
624 if ("baseNetwork" in n
) {
625 n
= libs
.bitcoin
.networks
[n
.baseNetwork
];
627 // try parsing using base network params
629 bip32RootKey
= libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
633 // try parsing using p2wpkh params
636 bip32RootKey
= libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
641 // try parsing using p2wpkh-in-p2sh network params
642 if ("p2wpkhInP2sh" in n
) {
644 bip32RootKey
= libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
650 // try the network params as currently specified
651 bip32RootKey
= libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
654 function calcBip32ExtendedKey(path
) {
655 // Check there's a root key to derive from
659 var extendedKey
= bip32RootKey
;
660 // Derive the key from the path
661 var pathBits
= path
.split("/");
662 for (var i
=0; i
<pathBits
.length
; i
++) {
663 var bit
= pathBits
[i
];
664 var index
= parseInt(bit
);
668 var hardened
= bit
[bit
.length
-1] == "'";
669 var isPriv
= !(extendedKey
.isNeutered());
670 var invalidDerivationPath
= hardened
&& !isPriv
;
671 if (invalidDerivationPath
) {
675 extendedKey
= extendedKey
.deriveHardened(index
);
678 extendedKey
= extendedKey
.derive(index
);
684 function showValidationError(errorText
) {
690 function hideValidationError() {
696 function findPhraseErrors(phrase
) {
697 // Preprocess the words
698 phrase
= mnemonic
.normalizeString(phrase
);
699 var words
= phraseToWordArray(phrase
);
700 // Detect blank phrase
701 if (words
.length
== 0) {
702 return "Blank mnemonic";
705 for (var i
=0; i
<words
.length
; i
++) {
707 var language
= getLanguage();
708 if (WORDLISTS
[language
].indexOf(word
) == -1) {
709 console
.log("Finding closest match to " + word
);
710 var nearestWord
= findNearestWord(word
);
711 return word
+ " not in wordlist, did you mean " + nearestWord
+ "?";
714 // Check the words are valid
715 var properPhrase
= wordArrayToPhrase(words
);
716 var isValid
= mnemonic
.check(properPhrase
);
718 return "Invalid mnemonic";
723 function validateRootKey(rootKeyBase58
) {
725 return validateRootKeyGRS(rootKeyBase58
);
727 // try various segwit network params since this extended key may be from
729 if (networkHasSegwit()) {
731 if ("baseNetwork" in n
) {
732 n
= libs
.bitcoin
.networks
[n
.baseNetwork
];
734 // try parsing using base network params
736 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
);
740 // try parsing using p2wpkh params
743 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
748 // try parsing using p2wpkh-in-p2sh network params
749 if ("p2wpkhInP2sh" in n
) {
751 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
756 // try parsing using p2wsh network params
759 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wsh
);
764 // try parsing using p2wsh-in-p2sh network params
765 if ("p2wshInP2sh" in n
) {
767 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wshInP2sh
);
773 // try the network params as currently specified
775 libs
.bitcoin
.HDNode
.fromBase58(rootKeyBase58
, network
);
778 return "Invalid root key";
783 function validateRootKeyGRS(rootKeyBase58
) {
784 // try various segwit network params since this extended key may be from
786 if (networkHasSegwit()) {
788 if ("baseNetwork" in n
) {
789 n
= libs
.bitcoin
.networks
[n
.baseNetwork
];
791 // try parsing using base network params
793 libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
);
797 // try parsing using p2wpkh params
800 libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkh
);
805 // try parsing using p2wpkh-in-p2sh network params
806 if ("p2wpkhInP2sh" in n
) {
808 libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, n
.p2wpkhInP2sh
);
814 // try the network params as currently specified
816 libs
.groestlcoinjs
.HDNode
.fromBase58(rootKeyBase58
, network
);
819 return "Invalid root key";
824 function getDerivationPath() {
825 if (bip44TabSelected()) {
826 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
827 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
828 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
829 var change
= parseIntNoNaN(DOM
.bip44change
.val(), "");
831 path
+= "/" + purpose
+ "'";
832 path
+= "/" + coin
+ "'";
833 path
+= "/" + account
+ "'";
835 path
+= "/" + change
;
837 DOM
.bip44path
.val(path
);
838 var derivationPath
= DOM
.bip44path
.val();
839 console
.log("Using derivation path from BIP44 tab: " + derivationPath
);
840 return derivationPath
;
842 else if (bip49TabSelected()) {
843 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
844 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
845 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
846 var change
= parseIntNoNaN(DOM
.bip49change
.val(), 0);
848 path
+= purpose
+ "'/";
850 path
+= account
+ "'/";
852 DOM
.bip49path
.val(path
);
853 var derivationPath
= DOM
.bip49path
.val();
854 console
.log("Using derivation path from BIP49 tab: " + derivationPath
);
855 return derivationPath
;
857 else if (bip84TabSelected()) {
858 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
859 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
860 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
861 var change
= parseIntNoNaN(DOM
.bip84change
.val(), 0);
863 path
+= purpose
+ "'/";
865 path
+= account
+ "'/";
867 DOM
.bip84path
.val(path
);
868 var derivationPath
= DOM
.bip84path
.val();
869 console
.log("Using derivation path from BIP84 tab: " + derivationPath
);
870 return derivationPath
;
872 else if (bip32TabSelected()) {
873 var derivationPath
= DOM
.bip32path
.val();
874 console
.log("Using derivation path from BIP32 tab: " + derivationPath
);
875 return derivationPath
;
877 else if (bip141TabSelected()) {
878 var derivationPath
= DOM
.bip141path
.val();
879 console
.log("Using derivation path from BIP141 tab: " + derivationPath
);
880 return derivationPath
;
883 console
.log("Unknown derivation path");
887 function findDerivationPathErrors(path
) {
888 // TODO is not perfect but is better than nothing
890 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
892 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#extended-keys
893 var maxDepth
= 255; // TODO verify this!!
894 var maxIndexValue
= Math
.pow(2, 31); // TODO verify this!!
895 if (path
[0] != "m") {
896 return "First character must be 'm'";
898 if (path
.length
> 1) {
899 if (path
[1] != "/") {
900 return "Separator must be '/'";
902 var indexes
= path
.split("/");
903 if (indexes
.length
> maxDepth
) {
904 return "Derivation depth is " + indexes
.length
+ ", must be less than " + maxDepth
;
906 for (var depth
= 1; depth
<indexes
.length
; depth
++) {
907 var index
= indexes
[depth
];
908 var invalidChars
= index
.replace(/^[0-9]+'?$/g, "")
909 if (invalidChars
.length
> 0) {
910 return "Invalid characters " + invalidChars
+ " found at depth " + depth
;
912 var indexValue
= parseInt(index
.replace("'", ""));
914 return "Invalid number at depth " + depth
;
916 if (indexValue
> maxIndexValue
) {
917 return "Value of " + indexValue
+ " at depth " + depth
+ " must be less than " + maxIndexValue
;
921 // Check root key exists or else derivation path is useless!
923 return "No root key";
925 // Check no hardened derivation path when using xpub keys
926 var hardenedPath
= path
.indexOf("'") > -1;
927 var hardenedAddresses
= bip32TabSelected() && DOM
.hardenedAddresses
.prop("checked");
928 var hardened
= hardenedPath
|| hardenedAddresses
;
929 var isXpubkey
= bip32RootKey
.isNeutered();
930 if (hardened
&& isXpubkey
) {
931 return "Hardened derivation path is invalid with xpub key";
937 return networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin" || networks
[DOM
.network
.val()].name
== "GRS - Groestlcoin Testnet";
941 return networks
[DOM
.network
.val()].name
== "ELA - Elastos"
944 function displayBip44Info() {
945 // Get the derivation path for the account
946 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
947 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
948 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
950 path
+= purpose
+ "'/";
952 path
+= account
+ "'/";
953 // Calculate the account extended keys
954 var accountExtendedKey
= calcBip32ExtendedKey(path
);
955 var accountXprv
= accountExtendedKey
.toBase58();
956 var accountXpub
= accountExtendedKey
.neutered().toBase58();
958 // Display the extended keys
959 DOM
.bip44accountXprv
.val(accountXprv
);
960 DOM
.bip44accountXpub
.val(accountXpub
);
963 displayBip44InfoForELA();
967 function displayBip49Info() {
968 // Get the derivation path for the account
969 var purpose
= parseIntNoNaN(DOM
.bip49purpose
.val(), 49);
970 var coin
= parseIntNoNaN(DOM
.bip49coin
.val(), 0);
971 var account
= parseIntNoNaN(DOM
.bip49account
.val(), 0);
973 path
+= purpose
+ "'/";
975 path
+= account
+ "'/";
976 // Calculate the account extended keys
977 var accountExtendedKey
= calcBip32ExtendedKey(path
);
978 var accountXprv
= accountExtendedKey
.toBase58();
979 var accountXpub
= accountExtendedKey
.neutered().toBase58();
980 // Display the extended keys
981 DOM
.bip49accountXprv
.val(accountXprv
);
982 DOM
.bip49accountXpub
.val(accountXpub
);
985 function displayBip84Info() {
986 // Get the derivation path for the account
987 var purpose
= parseIntNoNaN(DOM
.bip84purpose
.val(), 84);
988 var coin
= parseIntNoNaN(DOM
.bip84coin
.val(), 0);
989 var account
= parseIntNoNaN(DOM
.bip84account
.val(), 0);
991 path
+= purpose
+ "'/";
993 path
+= account
+ "'/";
994 // Calculate the account extended keys
995 var accountExtendedKey
= calcBip32ExtendedKey(path
);
996 var accountXprv
= accountExtendedKey
.toBase58();
997 var accountXpub
= accountExtendedKey
.neutered().toBase58();
998 // Display the extended keys
999 DOM
.bip84accountXprv
.val(accountXprv
);
1000 DOM
.bip84accountXpub
.val(accountXpub
);
1003 function displayBip32Info() {
1006 var rootKey
= bip32RootKey
.toBase58();
1007 DOM
.rootKey
.val(rootKey
);
1008 var xprvkeyB58
= "NA";
1009 if (!bip32ExtendedKey
.isNeutered()) {
1010 xprvkeyB58
= bip32ExtendedKey
.toBase58();
1012 var extendedPrivKey
= xprvkeyB58
;
1013 DOM
.extendedPrivKey
.val(extendedPrivKey
);
1014 var extendedPubKey
= bip32ExtendedKey
.neutered().toBase58();
1015 DOM
.extendedPubKey
.val(extendedPubKey
);
1016 // Display the addresses and privkeys
1017 clearAddressesList();
1018 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
1019 displayAddresses(0, initialAddressCount
);
1022 displayBip32InfoForELA();
1026 function displayAddresses(start
, total
) {
1027 generationProcesses
.push(new (function() {
1031 this.stop = function() {
1032 for (var i
=0; i
<rows
.length
; i
++) {
1033 rows
[i
].shouldGenerate
= false;
1038 for (var i
=0; i
<total
; i
++) {
1039 var index
= i
+ start
;
1040 var isLast
= i
== total
- 1;
1041 rows
.push(new TableRow(index
, isLast
));
1047 function segwitSelected() {
1048 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
1051 function p2wpkhSelected() {
1052 return bip84TabSelected() ||
1053 bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh";
1056 function p2wpkhInP2shSelected() {
1057 return bip49TabSelected() ||
1058 (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wpkh-p2sh");
1061 function p2wshSelected() {
1062 return bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wsh";
1065 function p2wshInP2shSelected() {
1066 return (bip141TabSelected() && DOM
.bip141semantics
.val() == "p2wsh-p2sh");
1069 function TableRow(index
, isLast
) {
1072 this.shouldGenerate
= true;
1073 var useHardenedAddresses
= DOM
.hardenedAddresses
.prop("checked");
1074 var useBip38
= DOM
.useBip38
.prop("checked");
1075 var bip38password
= DOM
.bip38Password
.val();
1076 var isSegwit
= segwitSelected();
1077 var segwitAvailable
= networkHasSegwit();
1078 var isP2wpkh
= p2wpkhSelected();
1079 var isP2wpkhInP2sh
= p2wpkhInP2shSelected();
1080 var isP2wsh
= p2wshSelected();
1081 var isP2wshInP2sh
= p2wshInP2shSelected();
1087 function calculateValues() {
1088 setTimeout(function() {
1089 if (!self
.shouldGenerate
) {
1092 // derive HDkey for this row of the table
1094 if (useHardenedAddresses
) {
1095 key
= bip32ExtendedKey
.deriveHardened(index
);
1098 key
= bip32ExtendedKey
.derive(index
);
1100 // bip38 requires uncompressed keys
1101 // see https://github.com/iancoleman/bip39/issues/140#issuecomment-352164035
1102 var keyPair
= key
.keyPair
;
1103 var useUncompressed
= useBip38
;
1104 if (useUncompressed
) {
1105 keyPair
= new libs
.bitcoin
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
1107 keyPair
= new libs
.groestlcoinjs
.ECPair(keyPair
.d
, null, { network: network
, compressed: false });
1111 var address
= keyPair
.getAddress().toString();
1113 var hasPrivkey
= !key
.isNeutered();
1116 privkey
= keyPair
.toWIF();
1117 // BIP38 encode private key if required
1120 privkey
= libs
.groestlcoinjsBip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1121 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1122 }, null, networks
[DOM
.network
.val()].name
.includes("Testnet"));
1124 privkey
= libs
.bip38
.encrypt(keyPair
.d
.toBuffer(), false, bip38password
, function(p
) {
1125 console
.log("Progressed " + p
.percent
.toFixed(1) + "% for index " + index
);
1130 var pubkey
= keyPair
.getPublicKeyBuffer().toString('hex');
1131 var indexText
= getDerivationPath() + "/" + index
;
1132 if (useHardenedAddresses
) {
1133 indexText
= indexText
+ "'";
1135 // Ethereum values are different
1136 if (networkIsEthereum()) {
1137 var pubkeyBuffer
= keyPair
.getPublicKeyBuffer();
1138 var ethPubkey
= libs
.ethUtil
.importPublic(pubkeyBuffer
);
1139 var addressBuffer
= libs
.ethUtil
.publicToAddress(ethPubkey
);
1140 var hexAddress
= addressBuffer
.toString('hex');
1141 var checksumAddress
= libs
.ethUtil
.toChecksumAddress(hexAddress
);
1142 address
= libs
.ethUtil
.addHexPrefix(checksumAddress
);
1143 pubkey
= libs
.ethUtil
.addHexPrefix(pubkey
);
1145 privkey
= libs
.ethUtil
.bufferToHex(keyPair
.d
.toBuffer());
1149 // Stellar is different
1150 if (networks
[DOM
.network
.val()].name
== "XLM - Stellar") {
1151 var purpose
= parseIntNoNaN(DOM
.bip44purpose
.val(), 44);
1152 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
1154 path
+= purpose
+ "'/";
1155 path
+= coin
+ "'/" + index
+ "'";
1156 var keypair
= libs
.stellarUtil
.getKeypair(path
, seed
);
1158 privkey
= keypair
.secret();
1159 pubkey
= address
= keypair
.publicKey();
1161 if ((networks
[DOM
.network
.val()].name
== "NAS - Nebulas")) {
1162 var privKeyBuffer
= keyPair
.d
.toBuffer(32);
1163 var nebulasAccount
= libs
.nebulas
.Account
.NewAccount();
1164 nebulasAccount
.setPrivateKey(privKeyBuffer
);
1165 address
= nebulasAccount
.getAddressString();
1166 privkey
= nebulasAccount
.getPrivateKeyString();
1167 pubkey
= nebulasAccount
.getPublicKeyString();
1169 // Ripple values are different
1170 if (networks
[DOM
.network
.val()].name
== "XRP - Ripple") {
1171 privkey
= convertRipplePriv(privkey
);
1172 address
= convertRippleAdrr(address
);
1174 // Jingtum values are different
1175 if (networks
[DOM
.network
.val()].name
== "SWTC - Jingtum") {
1176 privkey
= convertJingtumPriv(privkey
);
1177 address
= convertJingtumAdrr(address
);
1179 // CasinoCoin values are different
1180 if (networks
[DOM
.network
.val()].name
== "CSC - CasinoCoin") {
1181 privkey
= convertCasinoCoinPriv(privkey
);
1182 address
= convertCasinoCoinAdrr(address
);
1184 // Bitcoin Cash address format may vary
1185 if (networks
[DOM
.network
.val()].name
== "BCH - Bitcoin Cash") {
1186 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1187 if (bchAddrType
== "cashaddr") {
1188 address
= libs
.bchaddr
.toCashAddress(address
);
1190 else if (bchAddrType
== "bitpay") {
1191 address
= libs
.bchaddr
.toBitpayAddress(address
);
1194 // Bitcoin Cash address format may vary
1195 if (networks
[DOM
.network
.val()].name
== "SLP - Simple Ledger Protocol") {
1196 var bchAddrType
= DOM
.bitcoinCashAddressType
.filter(":checked").val();
1197 if (bchAddrType
== "cashaddr") {
1198 address
= libs
.bchaddrSlp
.toSlpAddress(address
);
1201 // Segwit addresses are different
1203 if (!segwitAvailable
) {
1207 var keyhash
= libs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1208 var scriptpubkey
= libs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1209 address
= libs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1211 else if (isP2wpkhInP2sh
) {
1212 var keyhash
= libs
.bitcoin
.crypto
.hash160(key
.getPublicKeyBuffer());
1213 var scriptsig
= libs
.bitcoin
.script
.witnessPubKeyHash
.output
.encode(keyhash
);
1214 var addressbytes
= libs
.bitcoin
.crypto
.hash160(scriptsig
);
1215 var scriptpubkey
= libs
.bitcoin
.script
.scriptHash
.output
.encode(addressbytes
);
1216 address
= libs
.bitcoin
.address
.fromOutputScript(scriptpubkey
, network
)
1219 // https://github.com/libs.bitcoinjs-lib/blob/v3.3.2/test/integration/addresses.js#L71
1221 var witnessScript
= libs
.bitcoin
.script
.multisig
.output
.encode(1, [key
.getPublicKeyBuffer()]);
1222 var scriptPubKey
= libs
.bitcoin
.script
.witnessScriptHash
.output
.encode(libs
.bitcoin
.crypto
.sha256(witnessScript
));
1223 address
= libs
.bitcoin
.address
.fromOutputScript(scriptPubKey
, network
);
1225 else if (isP2wshInP2sh
) {
1226 // https://github.com/libs.bitcoinjs-lib/blob/v3.3.2/test/integration/transactions.js#L183
1228 var witnessScript
= libs
.bitcoin
.script
.multisig
.output
.encode(1, [key
.getPublicKeyBuffer()]);
1229 var redeemScript
= libs
.bitcoin
.script
.witnessScriptHash
.output
.encode(libs
.bitcoin
.crypto
.sha256(witnessScript
));
1230 var scriptPubKey
= libs
.bitcoin
.script
.scriptHash
.output
.encode(libs
.bitcoin
.crypto
.hash160(redeemScript
));
1231 address
= libs
.bitcoin
.address
.fromOutputScript(scriptPubKey
, network
)
1235 if ((networks
[DOM
.network
.val()].name
== "CRW - Crown")) {
1236 address
= libs
.bitcoin
.networks
.crown
.toNewAddress(address
);
1239 if (networks
[DOM
.network
.val()].name
== "EOS - EOSIO") {
1241 pubkey
= eosUtil
.bufferToPublic(keyPair
.getPublicKeyBuffer());
1242 privkey
= eosUtil
.bufferToPrivate(keyPair
.d
.toBuffer(32));
1245 //Groestlcoin Addresses are different
1249 if (!segwitAvailable
) {
1253 address
= libs
.groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1255 else if (isP2wpkhInP2sh
) {
1256 address
= libs
.groestlcoinjs
.address
.fromOutputScript(scriptpubkey
, network
)
1259 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1263 let elaAddress
= calcAddressForELA(
1265 parseIntNoNaN(DOM
.bip44coin
.val(), 0),
1266 parseIntNoNaN(DOM
.bip44account
.val(), 0),
1267 parseIntNoNaN(DOM
.bip44change
.val(), 0),
1270 address
= elaAddress
.address
;
1271 privkey
= elaAddress
.privateKey
;
1272 pubkey
= elaAddress
.publicKey
;
1275 addAddressToList(indexText
, address
, pubkey
, privkey
);
1287 function showMore() {
1288 var rowsToAdd
= parseInt(DOM
.rowsToAdd
.val());
1289 if (isNaN(rowsToAdd
)) {
1291 DOM
.rowsToAdd
.val("20");
1293 var start
= parseInt(DOM
.moreRowsStartIndex
.val())
1295 start
= lastIndexInTable() + 1;
1298 var newStart
= start
+ rowsToAdd
;
1299 DOM
.moreRowsStartIndex
.val(newStart
);
1301 if (rowsToAdd
> 200) {
1302 var msg
= "Generating " + rowsToAdd
+ " rows could take a while. ";
1303 msg
+= "Do you want to continue?";
1304 if (!confirm(msg
)) {
1308 displayAddresses(start
, rowsToAdd
);
1311 function clearDisplay() {
1312 clearAddressesList();
1314 hideValidationError();
1317 function clearAddressesList() {
1318 DOM
.addresses
.empty();
1323 function stopGenerating() {
1324 while (generationProcesses
.length
> 0) {
1325 var generation
= generationProcesses
.shift();
1330 function clearKeys() {
1335 function clearRootKey() {
1336 DOM
.rootKey
.val("");
1339 function clearDerivedKeys() {
1340 DOM
.extendedPrivKey
.val("");
1341 DOM
.extendedPubKey
.val("");
1342 DOM
.bip44accountXprv
.val("");
1343 DOM
.bip44accountXpub
.val("");
1346 function addAddressToList(indexText
, address
, pubkey
, privkey
) {
1347 var row
= $(addressRowTemplate
.html());
1349 var indexCell
= row
.find(".index span");
1350 var addressCell
= row
.find(".address span");
1351 var pubkeyCell
= row
.find(".pubkey span");
1352 var privkeyCell
= row
.find(".privkey span");
1354 indexCell
.text(indexText
);
1355 addressCell
.text(address
);
1356 pubkeyCell
.text(pubkey
);
1357 privkeyCell
.text(privkey
);
1360 indexCell
.addClass("invisible");
1363 addressCell
.addClass("invisible");
1366 pubkeyCell
.addClass("invisible");
1369 privkeyCell
.addClass("invisible");
1371 DOM
.addresses
.append(row
);
1372 var rowShowQrEls
= row
.find("[data-show-qr]");
1373 setQrEvents(rowShowQrEls
);
1376 function hasStrongRandom() {
1377 return 'crypto' in window
&& window
['crypto'] !== null;
1380 function disableForms() {
1381 $("form").on("submit", function(e
) {
1386 function parseIntNoNaN(val
, defaultVal
) {
1387 var v
= parseInt(val
);
1394 function showPending() {
1396 .text("Calculating...")
1400 function findNearestWord(word
) {
1401 var language
= getLanguage();
1402 var words
= WORDLISTS
[language
];
1403 var minDistance
= 99;
1404 var closestWord
= words
[0];
1405 for (var i
=0; i
<words
.length
; i
++) {
1406 var comparedTo
= words
[i
];
1407 if (comparedTo
.indexOf(word
) == 0) {
1410 var distance
= libs
.levenshtein
.get(word
, comparedTo
);
1411 if (distance
< minDistance
) {
1412 closestWord
= comparedTo
;
1413 minDistance
= distance
;
1419 function hidePending() {
1425 function populateNetworkSelect() {
1426 for (var i
=0; i
<networks
.length
; i
++) {
1427 var network
= networks
[i
];
1428 var option
= $("<option>");
1429 option
.attr("value", i
);
1430 option
.text(network
.name
);
1431 if (network
.name
== "BTC - Bitcoin") {
1432 option
.prop("selected", true);
1434 DOM
.phraseNetwork
.append(option
);
1438 function populateClientSelect() {
1439 for (var i
=0; i
<clients
.length
; i
++) {
1440 var client
= clients
[i
];
1441 var option
= $("<option>");
1442 option
.attr("value", i
);
1443 option
.text(client
.name
);
1444 DOM
.bip32Client
.append(option
);
1448 function getLanguage() {
1449 var defaultLanguage
= "english";
1450 // Try to get from existing phrase
1451 var language
= getLanguageFromPhrase();
1452 // Try to get from url if not from phrase
1453 if (language
.length
== 0) {
1454 language
= getLanguageFromUrl();
1456 // Default to English if no other option
1457 if (language
.length
== 0) {
1458 language
= defaultLanguage
;
1463 function getLanguageFromPhrase(phrase
) {
1464 // Check if how many words from existing phrase match a language.
1467 phrase
= DOM
.phrase
.val();
1469 if (phrase
.length
> 0) {
1470 var words
= phraseToWordArray(phrase
);
1471 var languageMatches
= {};
1472 for (l
in WORDLISTS
) {
1473 // Track how many words match in this language
1474 languageMatches
[l
] = 0;
1475 for (var i
=0; i
<words
.length
; i
++) {
1476 var wordInLanguage
= WORDLISTS
[l
].indexOf(words
[i
]) > -1;
1477 if (wordInLanguage
) {
1478 languageMatches
[l
]++;
1481 // Find languages with most word matches.
1482 // This is made difficult due to commonalities between Chinese
1483 // simplified vs traditional.
1484 var mostMatches
= 0;
1485 var mostMatchedLanguages
= [];
1486 for (var l
in languageMatches
) {
1487 var numMatches
= languageMatches
[l
];
1488 if (numMatches
> mostMatches
) {
1489 mostMatches
= numMatches
;
1490 mostMatchedLanguages
= [l
];
1492 else if (numMatches
== mostMatches
) {
1493 mostMatchedLanguages
.push(l
);
1497 if (mostMatchedLanguages
.length
> 0) {
1498 // Use first language and warn if multiple detected
1499 language
= mostMatchedLanguages
[0];
1500 if (mostMatchedLanguages
.length
> 1) {
1501 console
.warn("Multiple possible languages");
1502 console
.warn(mostMatchedLanguages
);
1509 function getLanguageFromUrl() {
1510 for (var language
in WORDLISTS
) {
1511 if (window
.location
.hash
.indexOf(language
) > -1) {
1518 function setMnemonicLanguage() {
1519 var language
= getLanguage();
1520 // Load the bip39 mnemonic generator for this language if required
1521 if (!(language
in mnemonics
)) {
1522 mnemonics
[language
] = new Mnemonic(language
);
1524 mnemonic
= mnemonics
[language
];
1527 function convertPhraseToNewLanguage() {
1528 var oldLanguage
= getLanguageFromPhrase();
1529 var newLanguage
= getLanguageFromUrl();
1530 var oldPhrase
= DOM
.phrase
.val();
1531 var oldWords
= phraseToWordArray(oldPhrase
);
1533 for (var i
=0; i
<oldWords
.length
; i
++) {
1534 var oldWord
= oldWords
[i
];
1535 var index
= WORDLISTS
[oldLanguage
].indexOf(oldWord
);
1536 var newWord
= WORDLISTS
[newLanguage
][index
];
1537 newWords
.push(newWord
);
1539 newPhrase
= wordArrayToPhrase(newWords
);
1543 // TODO look at jsbip39 - mnemonic.splitWords
1544 function phraseToWordArray(phrase
) {
1545 var words
= phrase
.split(/\s/g);
1547 for (var i
=0; i
<words
.length
; i
++) {
1548 var word
= words
[i
];
1549 if (word
.length
> 0) {
1550 noBlanks
.push(word
);
1556 // TODO look at jsbip39 - mnemonic.joinWords
1557 function wordArrayToPhrase(words
) {
1558 var phrase
= words
.join(" ");
1559 var language
= getLanguageFromPhrase(phrase
);
1560 if (language
== "japanese") {
1561 phrase
= words
.join("\u3000");
1566 function writeSplitPhrase(phrase
) {
1567 var wordCount
= phrase
.split(/\s/g).length
;
1569 for (var i
=0;i
<wordCount
;i
++) left
.push(i
);
1570 var group
=[[],[],[]],
1572 var seed
= Math
.abs(sjcl
.hash
.sha256
.hash(phrase
)[0])% 2147483647;
1573 while (left
.length
>0) {
1574 groupI
=(groupI
+1)%3;
1575 seed
= seed
* 16807 % 2147483647;
1576 var selected
=Math
.floor(left
.length
*(seed
- 1) / 2147483646);
1577 group
[groupI
].push(left
[selected
]);
1578 left
.splice(selected
,1);
1580 var cards
=[phrase
.split(/\s/g),phrase
.split(/\s/g),phrase
.split(/\s/g)];
1581 for (var i
=0;i
<3;i
++) {
1582 for (var ii
=0;ii
<wordCount
/3;ii
++) cards
[i
][group
[i
][ii
]]='XXXX';
1583 cards
[i
]='Card '+(i
+1)+': '+wordArrayToPhrase(cards
[i
]);
1585 DOM
.phraseSplit
.val(cards
.join("\r\n"));
1586 var triesPerSecond
=10000000000;
1587 var hackTime
=Math
.pow(2,wordCount
*10/3)/triesPerSecond
;
1588 var displayRedText
= false;
1590 hackTime
="<1 second";
1591 displayRedText
= true;
1592 } else if (hackTime
<86400) {
1593 hackTime
=Math
.floor(hackTime
)+" seconds";
1594 displayRedText
= true;
1595 } else if(hackTime
<31557600) {
1596 hackTime
=Math
.floor(hackTime
/86400)+" days";
1597 displayRedText
= true;
1599 hackTime
=Math
.floor(hackTime
/31557600)+" years";
1601 DOM
.phraseSplitWarn
.html("Time to hack with only one card: "+hackTime
);
1602 if (displayRedText
) {
1603 DOM
.phraseSplitWarn
.addClass("text-danger");
1605 DOM
.phraseSplitWarn
.removeClass("text-danger");
1609 function isUsingOwnEntropy() {
1610 return DOM
.useEntropy
.prop("checked");
1613 function setMnemonicFromEntropy() {
1614 clearEntropyFeedback();
1615 // Get entropy value
1616 var entropyStr
= DOM
.entropy
.val();
1617 // Work out minimum base for entropy
1619 if (entropyTypeAutoDetect
) {
1620 entropy
= Entropy
.fromString(entropyStr
);
1623 let base
= DOM
.entropyTypeInputs
.filter(":checked").val();
1624 entropy
= Entropy
.fromString(entropyStr
, base
);
1626 if (entropy
.binaryStr
.length
== 0) {
1629 // Show entropy details
1630 showEntropyFeedback(entropy
);
1631 // Use entropy hash if not using raw entropy
1632 var bits
= entropy
.binaryStr
;
1633 var mnemonicLength
= DOM
.entropyMnemonicLength
.val();
1634 if (mnemonicLength
!= "raw") {
1635 // Get bits by hashing entropy with SHA256
1636 var hash
= sjcl
.hash
.sha256
.hash(entropy
.cleanStr
);
1637 var hex
= sjcl
.codec
.hex
.fromBits(hash
);
1638 bits
= libs
.BigInteger
.BigInteger
.parse(hex
, 16).toString(2);
1639 while (bits
.length
% 256 != 0) {
1642 // Truncate hash to suit number of words
1643 mnemonicLength
= parseInt(mnemonicLength
);
1644 var numberOfBits
= 32 * mnemonicLength
/ 3;
1645 bits
= bits
.substring(0, numberOfBits
);
1646 // show warning for weak entropy override
1647 if (mnemonicLength
/ 3 * 32 > entropy
.binaryStr
.length
) {
1648 DOM
.entropyWeakEntropyOverrideWarning
.removeClass("hidden");
1651 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1655 // hide warning for weak entropy override
1656 DOM
.entropyWeakEntropyOverrideWarning
.addClass("hidden");
1658 // Discard trailing entropy
1659 var bitsToUse
= Math
.floor(bits
.length
/ 32) * 32;
1660 var start
= bits
.length
- bitsToUse
;
1661 var binaryStr
= bits
.substring(start
);
1662 // Convert entropy string to numeric array
1663 var entropyArr
= [];
1664 for (var i
=0; i
<binaryStr
.length
/ 8; i
++) {
1665 var byteAsBits
= binaryStr
.substring(i
*8, i
*8+8);
1666 var entropyByte
= parseInt(byteAsBits
, 2);
1667 entropyArr
.push(entropyByte
)
1669 // Convert entropy array to mnemonic
1670 var phrase
= mnemonic
.toMnemonic(entropyArr
);
1671 // Set the mnemonic in the UI
1672 DOM
.phrase
.val(phrase
);
1673 writeSplitPhrase(phrase
);
1674 // Show the word indexes
1676 // Show the checksum
1680 function clearEntropyFeedback() {
1681 DOM
.entropyCrackTime
.text("...");
1682 DOM
.entropyType
.text("");
1683 DOM
.entropyWordCount
.text("0");
1684 DOM
.entropyEventCount
.text("0");
1685 DOM
.entropyBitsPerEvent
.text("0");
1686 DOM
.entropyBits
.text("0");
1687 DOM
.entropyFiltered
.html(" ");
1688 DOM
.entropyBinary
.html(" ");
1691 function showEntropyFeedback(entropy
) {
1692 var numberOfBits
= entropy
.binaryStr
.length
;
1693 var timeToCrack
= "unknown";
1695 var z
= libs
.zxcvbn(entropy
.base
.parts
.join(""));
1696 timeToCrack
= z
.crack_times_display
.offline_fast_hashing_1e10_per_second
;
1697 if (z
.feedback
.warning
!= "") {
1698 timeToCrack
= timeToCrack
+ " - " + z
.feedback
.warning
;
1702 console
.log("Error detecting entropy strength with zxcvbn:");
1705 var entropyTypeStr
= getEntropyTypeStr(entropy
);
1706 DOM
.entropyTypeInputs
.attr("checked", false);
1707 DOM
.entropyTypeInputs
.filter("[value='" + entropyTypeStr
+ "']").attr("checked", true);
1708 var wordCount
= Math
.floor(numberOfBits
/ 32) * 3;
1709 var bitsPerEvent
= entropy
.bitsPerEvent
.toFixed(2);
1710 var spacedBinaryStr
= addSpacesEveryElevenBits(entropy
.binaryStr
);
1711 DOM
.entropyFiltered
.html(entropy
.cleanHtml
);
1712 DOM
.entropyType
.text(entropyTypeStr
);
1713 DOM
.entropyCrackTime
.text(timeToCrack
);
1714 DOM
.entropyEventCount
.text(entropy
.base
.ints
.length
);
1715 DOM
.entropyBits
.text(numberOfBits
);
1716 DOM
.entropyWordCount
.text(wordCount
);
1717 DOM
.entropyBinary
.text(spacedBinaryStr
);
1718 DOM
.entropyBitsPerEvent
.text(bitsPerEvent
);
1719 // detect and warn of filtering
1720 var rawNoSpaces
= DOM
.entropy
.val().replace(/\s/g, "");
1721 var cleanNoSpaces
= entropy
.cleanStr
.replace(/\s/g, "");
1722 var isFiltered
= rawNoSpaces
.length
!= cleanNoSpaces
.length
;
1724 DOM
.entropyFilterWarning
.removeClass('hidden');
1727 DOM
.entropyFilterWarning
.addClass('hidden');
1731 function getEntropyTypeStr(entropy
) {
1732 var typeStr
= entropy
.base
.str
;
1733 // Add some detail if these are cards
1734 if (entropy
.base
.asInt
== 52) {
1735 var cardDetail
= []; // array of message strings
1736 // Detect duplicates
1738 var dupeTracker
= {};
1739 for (var i
=0; i
<entropy
.base
.parts
.length
; i
++) {
1740 var card
= entropy
.base
.parts
[i
];
1741 var cardUpper
= card
.toUpperCase();
1742 if (cardUpper
in dupeTracker
) {
1745 dupeTracker
[cardUpper
] = true;
1747 if (dupes
.length
> 0) {
1748 var dupeWord
= "duplicates";
1749 if (dupes
.length
== 1) {
1750 dupeWord
= "duplicate";
1752 var msg
= dupes
.length
+ " " + dupeWord
+ ": " + dupes
.slice(0,3).join(" ");
1753 if (dupes
.length
> 3) {
1756 cardDetail
.push(msg
);
1759 var uniqueCards
= [];
1760 for (var uniqueCard
in dupeTracker
) {
1761 uniqueCards
.push(uniqueCard
);
1763 if (uniqueCards
.length
== 52) {
1764 cardDetail
.unshift("full deck");
1766 // Detect missing cards
1767 var values
= "A23456789TJQK";
1769 var missingCards
= [];
1770 for (var i
=0; i
<suits
.length
; i
++) {
1771 for (var j
=0; j
<values
.length
; j
++) {
1772 var card
= values
[j
] + suits
[i
];
1773 if (!(card
in dupeTracker
)) {
1774 missingCards
.push(card
);
1778 // Display missing cards if six or less, ie clearly going for full deck
1779 if (missingCards
.length
> 0 && missingCards
.length
<= 6) {
1780 var msg
= missingCards
.length
+ " missing: " + missingCards
.slice(0,3).join(" ");
1781 if (missingCards
.length
> 3) {
1784 cardDetail
.push(msg
);
1786 // Add card details to typeStr
1787 if (cardDetail
.length
> 0) {
1788 typeStr
+= " (" + cardDetail
.join(", ") + ")";
1794 function setQrEvents(els
) {
1795 els
.on("mouseenter", createQr
);
1796 els
.on("mouseleave", destroyQr
);
1797 els
.on("click", toggleQr
);
1800 function createQr(e
) {
1801 var content
= e
.target
.textContent
|| e
.target
.value
;
1803 var qrEl
= libs
.kjua({
1809 DOM
.qrImage
.append(qrEl
);
1811 DOM
.qrHider
.addClass("hidden");
1814 DOM
.qrHider
.removeClass("hidden");
1816 DOM
.qrContainer
.removeClass("hidden");
1820 function destroyQr() {
1821 DOM
.qrImage
.text("");
1822 DOM
.qrContainer
.addClass("hidden");
1825 function toggleQr() {
1827 DOM
.qrHider
.toggleClass("hidden");
1828 DOM
.qrHint
.toggleClass("hidden");
1831 function bip44TabSelected() {
1832 return DOM
.bip44tab
.hasClass("active");
1835 function bip32TabSelected() {
1836 return DOM
.bip32tab
.hasClass("active");
1839 function networkIsEthereum() {
1840 var name
= networks
[DOM
.network
.val()].name
;
1841 return (name
== "ETH - Ethereum")
1842 || (name
== "ETC - Ethereum Classic")
1843 || (name
== "EWT - EnergyWeb")
1844 || (name
== "PIRL - Pirl")
1845 || (name
== "MIX - MIX")
1846 || (name
== "MOAC - MOAC")
1847 || (name
== "MUSIC - Musicoin")
1848 || (name
== "POA - Poa")
1849 || (name
== "EXP - Expanse")
1850 || (name
== "CLO - Callisto")
1851 || (name
== "DXN - DEXON")
1852 || (name
== "ELLA - Ellaism")
1853 || (name
== "ESN - Ethersocial Network")
1854 || (name
== "VET - VeChain")
1855 || (name
== "ERE - EtherCore")
1858 function networkHasSegwit() {
1860 if ("baseNetwork" in network
) {
1861 n
= libs
.bitcoin
.networks
[network
.baseNetwork
];
1863 // check if only p2wpkh params are required
1864 if (p2wpkhSelected()) {
1865 return "p2wpkh" in n
;
1867 // check if only p2wpkh-in-p2sh params are required
1868 else if (p2wpkhInP2shSelected()) {
1869 return "p2wpkhInP2sh" in n
;
1871 // require both if it's unclear which params are required
1872 return "p2wpkh" in n
&& "p2wpkhInP2sh" in n
;
1875 function bip49TabSelected() {
1876 return DOM
.bip49tab
.hasClass("active");
1879 function bip84TabSelected() {
1880 return DOM
.bip84tab
.hasClass("active");
1883 function bip141TabSelected() {
1884 return DOM
.bip141tab
.hasClass("active");
1887 function setBip44ChangeValue() {
1888 if (isDefaultBip44ChangeValue
) {
1889 if (networkIsEthereum()) {
1890 DOM
.bip44change
.val("");
1892 DOM
.bip44change
.val(0);
1897 function modifiedDefaultBip44ChangeValue() {
1898 isDefaultBip44ChangeValue
= false;
1901 function resetDefaultBip44ChangeValue() {
1902 isDefaultBip44ChangeValue
= true;
1903 setBip44ChangeValue();
1906 function setHdCoin(coinValue
) {
1907 DOM
.bip44coin
.val(coinValue
);
1908 DOM
.bip49coin
.val(coinValue
);
1909 DOM
.bip84coin
.val(coinValue
);
1910 setBip44ChangeValue();
1913 function showSegwitAvailable() {
1914 DOM
.bip49unavailable
.addClass("hidden");
1915 DOM
.bip49available
.removeClass("hidden");
1916 DOM
.bip84unavailable
.addClass("hidden");
1917 DOM
.bip84available
.removeClass("hidden");
1918 DOM
.bip141unavailable
.addClass("hidden");
1919 DOM
.bip141available
.removeClass("hidden");
1922 function showSegwitUnavailable() {
1923 DOM
.bip49available
.addClass("hidden");
1924 DOM
.bip49unavailable
.removeClass("hidden");
1925 DOM
.bip84available
.addClass("hidden");
1926 DOM
.bip84unavailable
.removeClass("hidden");
1927 DOM
.bip141available
.addClass("hidden");
1928 DOM
.bip141unavailable
.removeClass("hidden");
1931 function adjustNetworkForSegwit() {
1932 // If segwit is selected the xpub/xprv prefixes need to be adjusted
1933 // to avoid accidentally importing BIP49 xpub to BIP44 watch only
1935 // See https://github.com/iancoleman/bip39/issues/125
1936 var segwitNetworks
= null;
1937 // if a segwit network is alread selected, need to use base network to
1938 // look up new parameters
1939 if ("baseNetwork" in network
) {
1940 network
= libs
.bitcoin
.networks
[network
.baseNetwork
];
1942 // choose the right segwit params
1943 if (p2wpkhSelected() && "p2wpkh" in network
) {
1944 network
= network
.p2wpkh
;
1946 else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network
) {
1947 network
= network
.p2wpkhInP2sh
;
1949 else if (p2wshSelected() && "p2wsh" in network
) {
1950 network
= network
.p2wsh
;
1952 else if (p2wshInP2shSelected() && "p2wshInP2sh" in network
) {
1953 network
= network
.p2wshInP2sh
;
1957 function lastIndexInTable() {
1958 var pathText
= DOM
.addresses
.find(".index").last().text();
1959 var pathBits
= pathText
.split("/");
1960 var lastBit
= pathBits
[pathBits
.length
-1];
1961 var lastBitClean
= lastBit
.replace("'", "");
1962 return parseInt(lastBitClean
);
1965 function uint8ArrayToHex(a
) {
1967 for (var i
=0; i
<a
.length
; i
++) {
1968 var h
= a
[i
].toString(16);
1969 while (h
.length
< 2) {
1977 function showWordIndexes() {
1978 var phrase
= DOM
.phrase
.val();
1979 var words
= phraseToWordArray(phrase
);
1980 var wordIndexes
= [];
1981 var language
= getLanguage();
1982 for (var i
=0; i
<words
.length
; i
++) {
1983 var word
= words
[i
];
1984 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
1985 wordIndexes
.push(wordIndex
);
1987 var wordIndexesStr
= wordIndexes
.join(", ");
1988 DOM
.entropyWordIndexes
.text(wordIndexesStr
);
1991 function showChecksum() {
1992 var phrase
= DOM
.phrase
.val();
1993 var words
= phraseToWordArray(phrase
);
1994 var checksumBitlength
= words
.length
/ 3;
1997 var language
= getLanguage();
1998 for (var i
=words
.length
-1; i
>=0; i
--) {
1999 var word
= words
[i
];
2000 var wordIndex
= WORDLISTS
[language
].indexOf(word
);
2001 var wordBinary
= wordIndex
.toString(2);
2002 while (wordBinary
.length
< 11) {
2003 wordBinary
= "0" + wordBinary
;
2005 var binaryStr
= wordBinary
+ binaryStr
;
2006 if (binaryStr
.length
>= checksumBitlength
) {
2007 var start
= binaryStr
.length
- checksumBitlength
;
2008 var end
= binaryStr
.length
;
2009 checksum
= binaryStr
.substring(start
, end
);
2010 // add spaces so the last group is 11 bits, not the first
2011 checksum
= checksum
.split("").reverse().join("")
2012 checksum
= addSpacesEveryElevenBits(checksum
);
2013 checksum
= checksum
.split("").reverse().join("")
2017 DOM
.entropyChecksum
.text(checksum
);
2020 function updateCsv() {
2021 var tableCsv
= "path,address,public key,private key\n";
2022 var rows
= DOM
.addresses
.find("tr");
2023 for (var i
=0; i
<rows
.length
; i
++) {
2024 var row
= $(rows
[i
]);
2025 var cells
= row
.find("td");
2026 for (var j
=0; j
<cells
.length
; j
++) {
2027 var cell
= $(cells
[j
]);
2028 if (!cell
.children().hasClass("invisible")) {
2029 tableCsv
= tableCsv
+ cell
.text();
2031 if (j
!= cells
.length
- 1) {
2032 tableCsv
= tableCsv
+ ",";
2035 tableCsv
= tableCsv
+ "\n";
2037 DOM
.csv
.val(tableCsv
);
2040 function addSpacesEveryElevenBits(binaryStr
) {
2041 return binaryStr
.match(/.{1,11}/g).join(" ");
2046 name: "AC - Asiacoin",
2047 onSelect: function() {
2048 network
= libs
.bitcoin
.networks
.asiacoin
;
2053 name: "ACC - Adcoin",
2054 onSelect: function() {
2055 network
= libs
.bitcoin
.networks
.adcoin
;
2060 name: "ARYA - Aryacoin",
2061 onSelect: function() {
2062 network
= libs
.bitcoin
.networks
.aryacoin
;
2067 name: "AUR - Auroracoin",
2068 onSelect: function() {
2069 network
= libs
.bitcoin
.networks
.auroracoin
;
2075 onSelect: function() {
2076 network
= libs
.bitcoin
.networks
.axe
;
2081 name: "ANON - ANON",
2082 onSelect: function() {
2083 network
= libs
.bitcoin
.networks
.anon
;
2088 name: "BOLI - Bolivarcoin",
2089 onSelect: function() {
2090 network
= libs
.bitcoin
.networks
.bolivarcoin
;
2095 name: "BCA - Bitcoin Atom",
2096 onSelect: function() {
2097 network
= libs
.bitcoin
.networks
.atom
;
2102 name: "BCH - Bitcoin Cash",
2103 onSelect: function() {
2104 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
2109 name: "BEET - Beetlecoin",
2110 onSelect: function() {
2111 network
= libs
.bitcoin
.networks
.beetlecoin
;
2116 name: "BELA - Belacoin",
2117 onSelect: function() {
2118 network
= libs
.bitcoin
.networks
.belacoin
;
2123 name: "BLK - BlackCoin",
2124 onSelect: function() {
2125 network
= libs
.bitcoin
.networks
.blackcoin
;
2130 name: "BND - Blocknode",
2131 onSelect: function() {
2132 network
= libs
.bitcoin
.networks
.blocknode
;
2137 name: "tBND - Blocknode Testnet",
2138 onSelect: function() {
2139 network
= libs
.bitcoin
.networks
.blocknode_testnet
;
2144 name: "BRIT - Britcoin",
2145 onSelect: function() {
2146 network
= libs
.bitcoin
.networks
.britcoin
;
2151 name: "BSD - Bitsend",
2152 onSelect: function() {
2153 network
= libs
.bitcoin
.networks
.bitsend
;
2158 name: "BST - BlockStamp",
2159 onSelect: function() {
2160 network
= libs
.bitcoin
.networks
.blockstamp
;
2166 onSelect: function() {
2167 network
= libs
.bitcoin
.networks
.bata
;
2172 name: "BTC - Bitcoin",
2173 onSelect: function() {
2174 network
= libs
.bitcoin
.networks
.bitcoin
;
2179 name: "BTC - Bitcoin RegTest",
2180 onSelect: function() {
2181 network
= libs
.bitcoin
.networks
.regtest
;
2182 // Using hd coin value 1 based on bip44_coin_type
2183 // https://github.com/chaintope/bitcoinrb/blob/f1014406f6b8f9b4edcecedc18df70c80df06f11/lib/bitcoin/chainparams/regtest.yml
2188 name: "BTC - Bitcoin Testnet",
2189 onSelect: function() {
2190 network
= libs
.bitcoin
.networks
.testnet
;
2195 name: "BITG - Bitcoin Green",
2196 onSelect: function() {
2197 network
= libs
.bitcoin
.networks
.bitcoingreen
;
2202 name: "BTCP - Bitcoin Private",
2203 onSelect: function() {
2204 network
= libs
.bitcoin
.networks
.bitcoinprivate
;
2209 name: "BSV - BitcoinSV",
2210 onSelect: function() {
2211 network
= libs
.bitcoin
.networks
.bitcoinsv
;
2216 name: "BTCZ - Bitcoinz",
2217 onSelect: function() {
2218 network
= libs
.bitcoin
.networks
.bitcoinz
;
2223 name: "BTDX - BitCloud",
2224 onSelect: function() {
2225 network
= libs
.bitcoin
.networks
.bitcloud
;
2230 name: "BTG - Bitcoin Gold",
2231 onSelect: function() {
2232 network
= libs
.bitcoin
.networks
.bgold
;
2237 name: "BTX - Bitcore",
2238 onSelect: function() {
2239 network
= libs
.bitcoin
.networks
.bitcore
;
2244 name: "CCN - Cannacoin",
2245 onSelect: function() {
2246 network
= libs
.bitcoin
.networks
.cannacoin
;
2251 name: "CESC - Cryptoescudo",
2252 onSelect: function() {
2253 network
= libs
.bitcoin
.networks
.cannacoin
;
2258 name: "CDN - Canadaecoin",
2259 onSelect: function() {
2260 network
= libs
.bitcoin
.networks
.canadaecoin
;
2265 name: "CLAM - Clams",
2266 onSelect: function() {
2267 network
= libs
.bitcoin
.networks
.clam
;
2272 name: "CLO - Callisto",
2273 segwitAvailable: false,
2274 onSelect: function() {
2275 network
= libs
.bitcoin
.networks
.bitcoin
;
2280 name: "CLUB - Clubcoin",
2281 onSelect: function() {
2282 network
= libs
.bitcoin
.networks
.clubcoin
;
2287 name: "CMP - Compcoin",
2288 onSelect: function() {
2289 network
= libs
.bitcoin
.networks
.compcoin
;
2294 name: "CPU - CPUchain",
2295 onSelect: function() {
2296 network
= libs
.bitcoin
.networks
.cpuchain
;
2301 name: "CRAVE - Crave",
2302 onSelect: function() {
2303 network
= libs
.bitcoin
.networks
.crave
;
2308 name: "CRW - Crown (Legacy)",
2309 onSelect: function() {
2310 network
= libs
.bitcoin
.networks
.crown
;
2315 name: "CRW - Crown",
2316 onSelect: function() {
2317 network
= libs
.bitcoin
.networks
.crown
;
2322 name: "CSC - CasinoCoin",
2323 onSelect: function() {
2324 network
= libs
.bitcoin
.networks
.bitcoin
;
2329 name: "DASH - Dash",
2330 onSelect: function() {
2331 network
= libs
.bitcoin
.networks
.dash
;
2336 name: "DASH - Dash Testnet",
2337 onSelect: function() {
2338 network
= libs
.bitcoin
.networks
.dashtn
;
2343 name: "DFC - Defcoin",
2344 onSelect: function() {
2345 network
= libs
.bitcoin
.networks
.defcoin
;
2350 name: "DGB - Digibyte",
2351 onSelect: function() {
2352 network
= libs
.bitcoin
.networks
.digibyte
;
2357 name: "DGC - Digitalcoin",
2358 onSelect: function() {
2359 network
= libs
.bitcoin
.networks
.digitalcoin
;
2364 name: "DMD - Diamond",
2365 onSelect: function() {
2366 network
= libs
.bitcoin
.networks
.diamond
;
2371 name: "DNR - Denarius",
2372 onSelect: function() {
2373 network
= libs
.bitcoin
.networks
.denarius
;
2378 name: "DOGE - Dogecoin",
2379 onSelect: function() {
2380 network
= libs
.bitcoin
.networks
.dogecoin
;
2385 name: "DOGEt - Dogecoin Testnet",
2386 onSelect: function() {
2387 network
= libs
.bitcoin
.networks
.dogecointestnet
;
2392 name: "DXN - DEXON",
2393 onSelect: function() {
2394 network
= libs
.bitcoin
.networks
.bitcoin
;
2399 name: "ECN - Ecoin",
2400 onSelect: function() {
2401 network
= libs
.bitcoin
.networks
.ecoin
;
2406 name: "EDRC - Edrcoin",
2407 onSelect: function() {
2408 network
= libs
.bitcoin
.networks
.edrcoin
;
2413 name: "EFL - Egulden",
2414 onSelect: function() {
2415 network
= libs
.bitcoin
.networks
.egulden
;
2420 name: "ELA - Elastos",
2421 onSelect: function () {
2422 network
= libs
.bitcoin
.networks
.elastos
;
2427 name: "ELLA - Ellaism",
2428 segwitAvailable: false,
2429 onSelect: function() {
2430 network
= libs
.bitcoin
.networks
.bitcoin
;
2435 name: "EMC2 - Einsteinium",
2436 onSelect: function() {
2437 network
= libs
.bitcoin
.networks
.einsteinium
;
2442 name: "ERC - Europecoin",
2443 onSelect: function() {
2444 network
= libs
.bitcoin
.networks
.europecoin
;
2449 name: "EOS - EOSIO",
2450 onSelect: function() {
2451 network
= libs
.bitcoin
.networks
.bitcoin
;
2456 name: "ERE - EtherCore",
2457 segwitAvailable: false,
2458 onSelect: function() {
2459 network
= libs
.bitcoin
.networks
.bitcoin
;
2464 name: "ESN - Ethersocial Network",
2465 segwitAvailable: false,
2466 onSelect: function() {
2467 network
= libs
.bitcoin
.networks
.bitcoin
;
2472 name: "ETC - Ethereum Classic",
2473 segwitAvailable: false,
2474 onSelect: function() {
2475 network
= libs
.bitcoin
.networks
.bitcoin
;
2480 name: "ETH - Ethereum",
2481 onSelect: function() {
2482 network
= libs
.bitcoin
.networks
.bitcoin
;
2487 name: "EWT - EnergyWeb",
2488 onSelect: function() {
2489 network
= libs
.bitcoin
.networks
.bitcoin
;
2494 name: "EXCL - Exclusivecoin",
2495 onSelect: function() {
2496 network
= libs
.bitcoin
.networks
.exclusivecoin
;
2501 name: "EXCC - ExchangeCoin",
2502 onSelect: function() {
2503 network
= libs
.bitcoin
.networks
.exchangecoin
;
2508 name: "EXP - Expanse",
2509 segwitAvailable: false,
2510 onSelect: function() {
2511 network
= libs
.bitcoin
.networks
.bitcoin
;
2517 onSelect: function() {
2518 network
= libs
.bitcoin
.networks
.fix
;
2523 name: "FIX - FIX Testnet",
2524 onSelect: function() {
2525 network
= libs
.bitcoin
.networks
.fixtestnet
;
2530 name: "FJC - Fujicoin",
2531 onSelect: function() {
2532 network
= libs
.bitcoin
.networks
.fujicoin
;
2537 name: "FLASH - Flashcoin",
2538 onSelect: function() {
2539 network
= libs
.bitcoin
.networks
.flashcoin
;
2544 name: "FRST - Firstcoin",
2545 onSelect: function() {
2546 network
= libs
.bitcoin
.networks
.firstcoin
;
2551 name: "FTC - Feathercoin",
2552 onSelect: function() {
2553 network
= libs
.bitcoin
.networks
.feathercoin
;
2558 name: "GAME - GameCredits",
2559 onSelect: function() {
2560 network
= libs
.bitcoin
.networks
.game
;
2565 name: "GBX - Gobyte",
2566 onSelect: function() {
2567 network
= libs
.bitcoin
.networks
.gobyte
;
2572 name: "GCR - GCRCoin",
2573 onSelect: function() {
2574 network
= libs
.bitcoin
.networks
.gcr
;
2579 name: "GRC - Gridcoin",
2580 onSelect: function() {
2581 network
= libs
.bitcoin
.networks
.gridcoin
;
2586 name: "GRS - Groestlcoin",
2587 onSelect: function() {
2588 network
= libs
.bitcoin
.networks
.groestlcoin
;
2593 name: "GRS - Groestlcoin Testnet",
2594 onSelect: function() {
2595 network
= libs
.bitcoin
.networks
.groestlcointestnet
;
2600 name: "HNC - Helleniccoin",
2601 onSelect: function() {
2602 network
= libs
.bitcoin
.networks
.helleniccoin
;
2607 name: "HUSH - Hush (Legacy)",
2608 onSelect: function() {
2609 network
= libs
.bitcoin
.networks
.hush
;
2614 name: "HUSH - Hush3",
2615 onSelect: function() {
2616 network
= libs
.bitcoin
.networks
.hush3
;
2621 name: "INSN - Insane",
2622 onSelect: function() {
2623 network
= libs
.bitcoin
.networks
.insane
;
2629 onSelect: function() {
2630 network
= libs
.bitcoin
.networks
.iop
;
2635 name: "IXC - Ixcoin",
2636 onSelect: function() {
2637 network
= libs
.bitcoin
.networks
.ixcoin
;
2642 name: "JBS - Jumbucks",
2643 onSelect: function() {
2644 network
= libs
.bitcoin
.networks
.jumbucks
;
2649 name: "KMD - Komodo",
2650 bip49available: false,
2651 onSelect: function() {
2652 network
= libs
.bitcoin
.networks
.komodo
;
2657 name: "KOBO - Kobocoin",
2658 bip49available: false,
2659 onSelect: function() {
2660 network
= libs
.bitcoin
.networks
.kobocoin
;
2665 name: "LBC - Library Credits",
2666 onSelect: function() {
2667 network
= libs
.bitcoin
.networks
.lbry
;
2672 name: "LCC - Litecoincash",
2673 onSelect: function() {
2674 network
= libs
.bitcoin
.networks
.litecoincash
;
2679 name: "LDCN - Landcoin",
2680 onSelect: function() {
2681 network
= libs
.bitcoin
.networks
.landcoin
;
2686 name: "LINX - Linx",
2687 onSelect: function() {
2688 network
= libs
.bitcoin
.networks
.linx
;
2693 name: "LKR - Lkrcoin",
2694 segwitAvailable: false,
2695 onSelect: function() {
2696 network
= libs
.bitcoin
.networks
.lkrcoin
;
2701 name: "LTC - Litecoin",
2702 onSelect: function() {
2703 network
= libs
.bitcoin
.networks
.litecoin
;
2705 DOM
.litecoinLtubContainer
.removeClass("hidden");
2709 name: "LTCt - Litecoin Testnet",
2710 onSelect: function() {
2711 network
= libs
.bitcoin
.networks
.litecointestnet
;
2713 DOM
.litecoinLtubContainer
.removeClass("hidden");
2717 name: "LTZ - LitecoinZ",
2718 onSelect: function() {
2719 network
= libs
.bitcoin
.networks
.litecoinz
;
2724 name: "LYNX - Lynx",
2725 onSelect: function() {
2726 network
= libs
.bitcoin
.networks
.lynx
;
2731 name: "MAZA - Maza",
2732 onSelect: function() {
2733 network
= libs
.bitcoin
.networks
.maza
;
2738 name: "MEC - Megacoin",
2739 onSelect: function() {
2740 network
= libs
.bitcoin
.networks
.megacoin
;
2746 segwitAvailable: false,
2747 onSelect: function() {
2748 network
= libs
.bitcoin
.networks
.bitcoin
;
2753 name: "MNX - Minexcoin",
2754 onSelect: function() {
2755 network
= libs
.bitcoin
.networks
.minexcoin
;
2760 name: "MONA - Monacoin",
2761 onSelect: function() {
2762 network
= libs
.bitcoin
.networks
.monacoin
,
2767 name: "MONK - Monkey Project",
2768 onSelect: function() {
2769 network
= libs
.bitcoin
.networks
.monkeyproject
,
2774 name: "MOAC - MOAC",
2775 segwitAvailable: false,
2776 onSelect: function() {
2777 network
= libs
.bitcoin
.networks
.bitcoin
;
2782 name: "MUSIC - Musicoin",
2783 segwitAvailable: false,
2784 onSelect: function() {
2785 network
= libs
.bitcoin
.networks
.bitcoin
;
2790 name: "NAV - Navcoin",
2791 onSelect: function() {
2792 network
= libs
.bitcoin
.networks
.navcoin
;
2797 name: "NAS - Nebulas",
2798 onSelect: function() {
2799 network
= libs
.bitcoin
.networks
.bitcoin
;
2804 name: "NEBL - Neblio",
2805 onSelect: function() {
2806 network
= libs
.bitcoin
.networks
.neblio
;
2811 name: "NEOS - Neoscoin",
2812 onSelect: function() {
2813 network
= libs
.bitcoin
.networks
.neoscoin
;
2818 name: "NIX - NIX Platform",
2819 onSelect: function() {
2820 network
= libs
.bitcoin
.networks
.nix
;
2825 name: "NLG - Gulden",
2826 onSelect: function() {
2827 network
= libs
.bitcoin
.networks
.gulden
;
2832 name: "NMC - Namecoin",
2833 onSelect: function() {
2834 network
= libs
.bitcoin
.networks
.namecoin
;
2839 name: "NRG - Energi",
2840 onSelect: function() {
2841 network
= libs
.bitcoin
.networks
.energi
;
2846 name: "NRO - Neurocoin",
2847 onSelect: function() {
2848 network
= libs
.bitcoin
.networks
.neurocoin
;
2853 name: "NSR - Nushares",
2854 onSelect: function() {
2855 network
= libs
.bitcoin
.networks
.nushares
;
2860 name: "NYC - Newyorkc",
2861 onSelect: function() {
2862 network
= libs
.bitcoin
.networks
.newyorkc
;
2867 name: "NVC - Novacoin",
2868 onSelect: function() {
2869 network
= libs
.bitcoin
.networks
.novacoin
;
2874 name: "OK - Okcash",
2875 onSelect: function() {
2876 network
= libs
.bitcoin
.networks
.okcash
;
2881 name: "OMNI - Omnicore",
2882 onSelect: function() {
2883 network
= libs
.bitcoin
.networks
.omnicore
;
2888 name: "ONION - DeepOnion",
2889 onSelect: function() {
2890 network
= libs
.bitcoin
.networks
.deeponion
;
2895 name: "ONX - Onixcoin",
2896 onSelect: function() {
2897 network
= libs
.bitcoin
.networks
.onixcoin
;
2902 name: "PHR - Phore",
2903 onSelect: function() {
2904 network
= libs
.bitcoin
.networks
.phore
;
2909 name: "PINK - Pinkcoin",
2910 onSelect: function() {
2911 network
= libs
.bitcoin
.networks
.pinkcoin
;
2916 name: "PIRL - Pirl",
2917 segwitAvailable: false,
2918 onSelect: function() {
2919 network
= libs
.bitcoin
.networks
.bitcoin
;
2924 name: "PIVX - PIVX",
2925 onSelect: function() {
2926 network
= libs
.bitcoin
.networks
.pivx
;
2931 name: "PIVX - PIVX Testnet",
2932 onSelect: function() {
2933 network
= libs
.bitcoin
.networks
.pivxtestnet
;
2939 segwitAvailable: false,
2940 onSelect: function() {
2941 network
= libs
.bitcoin
.networks
.bitcoin
;
2946 name: "POSW - POSWcoin",
2947 onSelect: function() {
2948 network
= libs
.bitcoin
.networks
.poswcoin
;
2953 name: "POT - Potcoin",
2954 onSelect: function() {
2955 network
= libs
.bitcoin
.networks
.potcoin
;
2960 name: "PPC - Peercoin",
2961 onSelect: function() {
2962 network
= libs
.bitcoin
.networks
.peercoin
;
2967 name: "PRJ - ProjectCoin",
2968 onSelect: function() {
2969 network
= libs
.bitcoin
.networks
.projectcoin
;
2974 name: "PSB - Pesobit",
2975 onSelect: function() {
2976 network
= libs
.bitcoin
.networks
.pesobit
;
2981 name: "PUT - Putincoin",
2982 onSelect: function() {
2983 network
= libs
.bitcoin
.networks
.putincoin
;
2988 name: "RPD - Rapids",
2989 onSelect: function() {
2990 network
= libs
.bitcoin
.networks
.rapids
;
2995 name: "RVN - Ravencoin",
2996 onSelect: function() {
2997 network
= libs
.bitcoin
.networks
.ravencoin
;
3003 onSelect: function() {
3004 network
= libs
.bitcoin
.networks
.rubycoin
;
3009 name: "tRBTC - RSK Testnet",
3010 onSelect: function() {
3011 network
= libs
.bitcoin
.networks
.rubycoin
;
3016 name: "RBY - Rubycoin",
3017 onSelect: function() {
3018 network
= libs
.bitcoin
.networks
.rubycoin
;
3023 name: "RDD - Reddcoin",
3024 onSelect: function() {
3025 network
= libs
.bitcoin
.networks
.reddcoin
;
3030 name: "RVR - RevolutionVR",
3031 onSelect: function() {
3032 network
= libs
.bitcoin
.networks
.revolutionvr
;
3037 name: "SAFE - Safecoin",
3038 onSelect: function() {
3039 network
= libs
.bitcoin
.networks
.safecoin
;
3044 name: "SLS - Salus",
3045 onSelect: function() {
3046 network
= libs
.bitcoin
.networks
.salus
;
3051 name: "SDC - ShadowCash",
3052 onSelect: function() {
3053 network
= libs
.bitcoin
.networks
.shadow
;
3058 name: "SDC - ShadowCash Testnet",
3059 onSelect: function() {
3060 network
= libs
.bitcoin
.networks
.shadowtn
;
3065 name: "SLM - Slimcoin",
3066 onSelect: function() {
3067 network
= libs
.bitcoin
.networks
.slimcoin
;
3072 name: "SLM - Slimcoin Testnet",
3073 onSelect: function() {
3074 network
= libs
.bitcoin
.networks
.slimcointn
;
3079 name: "SLP - Simple Ledger Protocol",
3080 onSelect: function() {
3081 DOM
.bitcoinCashAddressTypeContainer
.removeClass("hidden");
3086 name: "SLR - Solarcoin",
3087 onSelect: function() {
3088 network
= libs
.bitcoin
.networks
.solarcoin
;
3093 name: "SMLY - Smileycoin",
3094 onSelect: function() {
3095 network
= libs
.bitcoin
.networks
.smileycoin
;
3100 name: "STASH - Stash",
3101 onSelect: function() {
3102 network
= libs
.bitcoin
.networks
.stash
;
3107 name: "STASH - Stash Testnet",
3108 onSelect: function() {
3109 network
= libs
.bitcoin
.networks
.stashtn
;
3114 name: "STRAT - Stratis",
3115 onSelect: function() {
3116 network
= libs
.bitcoin
.networks
.stratis
;
3121 name: "SWTC - Jingtum",
3122 onSelect: function() {
3123 network
= libs
.bitcoin
.networks
.bitcoin
;
3128 name: "TSTRAT - Stratis Testnet",
3129 onSelect: function() {
3130 network
= libs
.bitcoin
.networks
.stratistest
;
3135 name: "SYS - Syscoin",
3136 onSelect: function() {
3137 network
= libs
.bitcoin
.networks
.syscoin
;
3142 name: "THC - Hempcoin",
3143 onSelect: function() {
3144 network
= libs
.bitcoin
.networks
.hempcoin
;
3149 name: "THT - Thought",
3150 onSelect: function() {
3151 network
= libs
.bitcoin
.networks
.thought
;
3157 onSelect: function() {
3158 network
= libs
.bitcoin
.networks
.toa
;
3163 name: "TWINS - TWINS",
3164 onSelect: function() {
3165 network
= libs
.bitcoin
.networks
.twins
;
3170 name: "TWINS - TWINS Testnet",
3171 onSelect: function() {
3172 network
= libs
.bitcoin
.networks
.twinstestnet
;
3177 name: "USC - Ultimatesecurecash",
3178 onSelect: function() {
3179 network
= libs
.bitcoin
.networks
.ultimatesecurecash
;
3184 name: "USNBT - NuBits",
3185 onSelect: function() {
3186 network
= libs
.bitcoin
.networks
.nubits
;
3191 name: "UNO - Unobtanium",
3192 onSelect: function() {
3193 network
= libs
.bitcoin
.networks
.unobtanium
;
3198 name: "VASH - Vpncoin",
3199 onSelect: function() {
3200 network
= libs
.bitcoin
.networks
.vpncoin
;
3205 name: "VET - VeChain",
3206 onSelect: function() {
3207 network
= libs
.bitcoin
.networks
.bitcoin
;
3212 name: "VIA - Viacoin",
3213 onSelect: function() {
3214 network
= libs
.bitcoin
.networks
.viacoin
;
3219 name: "VIA - Viacoin Testnet",
3220 onSelect: function() {
3221 network
= libs
.bitcoin
.networks
.viacointestnet
;
3226 name: "VIVO - Vivo",
3227 onSelect: function() {
3228 network
= libs
.bitcoin
.networks
.vivo
;
3233 name: "VTC - Vertcoin",
3234 onSelect: function() {
3235 network
= libs
.bitcoin
.networks
.vertcoin
;
3240 name: "WGR - Wagerr",
3241 onSelect: function() {
3242 network
= libs
.bitcoin
.networks
.wagerr
;
3247 name: "WC - Wincoin",
3248 onSelect: function() {
3249 network
= libs
.bitcoin
.networks
.wincoin
;
3254 name: "XAX - Artax",
3255 onSelect: function() {
3256 network
= libs
.bitcoin
.networks
.artax
;
3261 name: "XBC - Bitcoinplus",
3262 onSelect: function() {
3263 network
= libs
.bitcoin
.networks
.bitcoinplus
;
3268 name: "XLM - Stellar",
3269 onSelect: function() {
3270 network
= libs
.stellarUtil
.dummyNetwork
;
3275 name: "XMY - Myriadcoin",
3276 onSelect: function() {
3277 network
= libs
.bitcoin
.networks
.myriadcoin
;
3282 name: "XRP - Ripple",
3283 onSelect: function() {
3284 network
= libs
.bitcoin
.networks
.bitcoin
;
3289 name: "XVC - Vcash",
3290 onSelect: function() {
3291 network
= libs
.bitcoin
.networks
.vcash
;
3296 name: "XVG - Verge",
3297 onSelect: function() {
3298 network
= libs
.bitcoin
.networks
.verge
;
3303 name: "XUEZ - Xuez",
3304 segwitAvailable: false,
3305 onSelect: function() {
3306 network
= libs
.bitcoin
.networks
.xuez
;
3311 name: "XWC - Whitecoin",
3312 onSelect: function() {
3313 network
= libs
.bitcoin
.networks
.whitecoin
;
3318 name: "XZC - Zcoin",
3319 onSelect: function() {
3320 network
= libs
.bitcoin
.networks
.zcoin
;
3325 name: "ZCL - Zclassic",
3326 onSelect: function() {
3327 network
= libs
.bitcoin
.networks
.zclassic
;
3332 name: "ZEC - Zcash",
3333 onSelect: function() {
3334 network
= libs
.bitcoin
.networks
.zcash
;
3339 name: "ZEN - Horizen",
3340 onSelect: function() {
3341 network
= libs
.bitcoin
.networks
.zencash
;
3349 name: "Bitcoin Core",
3350 onSelect: function() {
3351 DOM
.bip32path
.val("m/0'/0'");
3352 DOM
.hardenedAddresses
.prop('checked', true);
3356 name: "blockchain.info",
3357 onSelect: function() {
3358 DOM
.bip32path
.val("m/44'/0'/0'");
3359 DOM
.hardenedAddresses
.prop('checked', false);
3363 name: "MultiBit HD",
3364 onSelect: function() {
3365 DOM
.bip32path
.val("m/0'/0");
3366 DOM
.hardenedAddresses
.prop('checked', false);
3370 name: "Coinomi, Ledger",
3371 onSelect: function() {
3372 DOM
.bip32path
.val("m/44'/"+DOM
.bip44coin
.val()+"'/0'");
3373 DOM
.hardenedAddresses
.prop('checked', false);
3378 // ELA - Elastos functions - begin
3379 function displayBip44InfoForELA() {
3384 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
3385 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
3387 // Calculate the account extended keys
3388 var accountXprv
= libs
.elastosjs
.getAccountExtendedPrivateKey(seed
, coin
, account
);
3389 var accountXpub
= libs
.elastosjs
.getAccountExtendedPublicKey(seed
, coin
, account
);
3391 // Display the extended keys
3392 DOM
.bip44accountXprv
.val(accountXprv
);
3393 DOM
.bip44accountXpub
.val(accountXpub
);
3396 function displayBip32InfoForELA() {
3401 var coin
= parseIntNoNaN(DOM
.bip44coin
.val(), 0);
3402 var account
= parseIntNoNaN(DOM
.bip44account
.val(), 0);
3403 var change
= parseIntNoNaN(DOM
.bip44change
.val(), 0);
3405 DOM
.extendedPrivKey
.val(libs
.elastosjs
.getBip32ExtendedPrivateKey(seed
, coin
, account
, change
));
3406 DOM
.extendedPubKey
.val(libs
.elastosjs
.getBip32ExtendedPublicKey(seed
, coin
, account
, change
));
3408 // Display the addresses and privkeys
3409 clearAddressesList();
3410 var initialAddressCount
= parseInt(DOM
.rowsToAdd
.val());
3411 displayAddresses(0, initialAddressCount
);
3414 function calcAddressForELA(seed
, coin
, account
, change
, index
) {
3419 var publicKey
= libs
.elastosjs
.getDerivedPublicKey(libs
.elastosjs
.getMasterPublicKey(seed
), change
, index
);
3421 privateKey: libs
.elastosjs
.getDerivedPrivateKey(seed
, coin
, account
, change
, index
),
3422 publicKey: publicKey
,
3423 address: libs
.elastosjs
.getAddress(publicKey
.toString('hex'))
3426 // ELA - Elastos functions - end