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 +262 -0
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/RavenSafe.js +4 -0
- package/assets/ravensafe-cli-brand.png +0 -0
- package/cli.js +4 -0
- package/package.json +55 -0
- package/src/RavenSafe.js +753 -0
- package/src/config/index.js +25 -0
- package/src/core/address.js +67 -0
- package/src/core/network.js +13 -0
- package/src/core/scan.js +218 -0
- package/src/core/session-cache.js +158 -0
- package/src/explorer/zelcore.js +526 -0
- package/src/interactive/index.js +972 -0
- package/src/interactive/ui.js +441 -0
- package/src/ledger/index.js +405 -0
- package/src/tx/builder.js +448 -0
- package/src/tx/signer.js +205 -0
- package/tools/probe-ledger.js +90 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { Command } = require('commander');
|
|
5
|
+
const { EXPECTED_CONTEXTS, PROBE_PATHS, probeLedger } = require('../src/ledger');
|
|
6
|
+
|
|
7
|
+
function printError(error) {
|
|
8
|
+
console.log(`Error: ${error.message}`);
|
|
9
|
+
if (error.statusCode) {
|
|
10
|
+
console.log(`Status: ${error.statusCode}`);
|
|
11
|
+
}
|
|
12
|
+
console.log(`Hint: ${error.hint}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function printProbeResult(result) {
|
|
16
|
+
console.log('RVN Ledger public-key probe');
|
|
17
|
+
console.log('Reads public keys only. Does not sign, send, or broadcast.');
|
|
18
|
+
console.log('');
|
|
19
|
+
console.log(`Test context: ${result.expectedContext.label} (${result.expectedContext.purpose})`);
|
|
20
|
+
console.log(`HID detected: ${result.hidDetected ? 'yes' : 'no'}`);
|
|
21
|
+
console.log(`HID device count: ${result.hidDeviceCount}`);
|
|
22
|
+
|
|
23
|
+
if (result.app && result.app.name) {
|
|
24
|
+
console.log(`Open Ledger app: ${result.app.name} ${result.app.version}`);
|
|
25
|
+
console.log(`Detected context: ${result.app.context.label} (${result.app.context.purpose})`);
|
|
26
|
+
} else if (result.app && result.app.error) {
|
|
27
|
+
console.log('Open Ledger app: could not detect');
|
|
28
|
+
printError(result.app.error);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
for (const warning of result.warnings) {
|
|
32
|
+
console.log(`Warning: ${warning}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (result.error) {
|
|
36
|
+
console.log('');
|
|
37
|
+
printError(result.error);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
console.log(`Public-key export works: ${result.publicKeyExportWorks ? 'yes' : 'no'}`);
|
|
42
|
+
console.log('');
|
|
43
|
+
console.log('Allowed derivation paths:');
|
|
44
|
+
for (const path of PROBE_PATHS) {
|
|
45
|
+
console.log(`- ${path}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
for (const item of result.publicKeyResults) {
|
|
49
|
+
console.log('');
|
|
50
|
+
console.log(`Path: ${item.path}`);
|
|
51
|
+
|
|
52
|
+
if (!item.ok) {
|
|
53
|
+
printError(item.error);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
console.log(`Public key: ${item.publicKey}`);
|
|
58
|
+
console.log(`Chain code: ${item.chainCode || 'not returned'}`);
|
|
59
|
+
console.log(`Ledger-returned address: ${item.ledgerAddress || 'not returned'}`);
|
|
60
|
+
console.log(`Derived RVN P2PKH address: ${item.rvnAddress}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function main() {
|
|
65
|
+
const program = new Command();
|
|
66
|
+
program
|
|
67
|
+
.name('probe-ledger')
|
|
68
|
+
.description('RVN Ledger public-key export probe')
|
|
69
|
+
.option('--app <context>', 'expected Ledger app context: current, ravencoin, or bitcoin', 'current')
|
|
70
|
+
.parse(process.argv);
|
|
71
|
+
|
|
72
|
+
const options = program.opts();
|
|
73
|
+
if (!EXPECTED_CONTEXTS[options.app]) {
|
|
74
|
+
console.error(`Unknown app context "${options.app}". Use current, ravencoin, or bitcoin.`);
|
|
75
|
+
process.exitCode = 1;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const result = await probeLedger({
|
|
80
|
+
expectedContext: options.app,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
printProbeResult(result);
|
|
84
|
+
process.exitCode = result.publicKeyExportWorks ? 0 : 2;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
main().catch(error => {
|
|
88
|
+
console.error(error && error.stack ? error.stack : error);
|
|
89
|
+
process.exitCode = 1;
|
|
90
|
+
});
|