-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·33 lines (26 loc) · 1.11 KB
/
app.js
File metadata and controls
executable file
·33 lines (26 loc) · 1.11 KB
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
#!/usr/bin/env node
'use strict'
const bip39 = require('bip39')
const chalk = require('chalk')
const clear = require('cli-clear')
const inquirer = require('inquirer')
const Prompt = require('./utils/prompt');
(async () => {
const prompt = new Prompt(inquirer)
const mnemonic = await prompt.simple('Mnemonic Phrase (leave empty to generate one)')
if (mnemonic.trim() === '') {
console.log(`Mnemonic Phrase ${chalk.green(bip39.generateMnemonic())}`)
console.log(`Save this phrase in a safe place and use it from now on. ${chalk.red('This phrase will never be generated again.')}`)
process.exit(0)
}
if (!bip39.validateMnemonic(mnemonic)) {
console.log(chalk.red.bold('✗ Invalid Mnemonic Phrase'))
process.exit(1)
}
clear()
console.log(chalk.bold.blue('CRYPTONYM\n'))
const seed = bip39.mnemonicToSeed(mnemonic)
const coin = await prompt.list('Select Coin', [ 'Bitcoin', 'Bitcoin Cash', 'Ether', 'Golem', 'Litecoin', 'Request Token', 'SONM', 'Stellar Lumen', 'Streamr DATAcoin' ])
const lib = require(`./coins/${coin.replace(/\s+/g, '-').toLowerCase()}`)
await lib(seed, prompt)
})()