Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/connect-examples/electron-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hardware-example",
"productName": "HardwareExample",
"executableName": "onekey-hardware-example",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"author": "OneKey",
"description": "End-to-end encrypted workspaces for teams",
"main": "dist/index.js",
Expand All @@ -22,7 +22,7 @@
"ts:check": "yarn tsc --noEmit"
},
"dependencies": {
"@onekeyfe/hd-transport-electron": "1.1.32",
"@onekeyfe/hd-transport-electron": "1.1.34-alpha.0",
"@stoprocent/noble": "2.3.16",
"debug": "4.3.4",
"electron-is-dev": "^3.0.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/connect-examples/expo-example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expo-example",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"scripts": {
"start": "cross-env CONNECT_SRC=https://localhost:8087/ yarn expo start --dev-client",
"android": "yarn expo run:android",
Expand All @@ -19,10 +19,10 @@
"@noble/ed25519": "^2.1.0",
"@noble/hashes": "^1.3.3",
"@noble/secp256k1": "^1.7.1",
"@onekeyfe/hd-ble-sdk": "1.1.32",
"@onekeyfe/hd-common-connect-sdk": "1.1.32",
"@onekeyfe/hd-core": "1.1.32",
"@onekeyfe/hd-web-sdk": "1.1.32",
"@onekeyfe/hd-ble-sdk": "1.1.34-alpha.0",
"@onekeyfe/hd-common-connect-sdk": "1.1.34-alpha.0",
"@onekeyfe/hd-core": "1.1.34-alpha.0",
"@onekeyfe/hd-web-sdk": "1.1.34-alpha.0",
"@onekeyfe/react-native-ble-utils": "^0.1.3",
"@polkadot/util-crypto": "13.1.1",
"@react-native-async-storage/async-storage": "1.21.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/connect-examples/expo-playground/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onekey-hardware-playground",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"private": true,
"sideEffects": [
"app/utils/shim.js",
Expand All @@ -17,9 +17,9 @@
},
"dependencies": {
"@noble/hashes": "^1.8.0",
"@onekeyfe/hd-common-connect-sdk": "1.1.32",
"@onekeyfe/hd-core": "1.1.32",
"@onekeyfe/hd-shared": "1.1.32",
"@onekeyfe/hd-common-connect-sdk": "1.1.34-alpha.0",
"@onekeyfe/hd-core": "1.1.34-alpha.0",
"@onekeyfe/hd-shared": "1.1.34-alpha.0",
"@radix-ui/react-checkbox": "^1.3.2",
"@radix-ui/react-dialog": "^1.1.14",
"@radix-ui/react-dropdown-menu": "^2.1.15",
Expand Down
18 changes: 9 additions & 9 deletions packages/connect-examples/hwk-demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hwk-demo",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"private": true,
"main": "index.js",
"scripts": {
Expand All @@ -13,14 +13,14 @@
},
"dependencies": {
"@expo/metro-runtime": "~3.1.3",
"@onekeyfe/hwk-adapter-core": "1.1.32",
"@onekeyfe/hwk-ledger-adapter": "1.1.32",
"@onekeyfe/hwk-ledger-connector-ble": "1.1.32",
"@onekeyfe/hwk-ledger-connector-webhid": "1.1.32",
"@onekeyfe/hwk-trezor-adapter": "1.1.32",
"@onekeyfe/hwk-trezor-connector": "1.1.32",
"@onekeyfe/hwk-trezor-connector-rn-ble": "1.1.32",
"@onekeyfe/hwk-trezor-connector-webusb": "1.1.32",
"@onekeyfe/hwk-adapter-core": "1.1.34-alpha.0",
"@onekeyfe/hwk-ledger-adapter": "1.1.34-alpha.0",
"@onekeyfe/hwk-ledger-connector-ble": "1.1.34-alpha.0",
"@onekeyfe/hwk-ledger-connector-webhid": "1.1.34-alpha.0",
"@onekeyfe/hwk-trezor-adapter": "1.1.34-alpha.0",
"@onekeyfe/hwk-trezor-connector": "1.1.34-alpha.0",
"@onekeyfe/hwk-trezor-connector-rn-ble": "1.1.34-alpha.0",
"@onekeyfe/hwk-trezor-connector-webusb": "1.1.34-alpha.0",
"@react-native-async-storage/async-storage": "1.21.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
Expand Down
60 changes: 60 additions & 0 deletions packages/core/__tests__/kaspaSignTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,66 @@ describe('KaspaSignTransaction protocol negotiation', () => {
// Back to the current transaction after the previous one is streamed.
expect(mockTypedCall.mock.calls[4][0]).toBe('KaspaTxAckInput');
});

describe('previous-transaction id mismatch', () => {
const PREV_ID = 'aa'.repeat(32);
const withRefTxs = {
outputs: [{ satoshis: 100000, script: SCRIPT, address: ADDRESS }],
refTxs: [
{
txId: PREV_ID,
version: 0,
inputs: [],
outputs: [{ satoshis: '200000', script: SCRIPT }],
},
],
};

const streamThenReject = (error: unknown) =>
mockTypedCall
.mockResolvedValueOnce(
txRequest({ request_type: 'KASPA_TX_PREV_META', prev_tx_id: PREV_ID })
)
.mockRejectedValueOnce(error);

it('surfaces the device rejection under its own error code', async () => {
streamThenReject(
ERRORS.TypedError(
HardwareErrorCode.RuntimeError,
'Failure_ProcessError,Kaspa previous transaction id mismatch'
)
);

await expect(runMethod(withRefTxs)).rejects.toMatchObject({
errorCode: HardwareErrorCode.KaspaPrevTxIdMismatch,
});
// Never silently re-signs without refTxs.
expect(mockTypedCall).toHaveBeenCalledTimes(2);
});

it('leaves an unrelated device error untouched', async () => {
streamThenReject(
ERRORS.TypedError(
HardwareErrorCode.RuntimeError,
'Failure_ProcessError,some other device error'
)
);

await expect(runMethod(withRefTxs)).rejects.toMatchObject({
errorCode: HardwareErrorCode.RuntimeError,
});
expect(mockTypedCall).toHaveBeenCalledTimes(2);
});

it('leaves user cancellation untouched', async () => {
streamThenReject(ERRORS.TypedError(HardwareErrorCode.ActionCancelled));

await expect(runMethod(withRefTxs)).rejects.toMatchObject({
errorCode: HardwareErrorCode.ActionCancelled,
});
expect(mockTypedCall).toHaveBeenCalledTimes(2);
});
});
});

describe('KaspaSignTransaction wire encoding', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-core",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
Expand All @@ -25,8 +25,8 @@
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
},
"dependencies": {
"@onekeyfe/hd-shared": "1.1.32",
"@onekeyfe/hd-transport": "1.1.32",
"@onekeyfe/hd-shared": "1.1.34-alpha.0",
"@onekeyfe/hd-transport": "1.1.34-alpha.0",
"axios": "1.15.2",
"bignumber.js": "^9.0.2",
"bytebuffer": "^5.0.1",
Expand Down
13 changes: 12 additions & 1 deletion packages/core/src/api/kaspa/KaspaSignTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,18 @@ export default class KaspaSignTransaction extends BaseMethod<KaspaSignTransactio
'KaspaSignTransaction: device firmware uses the streaming protocol; every output requires address or addressN'
);
}
return this.signTxStream(typedCall, response);
try {
return await this.signTxStream(typedCall, response);
} catch (error) {
// Device rejected our refTxs; the caller decides whether to sign without them.
if (
error instanceof HardwareError &&
String(error.message).toLowerCase().includes('previous transaction id mismatch')
) {
throw ERRORS.TypedError(HardwareErrorCode.KaspaPrevTxIdMismatch, String(error.message));
}
throw error;
}
}

