-
Notifications
You must be signed in to change notification settings - Fork 1
/
.signersSign.js
36 lines (30 loc) · 967 Bytes
/
.signersSign.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
#!/usr/bin/env node
var program = require('commander'),
bitcoin = require('bitcoinjs-lib'),
fs = require('fs');
program
.version('0.0.1')
.usage('[options]')
.option('-c, --number-required <n>', 'number required', parseInt)
.option('-k, --private-key [value]', 'private key')
.option('-a, --additional-addresses <values>', 'public keys', (val) => val.split(','))
.parse(process.argv);
var privateKey = program.privateKey,
pair = bitcoin
.ECPair
.fromWIF(privateKey);
if (!program.additionalAddresses.includes(pair.getAddress())) {
program
.additionalAddresses
.unshift(pair.getAddress());
}
var clearText = `${program.numberRequired}:${program.additionalAddresses.join(',')}`,
cipherText = pair
.sign(
bitcoin
.crypto
.sha256(clearText))
.toDER()
.toString('base64');
console.log(`signs_required: ${clearText}`);
console.log(`signed message: ${cipherText}`);