-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
64 lines (51 loc) · 1.38 KB
/
index.js
File metadata and controls
64 lines (51 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
const inquirer = require("inquirer");
const chalk = require("chalk");
const figlet = require("figlet");
const shell = require("shelljs");
const Wallet = require('ethereumjs-wallet')
const util = require('ethereumjs-util')
const fs = require('fs');
const askQuestions = () => {
const questions = [
{
type: "input",
name: "PrivateKey",
message: "Please paste your private Key here"
},
{
type: "password",
name: "Password",
message: "Please paste your destination address here"
}
];
return inquirer.prompt(questions);
};
const init = () => {
console.log(
chalk.red(
figlet.textSync("Private key to Ethereum Wallet", {
font: "Standard",
horizontalLayout: "default",
verticalLayout: "default"
})
)
);
}
const success = (filepath) => {
console.log(
chalk.white.bgGreen.bold(`Generated wallet file ${filepath}`)
);
};
const run = async () => {
// show script introduction
init();
const answers = await askQuestions();
const { PrivateKey, Password} = answers;
let wl=new Wallet(util.toBuffer(PrivateKey))
let fn=wl.getV3Filename();
let data = JSON.stringify(wl.toV3(Password));
fs.writeFileSync(fn, data);
success(process.cwd()+"/"+fn);
};
run();