@onekeyfe/hd-core 1.0.26-alpha.0 → 1.0.26-alpha.1

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.
@@ -7,6 +7,18 @@ export default class AptosSignTransaction extends BaseMethod<HardwareAptosSignTx
7
7
  min: string;
8
8
  };
9
9
  };
10
+ getWithDataVersionRange(): {
11
+ pro: {
12
+ min: string;
13
+ };
14
+ model_classic1s: {
15
+ min: string;
16
+ };
17
+ classic: {
18
+ min: string;
19
+ };
20
+ };
21
+ checkWithDataError(): void;
10
22
  run(): Promise<import("@onekeyfe/hd-transport").AptosSignedTx>;
11
23
  }
12
24
  //# sourceMappingURL=AptosSignTransaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AptosSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/aptos/AptosSignTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAU,CAAC,mBAAmB,CAAC;IAC/E,IAAI;IAqBJ,eAAe;;;;;IAQT,GAAG;CAOV"}
1
+ {"version":3,"file":"AptosSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/aptos/AptosSignTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,WAAW,IAAI,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAGlG,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAU,CAAC,mBAAmB,CAAC;IAC/E,IAAI;IAuBJ,eAAe;;;;;IAQf,uBAAuB;;;;;;;;;;;IAcvB,kBAAkB;IAQZ,GAAG;CASV"}
@@ -1,4 +1,4 @@
1
- import { GetPublicKey } from '@onekeyfe/hd-transport';
1
+ import type { GetPublicKey } from '@onekeyfe/hd-transport';
2
2
  import { BaseMethod } from '../BaseMethod';
3
3
  import { BTCPublicKey } from '../../types/api/btcGetPublicKey';
