-
Notifications
You must be signed in to change notification settings - Fork 0
/
psf-bch-wallet.js
94 lines (79 loc) · 3.35 KB
/
psf-bch-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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
This is the primary entry point for the psf-bch-wallet CLI app.
This app uses commander.js.
*/
// Global npm libraries
import { Command } from 'commander'
// Local libraries
import WalletCreate from './src/commands/wallet-create.js'
import WalletList from './src/commands/wallet-list.js'
import WalletAddrs from './src/commands/wallet-addrs.js'
import WalletBalance from './src/commands/wallet-balance.js'
import SendBch from './src/commands/send-bch.js'
import SendTokens from './src/commands/send-tokens.js'
import WalletSweep from './src/commands/wallet-sweep.js'
import MsgSign from './src/commands/msg-sign.js'
import MsgVerify from './src/commands/msg-verify.js'
// Instantiate the subcommands
const walletCreate = new WalletCreate()
const walletList = new WalletList()
const walletAddrs = new WalletAddrs()
const walletBalance = new WalletBalance()
const sendBch = new SendBch()
const sendTokens = new SendTokens()
const walletSweep = new WalletSweep()
const msgSign = new MsgSign()
const msgVerify = new MsgVerify()
const program = new Command()
program
// Define the psf-bch-wallet app options
.name('psf-bch-wallet')
.description('A command-line BCH and SLP token wallet.')
// Define the wallet-create command
program.command('wallet-create')
.description('Create a new wallet with name (-n <name>) and description (-d)')
.option('-n, --name <string>', 'wallet name')
.option('-d --description <string>', 'what the wallet is being used for')
.action(walletCreate.run)
// Define the wallet-list command
program.command('wallet-list')
.description('List existing wallets')
.action(walletList.run)
program.command('wallet-addrs')
.description('List the different addresses for a wallet.')
.option('-n, --name <string>', 'wallet name')
.action(walletAddrs.run)
program.command('wallet-balance')
.description('Get balances in BCH and SLP tokens held by the wallet.')
.option('-n, --name <string>', 'wallet name')
.action(walletBalance.run)
program.command('wallet-sweep')
.description('Sweep funds from a WIF private key')
.option('-n, --name <string>', 'wallet name receiving BCH')
.option('-w, --wif <string>', 'WIF private key to sweep')
.action(walletSweep.run)
program.command('send-bch')
.description('Send BCH to an address')
.option('-n, --name <string>', 'wallet name sending BCH')
.option('-a, --addr <string>', 'address to send BCH to')
.option('-q, --qty <string>', 'The quantity of BCH to send')
.action(sendBch.run)
program.command('send-tokens')
.description('Send SLP tokens to an address')
.option('-n, --name <string>', 'wallet name sending BCH')
.option('-a, --addr <string>', 'address to send BCH to')
.option('-q, --qty <string>', 'The quantity of BCH to send')
.option('-t, --tokenId <string>', 'The token ID of the token to send')
.action(sendTokens.run)
program.command('msg-sign')
.description('Sign a message using the wallets private key')
.option('-n, --name <string>', 'wallet to sign the message')
.option('-m, --msg <string>', 'Message to sign')
.action(msgSign.run)
program.command('msg-verify')
.description('Verify a signature')
.option('-s, --sig <string>', 'Signature')
.option('-m, --msg <string>', 'Cleartext message that was signed')
.option('-a, --addr <string>', 'BCH address generated from private key that signed the message')
.action(msgVerify.run)
program.parseAsync(process.argv)