Add script/bin for creating an Ethereum wallet

This commit is contained in:
2017-05-06 15:34:35 +02:00
parent b4186d5062
commit 2f393e744a
3 changed files with 39 additions and 1 deletions

33
scripts/create-wallet.js Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env node
const fs = require('fs');
const Wallet = require('ethereumjs-wallet');
const userPrompt = require('prompt');
let schema = {
properties: {
path: {
required: true,
default: 'wallet.json'
},
password: {
hidden: true,
required: true
}
}
};
console.log(`You're about to create an Ethereum wallet. Please provide a path and password for encryption.\n`);
userPrompt.start();
userPrompt.get(schema, (err, result) => {
if (err) { throw(err); }
let wallet = Wallet.generate();
let content = JSON.stringify(wallet.toV3(result.password));
fs.writeFileSync(result.path, content);
console.log(`\nWrote encrypted wallet config to ${result.path}`);
});