-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathcli-cold-wallet.js
23 lines (21 loc) · 1021 Bytes
/
cli-cold-wallet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var path = require('path')
var qrcode = require('qrcode-terminal')
var bitcoin = require('bitcoinjs-lib')
var Table = require('cli-table')
var keyPair = bitcoin.ECPair.makeRandom()
var pubKey = keyPair.getPublicKeyBuffer()
var redeemScript = bitcoin.script.witnessPubKeyHash.output.encode(bitcoin.crypto.hash160(pubKey))
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript))
var displayAddress = bitcoin.address.fromOutputScript(scriptPubKey)
var displayWif = keyPair.toWIF()
qrcode.generate(displayWif, {small: true}, function (wifCode) {
qrcode.generate(displayAddress, {small: true}, function (addressCode) {
var table = new Table({head: ['BITCOIN PUBLIC ADDRESS', '', 'BITCOIN PRIVATE KEY (WIF)']})
table.push(
[addressCode, require('fs').readFileSync(path.join(__dirname, 'asciiart.txt'), 'utf8'), wifCode]
, ['DEPOSIT / VERIFY', '', 'WITHDRAW']
, [displayAddress, ' '.repeat(52), displayWif]
)
console.log(table.toString())
})
})