@onekeyfe/hd-core 1.1.32-alpha.4 → 1.1.32

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.
@@ -1 +1 @@
1
- {"version":3,"file":"TransferSerialize.d.ts","sourceRoot":"","sources":["../../../../src/api/kaspa/helpers/TransferSerialize.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAGV,0BAA0B,EAC3B,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,QAAQ,WAEvB;AAED,wBAAgB,gBAAgB,WAE/B;AAqGD,wBAAgB,SAAS,CAAC,WAAW,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM;;;EA0BrF"}
1
+ {"version":3,"file":"TransferSerialize.d.ts","sourceRoot":"","sources":["../../../../src/api/kaspa/helpers/TransferSerialize.ts"],"names":[],"mappings":";AAMA,OAAO,KAAK,EAGV,0BAA0B,EAC3B,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,QAAQ,WAEvB;AAED,wBAAgB,gBAAgB,WAE/B;AA2GD,wBAAgB,SAAS,CAAC,WAAW,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM;;;EAgCrF"}
package/dist/index.js CHANGED
@@ -38598,10 +38598,12 @@ function getSigOpCountsHash(transaction, sighashType) {
38598
38598
  return hashWriter.finalize();
38599
38599
  }
38600
38600
  function hashTxOut(hashWriter, output) {
38601
- var _a;
38602
38601
  hashWriter.writeUInt64LE(output.satoshis);
38603
38602
  hashWriter.writeUInt16LE(0);
38604
- hashWriter.writeVarBytes(Buffer.from((_a = output.script) !== null && _a !== void 0 ? _a : '', 'hex'));
38603
+ if (output.script === undefined) {
38604
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Kaspa legacy sighash requires output.script');
38605
+ }
38606
+ hashWriter.writeVarBytes(Buffer.from(output.script, 'hex'));
38605
38607
  }
38606
38608
  function getOutputsHash(transaction, inputNumber, sighashType) {
38607
38609
  if (isSighashNone(sighashType)) {
@@ -38628,6 +38630,9 @@ function serialize(transaction, inputNumber) {
38628
38630
  const input = transaction.inputs[inputNumber];
38629
38631
  hashOutpoint(hashWriter, input);
38630
38632
  hashWriter.writeUInt16LE(0);
38633
+ if (input.output.script === undefined) {
38634
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Kaspa legacy sighash requires input.output.script');
38635
+ }
38631
38636
  hashWriter.writeVarBytes(Buffer.from(input.output.script, 'hex'));
38632
38637
  hashWriter.writeUInt64LE(input.output.satoshis);
38633
38638
  hashWriter.writeUInt64LE(input.sequenceNumber);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.1.32-alpha.4",
3
+ "version": "1.1.32",
4
4
  "description": "Core processes and APIs for communicating with OneKey hardware devices.",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-shared": "1.1.32-alpha.4",
29
- "@onekeyfe/hd-transport": "1.1.32-alpha.4",
28
+ "@onekeyfe/hd-shared": "1.1.32",
29
+ "@onekeyfe/hd-transport": "1.1.32",
30
30
  "axios": "1.15.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -44,5 +44,5 @@
44
44
  "@types/w3c-web-usb": "^1.0.10",
45
45
  "@types/web-bluetooth": "^0.0.21"
46
46
  },
47
- "gitHead": "fc3bd904e2d35e9185d34c11460b53d558644009"
47
+ "gitHead": "d0640617adaa6769ae3954b9d618dcd682bef38a"
48
48
  }
@@ -1,4 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
+ import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
3
+
2
4
  import { SignatureType } from './SignatureType';
3
5
  import { HashWriter } from './HashWriter';
4
6
 
@@ -76,7 +78,13 @@ function getSigOpCountsHash(transaction: KaspaSignTransactionParams, sighashType
76
78
  function hashTxOut(hashWriter: HashWriter, output: KaspaSignOutputParams) {
77
79
  hashWriter.writeUInt64LE(output.satoshis);
78
80
  hashWriter.writeUInt16LE(0); // TODO: USE REAL SCRIPT VERSION
79
- hashWriter.writeVarBytes(Buffer.from(output.script ?? '', 'hex'));
81
+ if (output.script === undefined) {
82
+ throw ERRORS.TypedError(
83
+ HardwareErrorCode.CallMethodInvalidParameter,
84
+ 'Kaspa legacy sighash requires output.script'
85
+ );
86
+ }
87
+ hashWriter.writeVarBytes(Buffer.from(output.script, 'hex'));
80
88
  }
81
89
 
82
90
  function getOutputsHash(
@@ -126,7 +134,13 @@ export function serialize(transaction: KaspaSignTransactionParams, inputNumber:
126
134
  const input = transaction.inputs[inputNumber];
127
135
  hashOutpoint(hashWriter, input);
128
136
  hashWriter.writeUInt16LE(0); // TODO: USE REAL SCRIPT VERSION
129
- hashWriter.writeVarBytes(Buffer.from(input.output.script!, 'hex'));
137
+ if (input.output.script === undefined) {
138
+ throw ERRORS.TypedError(
139
+ HardwareErrorCode.CallMethodInvalidParameter,
140
+ 'Kaspa legacy sighash requires input.output.script'
141
+ );
142
+ }
143
+ hashWriter.writeVarBytes(Buffer.from(input.output.script, 'hex'));
130
144
  hashWriter.writeUInt64LE(input.output.satoshis);
131
145
  hashWriter.writeUInt64LE(input.sequenceNumber);
132
146
  hashWriter.writeUInt8(transaction.sigOpCount ?? 1); // sigOpCount