@onekeyfe/hd-core 1.2.8-alpha.13 → 1.2.8-alpha.131

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.
Files changed (125) hide show
  1. package/__tests__/allNetworkGetAddress-privacy-networks.test.ts +78 -0
  2. package/__tests__/core-dispose.test.ts +114 -1
  3. package/__tests__/core-error-output.test.ts +21 -0
  4. package/__tests__/device-connector-protocol.test.ts +5 -2
  5. package/__tests__/device-lifecycle-events.test.ts +118 -3
  6. package/__tests__/firmware-update/firmware-artifact-source.test.ts +11 -0
  7. package/__tests__/logBlockEvent.test.ts +292 -0
  8. package/__tests__/logger.test.ts +18 -0
  9. package/__tests__/monero-get-address.test.ts +147 -0
  10. package/__tests__/monero-key-image-sync.test.ts +272 -0
  11. package/__tests__/monero-sign-transaction.test.ts +436 -0
  12. package/__tests__/protocol-v2-resources.test.ts +14 -0
  13. package/__tests__/protocol-v2.test.ts +845 -3
  14. package/__tests__/protocolV2FileWrite.test.ts +454 -7
  15. package/__tests__/search-devices.test.ts +36 -0
  16. package/__tests__/usb-identity-probe.test.ts +358 -0
  17. package/__tests__/zcash-protobuf.test.ts +141 -0
  18. package/__tests__/zcash-sign-pczt.test.ts +446 -0
  19. package/dist/api/BaseMethod.d.ts.map +1 -1
  20. package/dist/api/FileWrite.d.ts.map +1 -1
  21. package/dist/api/FirmwareUpdateV4.d.ts +5 -0
  22. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  23. package/dist/api/SearchDevices.d.ts +21 -1
  24. package/dist/api/SearchDevices.d.ts.map +1 -1
  25. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  26. package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -1
  27. package/dist/api/helpers/pathUtils.d.ts +1 -0
  28. package/dist/api/helpers/pathUtils.d.ts.map +1 -1
  29. package/dist/api/helpers/protocolV2FileWrite.d.ts +5 -1
  30. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
  31. package/dist/api/index.d.ts +6 -0
  32. package/dist/api/index.d.ts.map +1 -1
  33. package/dist/api/monero/MoneroGetAddress.d.ts +11 -0
  34. package/dist/api/monero/MoneroGetAddress.d.ts.map +1 -0
  35. package/dist/api/monero/MoneroGetWatchKey.d.ts +11 -0
  36. package/dist/api/monero/MoneroGetWatchKey.d.ts.map +1 -0
  37. package/dist/api/monero/MoneroKeyImageSync.d.ts +20 -0
  38. package/dist/api/monero/MoneroKeyImageSync.d.ts.map +1 -0
  39. package/dist/api/monero/MoneroSignTransaction.d.ts +17 -0
  40. package/dist/api/monero/MoneroSignTransaction.d.ts.map +1 -0
  41. package/dist/api/monero/helpers.d.ts +5 -0
  42. package/dist/api/monero/helpers.d.ts.map +1 -0
  43. package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -1
  44. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
  45. package/dist/api/zcash/ZcashGetAddress.d.ts +12 -0
  46. package/dist/api/zcash/ZcashGetAddress.d.ts.map +1 -0
  47. package/dist/api/zcash/ZcashSignPczt.d.ts +16 -0
  48. package/dist/api/zcash/ZcashSignPczt.d.ts.map +1 -0
  49. package/dist/core/index.d.ts +3 -1
  50. package/dist/core/index.d.ts.map +1 -1
  51. package/dist/device/Device.d.ts +1 -0
  52. package/dist/device/Device.d.ts.map +1 -1
  53. package/dist/device/DeviceCommands.d.ts +4 -4
  54. package/dist/events/logBlockEvent.d.ts +10 -0
  55. package/dist/events/logBlockEvent.d.ts.map +1 -1
  56. package/dist/events/ui-request.d.ts +2 -0
  57. package/dist/events/ui-request.d.ts.map +1 -1
  58. package/dist/index.d.ts +183 -7
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +5631 -4192
  61. package/dist/inject.d.ts.map +1 -1
  62. package/dist/protocols/protocol-v2/resources.d.ts +1 -0
  63. package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
  64. package/dist/types/api/allNetworkGetAddress.d.ts +5 -1
  65. package/dist/types/api/allNetworkGetAddress.d.ts.map +1 -1
  66. package/dist/types/api/export.d.ts +6 -0
  67. package/dist/types/api/export.d.ts.map +1 -1
  68. package/dist/types/api/index.d.ts +12 -0
  69. package/dist/types/api/index.d.ts.map +1 -1
  70. package/dist/types/api/moneroGetAddress.d.ts +15 -0
  71. package/dist/types/api/moneroGetAddress.d.ts.map +1 -0
  72. package/dist/types/api/moneroGetWatchKey.d.ts +15 -0
  73. package/dist/types/api/moneroGetWatchKey.d.ts.map +1 -0
  74. package/dist/types/api/moneroKeyImageSync.d.ts +24 -0
  75. package/dist/types/api/moneroKeyImageSync.d.ts.map +1 -0
  76. package/dist/types/api/moneroSignTransaction.d.ts +32 -0
  77. package/dist/types/api/moneroSignTransaction.d.ts.map +1 -0
  78. package/dist/types/api/zcashGetAddress.d.ts +22 -0
  79. package/dist/types/api/zcashGetAddress.d.ts.map +1 -0
  80. package/dist/types/api/zcashSignPczt.d.ts +9 -0
  81. package/dist/types/api/zcashSignPczt.d.ts.map +1 -0
  82. package/dist/types/device.d.ts +10 -0
  83. package/dist/types/device.d.ts.map +1 -1
  84. package/dist/utils/logger.d.ts.map +1 -1
  85. package/dist/utils/patch.d.ts +1 -1
  86. package/dist/utils/patch.d.ts.map +1 -1
  87. package/package.json +4 -4
  88. package/src/api/BaseMethod.ts +2 -0
  89. package/src/api/FileWrite.ts +7 -1
  90. package/src/api/FirmwareUpdateV4.ts +358 -74
  91. package/src/api/SearchDevices.ts +172 -7
  92. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +38 -1
  93. package/src/api/firmware/FirmwareArtifactSource.ts +12 -3
  94. package/src/api/helpers/pathUtils.ts +23 -0
  95. package/src/api/helpers/protocolV2FileWrite.ts +382 -111
  96. package/src/api/index.ts +7 -0
  97. package/src/api/monero/MoneroGetAddress.ts +71 -0
  98. package/src/api/monero/MoneroGetWatchKey.ts +69 -0
  99. package/src/api/monero/MoneroKeyImageSync.ts +164 -0
  100. package/src/api/monero/MoneroSignTransaction.ts +319 -0
  101. package/src/api/monero/helpers.ts +28 -0
  102. package/src/api/protocol-v2/DeviceUploadNft.ts +6 -1
  103. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +15 -1
  104. package/src/api/zcash/ZcashGetAddress.ts +119 -0
  105. package/src/api/zcash/ZcashSignPczt.ts +152 -0
  106. package/src/core/index.ts +49 -17
  107. package/src/data/messages/messages-protocol-v2.json +138 -1
  108. package/src/device/Device.ts +21 -3
  109. package/src/device/DeviceConnector.ts +4 -4
  110. package/src/events/logBlockEvent.ts +55 -3
  111. package/src/events/ui-request.ts +2 -0
  112. package/src/index.ts +1 -0
  113. package/src/inject.ts +13 -0
  114. package/src/protocols/protocol-v2/resources.ts +6 -1
  115. package/src/types/api/allNetworkGetAddress.ts +9 -1
  116. package/src/types/api/export.ts +15 -0
  117. package/src/types/api/index.ts +20 -0
  118. package/src/types/api/moneroGetAddress.ts +27 -0
  119. package/src/types/api/moneroGetWatchKey.ts +28 -0
  120. package/src/types/api/moneroKeyImageSync.ts +45 -0
  121. package/src/types/api/moneroSignTransaction.ts +54 -0
  122. package/src/types/api/zcashGetAddress.ts +35 -0
  123. package/src/types/api/zcashSignPczt.ts +18 -0
  124. package/src/types/device.ts +18 -0
  125. package/src/utils/logger.ts +4 -0