// Legacy answer to a streaming-only packet: no prehash material exists.
Expand Down
8 changes: 4 additions & 4 deletions packages/hd-ble-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-ble-sdk",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "ISC",
Expand All @@ -20,8 +20,8 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-core": "1.1.32",
"@onekeyfe/hd-shared": "1.1.32",
"@onekeyfe/hd-transport-react-native": "1.1.32"
"@onekeyfe/hd-core": "1.1.34-alpha.0",
"@onekeyfe/hd-shared": "1.1.34-alpha.0",
"@onekeyfe/hd-transport-react-native": "1.1.34-alpha.0"
}
}
10 changes: 5 additions & 5 deletions packages/hd-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hardware-cli",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"description": "OneKey hardware wallet CLI for testing device communication",
"author": "OneKey",
"license": "Apache-2.0",
Expand Down Expand Up @@ -30,10 +30,10 @@
"test": "jest"
},
"dependencies": {
"@onekeyfe/hd-common-connect-sdk": "1.1.32",
"@onekeyfe/hd-core": "1.1.32",
"@onekeyfe/hd-shared": "1.1.32",
"@onekeyfe/hd-transport-usb": "1.1.32",
"@onekeyfe/hd-common-connect-sdk": "1.1.34-alpha.0",
"@onekeyfe/hd-core": "1.1.34-alpha.0",
"@onekeyfe/hd-shared": "1.1.34-alpha.0",
"@onekeyfe/hd-transport-usb": "1.1.34-alpha.0",
"commander": "^12.0.0"
}
}
16 changes: 8 additions & 8 deletions packages/hd-common-connect-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-common-connect-sdk",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "ISC",
Expand All @@ -20,12 +20,12 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-core": "1.1.32",
"@onekeyfe/hd-shared": "1.1.32",
"@onekeyfe/hd-transport-emulator": "1.1.32",
"@onekeyfe/hd-transport-http": "1.1.32",
"@onekeyfe/hd-transport-lowlevel": "1.1.32",
"@onekeyfe/hd-transport-usb": "1.1.32",
"@onekeyfe/hd-transport-web-device": "1.1.32"
"@onekeyfe/hd-core": "1.1.34-alpha.0",
"@onekeyfe/hd-shared": "1.1.34-alpha.0",
"@onekeyfe/hd-transport-emulator": "1.1.34-alpha.0",
"@onekeyfe/hd-transport-http": "1.1.34-alpha.0",
"@onekeyfe/hd-transport-lowlevel": "1.1.34-alpha.0",
"@onekeyfe/hd-transport-usb": "1.1.34-alpha.0",
"@onekeyfe/hd-transport-web-device": "1.1.34-alpha.0"
}
}
8 changes: 4 additions & 4 deletions packages/hd-transport-electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-electron",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "MIT",
Expand All @@ -25,9 +25,9 @@
"electron-log": ">=4.0.0"
},
"dependencies": {
"@onekeyfe/hd-core": "1.1.32",
"@onekeyfe/hd-shared": "1.1.32",
"@onekeyfe/hd-transport": "1.1.32",
"@onekeyfe/hd-core": "1.1.34-alpha.0",
"@onekeyfe/hd-shared": "1.1.34-alpha.0",
"@onekeyfe/hd-transport": "1.1.34-alpha.0",
"@stoprocent/noble": "2.3.16",
"p-retry": "^4.6.2"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/hd-transport-emulator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-emulator",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"description": "hardware emulator transport",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
Expand All @@ -24,8 +24,8 @@
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
},
"dependencies": {
"@onekeyfe/hd-shared": "1.1.32",
"@onekeyfe/hd-transport": "1.1.32",
"@onekeyfe/hd-shared": "1.1.34-alpha.0",
"@onekeyfe/hd-transport": "1.1.34-alpha.0",
"axios": "1.15.2",
"secure-json-parse": "^4.0.0"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/hd-transport-http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-http",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"description": "hardware http transport",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
Expand All @@ -24,8 +24,8 @@
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
},
"dependencies": {
"@onekeyfe/hd-shared": "1.1.32",
"@onekeyfe/hd-transport": "1.1.32",
"@onekeyfe/hd-shared": "1.1.34-alpha.0",
"@onekeyfe/hd-transport": "1.1.34-alpha.0",
"axios": "1.15.2",
"secure-json-parse": "^4.0.0"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/hd-transport-lowlevel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-lowlevel",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -19,7 +19,7 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-shared": "1.1.32",
"@onekeyfe/hd-transport": "1.1.32"
"@onekeyfe/hd-shared": "1.1.34-alpha.0",
"@onekeyfe/hd-transport": "1.1.34-alpha.0"
}
}
8 changes: 4 additions & 4 deletions packages/hd-transport-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-react-native",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -19,9 +19,9 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-core": "1.1.32",
"@onekeyfe/hd-shared": "1.1.32",
"@onekeyfe/hd-transport": "1.1.32",
"@onekeyfe/hd-core": "1.1.34-alpha.0",
"@onekeyfe/hd-shared": "1.1.34-alpha.0",
"@onekeyfe/hd-transport": "1.1.34-alpha.0",
"@onekeyfe/react-native-ble-utils": "^0.1.6",
"react-native-ble-plx": "3.5.1"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/hd-transport-usb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-usb",
"version": "1.1.32",
"version": "1.1.34-alpha.0",
"description": "OneKey hardware wallet direct USB transport plugin (libusb)",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "MIT",
Expand All @@ -20,8 +20,8 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-shared": "1.1.32",
"@onekeyfe/hd-transport": "1.1.32",
"@onekeyfe/hd-shared": "1.1.34-alpha.0",
"@onekeyfe/hd-transport": "1.1.34-alpha.0",
"bytebuffer": "^5.0.1",
"usb": "^2.14.0"
}
Expand Down
Loading
Loading