@@ -4,7 +4,7 @@ | |||
// Please see the included LICENSE file for more information. | |||
Object.defineProperty(exports, "__esModule", { value: true }); | |||
exports.CryptoUtils = void 0; | |||
const fedoragold_utils_1 = require("fedoragold-utils"); | |||
const fedoragold_utils_1 = require("fedoragold-utils"); // LedgerNote | |||
const _ = require("lodash"); | |||
/** @ignore */ | |||
const cached = {}; | |||
@@ -17,8 +17,24 @@ const cached = {}; | |||
function CryptoUtils(config) { | |||
if (!_.isEqual(cached.config, config) || !cached.config || !cached.interface) { | |||
cached.config = config; | |||
if (!config.ledgerTransport) { | |||
cached.interface = new fedoragold_utils_1.CryptoNote({ | |||
/*if (!config.ledgerTransport) {*/ | |||
cached.interface = new fedoragold_utils_1.CryptoNote({ | |||
addressPrefix: config.addressPrefix, | |||
coinUnitPlaces: config.decimalPlaces, | |||
keccakIterations: 1, | |||
}, { | |||
cn_fast_hash: config.cnFastHash, | |||
checkRingSignatures: config.checkRingSignatures, | |||
derivePublicKey: config.derivePublicKey, | |||
deriveSecretKey: config.deriveSecretKey, | |||
generateKeyDerivation: config.generateKeyDerivation, | |||
generateKeyImage: config.generateKeyImage, | |||
generateRingSignatures: config.generateRingSignatures, | |||
secretKeyToPublicKey: config.secretKeyToPublicKey, | |||
underivePublicKey: config.underivePublicKey, | |||
}); | |||
/*} else { | |||
cached.interface = new LedgerNote(config.ledgerTransport, { | |||
addressPrefix: config.addressPrefix, | |||
coinUnitPlaces: config.decimalPlaces, | |||
keccakIterations: 1, | |||
@@ -32,25 +48,8 @@ function CryptoUtils(config) { | |||
generateRingSignatures: config.generateRingSignatures, | |||
secretKeyToPublicKey: config.secretKeyToPublicKey, | |||
underivePublicKey: config.underivePublicKey, | |||
}); | |||
} | |||
else { | |||
cached.interface = new fedoragold_utils_1.LedgerNote(config.ledgerTransport, { | |||
addressPrefix: config.addressPrefix, | |||
coinUnitPlaces: config.decimalPlaces, | |||
keccakIterations: 1, | |||
}, { | |||
cn_fast_hash: config.cnFastHash, | |||
checkRingSignatures: config.checkRingSignatures, | |||
derivePublicKey: config.derivePublicKey, | |||
deriveSecretKey: config.deriveSecretKey, | |||
generateKeyDerivation: config.generateKeyDerivation, | |||
generateKeyImage: config.generateKeyImage, | |||
generateRingSignatures: config.generateRingSignatures, | |||
secretKeyToPublicKey: config.secretKeyToPublicKey, | |||
underivePublicKey: config.underivePublicKey, | |||
}); | |||
} | |||
}) | |||
}*/ | |||
return cached.interface; | |||
} | |||
else { | |||
@@ -1,6 +1,4 @@ | |||
/// <reference types="ledgerhq__hw-transport" /> | |||
import { MixinLimits } from './MixinLimits'; | |||
import { LedgerTransport } from 'fedoragold-utils'; | |||
/** | |||
* Configuration for the wallet backend. | |||
* | |||
@@ -142,12 +140,6 @@ export interface IConfig { | |||
* Allows specifying a custom configuration object for the request module. | |||
*/ | |||
customRequestOptions?: any; | |||
/** | |||
* Defines whether we are using the LedgerNote class instead of the | |||
* CryptoNote class | |||
*/ | |||
ledgerTransport?: LedgerTransport; | |||
[key: string]: any; | |||
} | |||
/** | |||
* Configuration for the wallet backend | |||
@@ -285,12 +277,6 @@ export declare class Config implements IConfig { | |||
* Allows specifying a custom configuration object for the request module. | |||
*/ | |||
customRequestOptions: any; | |||
/** | |||
* Defines whether we are using the LedgerNote class instead of the | |||
* CryptoNote class | |||
*/ | |||
ledgerTransport?: LedgerTransport; | |||
[key: string]: any; | |||
} | |||
/** | |||
* Merge the default config with the provided config | |||
@@ -5,6 +5,7 @@ | |||
Object.defineProperty(exports, "__esModule", { value: true }); | |||
exports.MergeConfig = exports.Config = void 0; | |||
const MixinLimits_1 = require("./MixinLimits"); | |||
//import { LedgerTransport } from 'fedoragold-utils'; | |||
/* eslint-disable @typescript-eslint/no-var-requires */ | |||
const version = require('../../package.json').version; | |||
/** | |||
@@ -164,6 +165,12 @@ class Config { | |||
* Allows specifying a custom configuration object for the request module. | |||
*/ | |||
this.customRequestOptions = {}; | |||
/** | |||
* Defines whether we are using the LedgerNote class instead of the | |||
* CryptoNote class | |||
ledgerTransport?: LedgerTransport; | |||
[key: string]: any;*/ | |||
} | |||
} | |||
exports.Config = Config; | |||
@@ -493,8 +493,63 @@ export declare class WalletBackend extends EventEmitter { | |||
* Defaults to zero. | |||
* | |||
* @param config | |||
*/ | |||
static importWalletFromLedger(daemon: Daemon, scanHeight: number | undefined, config: IConfig): Promise<[WalletBackend, undefined] | [undefined, WalletError]>; | |||
public static async importWalletFromLedger( | |||
daemon: Daemon, | |||
scanHeight: number = 0, | |||
config: IConfig): Promise<[WalletBackend, undefined] | [undefined, WalletError]> { | |||
logger.log( | |||
'Function importWalletFromLedger called', | |||
LogLevel.DEBUG, | |||
LogCategory.GENERAL, | |||
); | |||
if (!config.ledgerTransport) { | |||
return [undefined, new WalletError(WalletErrorCode.LEDGER_TRANSPORT_REQUIRED)]; | |||
} | |||
assertNumber(scanHeight, 'scanHeight'); | |||
if (scanHeight < 0) { | |||
return [undefined, new WalletError(WalletErrorCode.NEGATIVE_VALUE_GIVEN)]; | |||
} | |||
if (!Number.isInteger(scanHeight)) { | |||
return [undefined, new WalletError(WalletErrorCode.NON_INTEGER_GIVEN)]; | |||
} | |||
const merged = MergeConfig(config); | |||
let address: Address; | |||
try { | |||
await CryptoUtils(merged).init(); | |||
await CryptoUtils(merged).fetchKeys(); | |||
const tmpAddress = CryptoUtils(merged).address; | |||
if (tmpAddress) { | |||
address = tmpAddress; | |||
} else { | |||
return [undefined, new WalletError(WalletErrorCode.LEDGER_COULD_NOT_GET_KEYS)]; | |||
} | |||
} catch (e) { | |||
return [undefined, new WalletError(WalletErrorCode.LEDGER_COULD_NOT_GET_KEYS)]; | |||
} | |||
// Can't sync from the current scan height, not newly created | |||
const newWallet: boolean = false; | |||
const wallet = await WalletBackend.init( | |||
merged, daemon, await address.address(), scanHeight, newWallet, | |||
address.view.privateKey, '0'.repeat(64), | |||
); | |||
//return [wallet, undefined]; | |||
return [null, undefined]; | |||
} | |||
*/ | |||
/** | |||
* This method imports a wallet you have previously created, in a 'watch only' | |||
* state. This wallet can view incoming transactions, but cannot send | |||
@@ -203,9 +203,9 @@ class WalletBackend extends events_1.EventEmitter { | |||
const wallet = JSON.parse(json, WalletBackend.reviver); | |||
console.log("isLedgetRequired..."); | |||
if (yield wallet.isLedgerRequired()) { | |||
if (!merged.ledgerTransport) { | |||
return [undefined, new WalletError_1.WalletError(WalletError_1.WalletErrorCode.LEDGER_TRANSPORT_REQUIRED)]; | |||
} | |||
//if (!merged.ledgerTransport) { | |||
// return [undefined, new WalletError(WalletErrorCode.LEDGER_TRANSPORT_REQUIRED)]; | |||
//} | |||
try { | |||
console.log("init..."); | |||
yield (0, CnUtils_1.CryptoUtils)(merged).init(); | |||
@@ -379,42 +379,63 @@ class WalletBackend extends events_1.EventEmitter { | |||
* Defaults to zero. | |||
* | |||
* @param config | |||
*/ | |||
static importWalletFromLedger(daemon, scanHeight = 0, config) { | |||
return __awaiter(this, void 0, void 0, function* () { | |||
Logger_1.logger.log('Function importWalletFromLedger called', Logger_1.LogLevel.DEBUG, Logger_1.LogCategory.GENERAL); | |||
if (!config.ledgerTransport) { | |||
return [undefined, new WalletError_1.WalletError(WalletError_1.WalletErrorCode.LEDGER_TRANSPORT_REQUIRED)]; | |||
} | |||
(0, Assert_1.assertNumber)(scanHeight, 'scanHeight'); | |||
if (scanHeight < 0) { | |||
return [undefined, new WalletError_1.WalletError(WalletError_1.WalletErrorCode.NEGATIVE_VALUE_GIVEN)]; | |||
} | |||
if (!Number.isInteger(scanHeight)) { | |||
return [undefined, new WalletError_1.WalletError(WalletError_1.WalletErrorCode.NON_INTEGER_GIVEN)]; | |||
} | |||
const merged = (0, Config_1.MergeConfig)(config); | |||
let address; | |||
try { | |||
yield (0, CnUtils_1.CryptoUtils)(merged).init(); | |||
yield (0, CnUtils_1.CryptoUtils)(merged).fetchKeys(); | |||
const tmpAddress = (0, CnUtils_1.CryptoUtils)(merged).address; | |||
if (tmpAddress) { | |||
address = tmpAddress; | |||
} | |||
else { | |||
return [undefined, new WalletError_1.WalletError(WalletError_1.WalletErrorCode.LEDGER_COULD_NOT_GET_KEYS)]; | |||
} | |||
} | |||
catch (e) { | |||
return [undefined, new WalletError_1.WalletError(WalletError_1.WalletErrorCode.LEDGER_COULD_NOT_GET_KEYS)]; | |||
} | |||
/* Can't sync from the current scan height, not newly created */ | |||
const newWallet = false; | |||
const wallet = yield WalletBackend.init(merged, daemon, yield address.address(), scanHeight, newWallet, address.view.privateKey, '0'.repeat(64)); | |||
return [wallet, undefined]; | |||
}); | |||
} | |||
public static async importWalletFromLedger( | |||
daemon: Daemon, | |||
scanHeight: number = 0, | |||
config: IConfig): Promise<[WalletBackend, undefined] | [undefined, WalletError]> { | |||
logger.log( | |||
'Function importWalletFromLedger called', | |||
LogLevel.DEBUG, | |||
LogCategory.GENERAL, | |||
); | |||
if (!config.ledgerTransport) { | |||
return [undefined, new WalletError(WalletErrorCode.LEDGER_TRANSPORT_REQUIRED)]; | |||
} | |||
assertNumber(scanHeight, 'scanHeight'); | |||
if (scanHeight < 0) { | |||
return [undefined, new WalletError(WalletErrorCode.NEGATIVE_VALUE_GIVEN)]; | |||
} | |||
if (!Number.isInteger(scanHeight)) { | |||
return [undefined, new WalletError(WalletErrorCode.NON_INTEGER_GIVEN)]; | |||
} | |||
const merged = MergeConfig(config); | |||
let address: Address; | |||
try { | |||
await CryptoUtils(merged).init(); | |||
await CryptoUtils(merged).fetchKeys(); | |||
const tmpAddress = CryptoUtils(merged).address; | |||
if (tmpAddress) { | |||
address = tmpAddress; | |||
} else { | |||
return [undefined, new WalletError(WalletErrorCode.LEDGER_COULD_NOT_GET_KEYS)]; | |||
} | |||
} catch (e) { | |||
return [undefined, new WalletError(WalletErrorCode.LEDGER_COULD_NOT_GET_KEYS)]; | |||
} | |||
// Can't sync from the current scan height, not newly created | |||
const newWallet: boolean = false; | |||
const wallet = await WalletBackend.init( | |||
merged, daemon, await address.address(), scanHeight, newWallet, | |||
address.view.privateKey, '0'.repeat(64), | |||
); | |||
//return [wallet, undefined]; | |||
return [null, undefined]; | |||
} | |||
*/ | |||
/** | |||
* This method imports a wallet you have previously created, in a 'watch only' | |||
* state. This wallet can view incoming transactions, but cannot send | |||
@@ -498,17 +519,21 @@ class WalletBackend extends events_1.EventEmitter { | |||
const scanHeight = 0; | |||
const merged = (0, Config_1.MergeConfig)(config); | |||
let address = yield fedoragold_utils_1.Address.fromEntropy(undefined, undefined, merged.addressPrefix); | |||
if (merged.ledgerTransport) { | |||
yield (0, CnUtils_1.CryptoUtils)(merged).init(); | |||
yield (0, CnUtils_1.CryptoUtils)(merged).fetchKeys(); | |||
const ledgerAddress = (0, CnUtils_1.CryptoUtils)(merged).address; | |||
if (ledgerAddress) { | |||
address = ledgerAddress; | |||
} | |||
else { | |||
throw new Error('Could not create wallet from Ledger transport'); | |||
} | |||
} | |||
/* | |||
if (merged.ledgerTransport) { | |||
await CryptoUtils(merged).init(); | |||
await CryptoUtils(merged).fetchKeys(); | |||
const ledgerAddress = CryptoUtils(merged).address; | |||
if (ledgerAddress) { | |||
address = ledgerAddress; | |||
} else { | |||
throw new Error('Could not create wallet from Ledger transport'); | |||
} | |||
} | |||
*/ | |||
return WalletBackend.init(merged, daemon, yield address.address(), scanHeight, newWallet, address.view.privateKey, address.spend.privateKey); | |||
}); | |||
} | |||
@@ -2275,7 +2300,8 @@ class WalletBackend extends events_1.EventEmitter { | |||
} | |||
subwalletsSupported() { | |||
return __awaiter(this, void 0, void 0, function* () { | |||
return !((yield this.isLedgerRequired()) && this.config.ledgerTransport); | |||
//return !(await this.isLedgerRequired() && this.config.ledgerTransport); | |||
return true; | |||
}); | |||
} | |||
} | |||
@@ -14,7 +14,7 @@ const colors = require("colors"); | |||
const fs = require("fs"); | |||
const index_1 = require("../lib/index"); | |||
const CryptoWrapper_1 = require("../lib/CryptoWrapper"); | |||
const fedoragold_utils_1 = require("fedoragold-utils"); | |||
const fedoragold_utils_1 = require("fedoragold-utils"); // LedgerTransport | |||
const tester_1 = require("./tester"); | |||
const ValidateParametersTests_1 = require("./lib/ValidateParametersTests"); | |||
const doPerformanceTests = process.argv.includes('--do-performance-tests'); | |||
@@ -362,10 +362,10 @@ function roundTrip(wallet, daemon, password) { | |||
}), 'Testing wallet syncing performance (60 second test)', 'Wallet syncing performance test complete', 'Wallet syncing performance test failed!'); | |||
} | |||
if (fedoragold_utils_1.Crypto.type === fedoragold_utils_1.CryptoType.NODEADDON) { | |||
let skipLedgerTests = false; | |||
let skipLedgerTests = true; //false; | |||
let TransportNodeHID; | |||
let wallet; | |||
let transport; | |||
//let transport: LedgerTransport; | |||
try { | |||
//TransportNodeHID = (await import('@ledgerhq/hw-transport-node-hid')).default; | |||
TransportNodeHID = require('@ledgerhq/hw-transport-node-hid'); | |||
@@ -381,11 +381,12 @@ function roundTrip(wallet, daemon, password) { | |||
if (skipLedgerTests) { | |||
return tester_1.TestStatus.SKIP; | |||
} | |||
try { | |||
transport = yield TransportNodeHID.create(1000); | |||
wallet = yield index_1.WalletBackend.createWallet(daemon, { | |||
try { /* | |||
transport = await TransportNodeHID.create(1000); | |||
wallet = await WalletBackend.createWallet(daemon, { | |||
ledgerTransport: transport | |||
}); | |||
}) */ | |||
return tester_1.TestStatus.PASS; | |||
} | |||
catch (e) { | |||
@@ -430,13 +431,19 @@ function roundTrip(wallet, daemon, password) { | |||
if (skipLedgerTests) { | |||
return tester_1.TestStatus.SKIP; | |||
} | |||
const [openedWallet, error] = yield index_1.WalletBackend.openWalletFromFile(daemon, 'tmp.wallet', 'password', { ledgerTransport: transport }); | |||
/* Remove file */ | |||
/* | |||
const [openedWallet, error] = await WalletBackend.openWalletFromFile(daemon, 'tmp.wallet', | |||
'password', { ledgerTransport: transport }); | |||
// Remove file | |||
fs.unlinkSync('tmp.wallet'); | |||
if (error || !openedWallet) { | |||
return tester_1.TestStatus.FAIL; | |||
return TestStatus.FAIL; | |||
} | |||
wallet = openedWallet; | |||
*/ | |||
return tester_1.TestStatus.PASS; | |||
}), 'Open Ledger wallet', 'Test passed', 'Test failed', 'Ledger tests skipped'); | |||
yield tester.test(() => __awaiter(void 0, void 0, void 0, function* () { | |||
@@ -453,12 +460,15 @@ function roundTrip(wallet, daemon, password) { | |||
if (skipLedgerTests) { | |||
return tester_1.TestStatus.SKIP; | |||
} | |||
const [, error] = yield index_1.WalletBackend.importWalletFromLedger(daemon, 2000000, { | |||
ledgerTransport: transport | |||
}); | |||
/* | |||
const [, error] = await WalletBackend.importWalletFromLedger( | |||
daemon, 2000000, { | |||
ledgerTransport: transport}); | |||
if (error) { | |||
return tester_1.TestStatus.FAIL; | |||
return TestStatus.FAIL; | |||
} | |||
*/ | |||
return tester_1.TestStatus.PASS; | |||
}), 'Import wallet from Ledger', 'Test passed', 'Test failed', 'Ledger tests skipped'); | |||
} | |||
@@ -2,7 +2,7 @@ | |||
// | |||
// Please see the included LICENSE file for more information. | |||
import { CryptoNote, LedgerNote, ICryptoNote } from 'fedoragold-utils'; | |||
import { CryptoNote, ICryptoNote } from 'fedoragold-utils'; // LedgerNote | |||
import { Config } from './Config'; | |||
import * as _ from 'lodash'; | |||
@@ -25,7 +25,7 @@ export function CryptoUtils(config: Config): ICryptoNote { | |||
if (!_.isEqual(cached.config, config) || !cached.config || !cached.interface) { | |||
cached.config = config; | |||
if (!config.ledgerTransport) { | |||
/*if (!config.ledgerTransport) {*/ | |||
cached.interface = new CryptoNote({ | |||
addressPrefix: config.addressPrefix, | |||
coinUnitPlaces: config.decimalPlaces, | |||
@@ -41,7 +41,7 @@ export function CryptoUtils(config: Config): ICryptoNote { | |||
secretKeyToPublicKey: config.secretKeyToPublicKey, | |||
underivePublicKey: config.underivePublicKey, | |||
}); | |||
} else { | |||
/*} else { | |||
cached.interface = new LedgerNote(config.ledgerTransport, { | |||
addressPrefix: config.addressPrefix, | |||
coinUnitPlaces: config.decimalPlaces, | |||
@@ -57,7 +57,7 @@ export function CryptoUtils(config: Config): ICryptoNote { | |||
secretKeyToPublicKey: config.secretKeyToPublicKey, | |||
underivePublicKey: config.underivePublicKey, | |||
}) | |||
} | |||
}*/ | |||
return cached.interface; | |||
} else { | |||
@@ -3,7 +3,7 @@ | |||
// Please see the included LICENSE file for more information. | |||
import { MixinLimit, MixinLimits } from './MixinLimits'; | |||
import { LedgerTransport } from 'fedoragold-utils'; | |||
//import { LedgerTransport } from 'fedoragold-utils'; | |||
/* eslint-disable @typescript-eslint/no-var-requires */ | |||
const version = require('../../package.json').version; | |||
@@ -197,10 +197,9 @@ export interface IConfig { | |||
/** | |||
* Defines whether we are using the LedgerNote class instead of the | |||
* CryptoNote class | |||
*/ | |||
ledgerTransport?: LedgerTransport; | |||
[key: string]: any; | |||
[key: string]: any;*/ | |||
} | |||
/** | |||
@@ -410,10 +409,9 @@ export class Config implements IConfig { | |||
/** | |||
* Defines whether we are using the LedgerNote class instead of the | |||
* CryptoNote class | |||
*/ | |||
ledgerTransport?: LedgerTransport; | |||
[key: string]: any; | |||
[key: string]: any;*/ | |||
} | |||
/** | |||
@@ -568,9 +568,9 @@ export class WalletBackend extends EventEmitter { | |||
console.log("isLedgetRequired..."); | |||
if (await wallet.isLedgerRequired()) { | |||
if (!merged.ledgerTransport) { | |||
return [undefined, new WalletError(WalletErrorCode.LEDGER_TRANSPORT_REQUIRED)]; | |||
} | |||
//if (!merged.ledgerTransport) { | |||
// return [undefined, new WalletError(WalletErrorCode.LEDGER_TRANSPORT_REQUIRED)]; | |||
//} | |||
try { | |||
console.log("init..."); | |||
@@ -786,7 +786,6 @@ export class WalletBackend extends EventEmitter { | |||
* Defaults to zero. | |||
* | |||
* @param config | |||
*/ | |||
public static async importWalletFromLedger( | |||
daemon: Daemon, | |||
scanHeight: number = 0, | |||
@@ -832,7 +831,7 @@ export class WalletBackend extends EventEmitter { | |||
return [undefined, new WalletError(WalletErrorCode.LEDGER_COULD_NOT_GET_KEYS)]; | |||
} | |||
/* Can't sync from the current scan height, not newly created */ | |||
// Can't sync from the current scan height, not newly created | |||
const newWallet: boolean = false; | |||
const wallet = await WalletBackend.init( | |||
@@ -840,8 +839,10 @@ export class WalletBackend extends EventEmitter { | |||
address.view.privateKey, '0'.repeat(64), | |||
); | |||
return [wallet, undefined]; | |||
//return [wallet, undefined]; | |||
return [null, undefined]; | |||
} | |||
*/ | |||
/** | |||
* This method imports a wallet you have previously created, in a 'watch only' | |||
@@ -960,7 +961,7 @@ export class WalletBackend extends EventEmitter { | |||
const merged = MergeConfig(config); | |||
let address = await Address.fromEntropy(undefined, undefined, merged.addressPrefix); | |||
/* | |||
if (merged.ledgerTransport) { | |||
await CryptoUtils(merged).init(); | |||
@@ -974,6 +975,7 @@ export class WalletBackend extends EventEmitter { | |||
throw new Error('Could not create wallet from Ledger transport'); | |||
} | |||
} | |||
*/ | |||
return WalletBackend.init( | |||
merged, daemon, await address.address(), scanHeight, newWallet, | |||
@@ -3523,6 +3525,7 @@ export class WalletBackend extends EventEmitter { | |||
} | |||
private async subwalletsSupported(): Promise<boolean> { | |||
return !(await this.isLedgerRequired() && this.config.ledgerTransport); | |||
//return !(await this.isLedgerRequired() && this.config.ledgerTransport); | |||
return true; | |||
} | |||
} |
@@ -25,16 +25,17 @@ | |||
"dependencies": { | |||
"fedoragold-base58": "file:../fedoragold-base58", | |||
"fedoragold-bytestream": "file:../fedoragold-bytestream", | |||
"fedoragold-utils": "file:../fedoragold-utils", | |||
"lodash": "^4.17.21", | |||
"object-sizeof": "git+https://github.com/zpalmtree/sizeof.git", | |||
"pbkdf2": "^3.0.17", | |||
"request": "^2.88.2", | |||
"request-promise-native": "^1.0.9", | |||
"typedoc": "^0.22.10", | |||
"typedoc-plugin-no-inherit": "^1.3.1", | |||
"typescript": "^4.1.5" | |||
}, | |||
"devDependencies": { | |||
"@types/ledgerhq__hw-transport": "^4.21.3", | |||
"@types/ledgerhq__hw-transport-node-hid": "^4.22.1", | |||
"@types/lodash": "^4.14.168", | |||
"@types/node": "^14.14.31", | |||
"@types/pbkdf2": "^3.0.0", | |||
@@ -48,9 +49,7 @@ | |||
"eslint-plugin-jsdoc": "^32.1.0", | |||
"eslint-plugin-prefer-arrow": "^1.2.3", | |||
"husky": "^4.2.5", | |||
"lint-staged": "^10.5.4", | |||
"typedoc": "^0.18.0", | |||
"typedoc-plugin-no-inherit": "^1.1.10" | |||
"lint-staged": "^10.5.4" | |||
}, | |||
"lint-staged": { | |||
"**/*.{ts}": [ | |||
@@ -62,8 +61,5 @@ | |||
"hooks": { | |||
"pre-commit": "lint-staged" | |||
} | |||
}, | |||
"optionalDependencies": { | |||
"@ledgerhq/hw-transport-node-hid": "^5.51.1" | |||
} | |||
} |
@@ -18,7 +18,7 @@ import { | |||
import {generateKeyDerivation, underivePublicKey} from '../lib/CryptoWrapper'; | |||
import {Address, Crypto as TurtleCoinCrypto, CryptoType, LedgerTransport} from 'fedoragold-utils'; | |||
import {Address, Crypto as FedoragoldCoinCrypto, CryptoType} from 'fedoragold-utils'; // LedgerTransport | |||
import { Tester, TestStatus } from './tester' | |||
import { ValidateParametersTests } from './lib/ValidateParametersTests' | |||
@@ -688,11 +688,11 @@ async function roundTrip( | |||
'Wallet syncing performance test failed!'); | |||
} | |||
if (TurtleCoinCrypto.type === CryptoType.NODEADDON) { | |||
let skipLedgerTests = false; | |||
if (FedoragoldCoinCrypto.type === CryptoType.NODEADDON) { | |||
let skipLedgerTests = true; //false; | |||
let TransportNodeHID: any; | |||
let wallet: WalletBackend; | |||
let transport: LedgerTransport; | |||
//let transport: LedgerTransport; | |||
try { | |||
//TransportNodeHID = (await import('@ledgerhq/hw-transport-node-hid')).default; | |||
@@ -712,13 +712,13 @@ async function roundTrip( | |||
return TestStatus.SKIP; | |||
} | |||
try { | |||
try { /* | |||
transport = await TransportNodeHID.create(1000); | |||
wallet = await WalletBackend.createWallet(daemon, { | |||
ledgerTransport: transport | |||
}) | |||
}) */ | |||
return TestStatus.PASS; | |||
} catch (e) { | |||
skipLedgerTests = true; | |||
@@ -791,11 +791,11 @@ async function roundTrip( | |||
if (skipLedgerTests) { | |||
return TestStatus.SKIP; | |||
} | |||
/* | |||
const [openedWallet, error] = await WalletBackend.openWalletFromFile(daemon, 'tmp.wallet', | |||
'password', { ledgerTransport: transport }); | |||
/* Remove file */ | |||
// Remove file | |||
fs.unlinkSync('tmp.wallet'); | |||
if (error || !openedWallet) { | |||
@@ -803,7 +803,7 @@ async function roundTrip( | |||
} | |||
wallet = openedWallet; | |||
*/ | |||
return TestStatus.PASS; | |||
}, | |||
'Open Ledger wallet', | |||
@@ -833,7 +833,7 @@ async function roundTrip( | |||
if (skipLedgerTests) { | |||
return TestStatus.SKIP; | |||
} | |||
/* | |||
const [, error] = await WalletBackend.importWalletFromLedger( | |||
daemon, 2000000, { | |||
ledgerTransport: transport}); | |||
@@ -841,7 +841,7 @@ async function roundTrip( | |||
if (error) { | |||
return TestStatus.FAIL; | |||
} | |||
*/ | |||
return TestStatus.PASS; | |||
}, | |||
'Import wallet from Ledger', | |||