@@ -236,6 +236,9 @@ export class Device extends EventEmitter {
236
236
  */
237
237
  private deviceAcquired = false;
238
238
 
239
+ /** A completed BLE release left the physical link available for the next call. */
240
+ private releasedBleConnection = false;
241
+
239
242
  /**
240
243
  * Connection-attempt generation. interruptionFromUser() pins the current
241
244
  * attempt so a late acquire cannot finish, while the next public connect
@@ -452,6 +455,7 @@ export class Device extends EventEmitter {
452
455
  ) {
453
456
  const attempt = this.connectionAttempt;
454
457
  this.throwIfInterruptedByUser();
458
+ this.releasedBleConnection = false;
455
459
  const env = DataManager.getSettings('env');
456
460
  const mainIdKey = DataManager.isBleConnect(env) ? 'id' : 'session';
457
461
  const previousProtocol = this.originalDescriptor.protocolType;
@@ -562,6 +566,7 @@ export class Device extends EventEmitter {
562
566
  (this.isUsedHere() && !this.keepSession && this.mainId) ||
563
567
  (this.mainId && DataManager.isBleConnect(env))
564
568
  ) {
569
+ this.releasedBleConnection = false;
565
570
  // wait for callback tasks to complete before releasing device
566
571
  if (this.pendingCallbackPromise) {
567
572
  try {
@@ -585,12 +590,24 @@ export class Device extends EventEmitter {
585
590
  }
586
591
  }
587
592
  try {
593
+ const deviceType = this.getCurrentDeviceType();
594
+ const keepBleConnection =
595
+ (env === 'react-native' || env === 'desktop-web-ble') &&
596
+ this.isProtocolV2() &&
597
+ (deviceType === EDeviceType.Pro2 || deviceType === EDeviceType.Neo);
588
598
  // BLE releases even when keepSession is set, so forward the intent.
589
- await this.deviceConnector?.release(this.mainId, false, this.keepSession);
590
- this.updateDescriptor({ session: null } as DeviceDescriptor);
599
+ await this.deviceConnector?.release(
600
+ this.mainId,
601
+ false,
602
+ this.keepSession || keepBleConnection
603
+ );
604
+ this.releasedBleConnection = keepBleConnection;
591
605
  } catch (err) {
592
606
  Log.error('[Device] release error: ', err);
593
607
  } finally {
608
+ // Core no longer owns a logical transport session after release starts,
609
+ // even if native cleanup must be retried by the transport.
610
+ this.updateDescriptor({ session: null } as DeviceDescriptor);
594
611
  this.needReloadDevice = true;
595
612
  }
596
613
  }
@@ -1369,6 +1386,7 @@ export class Device extends EventEmitter {
1369
1386
 
1370
1387
  markTransportDisconnected() {
1371
1388
  this.deviceAcquired = false;
1389
+ this.releasedBleConnection = false;
1372
1390
  this.invalidateProtocolV2RuntimeState();
1373
1391
  }
1374
1392
 
@@ -1631,7 +1649,7 @@ export class Device extends EventEmitter {
1631
1649
  await commands?.cancelDevice?.().catch(cancelError => {
1632
1650
  Log.debug('Protocol V2 fallback cancel error', cancelError);
1633
1651
  });
1634
- } else if (!acquired) {
1652
+ } else if (!acquired && !this.releasedBleConnection) {
1635
1653
  // Abort setup without acquiring a session just to send Cancel.
1636
1654
  if (mainId && deviceConnector?.disconnect) {
1637
1655
  // The connector drops the link silently, so without this line a
@@ -133,10 +133,10 @@ export default class DeviceConnector {
133
133
  : undefined;
134
134
  const detectedProtocol = acquiredProtocol ?? transport.getProtocolType(path);
135
135
  if (detectedProtocol !== expectedProtocol) {
136
- throw ERRORS.TypedError(
137
- HardwareErrorCode.RuntimeError,
138
- `Device protocol mismatch: expected ${expectedProtocol}, detected ${detectedProtocol}`
139
- );
136
+ throw ERRORS.TypedError(HardwareErrorCode.TransportProtocolMismatch, undefined, {
137
+ expectedProtocol,
138
+ detectedProtocol,
139
+ });
140
140
  }
141
141
  }
142
142
  return res;
@@ -8,8 +8,8 @@ export const LogBlockEvent: Set<string> = new Set([
8
8
  UI_RESPONSE.RECEIVE_PASSPHRASE,
9
9
  ]);
10
10
 
11
- // These resource/file APIs did not exist in 1.1.32. Skip the payload so
12
- // the log layer does not copy huge Base64 or binary data.
11
+ // Drop sensitive wallet payloads and large resource data before logger caches
12
+ // or log events can retain them, regardless of whether debug output is enabled.
13
13
  const LogPayloadBlockMethod: Set<string> = new Set([
14
14
  'btcDeriveContextHash',
15
15
  'deviceUploadNft',
@@ -17,6 +17,12 @@ const LogPayloadBlockMethod: Set<string> = new Set([
17
17
  'uploadPortfolio',
18
18
  'fileWrite',
19
19
  'fileRead',
20
+ 'zcashGetAddress',
21
+ 'zcashSignPczt',
22
+ 'moneroGetAddress',
23
+ 'moneroGetWatchKey',
24
+ 'moneroKeyImageSync',
25
+ 'moneroSignTransaction',
20
26
  ]);
21
27
 
22
28
  export function getLogBlockLabel(message: unknown): string | undefined {
@@ -40,11 +46,57 @@ export function getLogBlockLabel(message: unknown): string | undefined {
40
46
  return undefined;
41
47
  }
42
48
 
49
+ // All-network results of these networks carry what their own address methods
50
+ // keep out of logs (viewing keys, private addresses).
51
+ const LogPayloadBlockNetwork: Set<string> = new Set(['zcash', 'xmr']);
52
+
53
+ type AllNetworkLogItem = { network?: string; success?: boolean; payload?: object | string } | null;
54
+
55
+ // A call response lists the results in `payload`; a loop callback carries one
56
+ // result, or all of them when finished, in `payload.data`.
57
+ type AllNetworkLogMessage = {
58
+ payload?: AllNetworkLogItem[] | { data?: AllNetworkLogItem | AllNetworkLogItem[] };
59
+ };
60
+
61
+ function redactAllNetworkItem(item: AllNetworkLogItem): AllNetworkLogItem {
62
+ if (!item || item.success === false || item.payload === undefined) return item;
63
+ return item.network && LogPayloadBlockNetwork.has(item.network)
64
+ ? { ...item, payload: '[REDACTED]' }
65
+ : item;
66
+ }
67
+
68
+ function redactAllNetworkItems(items: AllNetworkLogItem[]) {
69
+ const redacted = items.map(redactAllNetworkItem);
70
+ return redacted.some((item, index) => item !== items[index]) ? redacted : items;
71
+ }
72
+
73
+ // Returns `message` itself when nothing needs redacting.
74
+ function redactAllNetworkResults(message: AllNetworkLogMessage): AllNetworkLogMessage {
75
+ const { payload } = message;
76
+ if (Array.isArray(payload)) {
77
+ const items = redactAllNetworkItems(payload);
78
+ return items === payload ? message : { ...message, payload: items };
79
+ }
80
+ const data = payload?.data;
81
+ if (!data) return message;
82
+ const redacted = Array.isArray(data) ? redactAllNetworkItems(data) : redactAllNetworkItem(data);
83
+ return redacted === data ? message : { ...message, payload: { ...payload, data: redacted } };
84
+ }
85
+
43
86
  export function getSafeLogPayload(value: unknown, blockLabel?: string): unknown {
44
87
  if (blockLabel) {
45
88
  return { method: blockLabel, payload: '[REDACTED]' };
46
89
  }
47
- return value;
90
+ if (!value || typeof value !== 'object') return value;
91
+ return redactAllNetworkResults(value as AllNetworkLogMessage);
92
+ }
93
+
94
+ // A queued task holds its method's raw payload; redact it like the call.
95
+ export function getSafeLogTask<T extends { id?: number; method?: { payload?: unknown } }>(
96
+ task: T | undefined
97
+ ): T | { id?: number; method: string; payload: string } | undefined {
98
+ const blockLabel = getLogBlockLabel(task?.method?.payload);
99
+ return blockLabel ? { id: task?.id, method: blockLabel, payload: '[REDACTED]' } : task;
48
100
  }
49
101
 
50
102
  export function formatLogMethodLabel(label: string, methodName?: string): string {
@@ -211,6 +211,7 @@ export interface DeviceProgress {
211
211
  totalBytes?: number;
212
212
  rateBytesPerSecond?: number;
213
213
  elapsedMs?: number;
214
+ retryCount?: number;
214
215
  };
215
216
  }
216
217
 
@@ -218,6 +219,7 @@ export interface PreviousAddressResult {
218
219
  type: typeof UI_REQUEST.PREVIOUS_ADDRESS_RESULT;
219
220
  payload: {
220
221
  device: Device;
222
+ method: string;
221
223
  data: {
222
224
  address?: string;
223
225
  path?: string;
package/src/index.ts CHANGED
@@ -21,6 +21,7 @@ export { executeCallback, cleanupCallback };
21
21
  export { preloadSessionCache } from './device/Device';
22
22
  export { projectFeatures as projectDeviceStateFeatures } from './device/DeviceStateProjector';
23
23
  export { getMethodSupportedProtocols } from './api/utils';
24
+ export { probeUsbDeviceIdentitiesWithTransport } from './api/SearchDevices';
24
25
  export {
25
26
  getFirmwareUpdateHostBindingGeneration,
26
27
  registerFirmwareUpdateHostBinding,
package/src/inject.ts CHANGED
@@ -504,4 +504,17 @@ export const createCoreApi = (
504
504
  call({ ...params, connectId, deviceId, method: 'neoGetAddress' }),
505
505
  neoSignTransaction: (connectId, deviceId, params) =>
506
506
  call({ ...params, connectId, deviceId, method: 'neoSignTransaction' }),
507
+ zcashGetAddress: (connectId, deviceId, params) =>
508
+ call({ ...params, connectId, deviceId, method: 'zcashGetAddress' }),
509
+ zcashSignPczt: (connectId, deviceId, params) =>
510
+ call({ ...params, connectId, deviceId, method: 'zcashSignPczt' }),
511
+
512
+ moneroGetAddress: (connectId, deviceId, params) =>
513
+ call({ ...params, connectId, deviceId, method: 'moneroGetAddress' }),
514
+ moneroGetWatchKey: (connectId, deviceId, params) =>
515
+ call({ ...params, connectId, deviceId, method: 'moneroGetWatchKey' }),
516
+ moneroKeyImageSync: (connectId, deviceId, params) =>
517
+ call({ ...params, connectId, deviceId, method: 'moneroKeyImageSync' }),
518
+ moneroSignTransaction: (connectId, deviceId, params) =>
519
+ call({ ...params, connectId, deviceId, method: 'moneroSignTransaction' }),
507
520
  });
@@ -7,6 +7,8 @@ export const PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_PATH =
7
7
  export const PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH = `${PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_PATH}.staging`;
8
8
  export const PROTOCOL_V2_ROM_PARAMS_PACKAGE_PATH = 'vol0:/loaders/rom/params.okpkg';
9
9
  export const PROTOCOL_V2_RESOURCE_PACKAGE_HEADER_SIZE = 0x5f90;
10
+ // Installed-package comparison only needs the prefix through the header hash.
11
+ export const PROTOCOL_V2_RESOURCE_PACKAGE_COMPARE_SIZE = 0x280;
10
12
 
11
13
  const PROTOCOL_V2_RESOURCE_PACKAGE_HEADER_VERSION = 1;
12
14
  const PROTOCOL_V2_RESOURCE_PACKAGE_FLEXIBLE_OFFSET = 0x6c;
@@ -123,7 +125,7 @@ export function parseProtocolV2ResourcePackageHeader(
123
125
  bytes: Uint8Array,
124
126
  packageSize: number
125
127
  ): ProtocolV2ResourcePackageHeader {
126
- if (bytes.byteLength < PROTOCOL_V2_RESOURCE_PACKAGE_HEADER_SIZE) {
128
+ if (bytes.byteLength < PROTOCOL_V2_RESOURCE_PACKAGE_COMPARE_SIZE) {
127
129
  throw new Error('Pro2 RESOURCE package is shorter than its header');
128
130
  }
129
131
  const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
@@ -169,5 +171,8 @@ export function parseProtocolV2ResourcePackage(
169
171
  binary: ArrayBuffer | Uint8Array
170
172
  ): ProtocolV2ResourcePackageHeader {
171
173
  const bytes = binary instanceof Uint8Array ? binary : new Uint8Array(binary);
174
+ if (bytes.byteLength < PROTOCOL_V2_RESOURCE_PACKAGE_HEADER_SIZE) {
175
+ throw new Error('Pro2 RESOURCE package is shorter than its header');
176
+ }
172
177
  return parseProtocolV2ResourcePackageHeader(bytes, bytes.byteLength);
173
178
  }
@@ -34,7 +34,9 @@ export type INetwork =
34
34
  | 'nostr'
35
35
  | 'benfen'
36
36
  | 'neo'
37
- | 'stellar';
37
+ | 'stellar'
38
+ | 'xmr'
39
+ | 'zcash';
38
40
 
39
41
  export type CommonResponseParams = {
40
42
  path: string;
@@ -66,6 +68,12 @@ type AllNetworkAddressPayload =
66
68
  // Nostr public key (bech32)
67
69
  npub?: string;
68
70
  }
71
+ | {
72
+ // Zcash
73
+ address: string;
74
+ ufvk?: string;
75
+ seedFingerprint?: string;
76
+ }
69
77
  | {
70
78
  // Cardano
71
79
  addressParameters: CardanoAddressParameters;
@@ -227,3 +227,18 @@ export type { BenfenAddress, BenfenGetAddressParams } from './benfenGetAddress';
227
227
  export type { BenfenPublicKey, BenfenGetPublicKeyParams } from './benfenGetPublicKey';
228
228
  export type { BenfenSignMessageParams } from './benfenSignMessage';
229
229
  export type { BenfenSignedTx, BenfenSignTransactionParams } from './benfenSignTransaction';
230
+ export type { ZcashAddress, ZcashGetAddressParams } from './zcashGetAddress';
231
+ export type { ZcashSignedPczt, ZcashSignPcztParams } from './zcashSignPczt';
232
+
233
+ export type { MoneroAddress, MoneroGetAddressParams } from './moneroGetAddress';
234
+ export type { MoneroGetWatchKeyParams, MoneroWatchKey } from './moneroGetWatchKey';
235
+ export type {
236
+ MoneroEncryptedKeyImage,
237
+ MoneroKeyImageSyncParams,
238
+ MoneroKeyImageSyncResult,
239
+ MoneroKeyImageTransfer,
240
+ } from './moneroKeyImageSync';
241
+ export type {
242
+ MoneroSignTransactionParams,
243
+ MoneroSignTransactionResult,
244
+ } from './moneroSignTransaction';
@@ -154,6 +154,12 @@ import type { benfenSignTransaction } from './benfenSignTransaction';
154
154
  import type { benfenSignMessage } from './benfenSignMessage';
155
155
  import type { neoGetAddress } from './neoGetAddress';
156
156
  import type { neoSignTransaction } from './neoSignTransaction';
157
+ import type { zcashGetAddress } from './zcashGetAddress';
158
+ import type { zcashSignPczt } from './zcashSignPczt';
159
+ import type { moneroGetAddress } from './moneroGetAddress';
160
+ import type { moneroGetWatchKey } from './moneroGetWatchKey';
161
+ import type { moneroKeyImageSync } from './moneroKeyImageSync';
162
+ import type { moneroSignTransaction } from './moneroSignTransaction';
157
163
  import type { ConnectSettings } from '../settings';
158
164
  import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
159
165
 
@@ -472,4 +478,18 @@ export type CoreApi = {
472
478
  */
473
479
  neoGetAddress: typeof neoGetAddress;
474
480
  neoSignTransaction: typeof neoSignTransaction;
481
+
482
+ /**
483
+ * Zcash
484
+ */
485
+ zcashGetAddress: typeof zcashGetAddress;
486
+ zcashSignPczt: typeof zcashSignPczt;
487
+
488
+ /**
489
+ * Monero
490
+ */
491
+ moneroGetAddress: typeof moneroGetAddress;
492
+ moneroGetWatchKey: typeof moneroGetWatchKey;
493
+ moneroKeyImageSync: typeof moneroKeyImageSync;
494
+ moneroSignTransaction: typeof moneroSignTransaction;
475
495
  };
