chroid 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/cli/bitcoin.js +207 -0
- package/cli/evm.js +214 -0
- package/cli/tron.js +91 -0
- package/index.js +17 -0
- package/package.json +30 -0
- package/utils/askForPassword.js +23 -0
- package/utils/bitcoin.js +746 -0
- package/utils/const.js +8 -0
- package/utils/evm.js +425 -0
- package/utils/tron.js +163 -0
package/README.md
ADDED
package/cli/bitcoin.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
const askForPassword = require("../utils/askForPassword")
|
|
2
|
+
const { ExplorerURIs } = require("../utils/const")
|
|
3
|
+
const { generateWalletFromPassword, getConfirmedBalanceFromAddress, sendBtc, drainBtc, generateMultiSigWalletFromPasswords, sendBtcFromMultiSig, drainMultiSigBtc } = require("../utils/bitcoin");
|
|
4
|
+
|
|
5
|
+
const bitcoinCLI = async (yargs) => {
|
|
6
|
+
const argv = await yargs
|
|
7
|
+
.command("sat_addy", "Get Sat Address", {
|
|
8
|
+
t: {
|
|
9
|
+
alias: "type",
|
|
10
|
+
describe: "Address Type",
|
|
11
|
+
demandOption: false,
|
|
12
|
+
type: "string"
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
async (args) => {
|
|
16
|
+
const password = await askForPassword();
|
|
17
|
+
const { address } = await generateWalletFromPassword(password)
|
|
18
|
+
console.log(`\n${address}`)
|
|
19
|
+
})
|
|
20
|
+
.command("sat_maddy", "Get Sat MultiSig Address", {
|
|
21
|
+
t: {
|
|
22
|
+
alias: "type",
|
|
23
|
+
describe: "Address Type",
|
|
24
|
+
demandOption: false,
|
|
25
|
+
type: "string"
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
async (args) => {
|
|
29
|
+
const password0 = await askForPassword();
|
|
30
|
+
const password1 = await askForPassword();
|
|
31
|
+
const password2 = await askForPassword();
|
|
32
|
+
const { address } = await generateMultiSigWalletFromPasswords([password0, password1, password2])
|
|
33
|
+
console.log(`\n${address}`)
|
|
34
|
+
})
|
|
35
|
+
.command("sat_check", "Check Sats", {
|
|
36
|
+
t: {
|
|
37
|
+
alias: "type",
|
|
38
|
+
describe: "Address Type",
|
|
39
|
+
demandOption: false,
|
|
40
|
+
type: "string"
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
async (args) => {
|
|
44
|
+
const password = await askForPassword();
|
|
45
|
+
const { address } = await generateWalletFromPassword(password)
|
|
46
|
+
const balance = await getConfirmedBalanceFromAddress(address)
|
|
47
|
+
console.log(`\n${balance}`)
|
|
48
|
+
})
|
|
49
|
+
.command("sat_mcheck", "Check MultiSig Sats", {
|
|
50
|
+
},
|
|
51
|
+
async (args) => {
|
|
52
|
+
const password0 = await askForPassword();
|
|
53
|
+
const password1 = await askForPassword();
|
|
54
|
+
const password2 = await askForPassword();
|
|
55
|
+
const { address } = await generateMultiSigWalletFromPasswords([password0, password1, password2])
|
|
56
|
+
const balance = await getConfirmedBalanceFromAddress(address)
|
|
57
|
+
console.log(`\n${balance}`)
|
|
58
|
+
})
|
|
59
|
+
.command("sat_wif", "Get Sat WIF", {
|
|
60
|
+
t: {
|
|
61
|
+
alias: "type",
|
|
62
|
+
describe: "Address Type",
|
|
63
|
+
demandOption: false,
|
|
64
|
+
type: "string"
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
async (args) => {
|
|
68
|
+
const password = await askForPassword();
|
|
69
|
+
const { address, wif } = await generateWalletFromPassword(password)
|
|
70
|
+
console.log(`${wif}`)
|
|
71
|
+
})
|
|
72
|
+
.command("sat_trans", "Execute Sat Transaction", {
|
|
73
|
+
d: {
|
|
74
|
+
alias: "destination",
|
|
75
|
+
describe: "Destination address",
|
|
76
|
+
demandOption: true,
|
|
77
|
+
type: "string"
|
|
78
|
+
},
|
|
79
|
+
a: {
|
|
80
|
+
alias: "amount",
|
|
81
|
+
describe: "Amount in sats",
|
|
82
|
+
demandOption: true,
|
|
83
|
+
type: "string"
|
|
84
|
+
},
|
|
85
|
+
s: {
|
|
86
|
+
alias: "satsbyte",
|
|
87
|
+
describe: "Satoshis per byte",
|
|
88
|
+
demandOption: true,
|
|
89
|
+
type: "number"
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
async (args) => {
|
|
93
|
+
const password = await askForPassword();
|
|
94
|
+
const { mnemonic, wif, address } = await generateWalletFromPassword(password)
|
|
95
|
+
try {
|
|
96
|
+
const { success, result } = await sendBtc({ address, wif }, args.destination, parseInt(args.amount), parseInt(args.satsbyte))
|
|
97
|
+
if (!success) {
|
|
98
|
+
console.log("Error while bitcoin transfer")
|
|
99
|
+
console.log(result)
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
console.log(`\n${ExplorerURIs.bitcoin}${result}`)
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error(error)
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
.command("sat_mtrans", "Execute Sat MultiSig transaction", {
|
|
108
|
+
d: {
|
|
109
|
+
alias: "destination",
|
|
110
|
+
describe: "Destination address",
|
|
111
|
+
demandOption: true,
|
|
112
|
+
type: "string"
|
|
113
|
+
},
|
|
114
|
+
a: {
|
|
115
|
+
alias: "amount",
|
|
116
|
+
describe: "Amount in sats",
|
|
117
|
+
demandOption: true,
|
|
118
|
+
type: "string"
|
|
119
|
+
},
|
|
120
|
+
s: {
|
|
121
|
+
alias: "satsbyte",
|
|
122
|
+
describe: "Satoshis per byte",
|
|
123
|
+
demandOption: true,
|
|
124
|
+
type: "number"
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
async (args) => {
|
|
128
|
+
const password0 = await askForPassword();
|
|
129
|
+
const password1 = await askForPassword();
|
|
130
|
+
const password2 = await askForPassword();
|
|
131
|
+
const { address } = await generateMultiSigWalletFromPasswords([password0, password1, password2])
|
|
132
|
+
try {
|
|
133
|
+
const { success, result } = await sendBtcFromMultiSig(address, [password0, password1, password2], args.destination, parseInt(args.amount), parseInt(args.satsbyte))
|
|
134
|
+
if (!success) {
|
|
135
|
+
console.log("Error while transfer bitcoin from multi sig")
|
|
136
|
+
console.log(result)
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
console.log(`\n${ExplorerURIs.bitcoin}${result}`)
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error(error)
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
.command("sat_drain", "Execute Sat Drain Transaction", {
|
|
145
|
+
d: {
|
|
146
|
+
alias: "destination",
|
|
147
|
+
describe: "Destination address",
|
|
148
|
+
demandOption: true,
|
|
149
|
+
type: "string"
|
|
150
|
+
},
|
|
151
|
+
s: {
|
|
152
|
+
alias: "satsbyte",
|
|
153
|
+
describe: "Satoshis per byte",
|
|
154
|
+
demandOption: true,
|
|
155
|
+
type: "number"
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
async (args) => {
|
|
159
|
+
const password = await askForPassword();
|
|
160
|
+
const { mnemonic, wif, address } = await generateWalletFromPassword(password)
|
|
161
|
+
try {
|
|
162
|
+
const { success, result } = await drainBtc({ address, wif }, args.destination, parseInt(args.satsbyte))
|
|
163
|
+
if (!success) {
|
|
164
|
+
console.log("Error while bitcoin drain")
|
|
165
|
+
console.log(result)
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
console.log(`\n${ExplorerURIs.bitcoin}${result}`)
|
|
169
|
+
} catch (error) {
|
|
170
|
+
console.error(error)
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
.command("sat_mdrain", "Execute Sat MultiSig Drain Transaction", {
|
|
174
|
+
d: {
|
|
175
|
+
alias: "destination",
|
|
176
|
+
describe: "Destination address",
|
|
177
|
+
demandOption: true,
|
|
178
|
+
type: "string"
|
|
179
|
+
},
|
|
180
|
+
s: {
|
|
181
|
+
alias: "satsbyte",
|
|
182
|
+
describe: "Satoshis per byte",
|
|
183
|
+
demandOption: true,
|
|
184
|
+
type: "number"
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
async (args) => {
|
|
188
|
+
const password0 = await askForPassword();
|
|
189
|
+
const password1 = await askForPassword();
|
|
190
|
+
const password2 = await askForPassword();
|
|
191
|
+
const { address } = await generateMultiSigWalletFromPasswords([password0, password1, password2])
|
|
192
|
+
try {
|
|
193
|
+
const { success, result } = await drainMultiSigBtc(address, [password0, password1, password2], args.destination, parseInt(args.satsbyte))
|
|
194
|
+
if (!success) {
|
|
195
|
+
console.log("Error while bitcoin multisig drain")
|
|
196
|
+
console.log(result)
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
console.log(`\n${ExplorerURIs.bitcoin}${result}`)
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error(error)
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
return yargs
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
module.exports = bitcoinCLI
|
package/cli/evm.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
const askForPassword = require("../utils/askForPassword")
|
|
2
|
+
const { ExplorerURIs } = require("../utils/const")
|
|
3
|
+
const { generateWalletFromPassword, getBalanceFromAddress, getCustomBalanceFromAddress, transferNative, transferUSDT, transferUSDC, transferCustomToken } = require("../utils/evm");
|
|
4
|
+
|
|
5
|
+
const evmCLI = async (yargs) => {
|
|
6
|
+
const argv = await yargs
|
|
7
|
+
.command("evm_addy", "Get EVM Address", {
|
|
8
|
+
},
|
|
9
|
+
async (args) => {
|
|
10
|
+
const password = await askForPassword();
|
|
11
|
+
const { privateKeyHex, address } = await generateWalletFromPassword(password)
|
|
12
|
+
console.log(`\n${address}`)
|
|
13
|
+
})
|
|
14
|
+
.command("evm_pvkey", "Get EVM Private Key Hex", {
|
|
15
|
+
},
|
|
16
|
+
async (args) => {
|
|
17
|
+
const password = await askForPassword();
|
|
18
|
+
const { privateKeyHex, address } = await generateWalletFromPassword(password)
|
|
19
|
+
console.log(`\n${privateKeyHex}`)
|
|
20
|
+
})
|
|
21
|
+
.command("evm_networks", "Get Available EVM Networks", {},
|
|
22
|
+
async (args) => {
|
|
23
|
+
console.log(`\n`)
|
|
24
|
+
Object.keys(networks).forEach(network => {
|
|
25
|
+
network && console.log(`${network}`)
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
.command("evm_check", "Check Native Token, USDT and USDC", {
|
|
29
|
+
n: {
|
|
30
|
+
alias: "network",
|
|
31
|
+
describe: "Network",
|
|
32
|
+
demandOption: true,
|
|
33
|
+
type: "string"
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
async (args) => {
|
|
37
|
+
const password = await askForPassword();
|
|
38
|
+
const { address } = await generateWalletFromPassword(password)
|
|
39
|
+
const { native_balance, usdt_balance, usdc_balance } = await getBalanceFromAddress(address, args.network)
|
|
40
|
+
console.log(`\nN: ${native_balance}`)
|
|
41
|
+
console.log(`T: ${usdt_balance}`)
|
|
42
|
+
console.log(`C: ${usdc_balance}`)
|
|
43
|
+
})
|
|
44
|
+
.command("evm_checkc", "Check Custom ERC20 Token Balance", {
|
|
45
|
+
n: {
|
|
46
|
+
alias: "network",
|
|
47
|
+
describe: "Network",
|
|
48
|
+
demandOption: true,
|
|
49
|
+
type: "string"
|
|
50
|
+
},
|
|
51
|
+
t: {
|
|
52
|
+
alias: "token",
|
|
53
|
+
describe: "Custom token address",
|
|
54
|
+
demandOption: true,
|
|
55
|
+
type: "string"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
async (args) => {
|
|
59
|
+
const password = await askForPassword();
|
|
60
|
+
const { address } = await generateWalletFromPassword(password)
|
|
61
|
+
const { native_balance, token_balance } = await getCustomBalanceFromAddress(address, args.token, args.network)
|
|
62
|
+
console.log(`\nN: ${native_balance}`)
|
|
63
|
+
console.log(`B: ${token_balance}`)
|
|
64
|
+
})
|
|
65
|
+
.command("evm_transn", "Execute EVM Native Token Transaction", {
|
|
66
|
+
d: {
|
|
67
|
+
alias: "destination",
|
|
68
|
+
describe: "Destination address",
|
|
69
|
+
demandOption: true,
|
|
70
|
+
type: "string"
|
|
71
|
+
},
|
|
72
|
+
a: {
|
|
73
|
+
alias: "amount",
|
|
74
|
+
describe: "Amount in native coin",
|
|
75
|
+
demandOption: true,
|
|
76
|
+
type: "string"
|
|
77
|
+
},
|
|
78
|
+
n: {
|
|
79
|
+
alias: "network",
|
|
80
|
+
describe: "Network",
|
|
81
|
+
demandOption: true,
|
|
82
|
+
type: "string"
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
async (args) => {
|
|
86
|
+
const password = await askForPassword();
|
|
87
|
+
const { privateKeyHex, address } = await generateWalletFromPassword(password)
|
|
88
|
+
try {
|
|
89
|
+
const { success, txUrl, error } = await transferNative({ address, privateKeyHex }, args.destination, args.amount, args.network)
|
|
90
|
+
if (!success) {
|
|
91
|
+
console.log("Error while transfer")
|
|
92
|
+
console.log(error)
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
console.log(`\n${txUrl}`)
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error(error)
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
.command("evm_transt", "Execute USDT Transaction", {
|
|
101
|
+
d: {
|
|
102
|
+
alias: "destination",
|
|
103
|
+
describe: "Destination address",
|
|
104
|
+
demandOption: true,
|
|
105
|
+
type: "string"
|
|
106
|
+
},
|
|
107
|
+
a: {
|
|
108
|
+
alias: "amount",
|
|
109
|
+
describe: "Amount in usdt",
|
|
110
|
+
demandOption: true,
|
|
111
|
+
type: "string"
|
|
112
|
+
},
|
|
113
|
+
n: {
|
|
114
|
+
alias: "network",
|
|
115
|
+
describe: "Network",
|
|
116
|
+
demandOption: true,
|
|
117
|
+
type: "string"
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
async (args) => {
|
|
121
|
+
const password = await askForPassword();
|
|
122
|
+
const { privateKeyHex, address } = await generateWalletFromPassword(password)
|
|
123
|
+
try {
|
|
124
|
+
const { success, error, txUrl } = await transferUSDT({ address, privateKeyHex }, args.destination, args.amount, args.network)
|
|
125
|
+
if (!success) {
|
|
126
|
+
console.log("Error while transfer")
|
|
127
|
+
console.log(error)
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
console.log(`\n${txUrl}`)
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.error(error)
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
.command("evm_transc", "Execute USDC Transaction", {
|
|
136
|
+
d: {
|
|
137
|
+
alias: "destination",
|
|
138
|
+
describe: "Destination address",
|
|
139
|
+
demandOption: true,
|
|
140
|
+
type: "string"
|
|
141
|
+
},
|
|
142
|
+
a: {
|
|
143
|
+
alias: "amount",
|
|
144
|
+
describe: "Amount in usdc",
|
|
145
|
+
demandOption: true,
|
|
146
|
+
type: "string"
|
|
147
|
+
},
|
|
148
|
+
n: {
|
|
149
|
+
alias: "network",
|
|
150
|
+
describe: "Network",
|
|
151
|
+
demandOption: true,
|
|
152
|
+
type: "string"
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
async (args) => {
|
|
156
|
+
const password = await askForPassword();
|
|
157
|
+
const { privateKeyHex, address } = await generateWalletFromPassword(password)
|
|
158
|
+
try {
|
|
159
|
+
const { success, error, txUrl } = await transferUSDC({ address, privateKeyHex }, args.destination, args.amount, args.network)
|
|
160
|
+
if (!success) {
|
|
161
|
+
console.log("Error while transfer")
|
|
162
|
+
console.log(error)
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
console.log(`\n${txUrl}`)
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error(error)
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
.command("evm_transcus", "Transfer Custom ERC20 Token", {
|
|
171
|
+
d: {
|
|
172
|
+
alias: "destination",
|
|
173
|
+
describe: "Destination address",
|
|
174
|
+
demandOption: true,
|
|
175
|
+
type: "string"
|
|
176
|
+
},
|
|
177
|
+
a: {
|
|
178
|
+
alias: "amount",
|
|
179
|
+
describe: "Amount in native coin",
|
|
180
|
+
demandOption: true,
|
|
181
|
+
type: "string"
|
|
182
|
+
},
|
|
183
|
+
t: {
|
|
184
|
+
alias: "token",
|
|
185
|
+
describe: "Custom token address",
|
|
186
|
+
demandOption: true,
|
|
187
|
+
type: "string"
|
|
188
|
+
},
|
|
189
|
+
n: {
|
|
190
|
+
alias: "network",
|
|
191
|
+
describe: "Network",
|
|
192
|
+
demandOption: true,
|
|
193
|
+
type: "string"
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
async (args) => {
|
|
197
|
+
const password = await askForPassword();
|
|
198
|
+
const { privateKeyHex, address } = await generateWalletFromPassword(password)
|
|
199
|
+
try {
|
|
200
|
+
const { success, txUrl, error } = await transferCustomToken({ address, privateKeyHex }, args.destination, args.token, args.amount, args.network)
|
|
201
|
+
if (!success) {
|
|
202
|
+
console.log("Error while transfer")
|
|
203
|
+
console.log(error)
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
console.log(`\n${txUrl}`)
|
|
207
|
+
} catch (error) {
|
|
208
|
+
console.error(error)
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
return yargs
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
module.exports = evmCLI
|
package/cli/tron.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const askForPassword = require("../utils/askForPassword")
|
|
2
|
+
const { ExplorerURIs } = require("../utils/const")
|
|
3
|
+
const { generateWalletFromPassword, getBalanceFromAddress, transferTRX, transferUSDT } = require("../utils/tron");
|
|
4
|
+
|
|
5
|
+
const tronCLI = async (yargs) => {
|
|
6
|
+
const argv = await yargs
|
|
7
|
+
.command("trc_addy", "Get Tron Address", {
|
|
8
|
+
},
|
|
9
|
+
async (args) => {
|
|
10
|
+
const password = await askForPassword();
|
|
11
|
+
const { privateKeyHex, address } = await generateWalletFromPassword(password)
|
|
12
|
+
console.log(`\n${address}`)
|
|
13
|
+
})
|
|
14
|
+
.command("trc_check", "Check TRX and Tron USDT", {
|
|
15
|
+
},
|
|
16
|
+
async (args) => {
|
|
17
|
+
const password = await askForPassword();
|
|
18
|
+
const { address } = await generateWalletFromPassword(password)
|
|
19
|
+
const { trx_balance, usdt_balance } = await getBalanceFromAddress(address)
|
|
20
|
+
console.log(`\nX: ${trx_balance}`)
|
|
21
|
+
console.log(`T: ${usdt_balance}`)
|
|
22
|
+
})
|
|
23
|
+
.command("trc_pvkey", "Get Tron Private Key Hex", {
|
|
24
|
+
},
|
|
25
|
+
async (args) => {
|
|
26
|
+
const password = await askForPassword();
|
|
27
|
+
const { privateKeyHex, address } = await generateWalletFromPassword(password)
|
|
28
|
+
console.log(`\n${privateKeyHex}`)
|
|
29
|
+
})
|
|
30
|
+
.command("trc_transx", "Execute TRX transaction", {
|
|
31
|
+
d: {
|
|
32
|
+
alias: "destination",
|
|
33
|
+
describe: "Destination address",
|
|
34
|
+
demandOption: true,
|
|
35
|
+
type: "string"
|
|
36
|
+
},
|
|
37
|
+
a: {
|
|
38
|
+
alias: "amount",
|
|
39
|
+
describe: "Amount in trx",
|
|
40
|
+
demandOption: true,
|
|
41
|
+
type: "string"
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
async (args) => {
|
|
45
|
+
const password = await askForPassword();
|
|
46
|
+
const { privateKeyHex, address } = await generateWalletFromPassword(password)
|
|
47
|
+
try {
|
|
48
|
+
const { success, result } = await transferTRX({ address, privateKeyHex }, args.destination, args.amount)
|
|
49
|
+
if (!success) {
|
|
50
|
+
console.log("Error while TRX transfer")
|
|
51
|
+
console.log(result)
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
console.log(`\n${ExplorerURIs.tron}${result}`)
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error(error)
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
.command("trc_transt", "Execute Tron USDT Transaction", {
|
|
60
|
+
d: {
|
|
61
|
+
alias: "destination",
|
|
62
|
+
describe: "Destination address",
|
|
63
|
+
demandOption: true,
|
|
64
|
+
type: "string"
|
|
65
|
+
},
|
|
66
|
+
a: {
|
|
67
|
+
alias: "amount",
|
|
68
|
+
describe: "Amount in usdt",
|
|
69
|
+
demandOption: true,
|
|
70
|
+
type: "string"
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
async (args) => {
|
|
74
|
+
const password = await askForPassword();
|
|
75
|
+
const { privateKeyHex, address } = await generateWalletFromPassword(password)
|
|
76
|
+
try {
|
|
77
|
+
const { success, result } = await transferUSDT({ address, privateKeyHex }, args.destination, args.amount)
|
|
78
|
+
if (!success) {
|
|
79
|
+
console.log("Error while TRC20 transfer")
|
|
80
|
+
console.log(result)
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
console.log(`\n${ExplorerURIs.tron}${result}`)
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(error)
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
return yargs
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
module.exports = tronCLI
|
package/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const yargs = require("yargs");
|
|
4
|
+
|
|
5
|
+
const bitcoinCLI = require("./cli/bitcoin");
|
|
6
|
+
const tronCLI = require("./cli/tron");
|
|
7
|
+
const evmCLI = require("./cli/evm");
|
|
8
|
+
|
|
9
|
+
const mainFunction = async () => {
|
|
10
|
+
let cli = yargs;
|
|
11
|
+
cli = await bitcoinCLI(yargs)
|
|
12
|
+
cli = await tronCLI(yargs)
|
|
13
|
+
cli = await evmCLI(yargs)
|
|
14
|
+
cli.help().argv
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
mainFunction()
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chroid",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI wallet for multi-chain support",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"chroid": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"start": "node index.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "Chainoroid",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"base58": "^2.0.1",
|
|
18
|
+
"bip32": "^4.0.0",
|
|
19
|
+
"bip39": "^3.1.0",
|
|
20
|
+
"bitcoinjs-lib": "^6.1.5",
|
|
21
|
+
"ecpair": "^2.1.0",
|
|
22
|
+
"ethers": "^6.13.5",
|
|
23
|
+
"hdkey": "^2.1.0",
|
|
24
|
+
"js-sha256": "^0.11.0",
|
|
25
|
+
"readline": "^1.3.0",
|
|
26
|
+
"tiny-secp256k1": "^2.2.3",
|
|
27
|
+
"tronweb": "^6.0.0",
|
|
28
|
+
"yargs": "^17.7.2"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const readline = require('readline');
|
|
2
|
+
|
|
3
|
+
function askForPassword(query = "Check your passkey: ") {
|
|
4
|
+
return new Promise((resolve) => {
|
|
5
|
+
const rl = readline.createInterface({
|
|
6
|
+
input: process.stdin,
|
|
7
|
+
output: process.stdout
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
rl.question(query, (answer) => {
|
|
11
|
+
rl.close();
|
|
12
|
+
resolve(answer);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Hide input on the terminal by listening to keypress events
|
|
16
|
+
rl.stdoutMuted = true;
|
|
17
|
+
rl._writeToOutput = function _writeToOutput() {
|
|
18
|
+
// if (rl.stdoutMuted) rl.output.write("*");
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = askForPassword
|