-
Notifications
You must be signed in to change notification settings - Fork 6
/
_generate_wallet_config.js
48 lines (41 loc) · 1.31 KB
/
_generate_wallet_config.js
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
/*jslint node: true */
"use strict";
var generatePassword = require('password-generator');
var constants = require('constants');
var conf = require('./conf');
var fs = require('fs');
conf.hub = '';
conf.deviceName = '';
if(process.argv.length < 3) {
console.error("usage: " + process.argv[0] + " " + process.argv[1] + " <wallet_name>");
process.exit(1);
}
var wallet_name = process.argv[2];
var deviceName = wallet_name;
console.log(">> Generating wallet for: " + deviceName);
var config = {
deviceName: deviceName,
passphrase: generatePassword(16, true),
emitReady: false,
generate: true
}
var headlessWallet = require('headless-byteball');
conf.deviceName = config.deviceName;
headlessWallet.initialize(function (mnemonic_phrase, passphrase, definition, address, appDataDir) {
var finishedConfig = {
mnemonic_phrase: mnemonic_phrase,
passphrase: passphrase,
definition: definition,
address: address,
deviceName: deviceName,
appDataDir: appDataDir
};
console.log(">> Config: %j", finishedConfig);
fs.writeFile(deviceName + ".json", JSON.stringify(finishedConfig, null, '\t'), 'utf8', function(err){
if (err) {
console.log(err);
}
console.log("DONE, exiting.")
process.exit(0);
});
}, config);