@@ -0,0 +1,27 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export type MoneroAddress = {
4
+ path: string;
5
+ // Primary address of the account, base58
6
+ address: string;
7
+ };
8
+
9
+ export type MoneroGetAddressParams = {
10
+ // Account path, m/44'/128'/account'
11
+ path: string | number[];
12
+ showOnOneKey?: boolean;
13
+ // 0 mainnet, 1 testnet, 2 stagenet
14
+ networkType?: number;
15
+ };
16
+
17
+ export declare function moneroGetAddress(
18
+ connectId: string,
19
+ deviceId: string,
20
+ params: CommonParams & MoneroGetAddressParams
21
+ ): Response<MoneroAddress>;
22
+
23
+ export declare function moneroGetAddress(
24
+ connectId: string,
25
+ deviceId: string,
26
+ params: CommonParams & { bundle?: MoneroGetAddressParams[] }
27
+ ): Response<Array<MoneroAddress>>;
@@ -0,0 +1,28 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export type MoneroWatchKey = {
4
+ path: string;
5
+ // Private view key, hex
6
+ watchKey: string;
7
+ // Primary address of the account, base58
8
+ address: string;
9
+ };
10
+
11
+ export type MoneroGetWatchKeyParams = {
12
+ // Account path, m/44'/128'/account'
13
+ path: string | number[];
14
+ // 0 mainnet, 1 testnet, 2 stagenet
15
+ networkType?: number;
16
+ };
17
+
18
+ export declare function moneroGetWatchKey(
19
+ connectId: string,
20
+ deviceId: string,
21
+ params: CommonParams & MoneroGetWatchKeyParams
22
+ ): Response<MoneroWatchKey>;
23
+
24
+ export declare function moneroGetWatchKey(
25
+ connectId: string,
26
+ deviceId: string,
27
+ params: CommonParams & { bundle?: MoneroGetWatchKeyParams[] }
28
+ ): Response<Array<MoneroWatchKey>>;
@@ -0,0 +1,45 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ // One owned output, as wallet2 describes it to the device. Keys are 32-byte hex.
4
+ export type MoneroKeyImageTransfer = {
5
+ // Output public key
6
+ outKey: string;
7
+ // Transaction public key R
8
+ txPubKey: string;
9
+ // Additional tx public keys: the one for this output, or the whole list
10
+ additionalTxPubKeys?: string[];
11
+ // Index of the output within its transaction
12
+ internalOutputIndex: number;
13
+ // Receiving subaddress index; omitted means 0 (primary address)
14
+ subAddrMajor?: number;
15
+ subAddrMinor?: number;
16
+ };
17
+
18
+ // ChaCha20-Poly1305 under encKey, hex.
19
+ export type MoneroEncryptedKeyImage = {
20
+ // 12-byte nonce
21
+ iv: string;
22
+ // Ciphertext of key image || signature c || signature r, then the 16-byte tag
23
+ blob: string;
24
+ };
25
+
26
+ export type MoneroKeyImageSyncResult = {
27
+ // Key that decrypts every blob, hex
28
+ encKey: string;
29
+ // One entry per transfer, in request order
30
+ keyImages: MoneroEncryptedKeyImage[];
31
+ };
32
+
33
+ export type MoneroKeyImageSyncParams = {
34
+ // Account path, m/44'/128'/account'
35
+ path: string | number[];
36
+ // 0 mainnet, 1 testnet, 2 stagenet
37
+ networkType?: number;
38
+ transfers: MoneroKeyImageTransfer[];
39
+ };
40
+
41
+ export declare function moneroKeyImageSync(
42
+ connectId: string,
43
+ deviceId: string,
44
+ params: CommonParams & MoneroKeyImageSyncParams
45
+ ): Response<MoneroKeyImageSyncResult>;
@@ -0,0 +1,54 @@
1
+ import type { MoneroTransactionData, MoneroTransactionSourceEntry } from '@onekeyfe/hd-transport';
2
+ import type { CommonParams, Response } from '../params';
3
+
4
+ export type MoneroSignTransactionParams = {
5
+ // Account path, m/44'/128'/account'
6
+ path: string | number[];
7
+ // 0 mainnet, 1 testnet, 2 stagenet
8
+ networkType?: number;
9
+ // Init data in protobuf field names; outputs include the change, in final order
10
+ tsxData: MoneroTransactionData;
11
+ // One source entry per input, in original order, each with its full ring
12
+ inputs: MoneroTransactionSourceEntry[];
13
+ };
14
+
15
+ // Raw device output, hex unless noted. The host assembles the transaction.
16
+ export type MoneroSignTransactionResult = {
17
+ // Original input index of each sorted input
18
+ origIndices: number[];
19
+ // Serialized tx.vin entries, sorted by key image (descending)
20
+ vinis: string[];
21
+ // Pseudo-output commitments from SignInputAck, sorted order
22
+ pseudoOuts: string[];
23
+ // Sealed CLSAG signatures, sorted order; openingKey unseals them
24
+ signatures: string[];
25
+ // Serialized tx.vout entries, output order
26
+ txOuts: string[];
27
+ // Output key and commitment (64 bytes each), output order
28
+ outPks: string[];
29
+ // Encrypted 8-byte amounts, output order
30
+ ecdhInfos: string[];
31
+ // Aggregated Bulletproof+ without V
32
+ rsig: string;
33
+ extra: string;
34
+ txPrefixHash: string;
35
+ fullMessageHash: string;
36
+ rv: {
37
+ // Decimal piconero
38
+ txnFee: string;
39
+ message: string;
40
+ rvType: number;
41
+ };
42
+ openingKey: string;
43
+ // Tx private keys sealed by the device for later proofs (MoneroGetTxKeyRequest), with the
44
+ // salts that rederive the sealing key; wallet2 keeps them as salt1, salt2, enc_keys
45
+ salt: string;
46
+ randMult: string;
47
+ txEncKeys: string;
48
+ };
49
+
50
+ export declare function moneroSignTransaction(
51
+ connectId: string,
52
+ deviceId: string,
53
+ params: CommonParams & MoneroSignTransactionParams
54
+ ): Response<MoneroSignTransactionResult>;
@@ -0,0 +1,35 @@
1
+ import type { ZcashAddressScope, ZcashAddressType } from '@onekeyfe/hd-transport';
2
+ import type { CommonParams, Response } from '../params';
3
+
4
+ export type ZcashAddress = {
5
+ path: string;
6
+ // ZIP-316 unified address or transparent P2PKH address
7
+ address: string;
8
+ // ZIP-316 unified full viewing key, present when includeUfvk was requested
9
+ ufvk?: string;
10
+ // ZIP-32 seed fingerprint (hex), present when includeSeedFingerprint was requested
11
+ seedFingerprint?: string;
12
+ };
13
+
14
+ export type ZcashGetAddressParams = {
15
+ // ZIP-32 account path, m/32'/133'/account'
16
+ path: string | number[];
17
+ showOnOneKey?: boolean;
18
+ diversifierIndex?: number;
19
+ addressType?: ZcashAddressType;
20
+ scope?: ZcashAddressScope;
21
+ includeUfvk?: boolean;
22
+ includeSeedFingerprint?: boolean;
23
+ };
24
+
25
+ export declare function zcashGetAddress(
26
+ connectId: string,
27
+ deviceId: string,
28
+ params: CommonParams & ZcashGetAddressParams
29
+ ): Response<ZcashAddress>;
30
+
31
+ export declare function zcashGetAddress(
32
+ connectId: string,
33
+ deviceId: string,
34
+ params: CommonParams & { bundle?: ZcashGetAddressParams[] }
35
+ ): Response<Array<ZcashAddress>>;
@@ -0,0 +1,18 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export type ZcashSignPcztParams = {
4
+ // Unproved PCZT (v2, tx v6) as hex; the device signs it and returns a
5
+ // redacted copy with signatures filled in.
6
+ pczt: string;
7
+ };
8
+
9
+ export type ZcashSignedPczt = {
10
+ // Signed, redacted PCZT as hex
11
+ pczt: string;
12
+ };
13
+
14
+ export declare function zcashSignPczt(
15
+ connectId: string,
16
+ deviceId: string,
17
+ params: CommonParams & ZcashSignPcztParams
18
+ ): Response<ZcashSignedPczt>;
@@ -83,6 +83,24 @@ export type SearchDevice = {
83
83
  deviceType: IDeviceType;
84
84
  name: string;
85
85
  commType: OneKeyDeviceCommType;
86
+ /**
87
+ * React Native and Electron BLE discovery only. Serial-number color letter ('A'-'Z')
88
+ * advertised by Pro2 / Neo, possibly remembered from an earlier advertisement in this
89
+ * process. Absent when unknown; the letter's meaning depends on deviceType.
90
+ */
91
+ bleColorCode?: string;
92
+ };
93
+
94
+ /** Identity confirmed over USB. The descriptor path is only a transport address. */
95
+ export type UsbDeviceIdentity = {
96
+ path: string;
97
+ serialNo: string | null;
98
+ deviceId: string | null;
99
+ deviceType: IDeviceType;
100
+ connectProtocol: HardwareConnectProtocol;
101
+ commType: 'webusb' | 'bridge';
102
+ /** Mode confirmed by the device response; absent when discovery cannot establish it. */
103
+ mode?: DeviceStateMode;
86
104
  };
87
105
 
88
106
  // export type UnknownDevice = {
@@ -78,6 +78,10 @@ class Log {
78
78
  const _logs: { [k: string]: Log } = {};
79
79
 
80
80
  export const initLog = (prefix: string, enabled?: boolean) => {
81
+ // Loggers that share a prefix must share one instance; otherwise enableLog only reaches the
82
+ // last one registered and the others never print.
83
+ const existing = _logs[prefix];
84
+ if (existing) return existing;
81
85
  const instance = new Log(prefix, !!enabled);
82
86
  _logs[prefix] = instance;
83
87
  return instance;