4
4
  export default class BTCGetPublicKey extends BaseMethod<GetPublicKey[]> {
@@ -1 +1 @@
1
- {"version":3,"file":"BTCGetPublicKey.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCGetPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAG/D,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU,CAAC,YAAY,EAAE,CAAC;IACrE,SAAS,UAAS;IAElB,IAAI;IA4CJ,OAAO,CAAC,YAAY;IAIpB,eAAe;;;;;;;;;;;IAIT,GAAG;CAkCV"}
1
+ {"version":3,"file":"BTCGetPublicKey.d.ts","sourceRoot":"","sources":["../../../src/api/btc/BTCGetPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAK/D,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU,CAAC,YAAY,EAAE,CAAC;IACrE,SAAS,UAAS;IAElB,IAAI;IA4CJ,OAAO,CAAC,YAAY;IAIpB,eAAe;;;;;;;;;;;IAIT,GAAG;CAkFV"}
@@ -0,0 +1,3 @@
1
+ import type { HDNodeType, InputScriptType } from '@onekeyfe/hd-transport';
2
+ export declare function createExtendedPublicKey(node: HDNodeType, scriptType?: InputScriptType): string;
3
+ //# sourceMappingURL=xpubUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xpubUtils.d.ts","sourceRoot":"","sources":["../../../../src/api/btc/helpers/xpubUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AA0E1E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,eAAe,GAAG,MAAM,CAS9F"}
@@ -1 +1 @@
1
- {"version":3,"file":"CardanoSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/cardano/CardanoSignTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAoB3C,OAAO,KAAK,EAGV,mBAAmB,EAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAU,CAAC,GAAG,CAAC;IACjE,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,eAAe;;;;;;;;IAWf,IAAI;IAqJJ,SAAS,gBAyBP;IAEF,yBAAyB,QAAO,mBAAmB,CAOhD;IAEH,kBAAkB,aAuBhB;IAEI,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAyI5C,GAAG;CAKJ"}
1
+ {"version":3,"file":"CardanoSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/cardano/CardanoSignTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAoB3C,OAAO,KAAK,EAGV,mBAAmB,EAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAU,CAAC,GAAG,CAAC;IACjE,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,eAAe;;;;;;;;IAWf,IAAI;IAqJJ,SAAS,gBAyBP;IAEF,yBAAyB,QAAO,mBAAmB,CAUhD;IAEH,kBAAkB,aAuBhB;IAEI,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAyI5C,GAAG;CAKJ"}
@@ -1,4 +1,7 @@
1
1
  import { Path } from '@onekeyfe/hd-transport';
2
2
  import { Device } from '../../device/Device';
3
- export declare function batchGetPublickeys(device: Device, paths: Path[], ecdsaCurveName: string, coinType: number): Promise<import("../../device/DeviceCommands").TypedResponseMessage<"EcdsaPublicKeys">>;
3
+ export declare function batchGetPublickeys(device: Device, paths: Path[], ecdsaCurveName: string, coinType: number, options?: {
4
+ includeNode?: boolean;
5
+ ignoreCoinType?: boolean;
6
+ }): Promise<import("../../device/DeviceCommands").TypedResponseMessage<"EcdsaPublicKeys">>;
4
7
  //# sourceMappingURL=batchGetPublickeys.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"batchGetPublickeys.d.ts","sourceRoot":"","sources":["../../../src/api/helpers/batchGetPublickeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAG9C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,IAAI,EAAE,EACb,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,0FAqBjB"}
1
+ {"version":3,"file":"batchGetPublickeys.d.ts","sourceRoot":"","sources":["../../../src/api/helpers/batchGetPublickeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAG9C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,IAAI,EAAE,EACb,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IACR,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,0FAsBF"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import EventEmitter$1, { EventEmitter } from 'events';
2
- import { Messages, LowlevelTransportSharedPlugin, Success as Success$1, RecoveryDeviceType, SafetyCheckLevel, ResourceType, NextU2FCounter, SetU2FCounter, CipheredKeyValue as CipheredKeyValue$1, UintType, EthereumPublicKey, EthereumMessageSignature, Address, MultisigRedeemScriptType, InputScriptType, PublicKey, MessageSignature, SignedPsbt, PrevInput, TxOutputBinType, TxInput, TxOutputType, TxInputType, StarcoinAddress as StarcoinAddress$1, StarcoinPublicKey as StarcoinPublicKey$1, StarcoinMessageSignature, StarcoinSignedTx, NEMAddress as NEMAddress$1, NEMSignedTx, SolanaAddress as SolanaAddress$1, SolanaSignedTx as SolanaSignedTx$1, SolanaOffChainMessageVersion, SolanaOffChainMessageFormat, StellarAddress as StellarAddress$1, StellarSignedTx, TronAddress as TronAddress$1, TronResourceCode, TronSignedTx, TronMessageSignature, ConfluxAddress as ConfluxAddress$1, ConfluxMessageSignature, NearAddress as NearAddress$1, NearSignedTx, AptosAddress as AptosAddress$1, AptosMessageSignature as AptosMessageSignature$1, AptosSignedTx as AptosSignedTx$1, AlgorandAddress, AlgorandSignedTx, CosmosAddress as CosmosAddress$1, CosmosSignedTx as CosmosSignedTx$1, SuiAddress as SuiAddress$1, SuiMessageSignature, CardanoAddressParametersType, CardanoMessageSignature, FilecoinAddress as FilecoinAddress$1, FilecoinSignedTx as FilecoinSignedTx$1, PolkadotAddress as PolkadotAddress$1, PolkadotSignedTx as PolkadotSignedTx$1, KaspaAddress as KaspaAddress$1, NervosAddress as NervosAddress$1, NervosSignedTx as NervosSignedTx$1, DnxAddress as DnxAddress$1, TonWalletVersion, TonWorkChain, TonSignedMessage, TonSignedProof, ScdoAddress as ScdoAddress$1, ScdoSignedMessage, ScdoSignedTx as ScdoSignedTx$1, AlephiumMessageSignature, AlephiumSignedTx as AlephiumSignedTx$1, BenfenAddress as BenfenAddress$1, BenfenMessageSignature, OneKeyDeviceInfo, Transport, ChangeOutputScriptType } from '@onekeyfe/hd-transport';
2
+ import { Messages, LowlevelTransportSharedPlugin, Success as Success$1, RecoveryDeviceType, SafetyCheckLevel, ResourceType, NextU2FCounter, SetU2FCounter, CipheredKeyValue as CipheredKeyValue$1, UintType, EthereumPublicKey, EthereumMessageSignature, Address, MultisigRedeemScriptType, InputScriptType, PublicKey, MessageSignature, SignedPsbt, PrevInput, TxOutputBinType, TxInput, TxOutputType, TxInputType, StarcoinAddress as StarcoinAddress$1, StarcoinPublicKey as StarcoinPublicKey$1, StarcoinMessageSignature, StarcoinSignedTx, NEMAddress as NEMAddress$1, NEMSignedTx, SolanaAddress as SolanaAddress$1, SolanaSignedTx as SolanaSignedTx$1, SolanaOffChainMessageVersion, SolanaOffChainMessageFormat, StellarAddress as StellarAddress$1, StellarSignedTx, TronAddress as TronAddress$1, TronResourceCode, TronSignedTx, TronMessageSignature, ConfluxAddress as ConfluxAddress$1, ConfluxMessageSignature, NearAddress as NearAddress$1, NearSignedTx, AptosAddress as AptosAddress$1, AptosMessageSignature as AptosMessageSignature$1, AptosSignedTx as AptosSignedTx$1, AptosTransactionType, AlgorandAddress, AlgorandSignedTx, CosmosAddress as CosmosAddress$1, CosmosSignedTx as CosmosSignedTx$1, SuiAddress as SuiAddress$1, SuiMessageSignature, CardanoAddressParametersType, CardanoMessageSignature, FilecoinAddress as FilecoinAddress$1, FilecoinSignedTx as FilecoinSignedTx$1, PolkadotAddress as PolkadotAddress$1, PolkadotSignedTx as PolkadotSignedTx$1, KaspaAddress as KaspaAddress$1, NervosAddress as NervosAddress$1, NervosSignedTx as NervosSignedTx$1, DnxAddress as DnxAddress$1, TonWalletVersion, TonWorkChain, TonSignedMessage, TonSignedProof, ScdoAddress as ScdoAddress$1, ScdoSignedMessage, ScdoSignedTx as ScdoSignedTx$1, AlephiumMessageSignature, AlephiumSignedTx as AlephiumSignedTx$1, BenfenAddress as BenfenAddress$1, BenfenMessageSignature, OneKeyDeviceInfo, Transport, ChangeOutputScriptType } from '@onekeyfe/hd-transport';
3
3
  export { Messages as PROTO } from '@onekeyfe/hd-transport';
4
4
  import { EDeviceType, Deferred } from '@onekeyfe/hd-shared';
5
5
 
@@ -1491,6 +1491,7 @@ type AptosSignedTx = {
1491
1491
  type AptosSignTransactionParams = {
1492
1492
  path: string | number[];
1493
1493
  rawTx?: string;
1494
+ transactionType?: AptosTransactionType;
1494
1495
  };
1495
1496
  declare function aptosSignTransaction(connectId: string, deviceId: string, params: CommonParams & AptosSignTransactionParams): Response<AptosSignedTx>;
1496
1497
 
package/dist/index.js CHANGED
@@ -1554,6 +1554,21 @@ var nested$1 = {
1554
1554
  rule: "required",
1555
1555
  type: "bytes",
1556
1556
  id: 2
1557
+ },
1558
+ tx_type: {
1559
+ type: "AptosTransactionType",
1560
+ id: 3,
1561
+ options: {
1562
+ "default": "STANDARD"
1563
+ }
1564
+ }
1565
+ },
1566
+ nested: {
1567
+ AptosTransactionType: {
1568
+ values: {
1569
+ STANDARD: 0,
1570
+ WITH_DATA: 1
1571
+ }
1557
1572
  }
1558
1573
  }
1559
1574
  },
@@ -4880,6 +4895,13 @@ var nested$1 = {
4880
4895
  rule: "repeated",
4881
4896
  type: "Path",
4882
4897
  id: 2
4898
+ },
4899
+ include_node: {
4900
+ type: "bool",
4901
+ id: 3,
4902
+ options: {
4903
+ "default": false
4904
+ }
4883
4905
  }
4884
4906
  },
4885
4907
  nested: {
@@ -4903,6 +4925,15 @@ var nested$1 = {
4903
4925
  rule: "repeated",
4904
4926
  type: "bytes",
4905
4927
  id: 1
4928
+ },
4929
+ hd_nodes: {
4930
+ rule: "repeated",
4931
+ type: "HDNodeType",
4932
+ id: 2
4933
+ },
4934
+ root_fingerprint: {
4935
+ type: "uint32",
4936
+ id: 3
4906
4937
  }
4907
4938
  }
4908
4939
  },
@@ -24936,11 +24967,20 @@ const getPassphraseState = (features, commands) => __awaiter(void 0, void 0, voi
24936
24967
  }
24937
24968
  return message.address;
24938
24969
  });
