forked from sCrypt-Inc/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
privateKey.js
34 lines (26 loc) · 926 Bytes
/
privateKey.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
const { exit } = require('process')
const { bsv } = require('scryptlib');
// fill in private key on testnet in WIF here
const privKey = ''
// be default, you do NOT fill in these two, since they are only needed when multiple keys are required
const privKey2 = ''
const privKey3 = ''
if (!privKey) {
genPrivKey()
}
function genPrivKey() {
const newPrivKey = new bsv.PrivateKey.fromRandom('testnet')
console.log(`Missing private key, generating a new one ...
Private key generated: '${newPrivKey.toWIF()}'
You can fund its address '${newPrivKey.toAddress()}' from sCrypt faucet https://scrypt.io/#faucet`)
exit(-1)
}
const privateKey = new bsv.PrivateKey.fromWIF(privKey)
const privateKey2 = privKey2 ? new bsv.PrivateKey.fromWIF(privKey2) : privateKey
const privateKey3 = privKey3 ? new bsv.PrivateKey.fromWIF(privKey3) : privateKey
module.exports = {
privateKey,
privateKey2,
privateKey3,
genPrivKey
}