@onekeyfe/hd-core 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/helpers/pathUtils.d.ts +0 -1
- package/dist/api/helpers/pathUtils.d.ts.map +1 -1
- package/dist/index.d.ts +20 -5
- package/dist/index.js +107 -107
- package/dist/types/api/btcSignTransaction.d.ts +2 -2
- package/dist/types/api/btcSignTransaction.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +1 -0
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/api/btc/BTCGetPublicKey.ts +2 -2
- package/src/api/helpers/pathUtils.ts +1 -1
- package/src/types/api/btcSignTransaction.ts +1 -2
- package/src/types/api/export.ts +8 -0
- package/src/utils/index.ts +2 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ChangeOutputScriptType, InputScriptType } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
-
export declare const HD_HARDENED = 2147483648;
|
|
3
2
|
export declare const toHardened: (n: number) => number;
|
|
4
3
|
export declare const fromHardened: (n: number) => number;
|
|
5
4
|
export declare const getHDPath: (path: string) => Array<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../../../src/api/helpers/pathUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../../../src/api/helpers/pathUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAIpG,eAAO,MAAM,UAAU,MAAO,MAAM,KAAG,MAAiC,CAAC;AACzE,eAAO,MAAM,YAAY,MAAO,MAAM,KAAG,MAAkC,CAAC;AAQ5E,eAAO,MAAM,SAAS,SAAU,MAAM,KAAG,MAAM,MAAM,CAuBpD,CAAC;AAEF,eAAO,MAAM,cAAc,SAAU,MAAM,MAAM,CAAC,KAAG,OACF,CAAC;AAEpD,eAAO,MAAM,YAAY,SAAU,MAAM,MAAM,CAAC,KAAG,OACA,CAAC;AAEpD,eAAO,MAAM,YAAY,SAAU,MAAM,MAAM,CAAC,KAAG,OACA,CAAC;AAEpD,eAAO,MAAM,aAAa,SAAU,MAAM,MAAM,CAAC,KAAG,eAcnD,CAAC;AAEF,eAAO,MAAM,mBAAmB,mCAAsB,sBAmBrD,CAAC;AAEF,eAAO,MAAM,cAAc,SAAU,MAAM,MAAM,CAAC,KAAG,MAWpD,CAAC;AAEF,eAAO,MAAM,YAAY,SACjB,MAAM,GAAG,MAAM,MAAM,CAAC,sCAG3B,MAAM,MAAM,CAoBd,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import EventEmitter, { EventEmitter as EventEmitter$1 } from 'events';
|
|
2
2
|
import { Messages, Transport, OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
|
|
3
3
|
export { Messages as PROTO } from '@onekeyfe/hd-transport';
|
|
4
|
-
import { EthereumPublicKey, EthereumMessageSignature, Success as Success$1, Address, MultisigRedeemScriptType, InputScriptType, PublicKey, MessageSignature,
|
|
4
|
+
import { EthereumPublicKey, EthereumMessageSignature, Success as Success$1, Address, MultisigRedeemScriptType, InputScriptType, PublicKey, MessageSignature, PrevInput, TxOutputBinType, TxInput, TxOutputType, TxInputType, RecoveryDeviceType, SafetyCheckLevel, StarcoinAddress as StarcoinAddress$1, StarcoinPublicKey as StarcoinPublicKey$1, StarcoinMessageSignature, StarcoinSignedTx } from '@onekeyfe/hd-transport/src/types/messages';
|
|
5
5
|
|
|
6
6
|
interface CommonParams {
|
|
7
7
|
keepSession?: boolean;
|
|
@@ -361,6 +361,20 @@ declare type BTCSignMessageParams = {
|
|
|
361
361
|
};
|
|
362
362
|
declare function btcSignMessage(connectId: string, params: CommonParams & BTCSignMessageParams): Response<MessageSignature>;
|
|
363
363
|
|
|
364
|
+
declare type SignedTransaction = {
|
|
365
|
+
signatures: string[];
|
|
366
|
+
serializedTx: string;
|
|
367
|
+
txid?: string;
|
|
368
|
+
};
|
|
369
|
+
declare type TransactionOptions = {
|
|
370
|
+
version?: number;
|
|
371
|
+
lock_time?: number;
|
|
372
|
+
expiry?: number;
|
|
373
|
+
overwintered?: boolean;
|
|
374
|
+
version_group_id?: number;
|
|
375
|
+
timestamp?: number;
|
|
376
|
+
branch_id?: number;
|
|
377
|
+
};
|
|
364
378
|
declare type RefTransaction = {
|
|
365
379
|
hash: string;
|
|
366
380
|
version: number;
|
|
@@ -417,7 +431,7 @@ declare type BTCSignTransactionParams = {
|
|
|
417
431
|
branchId?: number;
|
|
418
432
|
timestamp?: number;
|
|
419
433
|
};
|
|
420
|
-
declare function btcSignTransaction(connectId: string, params: CommonParams & BTCSignTransactionParams): Response<
|
|
434
|
+
declare function btcSignTransaction(connectId: string, params: CommonParams & BTCSignTransactionParams): Response<SignedTransaction>;
|
|
421
435
|
|
|
422
436
|
declare type BTCVerifyMessageParams = {
|
|
423
437
|
address: string;
|
|
@@ -876,8 +890,9 @@ declare const getDeviceType: (features?: {
|
|
|
876
890
|
} | undefined) => IDeviceType;
|
|
877
891
|
declare const getDeviceUUID: (features: Features) => string;
|
|
878
892
|
declare const getDeviceLabel: (features: Features) => string;
|
|
879
|
-
|
|
880
|
-
declare const
|
|
893
|
+
|
|
894
|
+
declare const getHDPath: (path: string) => Array<number>;
|
|
895
|
+
declare const getScriptType: (path: Array<number>) => InputScriptType;
|
|
881
896
|
|
|
882
897
|
declare type RunOptions = {
|
|
883
898
|
keepSession?: boolean;
|
|
@@ -982,4 +997,4 @@ declare class DataManager {
|
|
|
982
997
|
|
|
983
998
|
declare const HardwareSdk: ({ init, call, dispose, eventEmitter, uiResponse, cancel, }: InjectApi) => CoreApi;
|
|
984
999
|
|
|
985
|
-
export { AssetsMap, BTCAddress, BTCGetAddressParams, BTCGetPublicKeyParams, BTCPublicKey, BTCSignMessageParams, BTCVerifyMessageParams, CORE_EVENT, CallMethod, CallMethodAnyResponse, CallMethodKeys, CallMethodPayload, CallMethodResponse, CallMethodUnion, CommonParams, ConnectSettings, Core, CoreApi, CoreMessage, DEFAULT_PRIORITY, DEVICE, DEVICE_EVENT, DataManager, Deferred, Device$1 as Device, DeviceButtonRequest, DeviceButtonRequestPayload, DeviceChangePinParams, DeviceEvent, DeviceEventListenerFn, DeviceEventMessage, DeviceFlagsParams, DeviceMode, DeviceRecoveryParams, DeviceResetParams, DeviceSettingsParams, DeviceStatus, DeviceTypeMap, errors as ERRORS, EVMAccessList, EVMAddress, EVMGetAddressParams, EVMGetPublicKeyParams, EVMPublicKey, EVMSignMessageEIP712Params, EVMSignMessageParams, EVMSignTransactionParams, EVMSignTypedDataParams, EVMSignedTx, EVMTransaction, EVMTransactionEIP1559, EVMVerifyMessageParams, EthereumSignTypedDataMessage, EthereumSignTypedDataTypeProperty, EthereumSignTypedDataTypes, Features, FirmwareRange, FirmwareRelease, IBLEFirmwareReleaseInfo, IDeviceBLEFirmwareStatus, IDeviceFirmwareStatus, IDeviceType, IFRAME, IFirmwareReleaseInfo, IFrameBridge, IFrameCallMessage, IFrameEvent, IFrameEventMessage, IFrameInit, ILocale, ITransportStatus, IVersionArray, KnownDevice, MethodResponseMessage, PostMessageEvent, RESPONSE_EVENT, ReleaseInfo, RemoteConfigResponse, Response, SearchDevice, StarcoinAddress, StarcoinGetAddressParams, StarcoinGetPublicKeyParams, StarcoinPublicKey, StarcoinSignMessageParams, StarcoinSignTransactionParams, StarcoinVerifyMessageParams, Success, TransportReleaseStatus, UI_EVENT, UI_REQUEST, UI_RESPONSE, UiEvent, UiEventMessage, UiPromise, UiPromiseResponse, UiRequestButton, UiRequestDeviceAction, UiRequestWithoutPayload, UiResponseEvent, UiResponseMessage, UiResponsePin, UnavailableCapabilities, UnavailableCapability, Unsuccessful, VersionArray, corsValidator, create, createDeviceMessage, createErrorMessage, createIFrameMessage, createResponseMessage, createUiMessage, createUiResponse, HardwareSdk as default, enableLog,
|
|
1000
|
+
export { AccountAddress, AccountAddresses, AssetsMap, BTCAddress, BTCGetAddressParams, BTCGetPublicKeyParams, BTCPublicKey, BTCSignMessageParams, BTCSignTransactionParams, BTCVerifyMessageParams, CORE_EVENT, CallMethod, CallMethodAnyResponse, CallMethodKeys, CallMethodPayload, CallMethodResponse, CallMethodUnion, CommonParams, ConnectSettings, Core, CoreApi, CoreMessage, DEFAULT_PRIORITY, DEVICE, DEVICE_EVENT, DataManager, Deferred, Device$1 as Device, DeviceButtonRequest, DeviceButtonRequestPayload, DeviceChangePinParams, DeviceEvent, DeviceEventListenerFn, DeviceEventMessage, DeviceFlagsParams, DeviceMode, DeviceRecoveryParams, DeviceResetParams, DeviceSettingsParams, DeviceStatus, DeviceTypeMap, errors as ERRORS, EVMAccessList, EVMAddress, EVMGetAddressParams, EVMGetPublicKeyParams, EVMPublicKey, EVMSignMessageEIP712Params, EVMSignMessageParams, EVMSignTransactionParams, EVMSignTypedDataParams, EVMSignedTx, EVMTransaction, EVMTransactionEIP1559, EVMVerifyMessageParams, EthereumSignTypedDataMessage, EthereumSignTypedDataTypeProperty, EthereumSignTypedDataTypes, Features, FirmwareRange, FirmwareRelease, IBLEFirmwareReleaseInfo, IDeviceBLEFirmwareStatus, IDeviceFirmwareStatus, IDeviceType, IFRAME, IFirmwareReleaseInfo, IFrameBridge, IFrameCallMessage, IFrameEvent, IFrameEventMessage, IFrameInit, ILocale, ITransportStatus, IVersionArray, KnownDevice, MethodResponseMessage, PostMessageEvent, RESPONSE_EVENT, RefTransaction, ReleaseInfo, RemoteConfigResponse, Response, SearchDevice, SignedTransaction, StarcoinAddress, StarcoinGetAddressParams, StarcoinGetPublicKeyParams, StarcoinPublicKey, StarcoinSignMessageParams, StarcoinSignTransactionParams, StarcoinVerifyMessageParams, Success, TransactionOptions, TransportReleaseStatus, UI_EVENT, UI_REQUEST, UI_RESPONSE, UiEvent, UiEventMessage, UiPromise, UiPromiseResponse, UiRequestButton, UiRequestDeviceAction, UiRequestWithoutPayload, UiResponseEvent, UiResponseMessage, UiResponsePin, UnavailableCapabilities, UnavailableCapability, Unsuccessful, VersionArray, corsValidator, create, createDeviceMessage, createErrorMessage, createIFrameMessage, createResponseMessage, createUiMessage, createUiResponse, HardwareSdk as default, enableLog, getDeviceLabel, getDeviceType, getDeviceUUID, getEnv, getHDPath, getScriptType, getTimeStamp, httpRequest, init as initCore, initLog, isValidVersionArray, isValidVersionString, normalizeVersionArray, parseConnectSettings, parseMessage, versionCompare, versionSplit };
|
package/dist/index.js
CHANGED
|
@@ -845,6 +845,109 @@ const getDeviceBLEFirmwareVersion = (features) => {
|
|
|
845
845
|
return features.ble_ver.split('.');
|
|
846
846
|
};
|
|
847
847
|
|
|
848
|
+
const HD_HARDENED = 0x80000000;
|
|
849
|
+
const toHardened = (n) => (n | HD_HARDENED) >>> 0;
|
|
850
|
+
const fromHardened = (n) => (n & ~HD_HARDENED) >>> 0;
|
|
851
|
+
const PATH_NOT_VALID = TypedError('Method_InvalidParameter', 'Not a valid path');
|
|
852
|
+
const PATH_NEGATIVE_VALUES = TypedError('Method_InvalidParameter', 'Path cannot contain negative values');
|
|
853
|
+
const getHDPath = (path) => {
|
|
854
|
+
const parts = path.toLowerCase().split('/');
|
|
855
|
+
if (parts[0] !== 'm')
|
|
856
|
+
throw PATH_NOT_VALID;
|
|
857
|
+
return parts
|
|
858
|
+
.filter((p) => p !== 'm' && p !== '')
|
|
859
|
+
.map((p) => {
|
|
860
|
+
let hardened = false;
|
|
861
|
+
if (p.substr(p.length - 1) === "'") {
|
|
862
|
+
hardened = true;
|
|
863
|
+
p = p.substr(0, p.length - 1);
|
|
864
|
+
}
|
|
865
|
+
let n = parseInt(p);
|
|
866
|
+
if (Number.isNaN(n)) {
|
|
867
|
+
throw PATH_NOT_VALID;
|
|
868
|
+
}
|
|
869
|
+
else if (n < 0) {
|
|
870
|
+
throw PATH_NEGATIVE_VALUES;
|
|
871
|
+
}
|
|
872
|
+
if (hardened) {
|
|
873
|
+
n = toHardened(n);
|
|
874
|
+
}
|
|
875
|
+
return n;
|
|
876
|
+
});
|
|
877
|
+
};
|
|
878
|
+
const isMultisigPath = (path) => Array.isArray(path) && path[0] === toHardened(48);
|
|
879
|
+
const isSegwitPath = (path) => Array.isArray(path) && path[0] === toHardened(49);
|
|
880
|
+
const getScriptType = (path) => {
|
|
881
|
+
if (!Array.isArray(path) || path.length < 1)
|
|
882
|
+
return 'SPENDADDRESS';
|
|
883
|
+
const p1 = fromHardened(path[0]);
|
|
884
|
+
switch (p1) {
|
|
885
|
+
case 48:
|
|
886
|
+
return 'SPENDMULTISIG';
|
|
887
|
+
case 49:
|
|
888
|
+
return 'SPENDP2SHWITNESS';
|
|
889
|
+
case 84:
|
|
890
|
+
return 'SPENDWITNESS';
|
|
891
|
+
default:
|
|
892
|
+
return 'SPENDADDRESS';
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
const getOutputScriptType = (path) => {
|
|
896
|
+
if (!Array.isArray(path) || path.length < 1)
|
|
897
|
+
return 'PAYTOADDRESS';
|
|
898
|
+
if (path[0] === 49) {
|
|
899
|
+
return 'PAYTOP2SHWITNESS';
|
|
900
|
+
}
|
|
901
|
+
const p = fromHardened(path[0]);
|
|
902
|
+
switch (p) {
|
|
903
|
+
case 48:
|
|
904
|
+
return 'PAYTOMULTISIG';
|
|
905
|
+
case 49:
|
|
906
|
+
return 'PAYTOP2SHWITNESS';
|
|
907
|
+
case 84:
|
|
908
|
+
return 'PAYTOWITNESS';
|
|
909
|
+
default:
|
|
910
|
+
return 'PAYTOADDRESS';
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
const serializedPath = (path) => {
|
|
914
|
+
const pathStr = path
|
|
915
|
+
.map((p) => {
|
|
916
|
+
if (p & HD_HARDENED) {
|
|
917
|
+
return `${p & ~HD_HARDENED}'`;
|
|
918
|
+
}
|
|
919
|
+
return p;
|
|
920
|
+
})
|
|
921
|
+
.join('/');
|
|
922
|
+
return `m/${pathStr}`;
|
|
923
|
+
};
|
|
924
|
+
const validatePath = (path, length = 0, base = false) => {
|
|
925
|
+
let valid;
|
|
926
|
+
if (typeof path === 'string') {
|
|
927
|
+
valid = getHDPath(path);
|
|
928
|
+
}
|
|
929
|
+
else if (Array.isArray(path)) {
|
|
930
|
+
valid = path.map((p) => {
|
|
931
|
+
const n = parseInt(p);
|
|
932
|
+
if (Number.isNaN(n)) {
|
|
933
|
+
throw PATH_NOT_VALID;
|
|
934
|
+
}
|
|
935
|
+
else if (n < 0) {
|
|
936
|
+
throw PATH_NEGATIVE_VALUES;
|
|
937
|
+
}
|
|
938
|
+
return n;
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
else {
|
|
942
|
+
valid = undefined;
|
|
943
|
+
}
|
|
944
|
+
if (!valid)
|
|
945
|
+
throw PATH_NOT_VALID;
|
|
946
|
+
if (length > 0 && valid.length < length)
|
|
947
|
+
throw PATH_NOT_VALID;
|
|
948
|
+
return base ? valid.splice(0, 3) : valid;
|
|
949
|
+
};
|
|
950
|
+
|
|
848
951
|
var nested = {
|
|
849
952
|
BinanceGetAddress: {
|
|
850
953
|
fields: {
|
|
@@ -10492,109 +10595,6 @@ class GetFeatures extends BaseMethod {
|
|
|
10492
10595
|
}
|
|
10493
10596
|
}
|
|
10494
10597
|
|
|
10495
|
-
const HD_HARDENED = 0x80000000;
|
|
10496
|
-
const toHardened = (n) => (n | HD_HARDENED) >>> 0;
|
|
10497
|
-
const fromHardened = (n) => (n & ~HD_HARDENED) >>> 0;
|
|
10498
|
-
const PATH_NOT_VALID = TypedError('Method_InvalidParameter', 'Not a valid path');
|
|
10499
|
-
const PATH_NEGATIVE_VALUES = TypedError('Method_InvalidParameter', 'Path cannot contain negative values');
|
|
10500
|
-
const getHDPath = (path) => {
|
|
10501
|
-
const parts = path.toLowerCase().split('/');
|
|
10502
|
-
if (parts[0] !== 'm')
|
|
10503
|
-
throw PATH_NOT_VALID;
|
|
10504
|
-
return parts
|
|
10505
|
-
.filter((p) => p !== 'm' && p !== '')
|
|
10506
|
-
.map((p) => {
|
|
10507
|
-
let hardened = false;
|
|
10508
|
-
if (p.substr(p.length - 1) === "'") {
|
|
10509
|
-
hardened = true;
|
|
10510
|
-
p = p.substr(0, p.length - 1);
|
|
10511
|
-
}
|
|
10512
|
-
let n = parseInt(p);
|
|
10513
|
-
if (Number.isNaN(n)) {
|
|
10514
|
-
throw PATH_NOT_VALID;
|
|
10515
|
-
}
|
|
10516
|
-
else if (n < 0) {
|
|
10517
|
-
throw PATH_NEGATIVE_VALUES;
|
|
10518
|
-
}
|
|
10519
|
-
if (hardened) {
|
|
10520
|
-
n = toHardened(n);
|
|
10521
|
-
}
|
|
10522
|
-
return n;
|
|
10523
|
-
});
|
|
10524
|
-
};
|
|
10525
|
-
const isMultisigPath = (path) => Array.isArray(path) && path[0] === toHardened(48);
|
|
10526
|
-
const isSegwitPath = (path) => Array.isArray(path) && path[0] === toHardened(49);
|
|
10527
|
-
const getScriptType = (path) => {
|
|
10528
|
-
if (!Array.isArray(path) || path.length < 1)
|
|
10529
|
-
return 'SPENDADDRESS';
|
|
10530
|
-
const p1 = fromHardened(path[0]);
|
|
10531
|
-
switch (p1) {
|
|
10532
|
-
case 48:
|
|
10533
|
-
return 'SPENDMULTISIG';
|
|
10534
|
-
case 49:
|
|
10535
|
-
return 'SPENDP2SHWITNESS';
|
|
10536
|
-
case 84:
|
|
10537
|
-
return 'SPENDWITNESS';
|
|
10538
|
-
default:
|
|
10539
|
-
return 'SPENDADDRESS';
|
|
10540
|
-
}
|
|
10541
|
-
};
|
|
10542
|
-
const getOutputScriptType = (path) => {
|
|
10543
|
-
if (!Array.isArray(path) || path.length < 1)
|
|
10544
|
-
return 'PAYTOADDRESS';
|
|
10545
|
-
if (path[0] === 49) {
|
|
10546
|
-
return 'PAYTOP2SHWITNESS';
|
|
10547
|
-
}
|
|
10548
|
-
const p = fromHardened(path[0]);
|
|
10549
|
-
switch (p) {
|
|
10550
|
-
case 48:
|
|
10551
|
-
return 'PAYTOMULTISIG';
|
|
10552
|
-
case 49:
|
|
10553
|
-
return 'PAYTOP2SHWITNESS';
|
|
10554
|
-
case 84:
|
|
10555
|
-
return 'PAYTOWITNESS';
|
|
10556
|
-
default:
|
|
10557
|
-
return 'PAYTOADDRESS';
|
|
10558
|
-
}
|
|
10559
|
-
};
|
|
10560
|
-
const serializedPath = (path) => {
|
|
10561
|
-
const pathStr = path
|
|
10562
|
-
.map((p) => {
|
|
10563
|
-
if (p & HD_HARDENED) {
|
|
10564
|
-
return `${p & ~HD_HARDENED}'`;
|
|
10565
|
-
}
|
|
10566
|
-
return p;
|
|
10567
|
-
})
|
|
10568
|
-
.join('/');
|
|
10569
|
-
return `m/${pathStr}`;
|
|
10570
|
-
};
|
|
10571
|
-
const validatePath = (path, length = 0, base = false) => {
|
|
10572
|
-
let valid;
|
|
10573
|
-
if (typeof path === 'string') {
|
|
10574
|
-
valid = getHDPath(path);
|
|
10575
|
-
}
|
|
10576
|
-
else if (Array.isArray(path)) {
|
|
10577
|
-
valid = path.map((p) => {
|
|
10578
|
-
const n = parseInt(p);
|
|
10579
|
-
if (Number.isNaN(n)) {
|
|
10580
|
-
throw PATH_NOT_VALID;
|
|
10581
|
-
}
|
|
10582
|
-
else if (n < 0) {
|
|
10583
|
-
throw PATH_NEGATIVE_VALUES;
|
|
10584
|
-
}
|
|
10585
|
-
return n;
|
|
10586
|
-
});
|
|
10587
|
-
}
|
|
10588
|
-
else {
|
|
10589
|
-
valid = undefined;
|
|
10590
|
-
}
|
|
10591
|
-
if (!valid)
|
|
10592
|
-
throw PATH_NOT_VALID;
|
|
10593
|
-
if (length > 0 && valid.length < length)
|
|
10594
|
-
throw PATH_NOT_VALID;
|
|
10595
|
-
return base ? valid.splice(0, 3) : valid;
|
|
10596
|
-
};
|
|
10597
|
-
|
|
10598
10598
|
const hasHexPrefix = (str) => str.slice(0, 2).toLowerCase() === '0x';
|
|
10599
10599
|
const stripHexPrefix = (str) => (hasHexPrefix(str) ? str.slice(2) : str);
|
|
10600
10600
|
const addHexPrefix = (str) => (hasHexPrefix(str) ? str : `0x${str}`);
|
|
@@ -10987,8 +10987,8 @@ class BTCGetPublicKey extends BaseMethod {
|
|
|
10987
10987
|
}
|
|
10988
10988
|
init() {
|
|
10989
10989
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
10990
|
-
|
|
10991
|
-
const payload = hasBundle ? this.payload : { bundle: [this.payload] };
|
|
10990
|
+
this.hasBundle = Object.prototype.hasOwnProperty.call(this.payload, 'bundle');
|
|
10991
|
+
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
10992
10992
|
validateParams(payload, [{ name: 'bundle', type: 'array' }]);
|
|
10993
10993
|
this.params = [];
|
|
10994
10994
|
payload.bundle.forEach((batch) => {
|
|
@@ -12582,12 +12582,12 @@ exports.createUiMessage = createUiMessage;
|
|
|
12582
12582
|
exports.createUiResponse = createUiResponse;
|
|
12583
12583
|
exports["default"] = HardwareSdk;
|
|
12584
12584
|
exports.enableLog = enableLog;
|
|
12585
|
-
exports.getDeviceBLEFirmwareVersion = getDeviceBLEFirmwareVersion;
|
|
12586
|
-
exports.getDeviceFirmwareVersion = getDeviceFirmwareVersion;
|
|
12587
12585
|
exports.getDeviceLabel = getDeviceLabel;
|
|
12588
12586
|
exports.getDeviceType = getDeviceType;
|
|
12589
12587
|
exports.getDeviceUUID = getDeviceUUID;
|
|
12590
12588
|
exports.getEnv = getEnv;
|
|
12589
|
+
exports.getHDPath = getHDPath;
|
|
12590
|
+
exports.getScriptType = getScriptType;
|
|
12591
12591
|
exports.getTimeStamp = getTimeStamp;
|
|
12592
12592
|
exports.httpRequest = httpRequest;
|
|
12593
12593
|
exports.initCore = init;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TxInput as OrigTxInput, PrevInput,
|
|
1
|
+
import { TxInput as OrigTxInput, PrevInput, TxOutputBinType, TxOutputType, TxInputType } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
2
|
import type { CommonParams, Response } from '../params';
|
|
3
3
|
export declare type SignedTransaction = {
|
|
4
4
|
signatures: string[];
|
|
@@ -70,5 +70,5 @@ export declare type BTCSignTransactionParams = {
|
|
|
70
70
|
branchId?: number;
|
|
71
71
|
timestamp?: number;
|
|
72
72
|
};
|
|
73
|
-
export declare function btcSignTransaction(connectId: string, params: CommonParams & BTCSignTransactionParams): Response<
|
|
73
|
+
export declare function btcSignTransaction(connectId: string, params: CommonParams & BTCSignTransactionParams): Response<SignedTransaction>;
|
|
74
74
|
//# sourceMappingURL=btcSignTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"btcSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/types/api/btcSignTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,WAAW,EACtB,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"btcSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/types/api/btcSignTransaction.ts"],"names":[],"mappings":"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"}
|
|
@@ -2,6 +2,7 @@ export type { BTCAddress, BTCGetAddressParams } from './btcGetAddress';
|
|
|
2
2
|
export type { BTCPublicKey, BTCGetPublicKeyParams } from './btcGetPublicKey';
|
|
3
3
|
export type { BTCSignMessageParams } from './btcSignMessage';
|
|
4
4
|
export type { BTCVerifyMessageParams } from './btcVerifyMessage';
|
|
5
|
+
export type { RefTransaction, AccountAddress, AccountAddresses, BTCSignTransactionParams, SignedTransaction, TransactionOptions, } from './btcSignTransaction';
|
|
5
6
|
export type { DeviceChangePinParams } from './deviceChangePin';
|
|
6
7
|
export type { DeviceFlagsParams } from './deviceFlags';
|
|
7
8
|
export type { DeviceRecoveryParams } from './deviceRecovery';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../src/types/api/export.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACvE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../src/types/api/export.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACvE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,YAAY,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACvE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACzE,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,wBAAwB,EACxB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,0BAA0B,EAC1B,iCAAiC,EACjC,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,YAAY,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACtF,YAAY,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC5F,YAAY,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,YAAY,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC/E,YAAY,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { initLog, enableLog } from './logger';
|
|
|
2
2
|
export * from './assets';
|
|
3
3
|
export * from './versionUtils';
|
|
4
4
|
export * from './deferred';
|
|
5
|
-
export
|
|
5
|
+
export { getDeviceType, getDeviceUUID, getDeviceLabel } from './deviceFeaturesUtils';
|
|
6
|
+
export { getHDPath, getScriptType } from '../api/helpers/pathUtils';
|
|
6
7
|
export { initLog, enableLog };
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE9C,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE9C,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-transport": "^0.0.
|
|
28
|
+
"@onekeyfe/hd-transport": "^0.0.5",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"bignumber.js": "^9.0.2",
|
|
31
31
|
"parse-uri": "^1.0.7",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"@types/parse-uri": "^1.0.0",
|
|
36
36
|
"@types/semver": "^7.3.9"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "24d2a28fd3f2e7fda4c21742e968bce764985615"
|
|
39
39
|
}
|
|
@@ -13,8 +13,8 @@ export default class BTCGetPublicKey extends BaseMethod<GetPublicKey[]> {
|
|
|
13
13
|
init() {
|
|
14
14
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
const payload = hasBundle ? this.payload : { bundle: [this.payload] };
|
|
16
|
+
this.hasBundle = Object.prototype.hasOwnProperty.call(this.payload, 'bundle');
|
|
17
|
+
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
18
18
|
|
|
19
19
|
validateParams(payload, [{ name: 'bundle', type: 'array' }]);
|
|
20
20
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { ChangeOutputScriptType, InputScriptType } from '@onekeyfe/hd-transport/src/types/messages';
|
|
4
4
|
import { ERRORS } from '../../constants';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const HD_HARDENED = 0x80000000;
|
|
7
7
|
export const toHardened = (n: number): number => (n | HD_HARDENED) >>> 0;
|
|
8
8
|
export const fromHardened = (n: number): number => (n & ~HD_HARDENED) >>> 0;
|
|
9
9
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TxInput as OrigTxInput,
|
|
3
3
|
PrevInput,
|
|
4
|
-
Success,
|
|
5
4
|
TxOutputBinType,
|
|
6
5
|
TxOutputType,
|
|
7
6
|
TxInputType,
|
|
@@ -95,4 +94,4 @@ export type BTCSignTransactionParams = {
|
|
|
95
94
|
export declare function btcSignTransaction(
|
|
96
95
|
connectId: string,
|
|
97
96
|
params: CommonParams & BTCSignTransactionParams
|
|
98
|
-
): Response<
|
|
97
|
+
): Response<SignedTransaction>;
|
package/src/types/api/export.ts
CHANGED
|
@@ -2,6 +2,14 @@ export type { BTCAddress, BTCGetAddressParams } from './btcGetAddress';
|
|
|
2
2
|
export type { BTCPublicKey, BTCGetPublicKeyParams } from './btcGetPublicKey';
|
|
3
3
|
export type { BTCSignMessageParams } from './btcSignMessage';
|
|
4
4
|
export type { BTCVerifyMessageParams } from './btcVerifyMessage';
|
|
5
|
+
export type {
|
|
6
|
+
RefTransaction,
|
|
7
|
+
AccountAddress,
|
|
8
|
+
AccountAddresses,
|
|
9
|
+
BTCSignTransactionParams,
|
|
10
|
+
SignedTransaction,
|
|
11
|
+
TransactionOptions,
|
|
12
|
+
} from './btcSignTransaction';
|
|
5
13
|
|
|
6
14
|
export type { DeviceChangePinParams } from './deviceChangePin';
|
|
7
15
|
export type { DeviceFlagsParams } from './deviceFlags';
|
package/src/utils/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { initLog, enableLog } from './logger';
|
|
|
3
3
|
export * from './assets';
|
|
4
4
|
export * from './versionUtils';
|
|
5
5
|
export * from './deferred';
|
|
6
|
-
export
|
|
6
|
+
export { getDeviceType, getDeviceUUID, getDeviceLabel } from './deviceFeaturesUtils';
|
|
7
|
+
export { getHDPath, getScriptType } from '../api/helpers/pathUtils';
|
|
7
8
|
|
|
8
9
|
export { initLog, enableLog };
|