ravensafe-cli 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/Docs.md ADDED
@@ -0,0 +1,262 @@
1
+ # RavenSafe CLI Technical Docs
2
+
3
+ This document contains implementation and advanced usage details for RavenSafe CLI. Normal users should start with the guided workflow in [README.md](README.md).
4
+
5
+ ## Project Architecture
6
+
7
+ - `RavenSafe.js` is the public executable entry point.
8
+ - `cli.js` is a small compatibility shim.
9
+ - `src/RavenSafe.js` wires the guided mode and command-mode actions.
10
+ - `src/interactive/` contains the guided wallet UI and menu flow.
11
+ - `src/ledger/` handles Ledger transport, app checks, public-key requests, and address verification.
12
+ - `src/core/` contains shared scan, address, network, and session-cache helpers.
13
+ - `src/explorer/zelcore.js` adapts Zelcore explorer responses for balances, UTXOs, raw transactions, and broadcast.
14
+ - `src/tx/` contains transaction planning and Ledger signing support.
15
+ - `src/config/index.js` contains public runtime defaults and branding constants.
16
+ - `tools/probe-ledger.js` is a diagnostic public-key export probe.
17
+
18
+ ## Runtime Defaults
19
+
20
+ Current public defaults live in `src/config/index.js`:
21
+
22
+ ```js
23
+ ravencoin: {
24
+ explorerBaseUrl: 'https://explorer.rvn.zelcore.io/api',
25
+ feeRateSatPerByte: 1000,
26
+ dustSats: 546,
27
+ defaultChangeIndex: 0,
28
+ scan: {
29
+ balanceReceivingMaxIndex: 50,
30
+ balanceChangeMaxIndex: 20,
31
+ receiveMaxIndex: 100
32
+ }
33
+ }
34
+ ```
35
+
36
+ Branding constants also live in `src/config/index.js`, including the RVN donation address and explorer link used by the startup UI and Support / Donate menu.
37
+
38
+ ## Ledger Derivation Paths
39
+
40
+ RavenSafe CLI uses Ravencoin coin type `175`.
41
+
42
+ Receiving addresses:
43
+
44
+ ```text
45
+ m/44'/175'/0'/0/index
46
+ ```
47
+
48
+ Change addresses:
49
+
50
+ ```text
51
+ m/44'/175'/0'/1/index
52
+ ```
53
+
54
+ The diagnostic probe reads these paths:
55
+
56
+ ```text
57
+ m/44'/175'/0'/0/0
58
+ m/44'/175'/0'/0/1
59
+ m/44'/175'/0'/0/2
60
+ m/44'/175'/175'/0/0
61
+ ```
62
+
63
+ For each path, the probe prints the derivation path, public key, chain code if returned by the Ledger, Ledger-returned address if available, and locally derived Ravencoin mainnet P2PKH address.
64
+
65
+ ## Explorer Adapter
66
+
67
+ The explorer backend is isolated in `src/explorer/zelcore.js`.
68
+
69
+ Expected Zelcore endpoints:
70
+
71
+ - `GET /addr/{address}/?noTxList=1` for confirmed and unconfirmed balance.
72
+ - `GET /txs?address={address}&pageNum={page}` for transaction pages used to construct UTXOs.
73
+ - `GET /rawtx/{txid}` for previous raw transaction hex required by Ledger signing.
74
+ - `POST https://explorer.rvn.zelcore.io/api/tx/send` for signed raw transaction broadcast with JSON body `{ "rawtx": rawtx }`.
75
+
76
+ Zelcore `/txs` returns transaction pages, so RavenSafe CLI constructs UTXOs by selecting unspent `vout` entries whose `scriptPubKey.addresses` contains the scanned address. Previous raw transaction hex is fetched from Zelcore `/rawtx/{txid}` and is not reconstructed.
77
+
78
+ ## Guided Transaction Flow
79
+
80
+ Guided Send RVN:
81
+
82
+ 1. Prompts for destination, amount, and fee choice.
83
+ 2. Reuses the current session scan cache when available.
84
+ 3. Checks the quick scan range if needed.
85
+ 4. Selects suitable confirmed UTXOs.
86
+ 5. Shows a human-readable summary with amount, destination, source, estimated fee, and change details.
87
+ 6. Requires typing exactly `SIGN`.
88
+ 7. Calls Ledger signing only after terminal confirmation.
89
+ 8. Requires approval on the Ledger device.
90
+ 9. Broadcasts automatically after successful guided signing.
91
+ 10. Prints the TXID and explorer link on success.
92
+
93
+ If signing fails or the Ledger rejects the request, nothing is broadcast.
94
+
95
+ ## Scan Ranges
96
+
97
+ Guided balance scan presets:
98
+
99
+ - Quick scan: receiving indexes `0-15`, change indexes `0-5`.
100
+ - Standard scan: receiving indexes `0-40`, change indexes `0-10`.
101
+ - Deep scan: receiving indexes `0-70`, change indexes `0-30`.
102
+ - Custom scan: accepts ranges such as `0-30`, `3-19`, or `100-150`.
103
+
104
+ Receive RVN searches receiving addresses and checks additional receiving indexes only when needed, up to the configured receive maximum.
105
+
106
+ ## Advanced Commands
107
+
108
+ Run the command help:
109
+
110
+ ```sh
111
+ node RavenSafe.js --help
112
+ ```
113
+
114
+ ### Address Listing
115
+
116
+ List Ledger-derived receiving addresses:
117
+
118
+ ```sh
119
+ node RavenSafe.js addresses --start 0 --count 10 --app ravencoin
120
+ ```
121
+
122
+ Options:
123
+
124
+ - `--start <number>` defaults to `0`.
125
+ - `--count <number>` defaults to `10` and must be between `1` and `100`.
126
+ - `--app <context>` defaults to `ravencoin`; supported contexts are `current`, `ravencoin`, and `bitcoin`.
127
+
128
+ The command prints index, derivation path, locally derived RVN address, Ledger-returned address, and match status.
129
+
130
+ ### Balance Scan
131
+
132
+ Scan receiving addresses:
133
+
134
+ ```sh
135
+ node RavenSafe.js scan --chain receiving --start 0 --count 10 --app ravencoin
136
+ ```
137
+
138
+ Scan both receiving and change chains:
139
+
140
+ ```sh
141
+ node RavenSafe.js scan --chain both --start 0 --count 3 --app ravencoin
142
+ ```
143
+
144
+ Options:
145
+
146
+ - `--start <number>` defaults to `0`.
147
+ - `--count <number>` defaults to `10` and must be between `1` and `200`.
148
+ - `--chain <receiving|change|both>` defaults to `receiving`.
149
+ - `--app <context>` defaults to `ravencoin`.
150
+
151
+ The scan command reads public keys from the Ledger, derives RVN addresses locally, checks Ledger-returned address matches, fetches public balance and UTXO data, and prints totals. It does not sign, send, build transactions, or broadcast.
152
+
153
+ ### Dry-Run Send Planner
154
+
155
+ Prepare a transaction plan from one Ledger-derived source address:
156
+
157
+ ```sh
158
+ node RavenSafe.js send --from-chain receiving --from-index 0 --to <RVN_ADDRESS> --amount 1
159
+ ```
160
+
161
+ Options:
162
+
163
+ - `--from-chain <receiving|change>` defaults to `receiving`.
164
+ - `--from-index <number>` is required.
165
+ - `--to <RVN_ADDRESS>` is required and must be a Ravencoin mainnet P2PKH or P2SH address.
166
+ - `--amount <RVN_AMOUNT>` is required and must be greater than `0`.
167
+ - `--fee-rate <sat_per_byte>` defaults to `config.ravencoin.feeRateSatPerByte`.
168
+ - `--change-chain <receiving|change>` defaults to `change`.
169
+ - `--change-index <number>` defaults to `config.ravencoin.defaultChangeIndex`.
170
+ - `--app <context>` defaults to `ravencoin`.
171
+ - `--dry-run` is enabled by default.
172
+ - `--sign` asks for `SIGN` confirmation and calls Ledger signing after review.
173
+
174
+ Without `--sign`, the command prints a dry-run plan and does not sign or broadcast.
175
+
176
+ With `--sign`, the command signs only after exact terminal confirmation and Ledger approval. Command-mode signing prints the signed raw transaction and locally derived txid, but does not broadcast.
177
+
178
+ ### Manual Broadcast
179
+
180
+ Broadcast raw signed transaction hex directly:
181
+
182
+ ```sh
183
+ node RavenSafe.js broadcast --rawtx <SIGNED_RAW_TX_HEX>
184
+ ```
185
+
186
+ Or read raw hex from a local file:
187
+
188
+ ```sh
189
+ node RavenSafe.js broadcast --file signed-tx.hex
190
+ ```
191
+
192
+ Rules:
193
+
194
+ - Exactly one of `--rawtx` or `--file` is required.
195
+ - The raw transaction must be non-empty even-length hex.
196
+ - The CLI decodes the transaction locally and prints txid, estimated bytes, input count, and output count.
197
+ - The CLI prints an irreversible-broadcast warning.
198
+ - Broadcasting only happens after typing exactly `BROADCAST`.
199
+ - If confirmation is not exact, nothing is broadcast.
200
+
201
+ ### Ledger Probe
202
+
203
+ Run the diagnostic probe:
204
+
205
+ ```sh
206
+ node tools/probe-ledger.js --app ravencoin
207
+ ```
208
+
209
+ The probe reads public information only. It does not sign, send, or broadcast.
210
+
211
+ ## Security Model
212
+
213
+ - The Ledger is the only signer.
214
+ - Recovery phrases and private keys are never requested.
215
+ - Addresses are derived locally from Ledger-returned public keys.
216
+ - Ledger-returned addresses are compared with locally derived RVN addresses.
217
+ - Balance and UTXO discovery use public explorer data.
218
+ - Signing requires explicit terminal confirmation and device approval.
219
+ - Guided-mode broadcast only follows successful guided signing.
220
+ - Command-mode broadcast requires exact `BROADCAST` confirmation.
221
+
222
+ ## Troubleshooting
223
+
224
+ Ledger cannot be found:
225
+
226
+ - Confirm the Ledger is connected over USB.
227
+ - Unlock the Ledger.
228
+ - Close Ledger Live and other wallet software.
229
+ - Open the Ravencoin app on the Ledger.
230
+
231
+ Ledger app mismatch:
232
+
233
+ - Open the Ravencoin app and retry.
234
+ - Use `--app ravencoin` for normal RVN operations.
235
+ - Use `--app current` only for diagnostics.
236
+
237
+ Explorer errors:
238
+
239
+ - Check internet connectivity.
240
+ - Retry later if the public explorer is unavailable.
241
+ - Confirm the endpoint in `src/config/index.js`.
242
+
243
+ Insufficient funds:
244
+
245
+ - Run guided balance scan first.
246
+ - Try a broader scan range.
247
+ - Check whether funds are on a change address.
248
+ - Test with a smaller amount.
249
+
250
+ Signing rejected:
251
+
252
+ - Review the Ledger screen carefully.
253
+ - Rejecting on the device is safe; nothing is broadcast.
254
+ - Restart guided mode and retry only if the transaction details are correct.
255
+
256
+ ## Developer Notes
257
+
258
+ - Keep guided mode as the primary user path.
259
+ - Keep advanced command behavior conservative.
260
+ - Do not couple informational screens to Ledger, scan, signing, send, or broadcast paths.
261
+ - Keep public defaults and branding constants centralized in `src/config/index.js`.
262
+ - Use safe checks for docs-only changes; do not run Ledger, scan, sign, or broadcast flows unless intentionally testing those paths.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Web3Dev-ma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,171 @@
1
+ # RavenSafe CLI
2
+
3
+ ![RavenSafe CLI brand identity](assets/ravensafe-cli-brand.png)
4
+
5
+ RavenSafe CLI is a guided Ravencoin wallet helper for Ledger devices. It helps you scan balances, receive RVN, send RVN, sign on the Ledger, and broadcast through a focused terminal workflow without exposing your recovery phrase.
6
+
7
+ ## Why This Exists
8
+
9
+ RavenSafe CLI was built after practical issues sending RVN with Electrum-RVN while using a Ledger device. Electrum-RVN is an important community project, but its GitHub repository is now archived and read-only, so some users may need a simpler working path for Ledger-based RVN operations.
10
+
11
+ This project is not a replacement for every wallet use case. It is a focused Ledger/RVN helper for users who want a guided flow for scanning, receiving, sending, signing, and broadcasting RVN.
12
+
13
+ Reference: <https://github.com/Electrum-RVN-SIG/electrum-ravencoin/>
14
+
15
+ ## Core Safety Promise
16
+
17
+ - RavenSafe CLI never asks for your Ledger recovery phrase.
18
+ - RavenSafe CLI never imports private keys.
19
+ - The Ledger remains the signer.
20
+ - Sending requires explicit confirmation in the terminal and approval on the Ledger.
21
+ - Always verify the destination address and amount on the Ledger screen.
22
+ - Use at your own risk.
23
+ - Test with a small amount first.
24
+
25
+ ## Features
26
+
27
+ - Guided wallet menu for normal use.
28
+ - Balance scanning for Ledger-derived RVN addresses.
29
+ - Receive-address discovery using receiving addresses only.
30
+ - Optional on-device verification for receive addresses.
31
+ - Guided RVN sending with a clear summary before signing.
32
+ - Automatic broadcast after a successful guided send.
33
+ - Help and safety notes inside the CLI.
34
+ - Informational Support / Donate screen.
35
+
36
+ ## Requirements
37
+
38
+ - Node.js
39
+ - A Ledger device with the Ravencoin app installed
40
+ - USB access to the Ledger
41
+ - Internet access for public Ravencoin explorer lookups and broadcasts
42
+
43
+ Before using guided mode:
44
+
45
+ 1. Close Ledger Live.
46
+ 2. Connect and unlock the Ledger.
47
+ 3. Open the Ravencoin app on the Ledger.
48
+
49
+ ## Quick Start
50
+
51
+ Run without installing:
52
+
53
+ ```sh
54
+ npx ravensafe-cli
55
+ ```
56
+
57
+ Or install globally:
58
+
59
+ ```sh
60
+ npm install -g ravensafe-cli
61
+ ```
62
+
63
+ Then start the guided CLI:
64
+
65
+ ```sh
66
+ ravensafe
67
+ ```
68
+
69
+ The package also exposes the `ravensafe-cli` command:
70
+
71
+ ```sh
72
+ ravensafe-cli
73
+ ```
74
+
75
+ For local development from a cloned repository:
76
+
77
+ ```sh
78
+ npm install
79
+ npm start
80
+ ```
81
+
82
+ You can also run the local entry point directly:
83
+
84
+ ```sh
85
+ node RavenSafe.js
86
+ ```
87
+
88
+ ## Guided Usage
89
+
90
+ The normal workflow starts with:
91
+
92
+ ```sh
93
+ ravensafe
94
+ ```
95
+
96
+ The guided menu provides:
97
+
98
+ ```text
99
+ 1. Scan wallet balances
100
+ 2. Send RVN
101
+ 3. Receive RVN
102
+ 4. Help / safety notes
103
+ 5. Support / Donate
104
+ 6. Exit
105
+ ```
106
+
107
+ ### 1. Scan Wallet Balances
108
+
109
+ Checks Ledger-derived receiving and change addresses, reads public blockchain data, and shows balances and UTXO counts. This does not sign, send, or broadcast anything.
110
+
111
+ ### 2. Send RVN
112
+
113
+ Guides you through destination, amount, fee choice, transaction review, Ledger signing, and broadcast. Nothing is signed until you type `SIGN`, and the Ledger must still approve the transaction.
114
+
115
+ ### 3. Receive RVN
116
+
117
+ Finds an unused receiving address and displays it. You can optionally verify the address on the Ledger screen.
118
+
119
+ ### 4. Help / Safety Notes
120
+
121
+ Shows reminders for safe Ledger use, including keeping the Ravencoin app open and verifying transaction details before approval.
122
+
123
+ ### 5. Support / Donate
124
+
125
+ Shows the RVN donation address and explorer link. This option is informational only and does not trigger Ledger access, scanning, signing, sending, or broadcasting.
126
+
127
+ ## Safety Notes
128
+
129
+ - Never type your recovery phrase into any computer, website, terminal, wallet, or support chat.
130
+ - Confirm the Ledger screen matches the amount and destination you intended.
131
+ - Start with a small test send before moving larger balances.
132
+ - Treat broadcast as final once confirmed by the network.
133
+ - Keep Ledger Live and other wallet apps closed while RavenSafe CLI is using the Ledger.
134
+
135
+ ## Limitations
136
+
137
+ - RavenSafe CLI is intentionally focused on Ledger-backed RVN wallet operations.
138
+ - It expects standard Ledger-derived Ravencoin addresses.
139
+ - It depends on the configured public explorer being reachable.
140
+ - It is a command-line tool, not a full graphical wallet.
141
+ - It does not manage recovery phrases, private keys, staking, assets, or exchange features.
142
+
143
+ ## Support / Donate
144
+
145
+ RVN donations are optional:
146
+
147
+ ```text
148
+ RYW4QozWJtmSipDAzXVJk2nyxRbY1fppbv
149
+ ```
150
+
151
+ Explorer:
152
+
153
+ ```text
154
+ https://explorer.rvn.zelcore.io/address/RYW4QozWJtmSipDAzXVJk2nyxRbY1fppbv
155
+ ```
156
+
157
+ ## Advanced Commands
158
+
159
+ Guided mode is the recommended path:
160
+
161
+ ```sh
162
+ ravensafe
163
+ ```
164
+
165
+ Advanced commands still exist for users who need command-mode address listing, scanning, dry-run send planning, signing, manual broadcast, or Ledger probing:
166
+
167
+ ```sh
168
+ ravensafe --help
169
+ ```
170
+
171
+ For technical details, command examples, derivation paths, explorer endpoints, transaction flow, and troubleshooting, see [Docs.md](Docs.md).
package/RavenSafe.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ require('./src/RavenSafe');
Binary file
package/cli.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ require('./RavenSafe');
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "ravensafe-cli",
3
+ "version": "1.0.0",
4
+ "description": "Guided Ravencoin Ledger wallet operations from the command line.",
5
+ "main": "RavenSafe.js",
6
+ "bin": {
7
+ "ravensafe": "./RavenSafe.js",
8
+ "ravensafe-cli": "./RavenSafe.js"
9
+ },
10
+ "files": [
11
+ "RavenSafe.js",
12
+ "cli.js",
13
+ "src/",
14
+ "tools/",
15
+ "README.md",
16
+ "Docs.md",
17
+ "LICENSE",
18
+ "assets/ravensafe-cli-brand.png"
19
+ ],
20
+ "scripts": {
21
+ "start": "node RavenSafe.js",
22
+ "check": "node --check RavenSafe.js && node --check cli.js && find src tools -name '*.js' -print0 | xargs -0 -n 1 node --check",
23
+ "test": "npm run check",
24
+ "pack:dry-run": "npm pack --dry-run"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/ELHARAKA/RavenSafe-CLI.git"
29
+ },
30
+ "keywords": [
31
+ "ravencoin",
32
+ "rvn",
33
+ "ledger",
34
+ "cli",
35
+ "wallet",
36
+ "hardware-wallet"
37
+ ],
38
+ "author": "",
39
+ "license": "MIT",
40
+ "bugs": {
41
+ "url": "https://github.com/ELHARAKA/RavenSafe-CLI/issues"
42
+ },
43
+ "homepage": "https://github.com/ELHARAKA/RavenSafe-CLI#readme",
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "dependencies": {
48
+ "@ledgerhq/hw-app-btc": "^10.22.1",
49
+ "@ledgerhq/hw-transport-node-hid": "^6.33.2",
50
+ "axios": "^1.16.1",
51
+ "bitcoinjs-lib": "^7.0.1",
52
+ "commander": "^14.0.3",
53
+ "tiny-secp256k1": "^2.2.4"
54
+ }
55
+ }