forked from uvmetal/neo-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (40 loc) · 1.18 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
40
41
42
43
44
45
46
47
48
49
50
const util = require('util')
const exec = util.promisify(require('child_process').exec)
const merge = require('easy-pdf-merge')
const fs = require('fs')
let defly = true
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+' '+account._WIF )
if (stderr) {
console.error(`error: ${stderr}`)
}
if (defly && stdout) console.log('\nstdout: \n'+stdout)
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('\nSuccess')
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)