@onekeyfe/hd-core 1.2.8-alpha.1 → 1.2.8-alpha.100
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/README.md +27 -0
- package/__tests__/DeviceCommands.test.ts +66 -13
- package/__tests__/btc-derive-context-hash.test.ts +200 -0
- package/__tests__/core-error-output.test.ts +34 -3
- package/__tests__/device-lifecycle-events.test.ts +73 -24
- package/__tests__/device-pool-state.test.ts +50 -0
- package/__tests__/logBlockEvent.test.ts +43 -0
- package/__tests__/protocol-v2-bootloader-mode.test.ts +43 -2
- package/__tests__/protocol-v2.test.ts +0 -47
- package/__tests__/refresh-device-state.test.ts +19 -17
- package/__tests__/sol-sign-offchain-message.test.ts +0 -8
- package/__tests__/zcash-sign-pczt.test.ts +212 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts.map +1 -1
- package/dist/api/btc/BTCDeriveContextHash.d.ts +16 -0
- package/dist/api/btc/BTCDeriveContextHash.d.ts.map +1 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/api/zcash/ZcashGetAddress.d.ts +12 -0
- package/dist/api/zcash/ZcashGetAddress.d.ts.map +1 -0
- package/dist/api/zcash/ZcashSignPczt.d.ts +17 -0
- package/dist/api/zcash/ZcashSignPczt.d.ts.map +1 -0
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +2 -0
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/index.d.ts +51 -5
- package/dist/index.js +488 -30
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/btcDeriveContextHash.d.ts +10 -0
- package/dist/types/api/btcDeriveContextHash.d.ts.map +1 -0
- package/dist/types/api/export.d.ts +3 -0
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +6 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/zcashGetAddress.d.ts +22 -0
- package/dist/types/api/zcashGetAddress.d.ts.map +1 -0
- package/dist/types/api/zcashSignPczt.d.ts +9 -0
- package/dist/types/api/zcashSignPczt.d.ts.map +1 -0
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +8 -25
- package/src/api/GetDeviceState.ts +2 -5
- package/src/api/btc/BTCDeriveContextHash.ts +90 -0
- package/src/api/index.ts +3 -0
- package/src/api/protocol-v2/DeviceReboot.ts +2 -0
- package/src/api/zcash/ZcashGetAddress.ts +121 -0
- package/src/api/zcash/ZcashSignPczt.ts +153 -0
- package/src/core/index.ts +3 -7
- package/src/data/messages/messages-protocol-v2.json +138 -1
- package/src/data/messages/messages.json +51 -0
- package/src/device/Device.ts +11 -1
- package/src/device/DeviceCommands.ts +15 -1
- package/src/device/DevicePool.ts +12 -2
- package/src/events/core.ts +2 -2
- package/src/events/logBlockEvent.ts +6 -2
- package/src/inject.ts +6 -0
- package/src/types/api/btcDeriveContextHash.ts +15 -0
- package/src/types/api/export.ts +3 -0
- package/src/types/api/index.ts +10 -0
- package/src/types/api/zcashGetAddress.ts +36 -0
- package/src/types/api/zcashSignPczt.ts +18 -0
- package/src/types/params.ts +1 -1
|
@@ -11034,6 +11034,61 @@
|
|
|
11034
11034
|
}
|
|
11035
11035
|
}
|
|
11036
11036
|
},
|
|
11037
|
+
"ZcashSignPczt": {
|
|
11038
|
+
"fields": {
|
|
11039
|
+
"pczt_length": {
|
|
11040
|
+
"rule": "required",
|
|
11041
|
+
"type": "uint32",
|
|
11042
|
+
"id": 1
|
|
11043
|
+
},
|
|
11044
|
+
"pczt_initial_chunk": {
|
|
11045
|
+
"rule": "required",
|
|
11046
|
+
"type": "bytes",
|
|
11047
|
+
"id": 2
|
|
11048
|
+
}
|
|
11049
|
+
}
|
|
11050
|
+
},
|
|
11051
|
+
"ZcashPcztChunkRequest": {
|
|
11052
|
+
"fields": {
|
|
11053
|
+
"chunk_length": {
|
|
11054
|
+
"rule": "required",
|
|
11055
|
+
"type": "uint32",
|
|
11056
|
+
"id": 1
|
|
11057
|
+
}
|
|
11058
|
+
}
|
|
11059
|
+
},
|
|
11060
|
+
"ZcashPcztChunkAck": {
|
|
11061
|
+
"fields": {
|
|
11062
|
+
"data_chunk": {
|
|
11063
|
+
"rule": "required",
|
|
11064
|
+
"type": "bytes",
|
|
11065
|
+
"id": 1
|
|
11066
|
+
}
|
|
11067
|
+
}
|
|
11068
|
+
},
|
|
11069
|
+
"ZcashSignedPczt": {
|
|
11070
|
+
"fields": {
|
|
11071
|
+
"pczt_length": {
|
|
11072
|
+
"rule": "required",
|
|
11073
|
+
"type": "uint32",
|
|
11074
|
+
"id": 1
|
|
11075
|
+
},
|
|
11076
|
+
"pczt_initial_chunk": {
|
|
11077
|
+
"rule": "required",
|
|
11078
|
+
"type": "bytes",
|
|
11079
|
+
"id": 2
|
|
11080
|
+
}
|
|
11081
|
+
}
|
|
11082
|
+
},
|
|
11083
|
+
"ZcashSignedPcztChunkRequest": {
|
|
11084
|
+
"fields": {
|
|
11085
|
+
"chunk_length": {
|
|
11086
|
+
"rule": "required",
|
|
11087
|
+
"type": "uint32",
|
|
11088
|
+
"id": 1
|
|
11089
|
+
}
|
|
11090
|
+
}
|
|
11091
|
+
},
|
|
11037
11092
|
"wire_in": {
|
|
11038
11093
|
"type": "bool",
|
|
11039
11094
|
"id": 50002,
|
|
@@ -11459,6 +11514,11 @@
|
|
|
11459
11514
|
"MessageType_NeoAddress": 12302,
|
|
11460
11515
|
"MessageType_NeoSignTx": 12303,
|
|
11461
11516
|
"MessageType_NeoSignedTx": 12304,
|
|
11517
|
+
"MessageType_ZcashSignPczt": 12402,
|
|
11518
|
+
"MessageType_ZcashSignedPczt": 12403,
|
|
11519
|
+
"MessageType_ZcashPcztChunkRequest": 12404,
|
|
11520
|
+
"MessageType_ZcashPcztChunkAck": 12405,
|
|
11521
|
+
"MessageType_ZcashSignedPcztChunkRequest": 12406,
|
|
11462
11522
|
"MessageType_DeviceFactoryInfoSet": 60000,
|
|
11463
11523
|
"MessageType_DeviceFactoryInfoGet": 60001,
|
|
11464
11524
|
"MessageType_DeviceFactoryInfo": 60002,
|
|
@@ -11511,7 +11571,9 @@
|
|
|
11511
11571
|
"MessageType_PortfolioUpdate": 61400,
|
|
11512
11572
|
"MessageType_NftUpdate": 61500,
|
|
11513
11573
|
"MessageType_OnboardingStatusGet": 61600,
|
|
11514
|
-
"MessageType_OnboardingStatus": 61601
|
|
11574
|
+
"MessageType_OnboardingStatus": 61601,
|
|
11575
|
+
"MessageType_ZcashGetAddress": 12400,
|
|
11576
|
+
"MessageType_ZcashAddress": 12401
|
|
11515
11577
|
},
|
|
11516
11578
|
"reserved": [
|
|
11517
11579
|
[90, 92],
|
|
@@ -13730,6 +13792,81 @@
|
|
|
13730
13792
|
}
|
|
13731
13793
|
}
|
|
13732
13794
|
}
|
|
13795
|
+
},
|
|
13796
|
+
"ZcashAddressType": {
|
|
13797
|
+
"values": {
|
|
13798
|
+
"UNIFIED_ORCHARD_P2PKH": 0,
|
|
13799
|
+
"TRANSPARENT_P2PKH": 1,
|
|
13800
|
+
"UNIFIED_ORCHARD": 2
|
|
13801
|
+
}
|
|
13802
|
+
},
|
|
13803
|
+
"ZcashAddressScope": {
|
|
13804
|
+
"values": {
|
|
13805
|
+
"EXTERNAL": 0,
|
|
13806
|
+
"INTERNAL": 1
|
|
13807
|
+
}
|
|
13808
|
+
},
|
|
13809
|
+
"ZcashGetAddress": {
|
|
13810
|
+
"fields": {
|
|
13811
|
+
"address_n": {
|
|
13812
|
+
"rule": "repeated",
|
|
13813
|
+
"type": "uint32",
|
|
13814
|
+
"id": 1,
|
|
13815
|
+
"options": {
|
|
13816
|
+
"packed": false
|
|
13817
|
+
}
|
|
13818
|
+
},
|
|
13819
|
+
"show_display": {
|
|
13820
|
+
"type": "bool",
|
|
13821
|
+
"id": 2
|
|
13822
|
+
},
|
|
13823
|
+
"include_seed_fingerprint": {
|
|
13824
|
+
"type": "bool",
|
|
13825
|
+
"id": 3
|
|
13826
|
+
},
|
|
13827
|
+
"include_ufvk": {
|
|
13828
|
+
"type": "bool",
|
|
13829
|
+
"id": 4
|
|
13830
|
+
},
|
|
13831
|
+
"diversifier_index": {
|
|
13832
|
+
"type": "uint32",
|
|
13833
|
+
"id": 5,
|
|
13834
|
+
"options": {
|
|
13835
|
+
"default": 0
|
|
13836
|
+
}
|
|
13837
|
+
},
|
|
13838
|
+
"address_type": {
|
|
13839
|
+
"type": "ZcashAddressType",
|
|
13840
|
+
"id": 6,
|
|
13841
|
+
"options": {
|
|
13842
|
+
"default": "UNIFIED_ORCHARD_P2PKH"
|
|
13843
|
+
}
|
|
13844
|
+
},
|
|
13845
|
+
"scope": {
|
|
13846
|
+
"type": "ZcashAddressScope",
|
|
13847
|
+
"id": 7,
|
|
13848
|
+
"options": {
|
|
13849
|
+
"default": "EXTERNAL"
|
|
13850
|
+
}
|
|
13851
|
+
}
|
|
13852
|
+
}
|
|
13853
|
+
},
|
|
13854
|
+
"ZcashAddress": {
|
|
13855
|
+
"fields": {
|
|
13856
|
+
"address": {
|
|
13857
|
+
"rule": "required",
|
|
13858
|
+
"type": "string",
|
|
13859
|
+
"id": 1
|
|
13860
|
+
},
|
|
13861
|
+
"ufvk": {
|
|
13862
|
+
"type": "string",
|
|
13863
|
+
"id": 2
|
|
13864
|
+
},
|
|
13865
|
+
"seed_fingerprint": {
|
|
13866
|
+
"type": "bytes",
|
|
13867
|
+
"id": 3
|
|
13868
|
+
}
|
|
13869
|
+
}
|
|
13733
13870
|
}
|
|
13734
13871
|
}
|
|
13735
13872
|
}
|
|
@@ -12485,6 +12485,8 @@
|
|
|
12485
12485
|
"(has_bitcoin_only_values)": true
|
|
12486
12486
|
},
|
|
12487
12487
|
"values": {
|
|
12488
|
+
"MessageType_BabylonDeriveContextHash": 10054,
|
|
12489
|
+
"MessageType_BabylonDerivedContextHash": 10055,
|
|
12488
12490
|
"MessageType_Initialize": 0,
|
|
12489
12491
|
"MessageType_Ping": 1,
|
|
12490
12492
|
"MessageType_Success": 2,
|
|
@@ -12949,6 +12951,55 @@
|
|
|
12949
12951
|
"MessageType_UpgradeFileHeader": 10050
|
|
12950
12952
|
}
|
|
12951
12953
|
},
|
|
12954
|
+
"CanonicalBitcoinNetwork": {
|
|
12955
|
+
"values": {
|
|
12956
|
+
"BITCOIN_MAINNET": 0,
|
|
12957
|
+
"BITCOIN_TESTNET": 1,
|
|
12958
|
+
"BITCOIN_SIGNET": 2,
|
|
12959
|
+
"BITCOIN_REGTEST": 3
|
|
12960
|
+
}
|
|
12961
|
+
},
|
|
12962
|
+
"BabylonDeriveContextHash": {
|
|
12963
|
+
"fields": {
|
|
12964
|
+
"address_n": {
|
|
12965
|
+
"rule": "repeated",
|
|
12966
|
+
"type": "uint32",
|
|
12967
|
+
"id": 1,
|
|
12968
|
+
"options": {
|
|
12969
|
+
"packed": false
|
|
12970
|
+
}
|
|
12971
|
+
},
|
|
12972
|
+
"script_type": {
|
|
12973
|
+
"rule": "required",
|
|
12974
|
+
"type": "InputScriptType",
|
|
12975
|
+
"id": 2
|
|
12976
|
+
},
|
|
12977
|
+
"app_name": {
|
|
12978
|
+
"rule": "required",
|
|
12979
|
+
"type": "bytes",
|
|
12980
|
+
"id": 3
|
|
12981
|
+
},
|
|
12982
|
+
"context": {
|
|
12983
|
+
"rule": "required",
|
|
12984
|
+
"type": "bytes",
|
|
12985
|
+
"id": 4
|
|
12986
|
+
},
|
|
12987
|
+
"network": {
|
|
12988
|
+
"rule": "required",
|
|
12989
|
+
"type": "CanonicalBitcoinNetwork",
|
|
12990
|
+
"id": 5
|
|
12991
|
+
}
|
|
12992
|
+
}
|
|
12993
|
+
},
|
|
12994
|
+
"BabylonDerivedContextHash": {
|
|
12995
|
+
"fields": {
|
|
12996
|
+
"secret": {
|
|
12997
|
+
"rule": "required",
|
|
12998
|
+
"type": "bytes",
|
|
12999
|
+
"id": 1
|
|
13000
|
+
}
|
|
13001
|
+
}
|
|
13002
|
+
},
|
|
12952
13003
|
"google": {
|
|
12953
13004
|
"nested": {
|
|
12954
13005
|
"protobuf": {
|
package/src/device/Device.ts
CHANGED
|
@@ -248,6 +248,9 @@ export class Device extends EventEmitter {
|
|
|
248
248
|
/** Canonical device-state cache; legacy Features is a compatibility projection. */
|
|
249
249
|
private stateStore = new DeviceStateStore();
|
|
250
250
|
|
|
251
|
+
/** Retain the old public identity only for disconnect notifications after wipe. */
|
|
252
|
+
private deviceBeforeWipe: DeviceTyped | null = null;
|
|
253
|
+
|
|
251
254
|
/** Force the next initialization to reload DeviceInfo after reconnect or reboot. */
|
|
252
255
|
private protocolV2StateNeedsReload = false;
|
|
253
256
|
|
|
@@ -351,6 +354,8 @@ export class Device extends EventEmitter {
|
|
|
351
354
|
toMessageObject(): DeviceTyped | null {
|
|
352
355
|
if (this.isUnacquired() || !this.features) return null;
|
|
353
356
|
|
|
357
|
+
this.deviceBeforeWipe = null;
|
|
358
|
+
|
|
354
359
|
const env = DataManager.getSettings('env');
|
|
355
360
|
const deviceType = this.getCurrentDeviceType();
|
|
356
361
|
|
|
@@ -395,6 +400,10 @@ export class Device extends EventEmitter {
|
|
|
395
400
|
};
|
|
396
401
|
}
|
|
397
402
|
|
|
403
|
+
toDisconnectMessageObject(): DeviceTyped | null {
|
|
404
|
+
return this.toMessageObject() ?? this.deviceBeforeWipe;
|
|
405
|
+
}
|
|
406
|
+
|
|
398
407
|
/**
|
|
399
408
|
* Device connect
|
|
400
409
|
* @returns {Promise<boolean>}
|
|
@@ -1364,6 +1373,7 @@ export class Device extends EventEmitter {
|
|
|
1364
1373
|
}
|
|
1365
1374
|
|
|
1366
1375
|
invalidateAfterWipe() {
|
|
1376
|
+
this.deviceBeforeWipe = this.toMessageObject() ?? this.deviceBeforeWipe;
|
|
1367
1377
|
const deviceId = this.getCurrentDeviceId();
|
|
1368
1378
|
if (deviceId) {
|
|
1369
1379
|
deviceWalletSessionStore.deleteDevice(deviceId);
|
|
@@ -1801,7 +1811,7 @@ export class Device extends EventEmitter {
|
|
|
1801
1811
|
// both allow and require cases might generate single unexpected mode
|
|
1802
1812
|
if (!this.isUnacquired()) {
|
|
1803
1813
|
// allow cases
|
|
1804
|
-
if (this.isBootloader()
|
|
1814
|
+
if ((this.isBootloader() || this.isRomloader()) && !allow.includes(UI_REQUEST.BOOTLOADER)) {
|
|
1805
1815
|
return UI_REQUEST.BOOTLOADER;
|
|
1806
1816
|
}
|
|
1807
1817
|
if (!this.isInitialized() && !allow.includes(UI_REQUEST.NOT_INITIALIZE)) {
|
|
@@ -549,6 +549,16 @@ export class DeviceCommands {
|
|
|
549
549
|
this.device.isProtocolV2() &&
|
|
550
550
|
DEVICE_CONTROL_CALLS.has(callType) &&
|
|
551
551
|
subcode === DeviceErrorCode.DeviceError_Busy;
|
|
552
|
+
const isProtocolV2PinCancelledBusyFailure =
|
|
553
|
+
this.device.isProtocolV2() &&
|
|
554
|
+
!DEVICE_SESSION_CALLS.has(callType) &&
|
|
555
|
+
subcode === DeviceSessionErrorCode.DeviceSessionError_UserCancelled &&
|
|
556
|
+
/^pin cancelled$/i.test(normalizedMessage);
|
|
557
|
+
const isProtocolV2FirmwareUpdateBusyFailure =
|
|
558
|
+
this.device.isProtocolV2() &&
|
|
559
|
+
/^requested command not allowed while a firmware update is in progress$/i.test(
|
|
560
|
+
normalizedMessage
|
|
561
|
+
);
|
|
552
562
|
const isLegacyProtocolV2LockedFailure =
|
|
553
563
|
this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(normalizedMessage);
|
|
554
564
|
if (
|
|
@@ -606,7 +616,11 @@ export class DeviceCommands {
|
|
|
606
616
|
subcode,
|
|
607
617
|
firmwareMessage: message,
|
|
608
618
|
});
|
|
609
|
-
} else if (
|
|
619
|
+
} else if (
|
|
620
|
+
isProtocolV2DeviceBusyFailure ||
|
|
621
|
+
isProtocolV2PinCancelledBusyFailure ||
|
|
622
|
+
isProtocolV2FirmwareUpdateBusyFailure
|
|
623
|
+
) {
|
|
610
624
|
error = ERRORS.TypedError(HardwareErrorCode.DeviceBusy, message, {
|
|
611
625
|
failureCode: code,
|
|
612
626
|
subcode,
|
package/src/device/DevicePool.ts
CHANGED
|
@@ -114,7 +114,11 @@ export class DevicePool extends EventEmitter {
|
|
|
114
114
|
const exist = canPathIdentifyDevice(cachedPath)
|
|
115
115
|
? descriptorList.find(d => d.path === cachedPath)
|
|
116
116
|
: undefined;
|
|
117
|
-
if (
|
|
117
|
+
if (
|
|
118
|
+
exist &&
|
|
119
|
+
!initOptions?.forceProtocolDetection &&
|
|
120
|
+
!(device.needReloadDevice && device.isUnacquired())
|
|
121
|
+
) {
|
|
118
122
|
// Log.debug('find existed Device: ', connectId);
|
|
119
123
|
device.updateDescriptor(exist, true);
|
|
120
124
|
await this._refreshRuntimeState(device, initOptions);
|
|
@@ -170,7 +174,13 @@ export class DevicePool extends EventEmitter {
|
|
|
170
174
|
const forceProtocolDetection = initOptions?.forceProtocolDetection === true;
|
|
171
175
|
const isNewDevice = !cachedDevice;
|
|
172
176
|
const device = cachedDevice ?? Device.fromDescriptor(descriptor);
|
|
173
|
-
if (
|
|
177
|
+
if (
|
|
178
|
+
isNewDevice ||
|
|
179
|
+
forceProtocolDetection ||
|
|
180
|
+
(device.needReloadDevice && device.isUnacquired())
|
|
181
|
+
) {
|
|
182
|
+
// Wipe invalidates state while the same USB path can remain discoverable.
|
|
183
|
+
if (cachedDevice) device.updateDescriptor(descriptor, true);
|
|
174
184
|
device.deviceConnector = this.connector;
|
|
175
185
|
// Search/discovery acquires outside Device.run(). Start a new attempt so
|
|
176
186
|
// a previous user cancel does not hide this device from later searches.
|
package/src/events/core.ts
CHANGED
|
@@ -54,9 +54,9 @@ export const parseMessage = (messageData: any): CoreMessage => {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
export const createErrorMessage = (error: Error & { code?: string | number }): Unsuccessful => {
|
|
57
|
-
let payload = { error: error.message, code: error.code };
|
|
57
|
+
let payload: Unsuccessful['payload'] = { error: error.message, code: error.code };
|
|
58
58
|
if (error instanceof HardwareError) {
|
|
59
|
-
payload = { error: error.message, code: error.errorCode };
|
|
59
|
+
payload = { error: error.message, code: error.errorCode, params: error.params };
|
|
60
60
|
}
|
|
61
61
|
return {
|
|
62
62
|
success: false,
|
|
@@ -8,14 +8,18 @@ export const LogBlockEvent: Set<string> = new Set([
|
|
|
8
8
|
UI_RESPONSE.RECEIVE_PASSPHRASE,
|
|
9
9
|
]);
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
//
|
|
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
|
+
'btcDeriveContextHash',
|
|
14
15
|
'deviceUploadNft',
|
|
15
16
|
'deviceUploadWallpaper',
|
|
16
17
|
'uploadPortfolio',
|
|
17
18
|
'fileWrite',
|
|
18
19
|
'fileRead',
|
|
20
|
+
'zcashGetAddress',
|
|
21
|
+
'zcashGetUnifiedAddress',
|
|
22
|
+
'zcashSignPczt',
|
|
19
23
|
]);
|
|
20
24
|
|
|
21
25
|
export function getLogBlockLabel(message: unknown): string | undefined {
|
package/src/inject.ts
CHANGED
|
@@ -309,6 +309,8 @@ export const createCoreApi = (
|
|
|
309
309
|
call({ ...params, connectId, deviceId, method: 'btcGetAddress' }),
|
|
310
310
|
btcGetPublicKey: (connectId, deviceId, params) =>
|
|
311
311
|
call({ ...params, connectId, deviceId, method: 'btcGetPublicKey' }),
|
|
312
|
+
btcDeriveContextHash: (connectId, deviceId, params) =>
|
|
313
|
+
call({ ...params, connectId, deviceId, method: 'btcDeriveContextHash' }),
|
|
312
314
|
btcSignMessage: (connectId, deviceId, params) =>
|
|
313
315
|
call({ ...params, connectId, deviceId, method: 'btcSignMessage' }),
|
|
314
316
|
btcSignPsbt: (connectId, deviceId, params) =>
|
|
@@ -502,4 +504,8 @@ export const createCoreApi = (
|
|
|
502
504
|
call({ ...params, connectId, deviceId, method: 'neoGetAddress' }),
|
|
503
505
|
neoSignTransaction: (connectId, deviceId, params) =>
|
|
504
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' }),
|
|
505
511
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BabylonDerivedContextHash } from '@onekeyfe/hd-transport';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type BTCDeriveContextHashParams = {
|
|
5
|
+
path: string | number[];
|
|
6
|
+
appName: string;
|
|
7
|
+
context: string;
|
|
8
|
+
network: 'bitcoin-mainnet' | 'bitcoin-testnet' | 'bitcoin-signet' | 'bitcoin-regtest';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export declare function btcDeriveContextHash(
|
|
12
|
+
connectId: string,
|
|
13
|
+
deviceId: string,
|
|
14
|
+
params: CommonParams & BTCDeriveContextHashParams
|
|
15
|
+
): Response<BabylonDerivedContextHash>;
|
package/src/types/api/export.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { BTCAddress, BTCGetAddressParams } from './btcGetAddress';
|
|
2
2
|
export type { BTCPublicKey, BTCGetPublicKeyParams } from './btcGetPublicKey';
|
|
3
|
+
export type { BTCDeriveContextHashParams } from './btcDeriveContextHash';
|
|
3
4
|
export type { BTCSignMessageParams } from './btcSignMessage';
|
|
4
5
|
export type { BTCVerifyMessageParams } from './btcVerifyMessage';
|
|
5
6
|
export type {
|
|
@@ -226,3 +227,5 @@ export type { BenfenAddress, BenfenGetAddressParams } from './benfenGetAddress';
|
|
|
226
227
|
export type { BenfenPublicKey, BenfenGetPublicKeyParams } from './benfenGetPublicKey';
|
|
227
228
|
export type { BenfenSignMessageParams } from './benfenSignMessage';
|
|
228
229
|
export type { BenfenSignedTx, BenfenSignTransactionParams } from './benfenSignTransaction';
|
|
230
|
+
export type { ZcashAddress, ZcashGetAddressParams } from './zcashGetAddress';
|
|
231
|
+
export type { ZcashSignedPczt, ZcashSignPcztParams } from './zcashSignPczt';
|
package/src/types/api/index.ts
CHANGED
|
@@ -73,6 +73,7 @@ import type { evmSignTypedData } from './evmSignTypedData';
|
|
|
73
73
|
import type { evmVerifyMessage } from './evmVerifyMessage';
|
|
74
74
|
import type { btcGetAddress } from './btcGetAddress';
|
|
75
75
|
import type { btcGetPublicKey } from './btcGetPublicKey';
|
|
76
|
+
import type { btcDeriveContextHash } from './btcDeriveContextHash';
|
|
76
77
|
import type { btcSignMessage } from './btcSignMessage';
|
|
77
78
|
import type { btcSignPsbt } from './btcSignPsbt';
|
|
78
79
|
import type { btcSignTransaction } from './btcSignTransaction';
|
|
@@ -153,6 +154,8 @@ import type { benfenSignTransaction } from './benfenSignTransaction';
|
|
|
153
154
|
import type { benfenSignMessage } from './benfenSignMessage';
|
|
154
155
|
import type { neoGetAddress } from './neoGetAddress';
|
|
155
156
|
import type { neoSignTransaction } from './neoSignTransaction';
|
|
157
|
+
import type { zcashGetAddress } from './zcashGetAddress';
|
|
158
|
+
import type { zcashSignPczt } from './zcashSignPczt';
|
|
156
159
|
import type { ConnectSettings } from '../settings';
|
|
157
160
|
import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
|
|
158
161
|
|
|
@@ -286,6 +289,7 @@ export type CoreApi = {
|
|
|
286
289
|
*/
|
|
287
290
|
btcGetAddress: typeof btcGetAddress;
|
|
288
291
|
btcGetPublicKey: typeof btcGetPublicKey;
|
|
292
|
+
btcDeriveContextHash: typeof btcDeriveContextHash;
|
|
289
293
|
btcSignMessage: typeof btcSignMessage;
|
|
290
294
|
btcSignPsbt: typeof btcSignPsbt;
|
|
291
295
|
btcSignTransaction: typeof btcSignTransaction;
|
|
@@ -470,4 +474,10 @@ export type CoreApi = {
|
|
|
470
474
|
*/
|
|
471
475
|
neoGetAddress: typeof neoGetAddress;
|
|
472
476
|
neoSignTransaction: typeof neoSignTransaction;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Zcash
|
|
480
|
+
*/
|
|
481
|
+
zcashGetAddress: typeof zcashGetAddress;
|
|
482
|
+
zcashSignPczt: typeof zcashSignPczt;
|
|
473
483
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ZcashAddressScope, ZcashAddressType } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
3
|
+
import type { CommonParams, Response } from '../params';
|
|
4
|
+
|
|
5
|
+
export type ZcashAddress = {
|
|
6
|
+
path: string;
|
|
7
|
+
// ZIP-316 unified address or transparent P2PKH address
|
|
8
|
+
address: string;
|
|
9
|
+
// ZIP-316 unified full viewing key, present when includeUfvk was requested
|
|
10
|
+
ufvk?: string;
|
|
11
|
+
// ZIP-32 seed fingerprint (hex), present when includeSeedFingerprint was requested
|
|
12
|
+
seedFingerprint?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type ZcashGetAddressParams = {
|
|
16
|
+
// ZIP-32 account path, m/32'/133'/account'
|
|
17
|
+
path: string | number[];
|
|
18
|
+
showOnOneKey?: boolean;
|
|
19
|
+
diversifierIndex?: number;
|
|
20
|
+
addressType?: ZcashAddressType;
|
|
21
|
+
scope?: ZcashAddressScope;
|
|
22
|
+
includeUfvk?: boolean;
|
|
23
|
+
includeSeedFingerprint?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export declare function zcashGetAddress(
|
|
27
|
+
connectId: string,
|
|
28
|
+
deviceId: string,
|
|
29
|
+
params: CommonParams & ZcashGetAddressParams
|
|
30
|
+
): Response<ZcashAddress>;
|
|
31
|
+
|
|
32
|
+
export declare function zcashGetAddress(
|
|
33
|
+
connectId: string,
|
|
34
|
+
deviceId: string,
|
|
35
|
+
params: CommonParams & { bundle?: ZcashGetAddressParams[] }
|
|
36
|
+
): 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>;
|
package/src/types/params.ts
CHANGED
|
@@ -83,7 +83,7 @@ export type Params<T> = CommonParams & T & { bundle?: undefined };
|
|
|
83
83
|
|
|
84
84
|
export interface Unsuccessful {
|
|
85
85
|
success: false;
|
|
86
|
-
payload: { error: string; code?: string | number };
|
|
86
|
+
payload: { error: string; code?: string | number; params?: Record<string, unknown> };
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export interface Success<T> {
|