diff --git a/encrypt-secret-key.js b/encrypt-secret-key.js new file mode 100644 index 0000000..74a1018 --- /dev/null +++ b/encrypt-secret-key.js @@ -0,0 +1,22 @@ +import CryptoJS from 'crypto-js' +import readlineSync from 'readline-sync' + +function encrypt() { + var ethPrivKey = readlineSync.question('please input eth private key: ',{hideEchoBack: true}); + var cryptowatchKey = readlineSync.question('please input cryptowatch key: ',{hideEchoBack: true}); + var passwd = readlineSync.question('please input your password: ',{hideEchoBack: true}); + var verifypasswd = readlineSync.question('please reinput your password: ',{hideEchoBack: true}); + + if (passwd != verifypasswd) { + console.log("your password mistach!") + return + } + var encryptEthPrivKey = CryptoJS.AES.encrypt(ethPrivKey, passwd).toString(); + var encryptCryptowatchKey = CryptoJS.AES.encrypt(cryptowatchKey, passwd).toString(); + + console.log("your encrypted eth private key: ", encryptEthPrivKey) + console.log("your encrypted cryptowatch key: ", encryptCryptowatchKey) +} + +eval(encrypt()) + diff --git a/marketmaker.js b/marketmaker.js index 8398897..ebdad63 100644 --- a/marketmaker.js +++ b/marketmaker.js @@ -4,6 +4,9 @@ import ethers from 'ethers'; import dotenv from 'dotenv'; import fetch from 'node-fetch'; import fs from 'fs'; +import readlineSync from 'readline-sync' +import CryptoJS from 'crypto-js' +import minimist from 'minimist' dotenv.config(); @@ -22,6 +25,13 @@ let FEE_TOKEN = null; let uniswap_error_counter = 0; let chainlink_error_counter = 0; +// Encrypt the eth private key and cryptowatch api key if you want +let args = minimist(process.argv.slice(2), {boolean: 'encrypt-key'}); +let passwd = null; +if (args['encrypt-key']) { + passwd = readlineSync.question('please input your password: ',{hideEchoBack: true}); +} + // Load MM config let MM_CONFIG; if (process.env.MM_CONFIG) { @@ -78,6 +88,9 @@ try { }); } for(let i=0; i= 0.8.0" + } + }, "node_modules/scrypt-js": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", @@ -2008,6 +2029,11 @@ "resolved": "https://registry.npmjs.org/chnl/-/chnl-1.2.0.tgz", "integrity": "sha512-g5gJb59edwCliFbX2j7G6sBfY4sX9YLy211yctONI2GRaiX0f2zIbKWmBm+sPqFNEpM7Ljzm7IJX/xrjiEbPrw==" }, + "crypto-js": { + "version": "4.1.1", + "resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.1.1.tgz", + "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==" + }, "d": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", @@ -2382,6 +2408,11 @@ "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" }, + "minimist": { + "version": "1.2.6", + "resolved": "https://registry.npmmirror.com/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -2448,6 +2479,11 @@ "es-abstract": "^1.19.1" } }, + "readline-sync": { + "version": "1.4.10", + "resolved": "https://registry.npmmirror.com/readline-sync/-/readline-sync-1.4.10.tgz", + "integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==" + }, "scrypt-js": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", diff --git a/package.json b/package.json index 19da3cb..149d395 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,12 @@ "author": "", "license": "ISC", "dependencies": { + "crypto-js": "^4.1.1", "dotenv": "^10.0.0", "ethers": "^5.5.1", + "minimist": "^1.2.6", "node-fetch": "^3.1.0", + "readline-sync": "^1.4.10", "ws": "^8.2.3", "zksync": "0.11.6" },