-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreveal-cli
More file actions
executable file
·80 lines (76 loc) · 3.23 KB
/
reveal-cli
File metadata and controls
executable file
·80 lines (76 loc) · 3.23 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env node
const commander = require('commander')
const { prompt, Separator } = require('inquirer')
const RevealAddress = require('./index')
commander
.command('reveal')
.description('show address and private key from mnemonic words')
.option('-w, --words <words>', 'Mnemonic words')
.option('-n, --number <number>', 'Number of address to show')
.option('-p, --hdPath <hdPath>', 'Derivation Path')
.option('-t, --type <type>', 'Type of network')
.action(async (params) => {
const questions = [
{
type: 'password',
name: 'words',
message: 'Enter mnemonic words'
},
{
type: 'number',
name: 'number',
message: 'Enter number of address to show',
default: 3
},
{
type: 'list',
name: 'hdPath',
message: 'Enter Derivation Path',
choices: [
{ name: "TomoChain - m/44'/889'/0'/0", value: "m/44'/889'/0'/0" },
{ name: "Ethereum - m/44'/60'/0'", value: "m/44'/60'/0'" },
{ name: "Ledger Live - m/44'/60'/0'/0", value: "m/44'/60'/0'/0" },
{ name: "Tron network - Ledger Live - m/44'/195'/0'/0", value: "m/44'/195'/0'/0" },
{ name: "Solana - m/501'/0'/0 - deprecated", value: "0" },
{ name: "Solana - m/44'/501'/0' - bip44", value: "1" },
{ name: "Solana - m/44'/501'/0'/0' - bip44Changed", value: "2" }
]
},
{
type : 'list',
name : 'type',
message : 'Choose type of network',
default: 'TomoChain - Ethereum',
choices: ['TomoChain - Ethereum', new Separator(), 'Bitcoin', new Separator(), 'Tron', new Separator(), 'Solana']
}
]
prompt(questions).then(async answers => {
try {
let result
if (!answers.words) {
throw new Error('mnemonic words are required')
}
switch (answers.type) {
case 'TomoChain - Ethereum':
result = await RevealAddress.tomo(answers.words.trim(), answers.number, answers.hdPath.trim())
break
case 'Bitcoin':
result = await RevealAddress.bitcoin(answers.words.trim(), answers.number, answers.hdPath.trim())
break
case 'Tron':
result = await RevealAddress.tron(answers.words.trim(), answers.number, answers.hdPath.trim())
break
case 'Solana':
result = await RevealAddress.solana(answers.words.trim(), answers.number, answers.hdPath.trim())
break
default:
result = await RevealAddress.tomo(answers.words.trim(), answers.number, answers.hdPath.trim())
break;
}
console.log(JSON.stringify(result, null, 2))
} catch (error) {
throw error
}
})
})
commander.parse(process.argv)