paytaca-cli 0.1.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/LICENSE +22 -0
- package/README.md +142 -0
- package/bin/paytaca.js +2 -0
- package/dist/commands/address.d.ts +10 -0
- package/dist/commands/address.d.ts.map +1 -0
- package/dist/commands/address.js +72 -0
- package/dist/commands/address.js.map +1 -0
- package/dist/commands/balance.d.ts +10 -0
- package/dist/commands/balance.d.ts.map +1 -0
- package/dist/commands/balance.js +70 -0
- package/dist/commands/balance.js.map +1 -0
- package/dist/commands/history.d.ts +10 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +114 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/receive.d.ts +10 -0
- package/dist/commands/receive.d.ts.map +1 -0
- package/dist/commands/receive.js +54 -0
- package/dist/commands/receive.js.map +1 -0
- package/dist/commands/send.d.ts +18 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +94 -0
- package/dist/commands/send.js.map +1 -0
- package/dist/commands/wallet.d.ts +11 -0
- package/dist/commands/wallet.d.ts.map +1 -0
- package/dist/commands/wallet.js +151 -0
- package/dist/commands/wallet.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/storage/keychain.d.ts +56 -0
- package/dist/storage/keychain.d.ts.map +1 -0
- package/dist/storage/keychain.js +92 -0
- package/dist/storage/keychain.js.map +1 -0
- package/dist/utils/crypto.d.ts +23 -0
- package/dist/utils/crypto.d.ts.map +1 -0
- package/dist/utils/crypto.js +68 -0
- package/dist/utils/crypto.js.map +1 -0
- package/dist/utils/network.d.ts +27 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +45 -0
- package/dist/utils/network.js.map +1 -0
- package/dist/wallet/bch.d.ts +137 -0
- package/dist/wallet/bch.d.ts.map +1 -0
- package/dist/wallet/bch.js +197 -0
- package/dist/wallet/bch.js.map +1 -0
- package/dist/wallet/index.d.ts +72 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +120 -0
- package/dist/wallet/index.js.map +1 -0
- package/dist/wallet/keys.d.ts +69 -0
- package/dist/wallet/keys.d.ts.map +1 -0
- package/dist/wallet/keys.js +125 -0
- package/dist/wallet/keys.js.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright Paytaca Inc. 2021. All rights reserved.
|
|
2
|
+
|
|
3
|
+
You acknowledge and agree that Paytaca Inc. (Paytaca) (or Paytaca's licensors) own all legal right, title and interest in and to the work, software, application, source code, documentation and any other documents in this repository (collectively, the “Program”), including any intellectual property rights which subsist in the Program (whether those rights happen to be registered or not, and wherever in the world those rights may exist), whether in source code or any other form.
|
|
4
|
+
|
|
5
|
+
Subject to the limited license below, you may not (and you may not permit anyone else to) distribute, publish, copy, modify, merge, combine with another program, create derivative works of, reverse engineer, decompile or otherwise attempt to extract the source code of, the Program or any part thereof, except that you may contribute to this repository.
|
|
6
|
+
|
|
7
|
+
You are granted a non-exclusive, non-transferable, non-sublicensable license to distribute, publish, copy, modify, merge, combine with another program or create derivative works of the Program (such resulting program, collectively, the “Resulting Program”) solely for Non-Commercial Use as long as you:
|
|
8
|
+
1. give prominent notice (“Notice”) with each copy of the Resulting Program that the Program is used in the Resulting Program and that the Program is the copyright of Paytaca; and
|
|
9
|
+
2. subject the Resulting Program and any distribution, publication, copy, modification, merger therewith, combination with another program or derivative works thereof to the same Notice requirement and Non-Commercial Use restriction set forth herein.
|
|
10
|
+
|
|
11
|
+
“Non-Commercial Use” means each use as described in clauses (1)-(3) below, as reasonably determined by Paytaca in its sole discretion:
|
|
12
|
+
1. personal use for research, personal study, private entertainment, hobby projects or amateur pursuits, in each case without any anticipated commercial application;
|
|
13
|
+
2. use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization or government institution; or
|
|
14
|
+
3. the number of monthly active users of the Resulting Program across all versions thereof and platforms globally do not exceed 10,000 at any time.
|
|
15
|
+
|
|
16
|
+
You will not use any trade mark, service mark, trade name, logo of Paytaca or any other company or organization in a way that is likely or intended to cause confusion about the owner or authorized user of such marks, names or logos.
|
|
17
|
+
|
|
18
|
+
If you have any questions, comments or interest in pursuing any other use cases, please reach out to us at info@paytaca.com.
|
|
19
|
+
|
|
20
|
+
-------
|
|
21
|
+
|
|
22
|
+
The license text above is patterned after MetaMask's license (https://github.com/MetaMask/metamask-extension/blob/develop/LICENSE)
|
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Paytaca CLI
|
|
2
|
+
|
|
3
|
+
A command-line interface for the Paytaca [Bitcoin Cash](https://bitcoincash.org) (BCH) wallet. Built with the same core logic as the [Paytaca mobile app](https://github.com/paytaca/paytaca-app), using [watchtower-cash-js](https://github.com/paytaca/watchtower-cash-js) for transaction operations and [libauth](https://github.com/bitauth/libauth) for HD key derivation.
|
|
4
|
+
|
|
5
|
+
Bitcoin Cash is peer-to-peer electronic cash, enabling fast, low-fee transactions for everyday use. Paytaca CLI brings the full capabilities of the Paytaca wallet to the terminal — create wallets, derive addresses, send and receive BCH, and view transaction history, all from the command line.
|
|
6
|
+
|
|
7
|
+
Designed to be AI agent-friendly and useful for automation by power users.
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
- Node.js >= 20 (developed on 22.12.0)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
git clone <repo-url> && cd paytaca-cli
|
|
17
|
+
npm install
|
|
18
|
+
npm run build
|
|
19
|
+
npm link
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
After linking, the `paytaca` command is available globally.
|
|
23
|
+
|
|
24
|
+
## Commands
|
|
25
|
+
|
|
26
|
+
### Wallet
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
paytaca wallet create # Generate a new 12-word seed phrase
|
|
30
|
+
paytaca wallet create --chipnet # Create on chipnet (testnet)
|
|
31
|
+
paytaca wallet import # Import an existing seed phrase
|
|
32
|
+
paytaca wallet info # Show wallet hash, address, and balance
|
|
33
|
+
paytaca wallet export # Display the stored seed phrase
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Balance
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
paytaca balance # Show BCH balance (BCH + sats)
|
|
40
|
+
paytaca balance --sats # Show in satoshis only
|
|
41
|
+
paytaca balance --chipnet # Query chipnet balance
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Receive
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
paytaca receive # Show receiving address with QR code
|
|
48
|
+
paytaca receive 3 # Show address at index 3
|
|
49
|
+
paytaca receive --no-qr # Address only, no QR code
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Send
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
paytaca send <address> <amount> # Send BCH
|
|
56
|
+
paytaca send <address> 50000 --unit sats # Send in satoshis
|
|
57
|
+
paytaca send <address> 0.001 --chipnet # Send on chipnet
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Transaction History
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
paytaca history # Show recent transactions
|
|
64
|
+
paytaca history --sats # Amounts in satoshis
|
|
65
|
+
paytaca history --type incoming # Filter: incoming, outgoing, or all
|
|
66
|
+
paytaca history --page 2 # Pagination
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Address
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
paytaca address derive # Derive address at index 0
|
|
73
|
+
paytaca address derive 5 # Derive address at index 5
|
|
74
|
+
paytaca address list # List first 5 addresses
|
|
75
|
+
paytaca address list -n 20 # List first 20 addresses
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Network
|
|
79
|
+
|
|
80
|
+
All commands default to **mainnet**. Pass `--chipnet` for testnet:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
paytaca wallet create --chipnet
|
|
84
|
+
paytaca balance --chipnet
|
|
85
|
+
paytaca send <address> <amount> --chipnet
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Security
|
|
89
|
+
|
|
90
|
+
Seed phrases are stored in the OS native keychain:
|
|
91
|
+
|
|
92
|
+
- **macOS** — Keychain
|
|
93
|
+
- **Linux** — GNOME Keyring / KWallet
|
|
94
|
+
- **Windows** — Credential Manager
|
|
95
|
+
|
|
96
|
+
Powered by [@napi-rs/keyring](https://github.com/Brooooooklyn/keyring-node) (prebuilt Rust binaries, no node-gyp required).
|
|
97
|
+
|
|
98
|
+
## Architecture
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
src/
|
|
102
|
+
commands/ CLI command definitions (Commander.js)
|
|
103
|
+
wallet.ts wallet create | import | info | export
|
|
104
|
+
balance.ts balance display
|
|
105
|
+
receive.ts receiving address + QR code
|
|
106
|
+
send.ts BCH sending
|
|
107
|
+
history.ts transaction history
|
|
108
|
+
address.ts HD address derivation
|
|
109
|
+
wallet/
|
|
110
|
+
index.ts Wallet class, mnemonic gen/import/load
|
|
111
|
+
bch.ts BchWallet (balance, send, history, subscribe)
|
|
112
|
+
keys.ts LibauthHDWallet (HD key derivation)
|
|
113
|
+
storage/
|
|
114
|
+
keychain.ts OS keychain wrapper (@napi-rs/keyring)
|
|
115
|
+
utils/
|
|
116
|
+
crypto.ts pubkey -> CashAddress pipeline
|
|
117
|
+
network.ts Watchtower URLs, derivation paths
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Key Dependencies
|
|
121
|
+
|
|
122
|
+
| Package | Purpose |
|
|
123
|
+
|---------|---------|
|
|
124
|
+
| `watchtower-cash-js` | UTXO fetching, tx building/signing/broadcasting |
|
|
125
|
+
| `@bitauth/libauth` | HD key derivation (pinned to 2.0.0-alpha.8) |
|
|
126
|
+
| `@napi-rs/keyring` | OS-native keychain storage |
|
|
127
|
+
| `bip39` | Mnemonic generation and validation |
|
|
128
|
+
| `commander` | CLI framework |
|
|
129
|
+
| `chalk` | Terminal colors |
|
|
130
|
+
| `qrcode-terminal` | Terminal QR code rendering |
|
|
131
|
+
|
|
132
|
+
## Development
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npm run dev # Watch mode (recompile on change)
|
|
136
|
+
npm run build # One-time build
|
|
137
|
+
npm run clean # Remove dist/
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
Copyright Paytaca Inc. 2021. All rights reserved. See [LICENSE](LICENSE) for details.
|
package/bin/paytaca.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI commands: address derive | list
|
|
3
|
+
*
|
|
4
|
+
* Derives Bitcoin Cash addresses from the stored seed phrase
|
|
5
|
+
* using the HD path m/44'/145'/0'/0/{index} (receiving)
|
|
6
|
+
* and m/44'/145'/0'/1/{index} (change).
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
export declare function registerAddressCommands(program: Command): void;
|
|
10
|
+
//# sourceMappingURL=address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/commands/address.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkF9D"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI commands: address derive | list
|
|
3
|
+
*
|
|
4
|
+
* Derives Bitcoin Cash addresses from the stored seed phrase
|
|
5
|
+
* using the HD path m/44'/145'/0'/0/{index} (receiving)
|
|
6
|
+
* and m/44'/145'/0'/1/{index} (change).
|
|
7
|
+
*/
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import { loadWallet, loadMnemonic } from '../wallet/index.js';
|
|
10
|
+
export function registerAddressCommands(program) {
|
|
11
|
+
const address = program
|
|
12
|
+
.command('address')
|
|
13
|
+
.description('Derive and list BCH addresses');
|
|
14
|
+
// ── address derive ─────────────────────────────────────────────────────
|
|
15
|
+
address
|
|
16
|
+
.command('derive')
|
|
17
|
+
.description('Derive receiving and change addresses at a given index')
|
|
18
|
+
.argument('[index]', 'Address index (default: 0)', '0')
|
|
19
|
+
.option('--chipnet', 'Use chipnet (testnet) instead of mainnet')
|
|
20
|
+
.action((_index, opts) => {
|
|
21
|
+
const isChipnet = Boolean(opts.chipnet);
|
|
22
|
+
const index = parseInt(_index, 10);
|
|
23
|
+
if (isNaN(index) || index < 0) {
|
|
24
|
+
console.log(chalk.red('\nError: Index must be a non-negative integer.\n'));
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const data = loadMnemonic();
|
|
28
|
+
if (!data) {
|
|
29
|
+
console.log(chalk.red('\nNo wallet found. Run `paytaca wallet create` or `paytaca wallet import` first.\n'));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
const w = loadWallet();
|
|
33
|
+
const bchWallet = w.forNetwork(isChipnet);
|
|
34
|
+
const network = isChipnet ? 'chipnet' : 'mainnet';
|
|
35
|
+
const addressSet = bchWallet.getAddressSetAt(index);
|
|
36
|
+
console.log(chalk.bold(`\n Address at index ${index} (${network})\n`));
|
|
37
|
+
console.log(` Receiving: ${addressSet.receiving}`);
|
|
38
|
+
console.log(chalk.dim(` Change: ${addressSet.change}`));
|
|
39
|
+
console.log();
|
|
40
|
+
});
|
|
41
|
+
// ── address list ───────────────────────────────────────────────────────
|
|
42
|
+
address
|
|
43
|
+
.command('list')
|
|
44
|
+
.description('List derived receiving addresses')
|
|
45
|
+
.option('-n, --count <count>', 'Number of addresses to derive', '5')
|
|
46
|
+
.option('--chipnet', 'Use chipnet (testnet) instead of mainnet')
|
|
47
|
+
.action((_opts) => {
|
|
48
|
+
const isChipnet = Boolean(_opts.chipnet);
|
|
49
|
+
const count = parseInt(_opts.count, 10);
|
|
50
|
+
if (isNaN(count) || count < 1) {
|
|
51
|
+
console.log(chalk.red('\nError: Count must be a positive integer.\n'));
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
const data = loadMnemonic();
|
|
55
|
+
if (!data) {
|
|
56
|
+
console.log(chalk.red('\nNo wallet found. Run `paytaca wallet create` or `paytaca wallet import` first.\n'));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
const w = loadWallet();
|
|
60
|
+
const bchWallet = w.forNetwork(isChipnet);
|
|
61
|
+
const network = isChipnet ? 'chipnet' : 'mainnet';
|
|
62
|
+
console.log(chalk.bold(`\n Addresses (${network})\n`));
|
|
63
|
+
console.log(chalk.dim(` ${'Index'.padEnd(8)}${'Receiving Address'}`));
|
|
64
|
+
console.log(chalk.dim(` ${'─'.repeat(70)}`));
|
|
65
|
+
for (let i = 0; i < count; i++) {
|
|
66
|
+
const addressSet = bchWallet.getAddressSetAt(i);
|
|
67
|
+
console.log(` ${String(i).padEnd(8)}${addressSet.receiving}`);
|
|
68
|
+
}
|
|
69
|
+
console.log();
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/commands/address.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAE7D,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,MAAM,OAAO,GAAG,OAAO;SACpB,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,+BAA+B,CAAC,CAAA;IAE/C,0EAA0E;IAC1E,O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OAAO,KAAK,CAAC,CAAC,CAAA;QACxD,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CACP,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,mBAAmB,EAAE,CAChD,CACF,CAAA;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;QAE9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/B,MAAM,UAAU,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;YAC/C,OAAO,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC,CAAA;QACjE,CAAC;QAED,OAAO,CAAC,GAAG,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: balance
|
|
3
|
+
*
|
|
4
|
+
* Displays the BCH balance for the current wallet.
|
|
5
|
+
* Shows both BCH and satoshi denominations, plus spendable vs total
|
|
6
|
+
* when they differ (e.g. unconfirmed UTXOs).
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
export declare function registerBalanceCommand(program: Command): void;
|
|
10
|
+
//# sourceMappingURL=balance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../src/commands/balance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAcnC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2E7D"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: balance
|
|
3
|
+
*
|
|
4
|
+
* Displays the BCH balance for the current wallet.
|
|
5
|
+
* Shows both BCH and satoshi denominations, plus spendable vs total
|
|
6
|
+
* when they differ (e.g. unconfirmed UTXOs).
|
|
7
|
+
*/
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import { loadWallet, loadMnemonic } from '../wallet/index.js';
|
|
10
|
+
/** Convert BCH to satoshis (1 BCH = 100,000,000 sats) */
|
|
11
|
+
function bchToSats(bch) {
|
|
12
|
+
return Math.round(bch * 1e8);
|
|
13
|
+
}
|
|
14
|
+
/** Format a number with thousands separators */
|
|
15
|
+
function formatSats(sats) {
|
|
16
|
+
return sats.toLocaleString('en-US');
|
|
17
|
+
}
|
|
18
|
+
export function registerBalanceCommand(program) {
|
|
19
|
+
program
|
|
20
|
+
.command('balance')
|
|
21
|
+
.description('Display wallet balance')
|
|
22
|
+
.option('--chipnet', 'Use chipnet (testnet) instead of mainnet')
|
|
23
|
+
.option('--sats', 'Display balance in satoshis only')
|
|
24
|
+
.action(async (opts) => {
|
|
25
|
+
const isChipnet = Boolean(opts.chipnet);
|
|
26
|
+
const showSatsOnly = Boolean(opts.sats);
|
|
27
|
+
const network = isChipnet ? 'chipnet' : 'mainnet';
|
|
28
|
+
// ── Validate wallet ──────────────────────────────────────────────
|
|
29
|
+
const data = loadMnemonic();
|
|
30
|
+
if (!data) {
|
|
31
|
+
console.log(chalk.red('\nNo wallet found. Run `paytaca wallet create` or `paytaca wallet import` first.\n'));
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
const w = loadWallet();
|
|
35
|
+
const bchWallet = w.forNetwork(isChipnet);
|
|
36
|
+
console.log(chalk.bold(`\n Balance (${network})\n`));
|
|
37
|
+
try {
|
|
38
|
+
const result = await bchWallet.getBalance();
|
|
39
|
+
const balanceSats = bchToSats(result.balance);
|
|
40
|
+
const spendableSats = bchToSats(result.spendable);
|
|
41
|
+
if (showSatsOnly) {
|
|
42
|
+
console.log(` Balance: ${formatSats(balanceSats)} sats`);
|
|
43
|
+
if (result.spendable !== result.balance) {
|
|
44
|
+
console.log(chalk.dim(` Spendable: ${formatSats(spendableSats)} sats`));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
console.log(` Balance: ${result.balance} BCH`);
|
|
49
|
+
console.log(chalk.dim(` ${formatSats(balanceSats)} sats`));
|
|
50
|
+
if (result.spendable !== result.balance) {
|
|
51
|
+
console.log(` Spendable: ${result.spendable} BCH`);
|
|
52
|
+
console.log(chalk.dim(` ${formatSats(spendableSats)} sats`));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
const status = err?.response?.status;
|
|
58
|
+
if (status === 404) {
|
|
59
|
+
console.log(chalk.yellow(' Wallet not yet registered with Watchtower on this network.'));
|
|
60
|
+
console.log(chalk.dim(' Run `paytaca wallet create` or `paytaca wallet import` to register.'));
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
console.log(chalk.red(` Error fetching balance: ${err.message || err}`));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
console.log();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/commands/balance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAE7D,yDAAyD;AACzD,SAAS,SAAS,CAAC,GAAW;IAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,CAAA;AAC9B,CAAC;AAED,gDAAgD;AAChD,SAAS,UAAU,CAAC,IAAY;IAC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,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: history
|
|
3
|
+
*
|
|
4
|
+
* Displays transaction history for the current wallet.
|
|
5
|
+
* Fetches paginated records from the Watchtower API, showing
|
|
6
|
+
* direction (incoming/outgoing), amount, date, and txid.
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
export declare function registerHistoryCommand(program: Command): void;
|
|
10
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA6BnC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsH7D"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: history
|
|
3
|
+
*
|
|
4
|
+
* Displays transaction history for the current wallet.
|
|
5
|
+
* Fetches paginated records from the Watchtower API, showing
|
|
6
|
+
* direction (incoming/outgoing), amount, date, and txid.
|
|
7
|
+
*/
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import { loadWallet, loadMnemonic } from '../wallet/index.js';
|
|
10
|
+
/** Convert BCH to satoshis (1 BCH = 100,000,000 sats) */
|
|
11
|
+
function bchToSats(bch) {
|
|
12
|
+
return Math.round(bch * 1e8);
|
|
13
|
+
}
|
|
14
|
+
/** Format a date string to a concise local representation */
|
|
15
|
+
function formatDate(isoDate) {
|
|
16
|
+
const d = new Date(isoDate);
|
|
17
|
+
if (isNaN(d.getTime()))
|
|
18
|
+
return isoDate;
|
|
19
|
+
return d.toLocaleString('en-US', {
|
|
20
|
+
year: 'numeric',
|
|
21
|
+
month: 'short',
|
|
22
|
+
day: '2-digit',
|
|
23
|
+
hour: '2-digit',
|
|
24
|
+
minute: '2-digit',
|
|
25
|
+
hour12: false,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Truncate a txid for display */
|
|
29
|
+
function shortTxid(txid) {
|
|
30
|
+
if (txid.length <= 20)
|
|
31
|
+
return txid;
|
|
32
|
+
return txid.slice(0, 10) + '...' + txid.slice(-10);
|
|
33
|
+
}
|
|
34
|
+
export function registerHistoryCommand(program) {
|
|
35
|
+
program
|
|
36
|
+
.command('history')
|
|
37
|
+
.description('Display transaction history')
|
|
38
|
+
.option('--chipnet', 'Use chipnet (testnet) instead of mainnet')
|
|
39
|
+
.option('--page <page>', 'Page number (default: 1)', '1')
|
|
40
|
+
.option('--type <type>', 'Filter by type: all, incoming, outgoing (default: all)', 'all')
|
|
41
|
+
.option('--sats', 'Display amounts in satoshis')
|
|
42
|
+
.action(async (opts) => {
|
|
43
|
+
const isChipnet = Boolean(opts.chipnet);
|
|
44
|
+
const showSats = Boolean(opts.sats);
|
|
45
|
+
const network = isChipnet ? 'chipnet' : 'mainnet';
|
|
46
|
+
const page = parseInt(opts.page, 10);
|
|
47
|
+
const recordType = opts.type;
|
|
48
|
+
if (isNaN(page) || page < 1) {
|
|
49
|
+
console.log(chalk.red('\nError: Page must be a positive integer.\n'));
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
if (!['all', 'incoming', 'outgoing'].includes(recordType)) {
|
|
53
|
+
console.log(chalk.red('\nError: Type must be "all", "incoming", or "outgoing".\n'));
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
// ── Validate wallet ──────────────────────────────────────────────
|
|
57
|
+
const data = loadMnemonic();
|
|
58
|
+
if (!data) {
|
|
59
|
+
console.log(chalk.red('\nNo wallet found. Run `paytaca wallet create` or `paytaca wallet import` first.\n'));
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
const w = loadWallet();
|
|
63
|
+
const bchWallet = w.forNetwork(isChipnet);
|
|
64
|
+
console.log(chalk.bold(`\n Transaction History (${network})\n`));
|
|
65
|
+
try {
|
|
66
|
+
const result = await bchWallet.getHistory({ page, recordType });
|
|
67
|
+
if (!result.history || result.history.length === 0) {
|
|
68
|
+
console.log(chalk.dim(' No transactions found.\n'));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// ── Table header ───────────────────────────────────────────────
|
|
72
|
+
const explorer = isChipnet
|
|
73
|
+
? 'https://chipnet.chaingraph.cash/tx/'
|
|
74
|
+
: 'https://bchexplorer.info/tx/';
|
|
75
|
+
for (const tx of result.history) {
|
|
76
|
+
const isIncoming = tx.record_type === 'incoming';
|
|
77
|
+
const arrow = isIncoming
|
|
78
|
+
? chalk.green(' IN')
|
|
79
|
+
: chalk.red(' OUT');
|
|
80
|
+
const amount = showSats
|
|
81
|
+
? `${bchToSats(tx.amount).toLocaleString('en-US')} sats`
|
|
82
|
+
: `${tx.amount} BCH`;
|
|
83
|
+
const amountColored = isIncoming
|
|
84
|
+
? chalk.green(`+${amount}`)
|
|
85
|
+
: chalk.red(`-${amount}`);
|
|
86
|
+
const date = formatDate(tx.tx_timestamp || tx.date_created);
|
|
87
|
+
console.log(` ${arrow} ${amountColored}`);
|
|
88
|
+
console.log(chalk.dim(` ${date}`));
|
|
89
|
+
console.log(chalk.dim(` ${shortTxid(tx.txid)}`));
|
|
90
|
+
console.log(chalk.dim(` ${explorer}${tx.txid}`));
|
|
91
|
+
console.log();
|
|
92
|
+
}
|
|
93
|
+
// ── Pagination info ────────────────────────────────────────────
|
|
94
|
+
const pageNum = parseInt(result.page, 10) || page;
|
|
95
|
+
console.log(chalk.dim(` Page ${pageNum} of ${result.num_pages}` +
|
|
96
|
+
(result.has_next
|
|
97
|
+
? ` — next: paytaca history --page ${pageNum + 1}${isChipnet ? ' --chipnet' : ''}`
|
|
98
|
+
: '')));
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
const status = err?.response?.status;
|
|
102
|
+
if (status === 404) {
|
|
103
|
+
console.log(chalk.yellow(' Wallet not yet registered with Watchtower on this network.'));
|
|
104
|
+
console.log(chalk.dim(' Run `paytaca wallet create` or `paytaca wallet import` to register.'));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
console.log(chalk.red(` Error fetching history: ${err.message || err}`));
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
console.log();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAE7D,yDAAyD;AACzD,SAAS,SAAS,CAAC,GAAW;IAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,CAAA;AAC9B,CAAC;AAED,6DAA6D;AAC7D,SAAS,UAAU,CAAC,OAAe;IACjC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAA;IAC3B,IAAI,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAAE,OAAO,OAAO,CAAA;IACtC,OAAO,CAAC,CAAC,cAAc,CAAC,OAAO,EAAE;QAC/B,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,OAAO;QACd,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,KAAK;KACd,CAAC,CAAA;AACJ,CAAC;AAED,kCAAkC;AAClC,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAI,IAAI,CAAC,MAAM,IAAI,EAAE;QAAE,OAAO,IAAI,CAAA;IAClC,OAAO,I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CACF,CAAA;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAA;YACpC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;gBACnB,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,MAAM,CACV,+DAA+D,CAChE,CACF,CAAA;gBACD,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CACP,wEAAwE,CACzE,CACF,CAAA;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CAAC,8BAA8B,GAAG,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC,CAC9D,CAAA;gBACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YACjB,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: receive
|
|
3
|
+
*
|
|
4
|
+
* Displays a receiving address and its QR code for accepting BCH payments.
|
|
5
|
+
* The QR code encodes the address in CashAddr format, rendered directly
|
|
6
|
+
* in the terminal using Unicode block characters.
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
export declare function registerReceiveCommand(program: Command): void;
|
|
10
|
+
//# sourceMappingURL=receive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receive.d.ts","sourceRoot":"","sources":["../../src/commands/receive.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsD7D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: receive
|
|
3
|
+
*
|
|
4
|
+
* Displays a receiving address and its QR code for accepting BCH payments.
|
|
5
|
+
* The QR code encodes the address in CashAddr format, rendered directly
|
|
6
|
+
* in the terminal using Unicode block characters.
|
|
7
|
+
*/
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import qrcode from 'qrcode-terminal';
|
|
10
|
+
import { loadWallet, loadMnemonic } from '../wallet/index.js';
|
|
11
|
+
export function registerReceiveCommand(program) {
|
|
12
|
+
program
|
|
13
|
+
.command('receive')
|
|
14
|
+
.description('Display receiving address and QR code')
|
|
15
|
+
.argument('[index]', 'Address index (default: 0)', '0')
|
|
16
|
+
.option('--chipnet', 'Use chipnet (testnet) instead of mainnet')
|
|
17
|
+
.option('--no-qr', 'Hide QR code, show address only')
|
|
18
|
+
.action((_index, opts) => {
|
|
19
|
+
const isChipnet = Boolean(opts.chipnet);
|
|
20
|
+
const showQr = opts.qr !== false;
|
|
21
|
+
const index = parseInt(_index, 10);
|
|
22
|
+
const network = isChipnet ? 'chipnet' : 'mainnet';
|
|
23
|
+
if (isNaN(index) || index < 0) {
|
|
24
|
+
console.log(chalk.red('\nError: Index must be a non-negative integer.\n'));
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
// ── Validate wallet ──────────────────────────────────────────────
|
|
28
|
+
const data = loadMnemonic();
|
|
29
|
+
if (!data) {
|
|
30
|
+
console.log(chalk.red('\nNo wallet found. Run `paytaca wallet create` or `paytaca wallet import` first.\n'));
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
const w = loadWallet();
|
|
34
|
+
const bchWallet = w.forNetwork(isChipnet);
|
|
35
|
+
const addressSet = bchWallet.getAddressSetAt(index);
|
|
36
|
+
const address = addressSet.receiving;
|
|
37
|
+
console.log(chalk.bold(`\n Receive BCH (${network})\n`));
|
|
38
|
+
console.log(` Address: ${address}`);
|
|
39
|
+
console.log(chalk.dim(` Index: ${index}`));
|
|
40
|
+
if (showQr) {
|
|
41
|
+
console.log();
|
|
42
|
+
qrcode.generate(address, { small: true }, (qr) => {
|
|
43
|
+
// Indent QR code for alignment with the rest of the output
|
|
44
|
+
const indented = qr
|
|
45
|
+
.split('\n')
|
|
46
|
+
.map((line) => ' ' + line)
|
|
47
|
+
.join('\n');
|
|
48
|
+
console.log(indented);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
console.log();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=receive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receive.js","sourceRoot":"","sources":["../../src/commands/receive.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAE7D,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,uCAAuC,CAAC;SACpD,QAAQ,CAAC,SAAS,EAAE,4BAA4B,EAAE,GAAG,CAAC;SACtD,MAAM,CAAC,WAAW,EAAE,0CAA0C,CAAC;SAC/D,MAAM,CAAC,SAAS,EAAE,iCAAiC,CAAC;SACpD,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;QACvB,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,KAAK,KAAK,CAAA;QAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QAClC,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAA;QAEjD,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,GAA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CAAC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,CAAC,GAAG,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: send <address> <amount>
|
|
3
|
+
*
|
|
4
|
+
* Sends BCH from the wallet to an external address.
|
|
5
|
+
*
|
|
6
|
+
* The transaction flow is identical to paytaca-app:
|
|
7
|
+
* 1. Load mnemonic + walletHash from keychain
|
|
8
|
+
* 2. Create BchWallet with watchtower-cash-js
|
|
9
|
+
* 3. Call watchtower.BCH.send() which handles:
|
|
10
|
+
* - UTXO fetching from Watchtower API
|
|
11
|
+
* - Transaction building with libauth
|
|
12
|
+
* - Signing with HD-derived private keys
|
|
13
|
+
* - Broadcasting to the BCH network
|
|
14
|
+
* 4. Return txid
|
|
15
|
+
*/
|
|
16
|
+
import { Command } from 'commander';
|
|
17
|
+
export declare function registerSendCommand(program: Command): void;
|
|
18
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/commands/send.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyF1D"}
|