forked from austintgriffith/paper-wallet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
39 lines (36 loc) · 1.12 KB
/
index.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
const util = require('util');
const exec = util.promisify(require('child_process').exec);
var merge = require('easy-pdf-merge');
var fs = require('fs')
let sources = []
let URL = process.argv[2]
async function generate(accounts){
let account
for(let a in accounts){
account = accounts[a]
const { stdout, stderr } = await exec('node create.js '+account.address+" "+account.pk+" "+URL);
if (stderr) {
console.error(`error: ${stderr}`);
}
let name = account.address
console.log("Generated: "+name);
await exec('mv generated.pdf '+name+'.pdf');
sources[a] = (""+name+".pdf")
}
merge(sources,"wallets.pdf",function(err){
if(err)
return console.log(err);
console.log('Success');
var i = sources.length;
sources.forEach(function(filepath){
console.log("Cleaning up "+filepath)
try{
if(fs.existsSync(filepath)){
fs.unlinkSync(filepath);
}
}catch(e){console.log(e)}
});
});
}
let accounts = JSON.parse(fs.readFileSync("./accounts.json").toString())
generate(accounts);