-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathnewuser.js
31 lines (26 loc) · 1.33 KB
/
newuser.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
var { PrivateKey, key, Address, Signature } = require("bitsharesjs");
var seedrandom = require('seedrandom');
var bip39 = require("bip39");
var fs = require('fs');
var mnemonic = bip39.generateMnemonic();
let privateKey = PrivateKey.fromSeed(key.normalize_brainKey(mnemonic));
let publicKey = privateKey.toPublicKey();
let address = Address.fromPublic(publicKey);
var space_count = 85 - mnemonic.length;
var spaceStr="";
for (let index = 0; index < space_count; index++) {
spaceStr = spaceStr + " ";
}
spaceStr = spaceStr + "|";
console.log("\n 你要把助忆词和地址抄在安全的地方,key文件里仅仅保存私钥。 \n");
console.log("+--------------+---------------------------------------------------------------------------------------+");
console.log("| mnemonic |", mnemonic.toString(),spaceStr);
console.log("| Privatekey |", privateKey.toWif().toString()," |");
console.log("| Publickey |", publicKey.toString(), " |");
console.log("| Address |", address.toString()," |");
console.log("+------------ +---------------------------------------------------------------------------------------+");
fs.writeFile('./key',privateKey.toWif().toString(),function (err) {
if (err) {
throw err;
}
});