@shapeshiftoss/hdwallet-keepkey 1.55.3 → 1.55.4
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/dist/adapter.js +148 -93
- package/dist/adapter.js.map +1 -1
- package/dist/binance.js +135 -96
- package/dist/binance.js.map +1 -1
- package/dist/bitcoin.js +323 -257
- package/dist/bitcoin.js.map +1 -1
- package/dist/bnbencoding.js +40 -9
- package/dist/bnbencoding.js.map +1 -1
- package/dist/cosmos.js +206 -158
- package/dist/cosmos.js.map +1 -1
- package/dist/eos.js +152 -108
- package/dist/eos.js.map +1 -1
- package/dist/ethereum.js +242 -189
- package/dist/ethereum.js.map +1 -1
- package/dist/index.js +21 -5
- package/dist/index.js.map +1 -1
- package/dist/keepkey.js +582 -444
- package/dist/keepkey.js.map +1 -1
- package/dist/osmosis.js +259 -211
- package/dist/osmosis.js.map +1 -1
- package/dist/ripple.js +96 -52
- package/dist/ripple.js.map +1 -1
- package/dist/thorchain.js +162 -114
- package/dist/thorchain.js.map +1 -1
- package/dist/transport.js +278 -220
- package/dist/transport.js.map +1 -1
- package/dist/typeRegistry.js +41 -12
- package/dist/typeRegistry.js.map +1 -1
- package/dist/utils.js +37 -7
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
package/dist/keepkey.js
CHANGED
|
@@ -1,20 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.KeepKeyHDWallet = exports.KeepKeyHDWalletInfo = void 0;
|
|
39
|
+
exports.isKeepKey = isKeepKey;
|
|
40
|
+
exports.info = info;
|
|
41
|
+
exports.create = create;
|
|
42
|
+
const Messages = __importStar(require("@keepkey/device-protocol/lib/messages_pb"));
|
|
43
|
+
const Types = __importStar(require("@keepkey/device-protocol/lib/types_pb"));
|
|
44
|
+
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
45
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
46
|
+
const semver_1 = __importDefault(require("semver"));
|
|
47
|
+
const Binance = __importStar(require("./binance"));
|
|
48
|
+
const Btc = __importStar(require("./bitcoin"));
|
|
49
|
+
const Cosmos = __importStar(require("./cosmos"));
|
|
50
|
+
const Eos = __importStar(require("./eos"));
|
|
51
|
+
const Eth = __importStar(require("./ethereum"));
|
|
52
|
+
const Osmosis = __importStar(require("./osmosis"));
|
|
53
|
+
const Ripple = __importStar(require("./ripple"));
|
|
54
|
+
const Thorchain = __importStar(require("./thorchain"));
|
|
55
|
+
const typeRegistry_1 = require("./typeRegistry");
|
|
56
|
+
const utils_1 = require("./utils");
|
|
57
|
+
function isKeepKey(wallet) {
|
|
58
|
+
return lodash_1.default.isObject(wallet) && wallet._isKeepKey;
|
|
18
59
|
}
|
|
19
60
|
function describeETHPath(path) {
|
|
20
61
|
const pathStr = core.addressNListToBIP32(path);
|
|
@@ -46,6 +87,7 @@ function describeETHPath(path) {
|
|
|
46
87
|
};
|
|
47
88
|
}
|
|
48
89
|
function describeUTXOPath(path, coin, scriptType) {
|
|
90
|
+
var _a;
|
|
49
91
|
const pathStr = core.addressNListToBIP32(path);
|
|
50
92
|
const unknown = {
|
|
51
93
|
verbose: pathStr,
|
|
@@ -74,11 +116,11 @@ function describeUTXOPath(path, coin, scriptType) {
|
|
|
74
116
|
return unknown;
|
|
75
117
|
const wholeAccount = path.length === 3;
|
|
76
118
|
const script = scriptType
|
|
77
|
-
? {
|
|
119
|
+
? (_a = {
|
|
78
120
|
[core.BTCInputScriptType.SpendAddress]: ["Legacy"],
|
|
79
121
|
[core.BTCInputScriptType.SpendP2SHWitness]: [],
|
|
80
122
|
[core.BTCInputScriptType.SpendWitness]: ["Segwit Native"],
|
|
81
|
-
}[scriptType]
|
|
123
|
+
}[scriptType]) !== null && _a !== void 0 ? _a : []
|
|
82
124
|
: [];
|
|
83
125
|
let isPrefork = false;
|
|
84
126
|
const slip44 = core.slip44ByCoin(coin);
|
|
@@ -339,26 +381,34 @@ function describeBinancePath(path) {
|
|
|
339
381
|
isPrefork: false,
|
|
340
382
|
};
|
|
341
383
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
384
|
+
class KeepKeyHDWalletInfo {
|
|
385
|
+
constructor() {
|
|
386
|
+
this._supportsBTCInfo = true;
|
|
387
|
+
this._supportsETHInfo = true;
|
|
388
|
+
this._supportsCosmosInfo = true;
|
|
389
|
+
this._supportsOsmosisInfo = true;
|
|
390
|
+
this._supportsRippleInfo = true;
|
|
391
|
+
this._supportsBinanceInfo = true;
|
|
392
|
+
this._supportsEosInfo = true;
|
|
393
|
+
this._supportsThorchainInfo = true;
|
|
394
|
+
}
|
|
351
395
|
getVendor() {
|
|
352
396
|
return "KeepKey";
|
|
353
397
|
}
|
|
354
|
-
|
|
355
|
-
return
|
|
398
|
+
btcSupportsCoin(coin) {
|
|
399
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
400
|
+
return Btc.btcSupportsCoin(coin);
|
|
401
|
+
});
|
|
356
402
|
}
|
|
357
|
-
|
|
358
|
-
return
|
|
403
|
+
btcSupportsScriptType(coin, scriptType) {
|
|
404
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
405
|
+
return Btc.btcSupportsScriptType(coin, scriptType);
|
|
406
|
+
});
|
|
359
407
|
}
|
|
360
|
-
|
|
361
|
-
return
|
|
408
|
+
btcSupportsSecureTransfer() {
|
|
409
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
410
|
+
return Btc.btcSupportsSecureTransfer();
|
|
411
|
+
});
|
|
362
412
|
}
|
|
363
413
|
btcSupportsNativeShapeShift() {
|
|
364
414
|
return Btc.btcSupportsNativeShapeShift();
|
|
@@ -369,18 +419,24 @@ export class KeepKeyHDWalletInfo {
|
|
|
369
419
|
btcIsSameAccount(msg) {
|
|
370
420
|
return Btc.btcIsSameAccount(msg);
|
|
371
421
|
}
|
|
372
|
-
|
|
373
|
-
return
|
|
422
|
+
ethSupportsNetwork(chain_id) {
|
|
423
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
424
|
+
return Eth.ethSupportsNetwork(chain_id);
|
|
425
|
+
});
|
|
374
426
|
}
|
|
375
|
-
|
|
376
|
-
return
|
|
427
|
+
ethSupportsSecureTransfer() {
|
|
428
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
429
|
+
return Eth.ethSupportsSecureTransfer();
|
|
430
|
+
});
|
|
377
431
|
}
|
|
378
432
|
ethSupportsNativeShapeShift() {
|
|
379
433
|
return Eth.ethSupportsNativeShapeShift();
|
|
380
434
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
435
|
+
ethSupportsEIP1559() {
|
|
436
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
437
|
+
// disable EIP1559 support until edge case fail states are fixed across all evm chains
|
|
438
|
+
return false;
|
|
439
|
+
});
|
|
384
440
|
}
|
|
385
441
|
ethGetAccountPaths(msg) {
|
|
386
442
|
return Eth.ethGetAccountPaths(msg);
|
|
@@ -456,10 +512,7 @@ export class KeepKeyHDWalletInfo {
|
|
|
456
512
|
addressNList[0] === 0x80000000 + 49 ||
|
|
457
513
|
addressNList[0] === 0x80000000 + 84) {
|
|
458
514
|
addressNList[2] += 1;
|
|
459
|
-
return {
|
|
460
|
-
...msg,
|
|
461
|
-
addressNList,
|
|
462
|
-
};
|
|
515
|
+
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
463
516
|
}
|
|
464
517
|
return undefined;
|
|
465
518
|
}
|
|
@@ -471,12 +524,7 @@ export class KeepKeyHDWalletInfo {
|
|
|
471
524
|
}
|
|
472
525
|
if (addressNList[0] === 0x80000000 + 44) {
|
|
473
526
|
addressNList[2] += 1;
|
|
474
|
-
return {
|
|
475
|
-
...msg,
|
|
476
|
-
addressNList,
|
|
477
|
-
hardenedPath: core.hardenedPath(addressNList),
|
|
478
|
-
relPath: core.relativePath(addressNList),
|
|
479
|
-
};
|
|
527
|
+
return Object.assign(Object.assign({}, msg), { addressNList, hardenedPath: core.hardenedPath(addressNList), relPath: core.relativePath(addressNList) });
|
|
480
528
|
}
|
|
481
529
|
return undefined;
|
|
482
530
|
}
|
|
@@ -487,10 +535,7 @@ export class KeepKeyHDWalletInfo {
|
|
|
487
535
|
}
|
|
488
536
|
const addressNList = msg.addressNList;
|
|
489
537
|
addressNList[2] += 1;
|
|
490
|
-
return {
|
|
491
|
-
...msg,
|
|
492
|
-
addressNList,
|
|
493
|
-
};
|
|
538
|
+
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
494
539
|
}
|
|
495
540
|
osmosisNextAccountPath(msg) {
|
|
496
541
|
const description = describeOsmosisPath(msg.addressNList);
|
|
@@ -499,10 +544,7 @@ export class KeepKeyHDWalletInfo {
|
|
|
499
544
|
}
|
|
500
545
|
const addressNList = msg.addressNList;
|
|
501
546
|
addressNList[2] += 1;
|
|
502
|
-
return {
|
|
503
|
-
...msg,
|
|
504
|
-
addressNList,
|
|
505
|
-
};
|
|
547
|
+
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
506
548
|
}
|
|
507
549
|
thorchainNextAccountPath(msg) {
|
|
508
550
|
const description = describeThorchainPath(msg.addressNList);
|
|
@@ -511,10 +553,7 @@ export class KeepKeyHDWalletInfo {
|
|
|
511
553
|
}
|
|
512
554
|
const addressNList = msg.addressNList;
|
|
513
555
|
addressNList[2] += 1;
|
|
514
|
-
return {
|
|
515
|
-
...msg,
|
|
516
|
-
addressNList,
|
|
517
|
-
};
|
|
556
|
+
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
518
557
|
}
|
|
519
558
|
rippleNextAccountPath(msg) {
|
|
520
559
|
const description = describeRipplePath(msg.addressNList);
|
|
@@ -523,10 +562,7 @@ export class KeepKeyHDWalletInfo {
|
|
|
523
562
|
}
|
|
524
563
|
const addressNList = msg.addressNList;
|
|
525
564
|
addressNList[2] += 1;
|
|
526
|
-
return {
|
|
527
|
-
...msg,
|
|
528
|
-
addressNList,
|
|
529
|
-
};
|
|
565
|
+
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
530
566
|
}
|
|
531
567
|
binanceNextAccountPath(msg) {
|
|
532
568
|
const description = describeBinancePath(msg.addressNList);
|
|
@@ -535,10 +571,7 @@ export class KeepKeyHDWalletInfo {
|
|
|
535
571
|
}
|
|
536
572
|
const addressNList = msg.addressNList;
|
|
537
573
|
addressNList[2] += 1;
|
|
538
|
-
return {
|
|
539
|
-
...msg,
|
|
540
|
-
addressNList,
|
|
541
|
-
};
|
|
574
|
+
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
542
575
|
}
|
|
543
576
|
eosNextAccountPath(msg) {
|
|
544
577
|
const description = describeEosPath(msg.addressNList);
|
|
@@ -547,171 +580,193 @@ export class KeepKeyHDWalletInfo {
|
|
|
547
580
|
}
|
|
548
581
|
const addressNList = msg.addressNList;
|
|
549
582
|
addressNList[2] += 1;
|
|
550
|
-
return {
|
|
551
|
-
...msg,
|
|
552
|
-
addressNList,
|
|
553
|
-
};
|
|
583
|
+
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
554
584
|
}
|
|
555
585
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
_supportsBTCInfo = true;
|
|
559
|
-
_supportsCosmosInfo = true;
|
|
560
|
-
_supportsOsmosisInfo = true;
|
|
561
|
-
_supportsRippleInfo = true;
|
|
562
|
-
_supportsBinanceInfo = true;
|
|
563
|
-
_supportsEosInfo = true;
|
|
564
|
-
_supportsFioInfo = false;
|
|
565
|
-
_supportsDebugLink;
|
|
566
|
-
_isKeepKey = true;
|
|
567
|
-
_supportsETH = true;
|
|
568
|
-
_supportsEthSwitchChain = false;
|
|
569
|
-
_supportsAvalanche = false;
|
|
570
|
-
_supportsOptimism = true;
|
|
571
|
-
_supportsBSC = true;
|
|
572
|
-
_supportsPolygon = true;
|
|
573
|
-
_supportsGnosis = true;
|
|
574
|
-
_supportsArbitrum = true;
|
|
575
|
-
_supportsArbitrumNova = false;
|
|
576
|
-
_supportsBase = true;
|
|
577
|
-
_supportsBTC = true;
|
|
578
|
-
_supportsCosmos = true;
|
|
579
|
-
_supportsOsmosis = true;
|
|
580
|
-
_supportsRipple = true;
|
|
581
|
-
_supportsBinance = true;
|
|
582
|
-
_supportsEos = true;
|
|
583
|
-
_supportsFio = false;
|
|
584
|
-
_supportsThorchainInfo = true;
|
|
585
|
-
_supportsThorchain = true;
|
|
586
|
-
_supportsSecretInfo = false;
|
|
587
|
-
_supportsSecret = false;
|
|
588
|
-
_supportsKava = false;
|
|
589
|
-
_supportsKavaInfo = false;
|
|
590
|
-
_supportsTerra = false;
|
|
591
|
-
_supportsTerraInfo = false;
|
|
592
|
-
transport;
|
|
593
|
-
features;
|
|
594
|
-
info;
|
|
595
|
-
featuresCache;
|
|
586
|
+
exports.KeepKeyHDWalletInfo = KeepKeyHDWalletInfo;
|
|
587
|
+
class KeepKeyHDWallet {
|
|
596
588
|
constructor(transport) {
|
|
589
|
+
this._supportsETHInfo = true;
|
|
590
|
+
this._supportsBTCInfo = true;
|
|
591
|
+
this._supportsCosmosInfo = true;
|
|
592
|
+
this._supportsOsmosisInfo = true;
|
|
593
|
+
this._supportsRippleInfo = true;
|
|
594
|
+
this._supportsBinanceInfo = true;
|
|
595
|
+
this._supportsEosInfo = true;
|
|
596
|
+
this._supportsFioInfo = false;
|
|
597
|
+
this._isKeepKey = true;
|
|
598
|
+
this._supportsETH = true;
|
|
599
|
+
this._supportsEthSwitchChain = false;
|
|
600
|
+
this._supportsAvalanche = false;
|
|
601
|
+
this._supportsOptimism = true;
|
|
602
|
+
this._supportsBSC = true;
|
|
603
|
+
this._supportsPolygon = true;
|
|
604
|
+
this._supportsGnosis = true;
|
|
605
|
+
this._supportsArbitrum = true;
|
|
606
|
+
this._supportsArbitrumNova = false;
|
|
607
|
+
this._supportsBase = true;
|
|
608
|
+
this._supportsBTC = true;
|
|
609
|
+
this._supportsCosmos = true;
|
|
610
|
+
this._supportsOsmosis = true;
|
|
611
|
+
this._supportsRipple = true;
|
|
612
|
+
this._supportsBinance = true;
|
|
613
|
+
this._supportsEos = true;
|
|
614
|
+
this._supportsFio = false;
|
|
615
|
+
this._supportsThorchainInfo = true;
|
|
616
|
+
this._supportsThorchain = true;
|
|
617
|
+
this._supportsSecretInfo = false;
|
|
618
|
+
this._supportsSecret = false;
|
|
619
|
+
this._supportsKava = false;
|
|
620
|
+
this._supportsKavaInfo = false;
|
|
621
|
+
this._supportsTerra = false;
|
|
622
|
+
this._supportsTerraInfo = false;
|
|
597
623
|
this.transport = transport;
|
|
598
624
|
this._supportsDebugLink = transport.debugLink;
|
|
599
625
|
this.info = new KeepKeyHDWalletInfo();
|
|
600
626
|
}
|
|
601
|
-
static
|
|
602
|
-
return
|
|
627
|
+
static create(transport) {
|
|
628
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
629
|
+
return new KeepKeyHDWallet(transport);
|
|
630
|
+
});
|
|
603
631
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
632
|
+
getDeviceID() {
|
|
633
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
634
|
+
const featuresId = (yield this.getFeatures(/*cached=*/ true)).deviceId;
|
|
635
|
+
// Devices in bootloader mode show up with empty string deviceId's in their features object.
|
|
636
|
+
if (featuresId)
|
|
637
|
+
return featuresId;
|
|
638
|
+
// Grabbing the one from the transport seems to be a reasonable fallback.
|
|
639
|
+
return yield this.transport.getDeviceID();
|
|
640
|
+
});
|
|
611
641
|
}
|
|
612
642
|
getVendor() {
|
|
613
643
|
return "KeepKey";
|
|
614
644
|
}
|
|
615
|
-
|
|
616
|
-
return
|
|
645
|
+
getModel() {
|
|
646
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
647
|
+
return core.mustBeDefined((yield this.getFeatures(/*cached=*/ true)).model);
|
|
648
|
+
});
|
|
617
649
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
650
|
+
getFirmwareVersion() {
|
|
651
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
652
|
+
const features = yield this.getFeatures(/*cached=*/ true);
|
|
653
|
+
return `v${features.majorVersion}.${features.minorVersion}.${features.patchVersion}`;
|
|
654
|
+
});
|
|
621
655
|
}
|
|
622
|
-
|
|
623
|
-
return (
|
|
656
|
+
getLabel() {
|
|
657
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
658
|
+
var _a;
|
|
659
|
+
return (_a = (yield this.getFeatures(/*cached=*/ true)).label) !== null && _a !== void 0 ? _a : "";
|
|
660
|
+
});
|
|
624
661
|
}
|
|
625
|
-
|
|
626
|
-
return
|
|
662
|
+
isInitialized() {
|
|
663
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
664
|
+
return !!(yield this.getFeatures()).initialized;
|
|
665
|
+
});
|
|
627
666
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
667
|
+
isLocked() {
|
|
668
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
669
|
+
const features = yield this.getFeatures();
|
|
670
|
+
if (features.pinProtection && !features.pinCached)
|
|
671
|
+
return true;
|
|
672
|
+
if (features.passphraseProtection && !features.passphraseCached)
|
|
673
|
+
return true;
|
|
674
|
+
return false;
|
|
675
|
+
});
|
|
635
676
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
677
|
+
getPublicKeys(getPublicKeys) {
|
|
678
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
679
|
+
const publicKeys = [];
|
|
680
|
+
for (let i = 0; i < getPublicKeys.length; i++) {
|
|
681
|
+
const { coin, addressNList, curve, showDisplay, scriptType } = getPublicKeys[i];
|
|
682
|
+
const GPK = new Messages.GetPublicKey();
|
|
683
|
+
if (coin)
|
|
684
|
+
GPK.setCoinName(coin);
|
|
685
|
+
GPK.setAddressNList(addressNList);
|
|
686
|
+
GPK.setShowDisplay(showDisplay || false);
|
|
687
|
+
GPK.setEcdsaCurveName(curve || "secp256k1");
|
|
688
|
+
GPK.setScriptType((0, utils_1.translateInputScriptType)(scriptType || core.BTCInputScriptType.SpendAddress));
|
|
689
|
+
const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETPUBLICKEY, GPK, {
|
|
690
|
+
msgTimeout: showDisplay ? core.LONG_TIMEOUT : core.DEFAULT_TIMEOUT,
|
|
691
|
+
});
|
|
692
|
+
const publicKey = event.proto;
|
|
693
|
+
publicKeys.push({ xpub: core.mustBeDefined(publicKey.getXpub()) });
|
|
694
|
+
}
|
|
695
|
+
return publicKeys;
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
ping(msg) {
|
|
699
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
700
|
+
const ping = new Messages.Ping();
|
|
701
|
+
ping.setMessage(msg.msg);
|
|
702
|
+
ping.setButtonProtection(msg.button || false);
|
|
703
|
+
ping.setPinProtection(msg.pin || false);
|
|
704
|
+
ping.setPassphraseProtection(msg.passphrase || false);
|
|
705
|
+
const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_PING, ping, {
|
|
706
|
+
msgTimeout: msg.button || msg.pin || msg.passphrase ? core.LONG_TIMEOUT : core.DEFAULT_TIMEOUT,
|
|
649
707
|
});
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
}
|
|
653
|
-
return publicKeys;
|
|
654
|
-
}
|
|
655
|
-
async ping(msg) {
|
|
656
|
-
const ping = new Messages.Ping();
|
|
657
|
-
ping.setMessage(msg.msg);
|
|
658
|
-
ping.setButtonProtection(msg.button || false);
|
|
659
|
-
ping.setPinProtection(msg.pin || false);
|
|
660
|
-
ping.setPassphraseProtection(msg.passphrase || false);
|
|
661
|
-
const event = await this.transport.call(Messages.MessageType.MESSAGETYPE_PING, ping, {
|
|
662
|
-
msgTimeout: msg.button || msg.pin || msg.passphrase ? core.LONG_TIMEOUT : core.DEFAULT_TIMEOUT,
|
|
708
|
+
const message = event.proto;
|
|
709
|
+
return { msg: core.mustBeDefined(message.getMessage()) };
|
|
663
710
|
});
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
711
|
+
}
|
|
712
|
+
reset(msg) {
|
|
713
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
714
|
+
const resetDevice = new Messages.ResetDevice();
|
|
715
|
+
resetDevice.setStrength(msg.entropy || 128);
|
|
716
|
+
resetDevice.setDisplayRandom(false);
|
|
717
|
+
resetDevice.setPassphraseProtection(msg.passphrase || false);
|
|
718
|
+
resetDevice.setPinProtection(msg.pin || false);
|
|
719
|
+
resetDevice.setLabel(msg.label);
|
|
720
|
+
if (msg.autoLockDelayMs) {
|
|
721
|
+
resetDevice.setAutoLockDelayMs(msg.autoLockDelayMs);
|
|
722
|
+
}
|
|
723
|
+
resetDevice.setU2fCounter(msg.u2fCounter || Math.floor(+new Date() / 1000));
|
|
724
|
+
// resetDevice.setWordsPerGape(wordsPerScreen) // Re-enable when patch gets in
|
|
725
|
+
// Send
|
|
726
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_RESETDEVICE, resetDevice, {
|
|
727
|
+
msgTimeout: core.LONG_TIMEOUT,
|
|
728
|
+
});
|
|
729
|
+
this.cacheFeatures(undefined);
|
|
682
730
|
});
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
731
|
+
}
|
|
732
|
+
recover(r) {
|
|
733
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
734
|
+
const msg = new Messages.RecoveryDevice();
|
|
735
|
+
msg.setWordCount({ 128: 12, 192: 18, 256: 24 }[r.entropy]);
|
|
736
|
+
msg.setPassphraseProtection(r.passphrase);
|
|
737
|
+
msg.setPinProtection(r.pin);
|
|
738
|
+
msg.setLabel(r.label);
|
|
739
|
+
msg.setLanguage(r.language || "english");
|
|
740
|
+
msg.setEnforceWordlist(true);
|
|
741
|
+
msg.setUseCharacterCipher(true);
|
|
742
|
+
if (r.autoLockDelayMs) {
|
|
743
|
+
msg.setAutoLockDelayMs(r.autoLockDelayMs);
|
|
744
|
+
}
|
|
745
|
+
msg.setU2fCounter(r.u2fCounter || Math.floor(+new Date() / 1000));
|
|
746
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_RECOVERYDEVICE, msg, {
|
|
747
|
+
msgTimeout: core.LONG_TIMEOUT,
|
|
748
|
+
});
|
|
749
|
+
this.cacheFeatures(undefined);
|
|
700
750
|
});
|
|
701
|
-
this.cacheFeatures(undefined);
|
|
702
751
|
}
|
|
703
|
-
|
|
704
|
-
return this
|
|
752
|
+
pressYes() {
|
|
753
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
754
|
+
return this.press(true);
|
|
755
|
+
});
|
|
705
756
|
}
|
|
706
|
-
|
|
707
|
-
return this
|
|
757
|
+
pressNo() {
|
|
758
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
759
|
+
return this.press(false);
|
|
760
|
+
});
|
|
708
761
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
762
|
+
press(isYes) {
|
|
763
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
764
|
+
const decision = new Messages.DebugLinkDecision();
|
|
765
|
+
decision.setYesNo(isYes);
|
|
766
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_DEBUGLINKDECISION, decision, {
|
|
767
|
+
noWait: true,
|
|
768
|
+
debugLink: true,
|
|
769
|
+
});
|
|
715
770
|
});
|
|
716
771
|
}
|
|
717
772
|
hasOnDevicePinEntry() {
|
|
@@ -739,295 +794,363 @@ export class KeepKeyHDWallet {
|
|
|
739
794
|
supportsBroadcast() {
|
|
740
795
|
return false;
|
|
741
796
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
797
|
+
sendPin(pin) {
|
|
798
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
799
|
+
const matrixAck = new Messages.PinMatrixAck();
|
|
800
|
+
matrixAck.setPin(pin);
|
|
801
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_PINMATRIXACK, matrixAck, {
|
|
802
|
+
msgTimeout: core.DEFAULT_TIMEOUT,
|
|
803
|
+
omitLock: true,
|
|
804
|
+
noWait: true,
|
|
805
|
+
});
|
|
749
806
|
});
|
|
750
807
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
808
|
+
sendPassphrase(passphrase) {
|
|
809
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
810
|
+
const passphraseAck = new Messages.PassphraseAck();
|
|
811
|
+
passphraseAck.setPassphrase(passphrase);
|
|
812
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_PASSPHRASEACK, passphraseAck, {
|
|
813
|
+
msgTimeout: core.DEFAULT_TIMEOUT,
|
|
814
|
+
omitLock: true,
|
|
815
|
+
noWait: true,
|
|
816
|
+
});
|
|
758
817
|
});
|
|
759
818
|
}
|
|
760
|
-
|
|
761
|
-
|
|
819
|
+
sendCharacter(character) {
|
|
820
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
821
|
+
yield this.sendCharacterProto(character, false, false);
|
|
822
|
+
});
|
|
762
823
|
}
|
|
763
|
-
|
|
764
|
-
|
|
824
|
+
sendCharacterDelete() {
|
|
825
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
826
|
+
yield this.sendCharacterProto("", true, false);
|
|
827
|
+
});
|
|
765
828
|
}
|
|
766
|
-
|
|
767
|
-
|
|
829
|
+
sendCharacterDone() {
|
|
830
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
831
|
+
yield this.sendCharacterProto("", false, true);
|
|
832
|
+
});
|
|
768
833
|
}
|
|
769
834
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
770
|
-
|
|
771
|
-
|
|
835
|
+
sendWord(word) {
|
|
836
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
837
|
+
throw new Error("Not Yet Implemented :(");
|
|
838
|
+
});
|
|
772
839
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
840
|
+
sendCharacterProto(character, _delete, _done) {
|
|
841
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
842
|
+
const characterAck = new Messages.CharacterAck();
|
|
843
|
+
if (character !== "") {
|
|
844
|
+
characterAck.setCharacter(character);
|
|
845
|
+
}
|
|
846
|
+
else if (_delete) {
|
|
847
|
+
characterAck.setDelete(_delete);
|
|
848
|
+
}
|
|
849
|
+
else if (_done) {
|
|
850
|
+
characterAck.setDone(_done);
|
|
851
|
+
}
|
|
852
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_CHARACTERACK, characterAck, {
|
|
853
|
+
msgTimeout: core.DEFAULT_TIMEOUT,
|
|
854
|
+
omitLock: true,
|
|
855
|
+
noWait: true,
|
|
856
|
+
});
|
|
788
857
|
});
|
|
789
858
|
}
|
|
790
859
|
// ApplyPolicy enables or disables a named policy such as "ShapeShift" on the device
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
860
|
+
applyPolicy(p) {
|
|
861
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
862
|
+
const policy = new Types.PolicyType();
|
|
863
|
+
policy.setPolicyName(p.policyName);
|
|
864
|
+
policy.setEnabled(p.enabled);
|
|
865
|
+
const applyPolicies = new Messages.ApplyPolicies();
|
|
866
|
+
applyPolicies.setPolicyList([policy]);
|
|
867
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_APPLYPOLICIES, applyPolicies, {
|
|
868
|
+
msgTimeout: core.LONG_TIMEOUT,
|
|
869
|
+
});
|
|
870
|
+
this.cacheFeatures(undefined);
|
|
799
871
|
});
|
|
800
|
-
this.cacheFeatures(undefined);
|
|
801
872
|
}
|
|
802
873
|
// ApplySettings changes the label, language, and enabling/disabling the passphrase
|
|
803
874
|
// The default language is english
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
875
|
+
applySettings(s) {
|
|
876
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
877
|
+
const applySettings = new Messages.ApplySettings();
|
|
878
|
+
if (s.label) {
|
|
879
|
+
applySettings.setLabel(s.label);
|
|
880
|
+
}
|
|
881
|
+
if (s.language) {
|
|
882
|
+
applySettings.setLanguage(s.language);
|
|
883
|
+
}
|
|
884
|
+
if (s.usePassphrase !== undefined) {
|
|
885
|
+
applySettings.setUsePassphrase(s.usePassphrase);
|
|
886
|
+
}
|
|
887
|
+
if (s.autoLockDelayMs) {
|
|
888
|
+
applySettings.setAutoLockDelayMs(s.autoLockDelayMs);
|
|
889
|
+
}
|
|
890
|
+
if (s.u2fCounter) {
|
|
891
|
+
applySettings.setU2fCounter(s.u2fCounter);
|
|
892
|
+
}
|
|
893
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_APPLYSETTINGS, applySettings);
|
|
894
|
+
this.cacheFeatures(undefined);
|
|
895
|
+
});
|
|
823
896
|
}
|
|
824
897
|
// Cancel aborts the last device action that required user interaction
|
|
825
898
|
// It can follow a button request, passphrase request, or pin request
|
|
826
|
-
|
|
827
|
-
|
|
899
|
+
cancel() {
|
|
900
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
901
|
+
yield this.transport.cancel();
|
|
902
|
+
});
|
|
828
903
|
}
|
|
829
904
|
// ChangePin requests setting/changing the pin
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
905
|
+
changePin() {
|
|
906
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
907
|
+
const changePin = new Messages.ChangePin();
|
|
908
|
+
// User may be propmpted for button press up to 2 times
|
|
909
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_CHANGEPIN, changePin, {
|
|
910
|
+
msgTimeout: core.LONG_TIMEOUT,
|
|
911
|
+
});
|
|
835
912
|
});
|
|
836
913
|
}
|
|
837
914
|
// CipherKeyValue encrypts or decrypts a value with a given key, nodepath, and initializationVector
|
|
838
915
|
// This method encrypts if encrypt is true and decrypts if false, the confirm paramater determines wether
|
|
839
916
|
// the user is prompted on the device. See EncryptKeyValue() and DecryptKeyValue() for convenience methods
|
|
840
917
|
// NOTE: If the length of the value in bytes is not divisible by 16 it will be zero padded
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
918
|
+
cipherKeyValue(v) {
|
|
919
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
920
|
+
// if(val.length % 16 !== 0) val = val.concat() TODO THIS
|
|
921
|
+
const cipherKeyValue = new Messages.CipherKeyValue();
|
|
922
|
+
cipherKeyValue.setAddressNList(v.addressNList);
|
|
923
|
+
cipherKeyValue.setKey(v.key);
|
|
924
|
+
cipherKeyValue.setValue(v.value);
|
|
925
|
+
cipherKeyValue.setEncrypt(!!v.encrypt);
|
|
926
|
+
cipherKeyValue.setAskOnEncrypt(v.askOnEncrypt || false);
|
|
927
|
+
cipherKeyValue.setAskOnDecrypt(v.askOnDecrypt || false);
|
|
928
|
+
cipherKeyValue.setIv(v.iv || "");
|
|
929
|
+
const response = yield this.transport.call(Messages.MessageType.MESSAGETYPE_CIPHERKEYVALUE, cipherKeyValue);
|
|
930
|
+
const ckv = response.message;
|
|
931
|
+
return ckv.getValue();
|
|
932
|
+
});
|
|
854
933
|
}
|
|
855
934
|
// ClearSession clears cached session values such as the pin and passphrase
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
935
|
+
clearSession() {
|
|
936
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
937
|
+
const clearSession = new Messages.ClearSession();
|
|
938
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_CLEARSESSION, clearSession);
|
|
939
|
+
this.cacheFeatures(undefined);
|
|
940
|
+
});
|
|
860
941
|
}
|
|
861
942
|
// DecryptKeyValue is a convenience method around decrypting with CipherKeyValue().
|
|
862
943
|
// For more granular control of the process use CipherKeyValue()
|
|
863
|
-
|
|
864
|
-
return this
|
|
944
|
+
decryptKeyValue(v) {
|
|
945
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
946
|
+
return this.cipherKeyValue(v);
|
|
947
|
+
});
|
|
865
948
|
}
|
|
866
949
|
// FirmwareErase askes the device to erase its firmware
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
950
|
+
firmwareErase() {
|
|
951
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
952
|
+
const firmwareErase = new Messages.FirmwareErase();
|
|
953
|
+
// send
|
|
954
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_FIRMWAREERASE, firmwareErase);
|
|
955
|
+
this.cacheFeatures(undefined);
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
firmwareUpload(firmware) {
|
|
959
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
960
|
+
const firmwareUpload = new Messages.FirmwareUpload();
|
|
961
|
+
const hash = yield this.transport.getFirmwareHash(firmware);
|
|
962
|
+
firmwareUpload.setPayload(firmware);
|
|
963
|
+
firmwareUpload.setPayloadHash(hash);
|
|
964
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_FIRMWAREUPLOAD, firmwareUpload);
|
|
965
|
+
this.cacheFeatures(undefined);
|
|
966
|
+
});
|
|
880
967
|
}
|
|
881
968
|
// Initialize assigns a hid connection to this KeepKey and send initialize message to device
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
969
|
+
initialize() {
|
|
970
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
971
|
+
const initialize = new Messages.Initialize();
|
|
972
|
+
const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_INITIALIZE, initialize);
|
|
973
|
+
if (!event.message)
|
|
974
|
+
throw event;
|
|
975
|
+
const out = event.message;
|
|
976
|
+
this.features = out;
|
|
977
|
+
// v6.1.0 firmware changed usb serial numbers to match STM32 desig_device_id
|
|
978
|
+
// If the deviceId in the features table doesn't match, then we need to
|
|
979
|
+
// add another k-v pair to the keyring so it can be looked up either way.
|
|
980
|
+
const transportDeviceID = yield this.transport.getDeviceID();
|
|
981
|
+
if (out.deviceId && transportDeviceID !== out.deviceId) {
|
|
982
|
+
this.transport.keyring.addAlias(transportDeviceID, out.deviceId);
|
|
983
|
+
}
|
|
984
|
+
const fwVersion = `v${out.majorVersion}.${out.minorVersion}.${out.patchVersion}`;
|
|
985
|
+
//Lost Support per proto 44.3
|
|
986
|
+
this._supportsOsmosis = semver_1.default.gte(fwVersion, "v7.7.0");
|
|
987
|
+
this._supportsCosmos = semver_1.default.gte(fwVersion, "v7.3.0");
|
|
988
|
+
this._supportsRipple = semver_1.default.gte(fwVersion, "v6.4.0");
|
|
989
|
+
this._supportsBinance = semver_1.default.gte(fwVersion, "v6.4.0");
|
|
990
|
+
this._supportsEos = semver_1.default.gte(fwVersion, "v6.4.0");
|
|
991
|
+
// this._supportsThorchain = semver.get(fwVersion, "v7.3.0");
|
|
992
|
+
this.cacheFeatures(out);
|
|
993
|
+
return out;
|
|
994
|
+
});
|
|
906
995
|
}
|
|
907
996
|
// GetFeatures returns the features and other device information such as the version, label, and supported coins
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
997
|
+
getFeatures() {
|
|
998
|
+
return __awaiter(this, arguments, void 0, function* (cached = false) {
|
|
999
|
+
if (cached && this.featuresCache)
|
|
1000
|
+
return this.featuresCache;
|
|
1001
|
+
const features = new Messages.GetFeatures();
|
|
1002
|
+
const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETFEATURES, features);
|
|
1003
|
+
this.cacheFeatures(event.message);
|
|
1004
|
+
return event.message;
|
|
1005
|
+
});
|
|
915
1006
|
}
|
|
916
1007
|
cacheFeatures(features) {
|
|
917
1008
|
this.featuresCache = features;
|
|
918
1009
|
}
|
|
919
1010
|
// GetEntropy requests sample data from the hardware RNG
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
1011
|
+
getEntropy(size) {
|
|
1012
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1013
|
+
const getEntropy = new Messages.GetEntropy();
|
|
1014
|
+
getEntropy.setSize(size);
|
|
1015
|
+
// send
|
|
1016
|
+
const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETENTROPY, getEntropy, {
|
|
1017
|
+
msgTimeout: core.LONG_TIMEOUT,
|
|
1018
|
+
});
|
|
1019
|
+
return core.mustBeDefined(event.proto).getEntropy_asU8();
|
|
926
1020
|
});
|
|
927
|
-
return core.mustBeDefined(event.proto).getEntropy_asU8();
|
|
928
1021
|
}
|
|
929
1022
|
// GetNumCoins returns the number of coins supported by the device regardless of if the hanve funds.
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1023
|
+
getNumCoins() {
|
|
1024
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1025
|
+
const getCoinTable = new Messages.GetCoinTable();
|
|
1026
|
+
const response = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETCOINTABLE, getCoinTable);
|
|
1027
|
+
return core.mustBeDefined(core.mustBeDefined(response.proto).getNumCoins());
|
|
1028
|
+
});
|
|
934
1029
|
}
|
|
935
1030
|
// GetCoinTable returns an array of Types.CoinTypes, with start and end arguments for paging.
|
|
936
1031
|
// You cannot request more than 10 at a time.
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1032
|
+
getCoinTable() {
|
|
1033
|
+
return __awaiter(this, arguments, void 0, function* (start = 0, end = start + 10) {
|
|
1034
|
+
const getCoinTable = new Messages.GetCoinTable();
|
|
1035
|
+
getCoinTable.setStart(start);
|
|
1036
|
+
getCoinTable.setEnd(end);
|
|
1037
|
+
const response = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETCOINTABLE, getCoinTable);
|
|
1038
|
+
const coinTable = response.message;
|
|
1039
|
+
return coinTable.tableList;
|
|
1040
|
+
});
|
|
944
1041
|
}
|
|
945
1042
|
// LoadDevice loads a provided seed onto the device and applies the provided settings
|
|
946
1043
|
// including setting a pin/device label, enabling/disabling the passphrase, and whether to
|
|
947
1044
|
// check the checksum of the provided mnemonic
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
1045
|
+
loadDevice(msg) {
|
|
1046
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1047
|
+
const loadDevice = new Messages.LoadDevice();
|
|
1048
|
+
loadDevice.setMnemonic(msg.mnemonic);
|
|
1049
|
+
loadDevice.setPassphraseProtection(!!msg.passphrase);
|
|
1050
|
+
loadDevice.setSkipChecksum(!!msg.skipChecksum);
|
|
1051
|
+
if (msg.pin)
|
|
1052
|
+
loadDevice.setPin(msg.pin);
|
|
1053
|
+
if (msg.label)
|
|
1054
|
+
loadDevice.setLabel(msg.label);
|
|
1055
|
+
// send
|
|
1056
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_LOADDEVICE, loadDevice, {
|
|
1057
|
+
msgTimeout: core.LONG_TIMEOUT,
|
|
1058
|
+
});
|
|
1059
|
+
this.cacheFeatures(undefined);
|
|
960
1060
|
});
|
|
961
|
-
this.cacheFeatures(undefined);
|
|
962
1061
|
}
|
|
963
1062
|
// RemovePin disables pin protection for the device. If a pin is currently enabled
|
|
964
1063
|
// it will prompt the user to enter the current pin
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
msg[setterMethod]
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1064
|
+
removePin() {
|
|
1065
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1066
|
+
const changePin = new Messages.ChangePin();
|
|
1067
|
+
changePin.setRemove(true);
|
|
1068
|
+
// send
|
|
1069
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_CHANGEPIN, changePin);
|
|
1070
|
+
this.cacheFeatures(undefined);
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
send(events) {
|
|
1074
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1075
|
+
for (const event of events) {
|
|
1076
|
+
const MessageType = typeRegistry_1.messageTypeRegistry[core.mustBeDefined(event.message_enum)];
|
|
1077
|
+
const msg = new MessageType();
|
|
1078
|
+
Object.entries(event.message).forEach(([key, value]) => {
|
|
1079
|
+
const setterMethod = (0, utils_1.protoFieldToSetMethod)(key);
|
|
1080
|
+
if (msg[setterMethod]) {
|
|
1081
|
+
// Assume setter methods are always of the format: strength -> setStrength
|
|
1082
|
+
// until this exists https://github.com/protocolbuffers/protobuf/issues/1591
|
|
1083
|
+
msg[setterMethod](value);
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1086
|
+
yield this.transport.call(core.mustBeDefined(event.message_enum), msg);
|
|
1087
|
+
}
|
|
1088
|
+
});
|
|
986
1089
|
}
|
|
987
1090
|
// SoftReset power cycles the device. The device only responds to
|
|
988
1091
|
// this message while in manufacturer mode
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1092
|
+
softReset() {
|
|
1093
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1094
|
+
const softReset = new Messages.SoftReset();
|
|
1095
|
+
// send
|
|
1096
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_SOFTRESET, softReset);
|
|
1097
|
+
this.cacheFeatures(undefined);
|
|
1098
|
+
});
|
|
994
1099
|
}
|
|
995
1100
|
// WipeDevice wipes all sensitive data and settings
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1101
|
+
wipe() {
|
|
1102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1103
|
+
const wipeDevice = new Messages.WipeDevice();
|
|
1104
|
+
// send
|
|
1105
|
+
yield this.transport.call(Messages.MessageType.MESSAGETYPE_WIPEDEVICE, wipeDevice);
|
|
1106
|
+
this.cacheFeatures(undefined);
|
|
1107
|
+
});
|
|
1001
1108
|
}
|
|
1002
|
-
|
|
1003
|
-
return this
|
|
1109
|
+
btcSupportsCoin(coin) {
|
|
1110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1111
|
+
return this.info.btcSupportsCoin(coin);
|
|
1112
|
+
});
|
|
1004
1113
|
}
|
|
1005
|
-
|
|
1006
|
-
return this
|
|
1114
|
+
btcSupportsScriptType(coin, scriptType) {
|
|
1115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1116
|
+
return this.info.btcSupportsScriptType(coin, scriptType);
|
|
1117
|
+
});
|
|
1007
1118
|
}
|
|
1008
|
-
|
|
1009
|
-
return
|
|
1119
|
+
btcGetAddress(msg) {
|
|
1120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1121
|
+
return Btc.btcGetAddress(this, this.transport, msg);
|
|
1122
|
+
});
|
|
1010
1123
|
}
|
|
1011
|
-
|
|
1012
|
-
return
|
|
1124
|
+
btcSignTx(msg) {
|
|
1125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1126
|
+
return Btc.btcSignTx(this, this.transport, msg);
|
|
1127
|
+
});
|
|
1013
1128
|
}
|
|
1014
|
-
|
|
1015
|
-
return this
|
|
1129
|
+
btcSupportsSecureTransfer() {
|
|
1130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1131
|
+
return this.info.btcSupportsSecureTransfer();
|
|
1132
|
+
});
|
|
1016
1133
|
}
|
|
1017
1134
|
btcSupportsNativeShapeShift() {
|
|
1018
1135
|
return this.info.btcSupportsNativeShapeShift();
|
|
1019
1136
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1137
|
+
ethSupportsEIP1559() {
|
|
1138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1139
|
+
// EIP1559 support starts in v7.2.1
|
|
1140
|
+
// return semver.gte(await this.getFirmwareVersion(), "v7.2.1");
|
|
1141
|
+
// disable EIP1559 support until edge case fail states are fixed across all evm chains
|
|
1142
|
+
return false;
|
|
1143
|
+
});
|
|
1025
1144
|
}
|
|
1026
|
-
|
|
1027
|
-
return
|
|
1145
|
+
btcSignMessage(msg) {
|
|
1146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1147
|
+
return Btc.btcSignMessage(this, this.transport, msg);
|
|
1148
|
+
});
|
|
1028
1149
|
}
|
|
1029
|
-
|
|
1030
|
-
return
|
|
1150
|
+
btcVerifyMessage(msg) {
|
|
1151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1152
|
+
return Btc.btcVerifyMessage(this, this.transport, msg);
|
|
1153
|
+
});
|
|
1031
1154
|
}
|
|
1032
1155
|
btcGetAccountPaths(msg) {
|
|
1033
1156
|
return this.info.btcGetAccountPaths(msg);
|
|
@@ -1039,26 +1162,40 @@ export class KeepKeyHDWallet {
|
|
|
1039
1162
|
// return false
|
|
1040
1163
|
return this.info.btcIsSameAccount(msg);
|
|
1041
1164
|
}
|
|
1042
|
-
|
|
1043
|
-
return
|
|
1165
|
+
ethSignTx(msg) {
|
|
1166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1167
|
+
return Eth.ethSignTx(this.transport, msg);
|
|
1168
|
+
});
|
|
1044
1169
|
}
|
|
1045
|
-
|
|
1046
|
-
return
|
|
1170
|
+
ethGetAddress(msg) {
|
|
1171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1172
|
+
return Eth.ethGetAddress(this.transport, msg);
|
|
1173
|
+
});
|
|
1047
1174
|
}
|
|
1048
|
-
|
|
1049
|
-
return
|
|
1175
|
+
ethSignMessage(msg) {
|
|
1176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1177
|
+
return Eth.ethSignMessage(this.transport, msg);
|
|
1178
|
+
});
|
|
1050
1179
|
}
|
|
1051
|
-
|
|
1052
|
-
return
|
|
1180
|
+
ethSignTypedData(msg) {
|
|
1181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1182
|
+
return Eth.ethSignTypedData(this.transport, msg);
|
|
1183
|
+
});
|
|
1053
1184
|
}
|
|
1054
|
-
|
|
1055
|
-
return
|
|
1185
|
+
ethVerifyMessage(msg) {
|
|
1186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1187
|
+
return Eth.ethVerifyMessage(this.transport, msg);
|
|
1188
|
+
});
|
|
1056
1189
|
}
|
|
1057
|
-
|
|
1058
|
-
return this
|
|
1190
|
+
ethSupportsNetwork(chain_id) {
|
|
1191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1192
|
+
return this.info.ethSupportsNetwork(chain_id);
|
|
1193
|
+
});
|
|
1059
1194
|
}
|
|
1060
|
-
|
|
1061
|
-
return this
|
|
1195
|
+
ethSupportsSecureTransfer() {
|
|
1196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1197
|
+
return this.info.ethSupportsSecureTransfer();
|
|
1198
|
+
});
|
|
1062
1199
|
}
|
|
1063
1200
|
ethSupportsNativeShapeShift() {
|
|
1064
1201
|
return this.info.ethSupportsNativeShapeShift();
|
|
@@ -1148,10 +1285,11 @@ export class KeepKeyHDWallet {
|
|
|
1148
1285
|
return this.info.binanceNextAccountPath(msg);
|
|
1149
1286
|
}
|
|
1150
1287
|
}
|
|
1151
|
-
|
|
1288
|
+
exports.KeepKeyHDWallet = KeepKeyHDWallet;
|
|
1289
|
+
function info() {
|
|
1152
1290
|
return new KeepKeyHDWalletInfo();
|
|
1153
1291
|
}
|
|
1154
|
-
|
|
1292
|
+
function create(transport) {
|
|
1155
1293
|
return new KeepKeyHDWallet(transport);
|
|
1156
1294
|
}
|
|
1157
1295
|
//# sourceMappingURL=keepkey.js.map
|