24939
- const supportBatchPublicKey = (features) => {
24970
+ const supportBatchPublicKey = (features, options) => {
24940
24971
  if (!features)
24941
24972
  return false;
24942
24973
  const currentVersion = getDeviceFirmwareVersion(features).join('.');
24943
24974
  const deviceType = getDeviceType(features);
24975
+ if (!!(options === null || options === void 0 ? void 0 : options.includeNode) && deviceType === hdShared.EDeviceType.Pro) {
24976
+ return semver__default["default"].gte(currentVersion, '4.14.0');
24977
+ }
24978
+ if (!!(options === null || options === void 0 ? void 0 : options.includeNode) && DeviceModelToTypes.model_classic1s.includes(deviceType)) {
24979
+ return semver__default["default"].gte(currentVersion, '3.12.0');
24980
+ }
24981
+ if (!!(options === null || options === void 0 ? void 0 : options.includeNode) && deviceType === hdShared.EDeviceType.Classic) {
24982
+ return semver__default["default"].gte(currentVersion, '3.10.0');
24983
+ }
24944
24984
  if (deviceType === hdShared.EDeviceType.Touch || deviceType === hdShared.EDeviceType.Pro) {
24945
24985
  return semver__default["default"].gte(currentVersion, '3.1.0');
24946
24986
  }
@@ -30235,6 +30275,82 @@ class BTCGetAddress extends BaseMethod {
30235
30275
  }
30236
30276
  }
30237
30277
 
30278
+ function batchGetPublickeys(device, paths, ecdsaCurveName, coinType, options) {
30279
+ var _a;
30280
+ const existsPathNotValid = paths.find(p => p.address_n.length < 3);
30281
+ if (existsPathNotValid) {
30282
+ throw hdShared.TypedError(hdShared.HardwareErrorCode.ForbiddenKeyPath, 'Path length must be greater than 3');
30283
+ }
30284
+ const supportsBatchPublicKey = supportBatchPublicKey(device.features, options);
30285
+ if (!supportsBatchPublicKey) {
30286
+ throw hdShared.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportMethod);
30287
+ }
30288
+ const existsPathNotEqualCoinType = paths.find(p => !isEqualBip44CoinType(p.address_n, coinType));
30289
+ if ((options === null || options === void 0 ? void 0 : options.ignoreCoinType) === false && existsPathNotEqualCoinType) {
30290
+ throw hdShared.TypedError(hdShared.HardwareErrorCode.ForbiddenKeyPath);
30291
+ }
30292
+ return device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
30293
+ paths,
30294
+ ecdsa_curve_name: ecdsaCurveName,
30295
+ include_node: (_a = options === null || options === void 0 ? void 0 : options.includeNode) !== null && _a !== void 0 ? _a : false,
30296
+ });
30297
+ }
30298
+
30299
+ const VERSION_BYTES = {
30300
+ XPUB: 0x0488b21e,
30301
+ YPUB: 0x049d7cb2,
30302
+ ZPUB: 0x04b24746,
30303
+ };
30304
+ function getVersionBytes(scriptType) {
30305
+ switch (scriptType) {
30306
+ case 'SPENDADDRESS':
30307
+ case 'SPENDMULTISIG':
30308
+ return VERSION_BYTES.XPUB;
30309
+ case 'SPENDP2SHWITNESS':
30310
+ return VERSION_BYTES.YPUB;
30311
+ case 'SPENDWITNESS':
30312
+ return VERSION_BYTES.ZPUB;
30313
+ default:
30314
+ return VERSION_BYTES.XPUB;
30315
+ }
30316
+ }
30317
+ function base58Check(data) {
30318
+ const checksum = sha256.sha256(sha256.sha256(new Uint8Array(data))).slice(0, 4);
30319
+ const withChecksum = Buffer.concat([new Uint8Array(data), new Uint8Array(checksum)]);
30320
+ const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
30321
+ let result = '';
30322
+ let num = BigInt(`0x${withChecksum.toString('hex')}`);
30323
+ const base = BigInt(58);
30324
+ while (num > 0) {
30325
+ const mod = Number(num % base);
30326
+ num /= base;
30327
+ result = ALPHABET[mod] + result;
30328
+ }
30329
+ for (let i = 0; i < withChecksum.length; i++) {
30330
+ if (withChecksum[i] === 0) {
30331
+ result = `1${result}`;
30332
+ }
30333
+ else {
30334
+ break;
30335
+ }
30336
+ }
30337
+ return result;
30338
+ }
30339
+ function generateExtendedPublicKey(depth, fingerprint, childNum, chainCode, publicKey, scriptType) {
30340
+ const versionBytes = getVersionBytes(scriptType);
30341
+ const buffer = Buffer.alloc(78);
30342
+ buffer.writeUInt32BE(versionBytes, 0);
30343
+ buffer.writeUInt8(depth, 4);
30344
+ buffer.writeUInt32BE(fingerprint, 5);
30345
+ buffer.writeUInt32BE(childNum, 9);
30346
+ buffer.write(chainCode, 13, 'hex');
30347
+ buffer.write(publicKey, 45, 'hex');
30348
+ return base58Check(buffer);
30349
+ }
30350
+ function createExtendedPublicKey(node, scriptType) {
30351
+ return generateExtendedPublicKey(node.depth, node.fingerprint, node.child_num, node.chain_code, node.public_key, scriptType);
30352
+ }
30353
+
30238
30354
  class BTCGetPublicKey extends BaseMethod {
30239
30355
  constructor() {
30240
30356
  super(...arguments);
@@ -30281,20 +30397,59 @@ class BTCGetPublicKey extends BaseMethod {
30281
30397
  return getBitcoinForkVersionRange(this.params.map(param => param.coin_name));
30282
30398
  }
30283
30399
  run() {
30400
+ var _a;
30284
30401
  return __awaiter(this, void 0, void 0, function* () {
30285
- const responses = [];
30286
- for (let i = 0; i < this.params.length; i++) {
30287
- const param = this.params[i];
30288
- const res = yield this.device.commands.typedCall('GetPublicKey', 'PublicKey', Object.assign({}, param));
30289
- const response = Object.assign(Object.assign({ path: serializedPath(param.address_n) }, res.message), { xpubSegwit: res.message.xpub });
30290
- if (this.isBtcNetwork(param) && isTaprootPath(param.address_n)) {
30291
- const fingerprint = Number(response.root_fingerprint || 0)
30292
- .toString(16)
30293
- .padStart(8, '0');
30294
- const descriptorPath = `${fingerprint}${response.path.substring(1)}`;
30295
- response.xpubSegwit = `tr([${descriptorPath}]${response.xpub}/<0;1>/*)`;
30402
+ let responses = [];
30403
+ try {
30404
+ const existsShowDisplay = this.params.some(param => param.show_display);
30405
+ if (existsShowDisplay || !this.hasBundle) {
30406
+ throw new Error('Goto getPublickey');
30407
+ }
30408
+ const res = yield batchGetPublickeys(this.device, this.params, 'secp256k1', 0, {
30409
+ includeNode: true,
30410
+ ignoreCoinType: true,
30411
+ });
30412
+ if (!((_a = res.message) === null || _a === void 0 ? void 0 : _a.hd_nodes) || this.params.length !== res.message.hd_nodes.length) {
30413
+ throw new Error('Invalid response from Publickeys');
30414
+ }
30415
+ for (let i = 0; i < this.params.length; i++) {
30416
+ const param = this.params[i];
30417
+ const node = res.message.hd_nodes[i];
30418
+ const path = serializedPath(param.address_n);
30419
+ const xpub = createExtendedPublicKey(node, param.script_type);
30420
+ const rootFingerprint = res.message.root_fingerprint;
30421
+ let xpubSegwit = xpub;
30422
+ if (this.isBtcNetwork(param) && isTaprootPath(param.address_n)) {
30423
+ const fingerprint = Number(rootFingerprint || 0)
30424
+ .toString(16)
30425
+ .padStart(8, '0');
30426
+ const descriptorPath = `${fingerprint}${path.substring(1)}`;
30427
+ xpubSegwit = `tr([${descriptorPath}]${xpub}/<0;1>/*)`;
30428
+ }
30429
+ responses.push({
30430
+ path,
30431
+ node,
30432
+ xpub,
30433
+ root_fingerprint: rootFingerprint,
30434
+ xpubSegwit,
30435
+ });
30436
+ }
30437
+ }
30438
+ catch (error) {
30439
+ responses = [];
30440
+ for (let i = 0; i < this.params.length; i++) {
30441
+ const param = this.params[i];
30442
+ const res = yield this.device.commands.typedCall('GetPublicKey', 'PublicKey', Object.assign({}, param));
30443
+ const response = Object.assign(Object.assign({ path: serializedPath(param.address_n) }, res.message), { xpubSegwit: res.message.xpub });
30444
+ if (this.isBtcNetwork(param) && isTaprootPath(param.address_n)) {
30445
+ const fingerprint = Number(response.root_fingerprint || 0)
30446
+ .toString(16)
30447
+ .padStart(8, '0');
30448
+ const descriptorPath = `${fingerprint}${response.path.substring(1)}`;
30449
+ response.xpubSegwit = `tr([${descriptorPath}]${response.xpub}/<0;1>/*)`;
30450
+ }
30451
+ responses.push(response);
30296
30452
  }
30297
- responses.push(response);
30298
30453
  }
30299
30454
  validateResult(responses, ['xpub'], {
30300
30455
  expectedLength: this.params.length,
@@ -33163,25 +33318,6 @@ class NearSignTransaction extends BaseMethod {
33163
33318
  }
33164
33319
  }
33165
33320
 
33166
- function batchGetPublickeys(device, paths, ecdsaCurveName, coinType) {
33167
- const existsPathNotValid = paths.find(p => p.address_n.length < 3);
33168
- if (existsPathNotValid) {
33169
- throw hdShared.TypedError(hdShared.HardwareErrorCode.ForbiddenKeyPath, 'Path length must be greater than 3');
33170
- }
33171
- const supportsBatchPublicKey = supportBatchPublicKey(device.features);
33172
- if (!supportsBatchPublicKey) {
33173
- throw hdShared.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportMethod);
33174
- }
33175
- const existsPathNotEqualCoinType = paths.find(p => !isEqualBip44CoinType(p.address_n, coinType));
33176
- if (existsPathNotEqualCoinType) {
33177
- throw hdShared.TypedError(hdShared.HardwareErrorCode.ForbiddenKeyPath);
33178
- }
33179
- return device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
33180
- paths,
33181
- ecdsa_curve_name: ecdsaCurveName,
33182
- });
33183
- }
33184
-
33185
33321
  class AptosGetAddress extends BaseMethod {
33186
33322
  constructor() {
33187
33323
  super(...arguments);
@@ -33335,12 +33471,14 @@ class AptosSignTransaction extends BaseMethod {
33335
33471
  validateParams(this.payload, [
33336
33472
  { name: 'path', required: true },
33337
33473
  { name: 'rawTx', type: 'hexString', required: true },
33474
+ { name: 'transactionType', type: 'number', required: false },
33338
33475
  ]);
33339
- const { path, rawTx } = this.payload;
33476
+ const { path, rawTx, transactionType } = this.payload;
33340
33477
  const addressN = validatePath(path, 3);
33341
33478
  this.params = {
33342
33479
  address_n: addressN,
33343
33480
  raw_tx: formatAnyHex(rawTx),
33481
+ tx_type: transactionType,
33344
33482
  };
33345
33483
  }
33346
33484
  getVersionRange() {
@@ -33350,8 +33488,26 @@ class AptosSignTransaction extends BaseMethod {
33350
33488
  },
33351
33489
  };
33352
33490
  }
33491
+ getWithDataVersionRange() {
33492
+ return {
33493
+ pro: {
33494
+ min: '4.14.0',
33495
+ },
33496
+ model_classic1s: {
33497
+ min: '3.12.0',
33498
+ },
33499
+ classic: {
33500
+ min: '3.10.0',
33501
+ },
33502
+ };
33503
+ }
33504
+ checkWithDataError() {
33505
+ const { transactionType } = this.payload;
33506
+ this.checkFeatureVersionLimit(() => transactionType === 1, () => this.getWithDataVersionRange());
33507
+ }
33353
33508
  run() {
33354
33509
  return __awaiter(this, void 0, void 0, function* () {
33510
+ this.checkWithDataError();
33355
33511
  const res = yield this.device.commands.typedCall('AptosSignTx', 'AptosSignedTx', Object.assign({}, this.params));
33356
33512
  return Promise.resolve(res.message);
33357
33513
  });
@@ -34806,6 +34962,9 @@ class CardanoSignTransaction extends BaseMethod {
34806
34962
  touch: {
34807
34963
  min: '4.10.0',
34808
34964
  },
34965
+ classic: {
34966
+ min: '3.10.0',
34967
+ },
34809
34968
  });
34810
34969
  this.checkSupportConway = () => {
34811
34970
  var _a;
@@ -1,4 +1,4 @@
1
- import { AptosSignedTx as HardwareAptosSignedTx } from '@onekeyfe/hd-transport';
1
+ import { AptosSignedTx as HardwareAptosSignedTx, AptosTransactionType } from '@onekeyfe/hd-transport';
2
2
  import type { CommonParams, Response } from '../params';
3
3
  export type AptosSignedTx = {
4
4
  path: string;
@@ -6,6 +6,7 @@ export type AptosSignedTx = {
6
6
  export type AptosSignTransactionParams = {
7
7
  path: string | number[];
8
8
  rawTx?: string;
9
+ transactionType?: AptosTransactionType;
9
10
  };
10
11
  export declare function aptosSignTransaction(connectId: string, deviceId: string, params: CommonParams & AptosSignTransactionParams): Response<AptosSignedTx>;
11
12
  //# sourceMappingURL=aptosSignTransaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aptosSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/types/api/aptosSignTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,qBAAqB,CAAC;AAE1B,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,0BAA0B,GAChD,QAAQ,CAAC,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"aptosSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/types/api/aptosSignTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,IAAI,qBAAqB,EACtC,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,qBAAqB,CAAC;AAE1B,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,oBAAoB,CAAC;CACxC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,0BAA0B,GAChD,QAAQ,CAAC,aAAa,CAAC,CAAC"}
@@ -10,7 +10,9 @@ export declare const supportInputPinOnSoftware: (features: Features) => SupportF
10
10
  export declare const supportNewPassphrase: (features?: Features) => SupportFeatureType;
11
11
  export declare const getPassphraseStateWithRefreshDeviceInfo: (device: Device) => Promise<string | false>;
12
12
  export declare const getPassphraseState: (features: Features | undefined, commands: DeviceCommands) => Promise<string | false>;
13
- export declare const supportBatchPublicKey: (features?: Features) => boolean;
13
+ export declare const supportBatchPublicKey: (features?: Features, options?: {
14
+ includeNode?: boolean;
15
+ }) => boolean;
14
16
  export declare const supportModifyHomescreen: (features?: Features) => SupportFeatureType;
15
17
  export declare const getFirmwareUpdateField: ({ features, updateType, targetVersion, }: {
16
18
  features: Features;
@@ -1 +1 @@
1
- {"version":3,"file":"deviceFeaturesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE7D,OAAoB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE1F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI1C,eAAO,MAAM,wBAAwB,aACzB,QAAQ,GAAG,SAAS,KAC7B;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,cAAc,CAAA;CAiClD,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,QAAQ,KAAG,kBAU9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAAe,QAAQ,KAAG,kBAW1D,CAAC;AAEF,eAAO,MAAM,uCAAuC,WAAkB,MAAM,4BAqB3E,CAAC;AAEF,eAAO,MAAM,kBAAkB,aACnB,QAAQ,GAAG,SAAS,YACpB,cAAc,4BAgBzB,CAAC;AAEF,eAAO,MAAM,qBAAqB,cAAe,QAAQ,KAAG,OAU3D,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,QAAQ,KAAG,kBAU7D,CAAC;AAKF,eAAO,MAAM,sBAAsB;cAKvB,QAAQ;gBACN,UAAU,GAAG,KAAK;;MAE5B,KAAK,GAAG,cAyBX,CAAC;AAMF,eAAO,MAAM,2BAA2B,aAC5B,QAAQ,cACN,UAAU,GAAG,KAAK,GAAG,YAAY,KAC5C,CAAC,UAAU,GAAG,KAAK,GAAG,aAAa,GAAG,aAAa,CAAC,EAkCtD,CAAC;AAEF,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,UASzC;AAED,eAAO,MAAM,0BAA0B,aAAc,QAAQ,KAAG,QAc/D,CAAC"}
1
+ {"version":3,"file":"deviceFeaturesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE7D,OAAoB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE1F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI1C,eAAO,MAAM,wBAAwB,aACzB,QAAQ,GAAG,SAAS,KAC7B;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,cAAc,CAAA;CAiClD,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,QAAQ,KAAG,kBAU9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAAe,QAAQ,KAAG,kBAW1D,CAAC;AAEF,eAAO,MAAM,uCAAuC,WAAkB,MAAM,4BAqB3E,CAAC;AAEF,eAAO,MAAM,kBAAkB,aACnB,QAAQ,GAAG,SAAS,YACpB,cAAc,4BAgBzB,CAAC;AAEF,eAAO,MAAM,qBAAqB,cACrB,QAAQ,YACT;IACR,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,KACA,OAsBF,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,QAAQ,KAAG,kBAU7D,CAAC;AAKF,eAAO,MAAM,sBAAsB;cAKvB,QAAQ;gBACN,UAAU,GAAG,KAAK;;MAE5B,KAAK,GAAG,cAyBX,CAAC;AAMF,eAAO,MAAM,2BAA2B,aAC5B,QAAQ,cACN,UAAU,GAAG,KAAK,GAAG,YAAY,KAC5C,CAAC,UAAU,GAAG,KAAK,GAAG,aAAa,GAAG,aAAa,CAAC,EAkCtD,CAAC;AAEF,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,UASzC;AAED,eAAO,MAAM,0BAA0B,aAAc,QAAQ,KAAG,QAc/D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.0.26-alpha.0",
3
+ "version": "1.0.26-alpha.1",
4
4
  "description": "> TODO: description",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-shared": "^1.0.26-alpha.0",
29
- "@onekeyfe/hd-transport": "^1.0.26-alpha.0",
28
+ "@onekeyfe/hd-shared": "^1.0.26-alpha.1",
29
+ "@onekeyfe/hd-transport": "^1.0.26-alpha.1",
30
30
  "axios": "^0.27.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -46,5 +46,5 @@
46
46
  "@types/web-bluetooth": "^0.0.21",
47
47
  "ripple-keypairs": "^1.1.4"
48
48
  },
49
- "gitHead": "05cde6f4b6ca9ac3ead441f3956a37b419b50396"
49
+ "gitHead": "941f5592107bb81370bf18c2c8bebe0f88d094bf"
50
50
  }
@@ -1,4 +1,4 @@
1
- import { AptosSignTx as HardwareAptosSignTx } from '@onekeyfe/hd-transport';
1
+ import { AptosTransactionType, AptosSignTx as HardwareAptosSignTx } from '@onekeyfe/hd-transport';
2
2
  import { UI_REQUEST } from '../../constants/ui-request';
3
3
  import { validatePath } from '../helpers/pathUtils';
4
4
  import { BaseMethod } from '../BaseMethod';
@@ -14,9 +14,10 @@ export default class AptosSignTransaction extends BaseMethod<HardwareAptosSignTx
14
14
  validateParams(this.payload, [
15
15
  { name: 'path', required: true },
16
16
  { name: 'rawTx', type: 'hexString', required: true },
17
+ { name: 'transactionType', type: 'number', required: false },
17
18
  ]);
18
19
 
19
- const { path, rawTx } = this.payload;
20
+ const { path, rawTx, transactionType } = this.payload;
20
21
 
21
22
  const addressN = validatePath(path, 3);
22
23
 
@@ -24,6 +25,7 @@ export default class AptosSignTransaction extends BaseMethod<HardwareAptosSignTx
24
25
  this.params = {
25
26
  address_n: addressN,
26
27
  raw_tx: formatAnyHex(rawTx),
28
+ tx_type: transactionType,
27
29
  };
28
30
  }
29
31
 
@@ -35,7 +37,31 @@ export default class AptosSignTransaction extends BaseMethod<HardwareAptosSignTx
35
37
  };
36
38
  }
37
39
 
40
+ getWithDataVersionRange() {
41
+ return {
42
+ pro: {
43
+ min: '4.14.0',
44
+ },
45
+ model_classic1s: {
46
+ min: '3.12.0',
47
+ },
48
+ classic: {
49
+ min: '3.10.0',
50
+ },
51
+ };
52
+ }
53
+
54
+ checkWithDataError() {
55
+ const { transactionType } = this.payload;
56
+ this.checkFeatureVersionLimit(
57
+ () => transactionType === 1,
58
+ () => this.getWithDataVersionRange()
59
+ );
60
+ }
61
+
38
62
  async run() {
63
+ this.checkWithDataError();
64
+
39
65
  const res = await this.device.commands.typedCall('AptosSignTx', 'AptosSignedTx', {
40
66
  ...this.params,
41
67
  });
@@ -1,4 +1,4 @@
1
- import { GetPublicKey } from '@onekeyfe/hd-transport';
1
+ import type { GetPublicKey } from '@onekeyfe/hd-transport';
2
2
  import { UI_REQUEST } from '../../constants/ui-request';
3
3
  import { getScriptType, isTaprootPath, serializedPath, validatePath } from '../helpers/pathUtils';
4
4
  import { BaseMethod } from '../BaseMethod';
@@ -7,6 +7,8 @@ import { BTCGetAddressParams } from '../../types/api/btcGetAddress';
7
7
  import { getCoinInfo } from './helpers/btcParamsUtils';
8
8
  import { BTCPublicKey } from '../../types/api/btcGetPublicKey';
9
9
  import { getBitcoinForkVersionRange } from './helpers/versionLimit';
10
+ import { batchGetPublickeys } from '../helpers/batchGetPublickeys';
11
+ import { createExtendedPublicKey } from './helpers/xpubUtils';
10
12
 
11
13
  export default class BTCGetPublicKey extends BaseMethod<GetPublicKey[]> {
12
14
  hasBundle = false;
@@ -64,31 +66,79 @@ export default class BTCGetPublicKey extends BaseMethod<GetPublicKey[]> {
64
66
  }
65
67
 
66
68
  async run() {
67
- const responses: BTCPublicKey[] = [];
69
+ let responses: BTCPublicKey[] = [];
68
70
 
69
- for (let i = 0; i < this.params.length; i++) {
70
- const param = this.params[i];
71
+ try {
72
+ const existsShowDisplay = this.params.some(param => param.show_display);
73
+ if (existsShowDisplay || !this.hasBundle) {
74
+ throw new Error('Goto getPublickey');
75
+ }
71
76
 
72
- const res = await this.device.commands.typedCall('GetPublicKey', 'PublicKey', {
73
- ...param,
77
+ const res = await batchGetPublickeys(this.device, this.params, 'secp256k1', 0, {
78
+ includeNode: true,
79
+ ignoreCoinType: true,
74
80
  });
75
81
 
76
- const response = {
77
- path: serializedPath(param.address_n),
78
- ...res.message,
79
- xpubSegwit: res.message.xpub,
80
- };
81
-
82
- if (this.isBtcNetwork(param) && isTaprootPath(param.address_n)) {
83
- // wrap regular xpub into bitcoind native descriptor
84
- const fingerprint = Number(response.root_fingerprint || 0)
85
- .toString(16)
86
- .padStart(8, '0');
87
- const descriptorPath = `${fingerprint}${response.path.substring(1)}`;
88
- response.xpubSegwit = `tr([${descriptorPath}]${response.xpub}/<0;1>/*)`;
82
+ if (!res.message?.hd_nodes || this.params.length !== res.message.hd_nodes.length) {
83
+ throw new Error('Invalid response from Publickeys');
89
84
  }
90
85
 
91
- responses.push(response);
86
+ for (let i = 0; i < this.params.length; i++) {
87
+ const param = this.params[i];
88
+ const node = res.message.hd_nodes[i];
89
+
90
+ const path = serializedPath(param.address_n);
91
+
92
+ const xpub = createExtendedPublicKey(node, param.script_type);
93
+
94
+ const rootFingerprint = res.message.root_fingerprint;
95
+
96
+ let xpubSegwit = xpub;
97
+ if (this.isBtcNetwork(param) && isTaprootPath(param.address_n)) {
98
+ // wrap regular xpub into bitcoind native descriptor
99
+ const fingerprint = Number(rootFingerprint || 0)
100
+ .toString(16)
101
+ .padStart(8, '0');
102
+ const descriptorPath = `${fingerprint}${path.substring(1)}`;
103
+ xpubSegwit = `tr([${descriptorPath}]${xpub}/<0;1>/*)`;
104
+ }
105
+
106
+ responses.push({
107
+ path,
108
+ node,
109
+ xpub,
110
+ root_fingerprint: rootFingerprint,
111
+ xpubSegwit,
112
+ });
113
+ }
114
+ } catch (error) {
115
+ // clear responses
116
+ responses = [];
117
+
118
+ for (let i = 0; i < this.params.length; i++) {
119
+ const param = this.params[i];
120
+
121
+ const res = await this.device.commands.typedCall('GetPublicKey', 'PublicKey', {
122
+ ...param,
123
+ });
124
+
125
+ const response = {
126
+ path: serializedPath(param.address_n),
127
+ ...res.message,
128
+ xpubSegwit: res.message.xpub,
129
+ };
130
+
131
+ if (this.isBtcNetwork(param) && isTaprootPath(param.address_n)) {
132
+ // wrap regular xpub into bitcoind native descriptor
133
+ const fingerprint = Number(response.root_fingerprint || 0)
134
+ .toString(16)
135
+ .padStart(8, '0');
136
+ const descriptorPath = `${fingerprint}${response.path.substring(1)}`;
137
+ response.xpubSegwit = `tr([${descriptorPath}]${response.xpub}/<0;1>/*)`;
138
+ }
139
+
140
+ responses.push(response);
141
+ }
92
142
  }
93
143
 
94
144
  validateResult(responses, ['xpub'], {
@@ -0,0 +1,85 @@
1
+ import { sha256 } from '@noble/hashes/sha256';
2
+ import type { HDNodeType, InputScriptType } from '@onekeyfe/hd-transport';
3
+
4
+ // 定义版本字节常量
5
+ const VERSION_BYTES = {
6
+ // xpub - (SPENDADDRESS, SPENDMULTISIG)
7
+ XPUB: 0x0488b21e,
8
+ // ypub - (SPENDP2SHWITNESS)
9
+ YPUB: 0x049d7cb2,
10
+ // zpub - (SPENDWITNESS)
11
+ ZPUB: 0x04b24746,
12
+ };
13
+
14
+ function getVersionBytes(scriptType?: InputScriptType): number {
15
+ switch (scriptType) {
16
+ case 'SPENDADDRESS':
17
+ case 'SPENDMULTISIG':
18
+ return VERSION_BYTES.XPUB;
19
+ case 'SPENDP2SHWITNESS':
20
+ return VERSION_BYTES.YPUB;
21
+ case 'SPENDWITNESS':
22
+ return VERSION_BYTES.ZPUB;
23
+ default:
24
+ return VERSION_BYTES.XPUB;
25
+ }
26
+ }
27
+
28
+ function base58Check(data: Buffer): string {
29
+ const checksum = sha256(sha256(new Uint8Array(data))).slice(0, 4);
30
+ const withChecksum = Buffer.concat([new Uint8Array(data), new Uint8Array(checksum)]);
31
+ const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
32
+
33
+ let result = '';
34
+ let num = BigInt(`0x${withChecksum.toString('hex')}`);
35
+ const base = BigInt(58);
36
+
37
+ while (num > 0) {
38
+ const mod = Number(num % base);
39
+ num /= base;
40
+ result = ALPHABET[mod] + result;
41
+ }
42
+
43
+ // 处理前导零字节
44
+ for (let i = 0; i < withChecksum.length; i++) {
45
+ if (withChecksum[i] === 0) {
46
+ result = `1${result}`;
47
+ } else {
48
+ break;
49
+ }
50
+ }
51
+
52
+ return result;
53
+ }
54
+
55
+ function generateExtendedPublicKey(
56
+ depth: number,
57
+ fingerprint: number,
58
+ childNum: number,
59
+ chainCode: string,
60
+ publicKey: string,
61
+ scriptType?: InputScriptType
62
+ ): string {
63
+ const versionBytes = getVersionBytes(scriptType);
64
+
65
+ const buffer = Buffer.alloc(78);
66
+ buffer.writeUInt32BE(versionBytes, 0);
67
+ buffer.writeUInt8(depth, 4);
68
+ buffer.writeUInt32BE(fingerprint, 5);
69
+ buffer.writeUInt32BE(childNum, 9);
70
+ buffer.write(chainCode, 13, 'hex');
71
+ buffer.write(publicKey, 45, 'hex');
72
+
73
+ return base58Check(buffer);
74
+ }
75
+
76
+ export function createExtendedPublicKey(node: HDNodeType, scriptType?: InputScriptType): string {
77
+ return generateExtendedPublicKey(
78
+ node.depth,
79
+ node.fingerprint,
80
+ node.child_num,
81
+ node.chain_code,
82
+ node.public_key,
83
+ scriptType
84
+ );
85
+ }
@@ -228,6 +228,9 @@ export default class CardanoSignTransaction extends BaseMethod<any> {
228
228
  touch: {
229
229
  min: '4.10.0',
230
230
  },
231
+ classic: {
232
+ min: '3.10.0',
233
+ },
231
234
  });
232
235
 
233
236
  checkSupportConway = () => {
@@ -9,25 +9,30 @@ export function batchGetPublickeys(
9
9
  device: Device,
10
10
  paths: Path[],
11
11
  ecdsaCurveName: string,
12
- coinType: number
12
+ coinType: number,
13
+ options?: {
14
+ includeNode?: boolean;
15
+ ignoreCoinType?: boolean;
16
+ }
13
17
  ) {
14
18
  const existsPathNotValid = paths.find(p => p.address_n.length < 3);
15
19
  if (existsPathNotValid) {
16
20
  throw TypedError(HardwareErrorCode.ForbiddenKeyPath, 'Path length must be greater than 3');
17
21
  }
18
22
 
19
- const supportsBatchPublicKey = supportBatchPublicKey(device.features);
23
+ const supportsBatchPublicKey = supportBatchPublicKey(device.features, options);
20
24
  if (!supportsBatchPublicKey) {
21
25
  throw TypedError(HardwareErrorCode.DeviceNotSupportMethod);
22
26
  }
23
27
 
24
28
  const existsPathNotEqualCoinType = paths.find(p => !isEqualBip44CoinType(p.address_n, coinType));
25
- if (existsPathNotEqualCoinType) {
29
+ if (options?.ignoreCoinType === false && existsPathNotEqualCoinType) {
26
30
  throw TypedError(HardwareErrorCode.ForbiddenKeyPath);
27
31
  }
28
32
 
29
33
  return device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
30
34
  paths,
31
35
  ecdsa_curve_name: ecdsaCurveName,
36
+ include_node: options?.includeNode ?? false,
32
37
  });
33
38
  }
@@ -250,6 +250,21 @@
250
250
  "rule": "required",
251
251
  "type": "bytes",
252
252
  "id": 2
253
+ },
254
+ "tx_type": {
255
+ "type": "AptosTransactionType",
256
+ "id": 3,
257
+ "options": {
258
+ "default": "STANDARD"
259
+ }
260
+ }
261
+ },
262
+ "nested": {
263
+ "AptosTransactionType": {
264
+ "values": {
265
+ "STANDARD": 0,
266
+ "WITH_DATA": 1
267
+ }
253
268
  }
254
269
  }
255
270
  },
@@ -3569,6 +3584,13 @@
3569
3584
  "rule": "repeated",
3570
3585
  "type": "Path",
3571
3586
  "id": 2
3587
+ },
3588
+ "include_node": {
3589
+ "type": "bool",
3590
+ "id": 3,
3591
+ "options": {
3592
+ "default": false
3593
+ }
3572
3594
  }
3573
3595
  },
3574
3596
  "nested": {
@@ -3592,6 +3614,15 @@
3592
3614
  "rule": "repeated",
3593
3615
  "type": "bytes",
3594
3616
  "id": 1
3617
+ },
3618
+ "hd_nodes": {
3619
+ "rule": "repeated",
3620
+ "type": "HDNodeType",
3621
+ "id": 2
3622
+ },
3623
+ "root_fingerprint": {
3624
+ "type": "uint32",
3625
+ "id": 3
3595
3626
  }
3596
3627
  }
3597
3628
  },
@@ -1,4 +1,7 @@
1
- import { AptosSignedTx as HardwareAptosSignedTx } from '@onekeyfe/hd-transport';
1
+ import {
2
+ AptosSignedTx as HardwareAptosSignedTx,
3
+ AptosTransactionType,
4
+ } from '@onekeyfe/hd-transport';
2
5
  import type { CommonParams, Response } from '../params';
3
6
 
4
7
  export type AptosSignedTx = {
@@ -8,6 +11,7 @@ export type AptosSignedTx = {
8
11
  export type AptosSignTransactionParams = {
9
12
  path: string | number[];
10
13
  rawTx?: string;
14
+ transactionType?: AptosTransactionType;
11
15
  };
12
16
 
13
17
  export declare function aptosSignTransaction(
@@ -116,11 +116,28 @@ export const getPassphraseState = async (
116
116
  return message.address;
117
117
  };
118
118
 
119
- export const supportBatchPublicKey = (features?: Features): boolean => {
119
+ export const supportBatchPublicKey = (
120
+ features?: Features,
121
+ options?: {
122
+ includeNode?: boolean;
123
+ }
124
+ ): boolean => {
120
125
  if (!features) return false;
121
126
  const currentVersion = getDeviceFirmwareVersion(features).join('.');
122
127
 
123
128
  const deviceType = getDeviceType(features);
129
+ // btc batch get public key
130
+ if (!!options?.includeNode && deviceType === EDeviceType.Pro) {
131
+ return semver.gte(currentVersion, '4.14.0');
132
+ }
133
+ if (!!options?.includeNode && DeviceModelToTypes.model_classic1s.includes(deviceType)) {
134
+ return semver.gte(currentVersion, '3.12.0');
135
+ }
136
+ if (!!options?.includeNode && deviceType === EDeviceType.Classic) {
137
+ return semver.gte(currentVersion, '3.10.0');
138
+ }
139
+
140
+ // support batch get public key
124
141
  if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
125
142
  return semver.gte(currentVersion, '3.1.0');
126
143
  }