@btc-vision/bitcoin 7.0.0-alpha.9 → 7.0.0-beta.0

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 (202) hide show
  1. package/README.md +22 -0
  2. package/benchmark-compare/BENCHMARK.md +144 -0
  3. package/benchmark-compare/compare.bench.ts +1024 -0
  4. package/benchmark-compare/harness.ts +220 -0
  5. package/benchmark-compare/package.json +18 -0
  6. package/browser/address.d.ts.map +1 -1
  7. package/browser/block.d.ts.map +1 -1
  8. package/browser/chunks/{psbt-parallel-BBFlkmiv.js → psbt-parallel-B-dfm5GZ.js} +2430 -2523
  9. package/browser/crypto-hashes.d.ts +4 -0
  10. package/browser/crypto-hashes.d.ts.map +1 -0
  11. package/browser/crypto-hashes.native.d.ts +4 -0
  12. package/browser/crypto-hashes.native.d.ts.map +1 -0
  13. package/browser/crypto.d.ts.map +1 -1
  14. package/browser/index.d.ts +2 -2
  15. package/browser/index.d.ts.map +1 -1
  16. package/browser/index.js +571 -547
  17. package/browser/io/base58check.d.ts +26 -0
  18. package/browser/io/base58check.d.ts.map +1 -0
  19. package/browser/io/base64.d.ts +8 -0
  20. package/browser/io/base64.d.ts.map +1 -1
  21. package/browser/io/index.d.ts +2 -1
  22. package/browser/io/index.d.ts.map +1 -1
  23. package/browser/io/utils.d.ts.map +1 -1
  24. package/browser/payments/bip341.d.ts.map +1 -1
  25. package/browser/payments/p2op.d.ts.map +1 -1
  26. package/browser/payments/p2pkh.d.ts.map +1 -1
  27. package/browser/payments/p2sh.d.ts.map +1 -1
  28. package/browser/payments/p2tr.d.ts.map +1 -1
  29. package/browser/payments/p2wpkh.d.ts.map +1 -1
  30. package/browser/psbt/PsbtCache.d.ts.map +1 -1
  31. package/browser/psbt/PsbtSigner.d.ts.map +1 -1
  32. package/browser/psbt/PsbtTransaction.d.ts +2 -2
  33. package/browser/psbt/PsbtTransaction.d.ts.map +1 -1
  34. package/browser/psbt/bip371.d.ts.map +1 -1
  35. package/browser/psbt.d.ts +1 -1
  36. package/browser/psbt.d.ts.map +1 -1
  37. package/browser/react-native-quick-crypto.d.ts +11 -0
  38. package/browser/script.d.ts.map +1 -1
  39. package/browser/transaction.d.ts.map +1 -1
  40. package/browser/workers/WorkerSigningPool.node.d.ts.map +1 -1
  41. package/browser/workers/WorkerSigningPool.sequential.d.ts.map +1 -1
  42. package/browser/workers/index.js +5 -5
  43. package/build/address.d.ts.map +1 -1
  44. package/build/address.js +19 -12
  45. package/build/address.js.map +1 -1
  46. package/build/bip66.js +4 -4
  47. package/build/bip66.js.map +1 -1
  48. package/build/block.d.ts.map +1 -1
  49. package/build/block.js +9 -2
  50. package/build/block.js.map +1 -1
  51. package/build/crypto-hashes.d.ts +4 -0
  52. package/build/crypto-hashes.d.ts.map +1 -0
  53. package/build/crypto-hashes.js +4 -0
  54. package/build/crypto-hashes.js.map +1 -0
  55. package/build/crypto-hashes.native.d.ts +4 -0
  56. package/build/crypto-hashes.native.d.ts.map +1 -0
  57. package/build/crypto-hashes.native.js +15 -0
  58. package/build/crypto-hashes.native.js.map +1 -0
  59. package/build/crypto.d.ts.map +1 -1
  60. package/build/crypto.js +1 -2
  61. package/build/crypto.js.map +1 -1
  62. package/build/env.js.map +1 -1
  63. package/build/index.d.ts +2 -2
  64. package/build/index.d.ts.map +1 -1
  65. package/build/index.js +1 -1
  66. package/build/index.js.map +1 -1
  67. package/build/io/BinaryReader.js +1 -1
  68. package/build/io/BinaryReader.js.map +1 -1
  69. package/build/io/base58check.d.ts +26 -0
  70. package/build/io/base58check.d.ts.map +1 -0
  71. package/build/io/base58check.js +32 -0
  72. package/build/io/base58check.js.map +1 -0
  73. package/build/io/base64.d.ts +8 -0
  74. package/build/io/base64.d.ts.map +1 -1
  75. package/build/io/base64.js +14 -0
  76. package/build/io/base64.js.map +1 -1
  77. package/build/io/hex.js +1 -1
  78. package/build/io/hex.js.map +1 -1
  79. package/build/io/index.d.ts +2 -1
  80. package/build/io/index.d.ts.map +1 -1
  81. package/build/io/index.js +4 -2
  82. package/build/io/index.js.map +1 -1
  83. package/build/io/utils.d.ts.map +1 -1
  84. package/build/io/utils.js +3 -4
  85. package/build/io/utils.js.map +1 -1
  86. package/build/merkle.js.map +1 -1
  87. package/build/payments/bip341.d.ts.map +1 -1
  88. package/build/payments/bip341.js +4 -3
  89. package/build/payments/bip341.js.map +1 -1
  90. package/build/payments/p2op.d.ts.map +1 -1
  91. package/build/payments/p2op.js +6 -4
  92. package/build/payments/p2op.js.map +1 -1
  93. package/build/payments/p2pkh.d.ts.map +1 -1
  94. package/build/payments/p2pkh.js +3 -4
  95. package/build/payments/p2pkh.js.map +1 -1
  96. package/build/payments/p2sh.d.ts.map +1 -1
  97. package/build/payments/p2sh.js +3 -4
  98. package/build/payments/p2sh.js.map +1 -1
  99. package/build/payments/p2tr.d.ts.map +1 -1
  100. package/build/payments/p2tr.js +13 -6
  101. package/build/payments/p2tr.js.map +1 -1
  102. package/build/payments/p2wpkh.d.ts.map +1 -1
  103. package/build/payments/p2wpkh.js +7 -5
  104. package/build/payments/p2wpkh.js.map +1 -1
  105. package/build/payments/p2wsh.js.map +1 -1
  106. package/build/psbt/PsbtCache.d.ts.map +1 -1
  107. package/build/psbt/PsbtCache.js +8 -4
  108. package/build/psbt/PsbtCache.js.map +1 -1
  109. package/build/psbt/PsbtFinalizer.js +14 -8
  110. package/build/psbt/PsbtFinalizer.js.map +1 -1
  111. package/build/psbt/PsbtSigner.d.ts.map +1 -1
  112. package/build/psbt/PsbtSigner.js +3 -2
  113. package/build/psbt/PsbtSigner.js.map +1 -1
  114. package/build/psbt/PsbtTransaction.d.ts +2 -2
  115. package/build/psbt/PsbtTransaction.d.ts.map +1 -1
  116. package/build/psbt/PsbtTransaction.js.map +1 -1
  117. package/build/psbt/bip371.d.ts.map +1 -1
  118. package/build/psbt/bip371.js +4 -3
  119. package/build/psbt/bip371.js.map +1 -1
  120. package/build/psbt/utils.js.map +1 -1
  121. package/build/psbt.d.ts +1 -1
  122. package/build/psbt.d.ts.map +1 -1
  123. package/build/psbt.js.map +1 -1
  124. package/build/push_data.js +1 -1
  125. package/build/push_data.js.map +1 -1
  126. package/build/script.d.ts.map +1 -1
  127. package/build/script.js +4 -3
  128. package/build/script.js.map +1 -1
  129. package/build/script_number.js +1 -1
  130. package/build/script_number.js.map +1 -1
  131. package/build/script_signature.js.map +1 -1
  132. package/build/transaction.d.ts.map +1 -1
  133. package/build/transaction.js +2 -1
  134. package/build/transaction.js.map +1 -1
  135. package/build/tsconfig.build.tsbuildinfo +1 -1
  136. package/build/types.js.map +1 -1
  137. package/build/workers/WorkerSigningPool.js.map +1 -1
  138. package/build/workers/WorkerSigningPool.node.d.ts.map +1 -1
  139. package/build/workers/WorkerSigningPool.node.js +25 -3
  140. package/build/workers/WorkerSigningPool.node.js.map +1 -1
  141. package/build/workers/WorkerSigningPool.sequential.d.ts.map +1 -1
  142. package/build/workers/WorkerSigningPool.sequential.js +2 -0
  143. package/build/workers/WorkerSigningPool.sequential.js.map +1 -1
  144. package/build/workers/psbt-parallel.js.map +1 -1
  145. package/package.json +7 -5
  146. package/src/address.ts +18 -13
  147. package/src/bip66.ts +18 -18
  148. package/src/block.ts +7 -2
  149. package/src/crypto-hashes.native.ts +18 -0
  150. package/src/crypto-hashes.ts +3 -0
  151. package/src/crypto.ts +1 -2
  152. package/src/env.ts +6 -6
  153. package/src/index.ts +3 -0
  154. package/src/io/BinaryReader.ts +1 -1
  155. package/src/io/base58check.ts +35 -0
  156. package/src/io/base64.ts +15 -0
  157. package/src/io/hex.ts +1 -1
  158. package/src/io/index.ts +5 -2
  159. package/src/io/utils.ts +6 -7
  160. package/src/merkle.ts +3 -3
  161. package/src/payments/bip341.ts +5 -4
  162. package/src/payments/p2op.ts +6 -4
  163. package/src/payments/p2pkh.ts +4 -5
  164. package/src/payments/p2sh.ts +4 -5
  165. package/src/payments/p2tr.ts +18 -11
  166. package/src/payments/p2wpkh.ts +7 -5
  167. package/src/payments/p2wsh.ts +1 -1
  168. package/src/psbt/PsbtCache.ts +14 -11
  169. package/src/psbt/PsbtFinalizer.ts +14 -8
  170. package/src/psbt/PsbtSigner.ts +4 -3
  171. package/src/psbt/PsbtTransaction.ts +2 -2
  172. package/src/psbt/bip371.ts +4 -3
  173. package/src/psbt/utils.ts +1 -1
  174. package/src/psbt.ts +10 -8
  175. package/src/push_data.ts +5 -5
  176. package/src/react-native-quick-crypto.d.ts +11 -0
  177. package/src/script.ts +5 -4
  178. package/src/script_number.ts +6 -6
  179. package/src/script_signature.ts +2 -2
  180. package/src/transaction.ts +14 -13
  181. package/src/types.ts +1 -1
  182. package/src/workers/WorkerSigningPool.node.ts +28 -4
  183. package/src/workers/WorkerSigningPool.sequential.ts +2 -1
  184. package/src/workers/WorkerSigningPool.ts +3 -3
  185. package/src/workers/psbt-parallel.ts +2 -2
  186. package/test/address.spec.ts +1 -0
  187. package/test/bitcoin.core.spec.ts +9 -2
  188. package/test/browser/psbt.spec.ts +54 -29
  189. package/test/browser/workers-signing.spec.ts +8 -8
  190. package/test/crypto.spec.ts +1 -1
  191. package/test/env.spec.ts +2 -2
  192. package/test/integration/_regtest.ts +2 -2
  193. package/test/integration/blocks.spec.ts +1 -1
  194. package/test/integration/csv.spec.ts +1 -1
  195. package/test/integration/payments.spec.ts +2 -2
  196. package/test/integration/taproot.spec.ts +3 -3
  197. package/test/integration/transactions.spec.ts +6 -5
  198. package/test/psbt.spec.ts +49 -25
  199. package/test/transaction.spec.ts +6 -3
  200. package/test/workers-pool.spec.ts +5 -5
  201. package/test/workers-signing.spec.ts +8 -8
  202. package/test/workers.spec.ts +3 -3
@@ -42,7 +42,7 @@ async function buildAndSign(
42
42
  psbt.signInput(0, keyPair);
43
43
  });
44
44
  } else if (depends.signature) {
45
- psbt.signInput(0, keyPairs[0]);
45
+ psbt.signInput(0, keyPairs[0]!);
46
46
  }
47
47
 
48
48
  return regtestUtils.broadcast(psbt.finalizeAllInputs().extractTransaction().toHex());
@@ -54,7 +54,7 @@ async function buildAndSign(
54
54
  const fn: any = (bitcoin.payments as any)[k];
55
55
 
56
56
  const base: any = {};
57
- if (depends.pubkey) base.pubkey = keyPairs[0].publicKey;
57
+ if (depends.pubkey) base.pubkey = keyPairs[0]!.publicKey;
58
58
  if (depends.pubkeys) base.pubkeys = keyPairs.map((x) => x.publicKey);
59
59
  if (depends.m) base.m = base.pubkeys.length;
60
60
 
@@ -508,9 +508,9 @@ describe('bitcoinjs-lib (transaction with taproot)', () => {
508
508
  psbt.addOutput({ value: BigInt(sendAmount) as Satoshi, address: address! });
509
509
 
510
510
  // random order for signers
511
- psbt.signInput(0, leafKeys[1]);
512
- psbt.signInput(0, leafKeys[2]);
513
- psbt.signInput(0, leafKeys[0]);
511
+ psbt.signInput(0, leafKeys[1]!);
512
+ psbt.signInput(0, leafKeys[2]!);
513
+ psbt.signInput(0, leafKeys[0]!);
514
514
 
515
515
  psbt.finalizeInput(0);
516
516
  const tx = psbt.extractTransaction();
@@ -2,7 +2,8 @@ import assert from 'assert';
2
2
  import { BIP32Factory } from '@btc-vision/bip32';
3
3
  import * as ecc from 'tiny-secp256k1';
4
4
  import { describe, it } from 'vitest';
5
- import type { MessageHash, PrivateKey, PublicKey, Satoshi, Signature } from '../../src/index.js';
5
+ import type { PrivateKey, PublicKey, Satoshi, Signature } from '../../src/index.js';
6
+ import type { MessageHash } from '../../src/types.js';
6
7
  import * as bitcoin from '../../src/index.js';
7
8
  import { compare, fromHex } from '../../src/index.js';
8
9
  import type { HDSigner } from '../../src/psbt/types.js';
@@ -600,13 +601,13 @@ describe('bitcoinjs-lib (transactions with psbt)', () => {
600
601
  function createPayment(_type: string, myKeys?: any[], network?: any): any {
601
602
  network = network || regtest;
602
603
  const splitType = _type.split('-').reverse();
603
- const isMultisig = splitType[0].slice(0, 4) === 'p2ms';
604
+ const isMultisig = splitType[0]!.slice(0, 4) === 'p2ms';
604
605
  const keys = myKeys || [];
605
606
  let m: number | undefined;
606
607
  if (isMultisig) {
607
- const match = splitType[0].match(/^p2ms\((\d+) of (\d+)\)$/);
608
- m = parseInt(match![1], 10);
609
- let n = parseInt(match![2], 10);
608
+ const match = splitType[0]!.match(/^p2ms\((\d+) of (\d+)\)$/);
609
+ m = parseInt(match![1]!, 10);
610
+ let n = parseInt(match![2]!, 10);
610
611
  if (keys.length > 0 && keys.length !== n) {
611
612
  throw new Error('Need n keys for multisig');
612
613
  }
package/test/psbt.spec.ts CHANGED
@@ -42,8 +42,8 @@ const initBuffers = (object: any): typeof preFixtures =>
42
42
  const result = regex.exec(value);
43
43
  if (!result) return value;
44
44
 
45
- const data = result[1];
46
- const encoding = result[2];
45
+ const data = result[1] as string;
46
+ const encoding = result[2] as string;
47
47
 
48
48
  return Buffer.from(data, encoding as BufferEncoding);
49
49
  });
@@ -55,7 +55,7 @@ const upperCaseFirstLetter = (str: string): string => str.replace(/^./, (s) => s
55
55
  const toAsyncSigner = (signer: Signer): SignerAsync => {
56
56
  return {
57
57
  publicKey: signer.publicKey,
58
- sign: (hash: Bytes32, lowerR: boolean | undefined): Promise<Signature> => {
58
+ sign: (hash: MessageHash, lowerR: boolean | undefined): Promise<Signature> => {
59
59
  return new Promise((resolve, rejects): void => {
60
60
  setTimeout(() => {
61
61
  try {
@@ -69,10 +69,10 @@ const toAsyncSigner = (signer: Signer): SignerAsync => {
69
69
  },
70
70
  };
71
71
  };
72
- const failedAsyncSigner = (publicKey: Buffer): SignerAsync => {
72
+ const failedAsyncSigner = (publicKey: Uint8Array): SignerAsync => {
73
73
  return <SignerAsync>{
74
74
  publicKey: publicKey as unknown as PublicKey,
75
- sign: (__: Bytes32): Promise<Signature> => {
75
+ sign: (__: MessageHash): Promise<Signature> => {
76
76
  return new Promise((_, reject): void => {
77
77
  setTimeout(() => {
78
78
  reject(new Error('sign failed'));
@@ -178,14 +178,17 @@ describe(`Psbt`, () => {
178
178
  fixtures.bip174.combiner.forEach((f) => {
179
179
  it('Combines two PSBTs to the expected result', () => {
180
180
  const psbts = f.psbts.map((psbt) => Psbt.fromBase64(psbt));
181
+ const psbt0 = psbts[0];
182
+ const psbt1 = psbts[1];
183
+ assert(psbt0 && psbt1);
181
184
 
182
- psbts[0].combine(psbts[1]);
185
+ psbt0.combine(psbt1);
183
186
 
184
187
  // Produces a different Base64 string due to implementation specific key-value ordering.
185
188
  // That means this test will fail:
186
189
  // assert.strictEqual(psbts[0].toBase64(), f.result)
187
190
  // Compare the serialized PSBT hex instead - this is deterministic
188
- assert.strictEqual(psbts[0].toHex(), Psbt.fromBase64(f.result).toHex());
191
+ assert.strictEqual(psbt0.toHex(), Psbt.fromBase64(f.result).toHex());
189
192
  });
190
193
  });
191
194
 
@@ -212,8 +215,10 @@ describe(`Psbt`, () => {
212
215
  assert.strictEqual(transaction1, f.transaction);
213
216
 
214
217
  const psbt3 = Psbt.fromBase64(f.psbt);
215
- delete psbt3.data.inputs[0].finalScriptSig;
216
- delete psbt3.data.inputs[0].finalScriptWitness;
218
+ const psbt3Input0 = psbt3.data.inputs[0];
219
+ assert(psbt3Input0);
220
+ delete psbt3Input0.finalScriptSig;
221
+ delete psbt3Input0.finalScriptWitness;
217
222
  assert.throws(() => {
218
223
  psbt3.extractTransaction();
219
224
  }, new RegExp('Not finalized'));
@@ -691,9 +696,13 @@ describe(`Psbt`, () => {
691
696
  });
692
697
 
693
698
  assert.strictEqual(psbt.inputCount, 1);
694
- assert.strictEqual(psbt.txInputs[0].sequence, 0xffffffff);
699
+ const txIn0 = psbt.txInputs[0];
700
+ assert(txIn0);
701
+ assert.strictEqual(txIn0.sequence, 0xffffffff);
695
702
  psbt.setInputSequence(0, 0);
696
- assert.strictEqual(psbt.txInputs[0].sequence, 0);
703
+ const txIn0After = psbt.txInputs[0];
704
+ assert(txIn0After);
705
+ assert.strictEqual(txIn0After.sequence, 0);
697
706
  });
698
707
 
699
708
  it('throws if input index is too high', () => {
@@ -847,6 +856,9 @@ describe(`Psbt`, () => {
847
856
  index: 0,
848
857
  });
849
858
 
859
+ const input0 = psbt.data.inputs[0];
860
+ assert(input0);
861
+
850
862
  assert.throws(() => {
851
863
  psbt.inputHasPubkey(0, testPubkey);
852
864
  }, new RegExp("Can't find pubkey in input without Utxo data"));
@@ -856,7 +868,7 @@ describe(`Psbt`, () => {
856
868
  value: 1337n as Satoshi,
857
869
  script: payments.p2sh({
858
870
  redeem: { output: Buffer.from([0x51]) as unknown as Script },
859
- }).output!,
871
+ }).output as Script,
860
872
  },
861
873
  });
862
874
 
@@ -864,14 +876,14 @@ describe(`Psbt`, () => {
864
876
  psbt.inputHasPubkey(0, testPubkey);
865
877
  }, new RegExp('scriptPubkey is P2SH but redeemScript missing'));
866
878
 
867
- delete psbt.data.inputs[0].witnessUtxo;
879
+ delete input0.witnessUtxo;
868
880
 
869
881
  psbt.updateInput(0, {
870
882
  witnessUtxo: {
871
883
  value: 1337n as Satoshi,
872
884
  script: payments.p2wsh({
873
885
  redeem: { output: Buffer.from([0x51]) as unknown as Script },
874
- }).output!,
886
+ }).output as Script,
875
887
  },
876
888
  });
877
889
 
@@ -879,7 +891,7 @@ describe(`Psbt`, () => {
879
891
  psbt.inputHasPubkey(0, testPubkey);
880
892
  }, new RegExp('scriptPubkey or redeemScript is P2WSH but witnessScript missing'));
881
893
 
882
- delete psbt.data.inputs[0].witnessUtxo;
894
+ delete input0.witnessUtxo;
883
895
 
884
896
  // Create a script that contains the test pubkey
885
897
  const scriptWithPubkey = Buffer.concat([
@@ -1011,7 +1023,9 @@ describe(`Psbt`, () => {
1011
1023
  psbt3.outputHasPubkey(0, testPubkey);
1012
1024
  }, new RegExp('scriptPubkey or redeemScript is P2WSH but witnessScript missing'));
1013
1025
 
1014
- delete psbt3.data.outputs[0].redeemScript;
1026
+ const psbt3Output0 = psbt3.data.outputs[0];
1027
+ assert(psbt3Output0);
1028
+ delete psbt3Output0.redeemScript;
1015
1029
 
1016
1030
  psbt.updateOutput(0, {
1017
1031
  witnessScript: scriptWithPubkey,
@@ -1046,7 +1060,9 @@ describe(`Psbt`, () => {
1046
1060
  assert.strictEqual(clone.toBase64(), notAClone.toBase64());
1047
1061
  assert.strictEqual(psbt.toBase64(), notAClone.toBase64());
1048
1062
  // Mutate data layer to prove clone is independent
1049
- psbt.data.inputs[0].partialSig = [];
1063
+ const cloneInput0 = psbt.data.inputs[0];
1064
+ assert(cloneInput0);
1065
+ cloneInput0.partialSig = [];
1050
1066
  assert.notStrictEqual(clone.toBase64(), psbt.toBase64());
1051
1067
  assert.notStrictEqual(clone.toBase64(), notAClone.toBase64());
1052
1068
  assert.strictEqual(psbt.toBase64(), notAClone.toBase64());
@@ -1414,17 +1430,20 @@ describe(`Psbt`, () => {
1414
1430
  const psbt = Psbt.fromBase64(f.psbt);
1415
1431
  const index = f.inputIndex;
1416
1432
 
1433
+ const cacheInput = psbt.data.inputs[index];
1434
+ assert(cacheInput);
1435
+
1417
1436
  // nonWitnessUtxo is not set before updateInput
1418
- assert.strictEqual(psbt.data.inputs[index].nonWitnessUtxo, undefined);
1437
+ assert.strictEqual(cacheInput.nonWitnessUtxo, undefined);
1419
1438
 
1420
1439
  // After updateInput, the nonWitnessUtxo is stored on the input
1421
1440
  psbt.updateInput(index, {
1422
1441
  nonWitnessUtxo: f.nonWitnessUtxo as any,
1423
1442
  });
1424
- assert.ok(psbt.data.inputs[index].nonWitnessUtxo);
1443
+ assert.ok(cacheInput.nonWitnessUtxo);
1425
1444
  assert.ok(
1426
1445
  equals(
1427
- psbt.data.inputs[index].nonWitnessUtxo!,
1446
+ cacheInput.nonWitnessUtxo as Uint8Array,
1428
1447
  f.nonWitnessUtxo as any,
1429
1448
  ),
1430
1449
  );
@@ -1440,10 +1459,11 @@ describe(`Psbt`, () => {
1440
1459
  });
1441
1460
 
1442
1461
  const input = psbt.data.inputs[index];
1462
+ assert(input);
1443
1463
  const desc = Object.getOwnPropertyDescriptor(input, 'nonWitnessUtxo');
1444
1464
  assert.ok(desc, 'property should exist');
1445
- assert.strictEqual(desc!.get, undefined, 'should not have a getter');
1446
- assert.strictEqual(desc!.set, undefined, 'should not have a setter');
1465
+ assert.strictEqual(desc.get, undefined, 'should not have a getter');
1466
+ assert.strictEqual(desc.set, undefined, 'should not have a setter');
1447
1467
  });
1448
1468
  });
1449
1469
 
@@ -1473,17 +1493,19 @@ describe(`Psbt`, () => {
1473
1493
  psbt.addInput({ hash, index });
1474
1494
 
1475
1495
  const input = psbt.txInputs[0];
1496
+ assert(input);
1476
1497
  const originalHash = new Uint8Array(input.hash);
1477
1498
  const originalIndex = input.index;
1478
1499
  const originalSequence = input.sequence;
1479
1500
 
1480
1501
  // Mutate the returned clone
1481
1502
  input.hash[0] = 123;
1482
- input.index = 123;
1483
- input.sequence = 123;
1503
+ (input as { index: number }).index = 123;
1504
+ (input as { sequence: number }).sequence = 123;
1484
1505
 
1485
1506
  // Internal state should be unchanged
1486
1507
  const fresh = psbt.txInputs[0];
1508
+ assert(fresh);
1487
1509
  assert.ok(equals(fresh.hash, originalHash));
1488
1510
  assert.strictEqual(fresh.index, originalIndex);
1489
1511
  assert.strictEqual(fresh.sequence, originalSequence);
@@ -1496,6 +1518,7 @@ describe(`Psbt`, () => {
1496
1518
  psbt.addOutput({ address, value });
1497
1519
 
1498
1520
  const output = psbt.txOutputs[0];
1521
+ assert(output);
1499
1522
  assert.strictEqual(output.address, address);
1500
1523
 
1501
1524
  const originalScript = new Uint8Array(output.script);
@@ -1503,10 +1526,11 @@ describe(`Psbt`, () => {
1503
1526
 
1504
1527
  // Mutate the returned clone
1505
1528
  output.script[0] = 123;
1506
- output.value = 123n;
1529
+ (output as { value: bigint }).value = 123n;
1507
1530
 
1508
1531
  // Internal state should be unchanged
1509
1532
  const fresh = psbt.txOutputs[0];
1533
+ assert(fresh);
1510
1534
  assert.ok(equals(fresh.script, originalScript));
1511
1535
  assert.strictEqual(fresh.value, originalValue);
1512
1536
  });
@@ -104,6 +104,7 @@ describe('Transaction', () => {
104
104
 
105
105
  it('accepts target Buffer and offset parameters', () => {
106
106
  const f = fixtures.valid[0];
107
+ assert(f !== undefined);
107
108
  const actual = fromRaw(f.raw);
108
109
  const byteLength = actual.byteLength();
109
110
 
@@ -169,9 +170,11 @@ describe('Transaction', () => {
169
170
  const tx = new Transaction();
170
171
  tx.addInput(prevTxHash, 0);
171
172
 
172
- assert.strictEqual(tx.ins[0].script.length, 0);
173
- assert.strictEqual(tx.ins[0].witness.length, 0);
174
- assert.strictEqual(tx.ins[0].sequence, 0xffffffff);
173
+ const firstIn = tx.ins[0];
174
+ assert(firstIn !== undefined);
175
+ assert.strictEqual(firstIn.script.length, 0);
176
+ assert.strictEqual(firstIn.witness.length, 0);
177
+ assert.strictEqual(firstIn.sequence, 0xffffffff);
175
178
  });
176
179
 
177
180
  fixtures.invalid.addInput.forEach((f) => {
@@ -125,7 +125,7 @@ class MockWorker {
125
125
 
126
126
  // Mock Worker that fails signing
127
127
  class MockFailingWorker extends MockWorker {
128
- postMessage(data: unknown): void {
128
+ override postMessage(data: unknown): void {
129
129
  if ((data as { type: string }).type === 'signBatch') {
130
130
  setTimeout(() => {
131
131
  const batchMsg = data as {
@@ -161,7 +161,7 @@ class MockFailingWorker extends MockWorker {
161
161
 
162
162
  // Mock Worker that times out (never responds)
163
163
  class MockTimeoutWorker extends MockWorker {
164
- postMessage(data: unknown): void {
164
+ override postMessage(data: unknown): void {
165
165
  if ((data as { type: string }).type === 'signBatch') {
166
166
  // Never respond - simulates timeout
167
167
  // Still zero the key for security
@@ -188,7 +188,7 @@ beforeEach(() => {
188
188
  };
189
189
  }
190
190
 
191
- (globalThis.URL as any).createObjectURL = vi.fn((blob: Blob) => {
191
+ (globalThis.URL as any).createObjectURL = vi.fn((_blob: Blob) => {
192
192
  const url = `blob:mock-${blobUrlCounter++}`;
193
193
  mockBlobUrls.push(url);
194
194
  return url;
@@ -634,7 +634,7 @@ describe('WorkerSigningPool', () => {
634
634
  it('should clean up with await using', async () => {
635
635
  WorkerSigningPool.resetInstance();
636
636
 
637
- let poolRef: InstanceType<typeof WorkerSigningPool> | undefined;
637
+ let poolRef: import("../src/workers/WorkerSigningPool.js").WorkerSigningPool | undefined;
638
638
 
639
639
  // Scoped block — pool is disposed when the block exits
640
640
  {
@@ -732,7 +732,7 @@ describe('WorkerSigningPool Error Handling', () => {
732
732
  vi.resetModules();
733
733
 
734
734
  class MixedWorker extends MockWorker {
735
- postMessage(data: unknown): void {
735
+ override postMessage(data: unknown): void {
736
736
  if ((data as { type: string }).type === 'signBatch') {
737
737
  setTimeout(() => {
738
738
  const batchMsg = data as {
@@ -96,7 +96,7 @@ describe('Worker Signing - Signature Verification', () => {
96
96
 
97
97
  // Modify the hash
98
98
  const modifiedHash = Buffer.from(hash);
99
- modifiedHash[0] ^= 0xff;
99
+ modifiedHash[0]! ^= 0xff;
100
100
 
101
101
  const isValid = ecc.verify(modifiedHash, keyPair.publicKey, signature);
102
102
  expect(isValid).toBe(false);
@@ -109,7 +109,7 @@ describe('Worker Signing - Signature Verification', () => {
109
109
  const signature = Buffer.from(ecc.sign(hash, keyPair.privateKey!));
110
110
 
111
111
  // Corrupt the signature
112
- signature[0] ^= 0xff;
112
+ signature[0]! ^= 0xff;
113
113
 
114
114
  const isValid = ecc.verify(hash, keyPair.publicKey, signature);
115
115
  expect(isValid).toBe(false);
@@ -167,7 +167,7 @@ describe('Worker Signing - Signature Verification', () => {
167
167
  const signature = ecc.signSchnorr(hash, keyPair.privateKey!);
168
168
 
169
169
  const modifiedHash = Buffer.from(hash);
170
- modifiedHash[0] ^= 0xff;
170
+ modifiedHash[0]! ^= 0xff;
171
171
 
172
172
  const xOnlyPubkey = toXOnly(keyPair.publicKey);
173
173
  const isValid = ecc.verifySchnorr(modifiedHash, xOnlyPubkey, signature);
@@ -179,7 +179,7 @@ describe('Worker Signing - Signature Verification', () => {
179
179
  const hash = randomBytes(32);
180
180
 
181
181
  const signature = Buffer.from(ecc.signSchnorr(hash, keyPair.privateKey!));
182
- signature[0] ^= 0xff;
182
+ signature[0]! ^= 0xff;
183
183
 
184
184
  const xOnlyPubkey = toXOnly(keyPair.publicKey);
185
185
  const isValid = ecc.verifySchnorr(hash, xOnlyPubkey, signature);
@@ -190,7 +190,7 @@ describe('Worker Signing - Signature Verification', () => {
190
190
  describe('WorkerEccLib Interface Compatibility', () => {
191
191
  it('should create WorkerEccLib compatible wrapper', () => {
192
192
  const eccLib: WorkerEccLib = {
193
- sign: (hash: Uint8Array, privateKey: Uint8Array, lowR?: boolean): Uint8Array => {
193
+ sign: (hash: Uint8Array, privateKey: Uint8Array, _lowR?: boolean): Uint8Array => {
194
194
  return ecc.sign(hash, privateKey, undefined);
195
195
  },
196
196
  signSchnorr: (hash: Uint8Array, privateKey: Uint8Array): Uint8Array => {
@@ -284,7 +284,7 @@ describe('Worker Signing - Signature Verification', () => {
284
284
 
285
285
  // All signatures should be valid
286
286
  for (let i = 0; i < hashes.length; i++) {
287
- expect(ecc.verify(hashes[i], keyPair.publicKey, signatures[i])).toBe(true);
287
+ expect(ecc.verify(hashes[i]!, keyPair.publicKey, signatures[i]!)).toBe(true);
288
288
  }
289
289
  });
290
290
 
@@ -354,7 +354,7 @@ describe('Worker Signing - Signature Verification', () => {
354
354
  }
355
355
  });
356
356
 
357
- const duration = Date.now() - startTime;
357
+ void (Date.now() - startTime);
358
358
 
359
359
  // Verify all signatures
360
360
  let validCount = 0;
@@ -442,7 +442,7 @@ describe('Worker Signing - Signature Verification', () => {
442
442
  let signature: Uint8Array;
443
443
 
444
444
  try {
445
- if (signatureType === SignatureType.Schnorr) {
445
+ if ((signatureType as SignatureType) === SignatureType.Schnorr) {
446
446
  if (!eccLib.signSchnorr) {
447
447
  throw new Error('ECC library does not support Schnorr');
448
448
  }
@@ -306,7 +306,7 @@ describe('ParallelSignerKeyPair Interface', () => {
306
306
  const keyPair: ParallelSignerKeyPair = {
307
307
  publicKey,
308
308
  getPrivateKey: () => privateKey,
309
- sign: (hash: Uint8Array, _lowR?: boolean) => new Uint8Array(64), // DER signature
309
+ sign: (_hash: Uint8Array, _lowR?: boolean) => new Uint8Array(64), // DER signature
310
310
  };
311
311
 
312
312
  expect(keyPair.sign).toBeDefined();
@@ -320,7 +320,7 @@ describe('ParallelSignerKeyPair Interface', () => {
320
320
  const keyPair: ParallelSignerKeyPair = {
321
321
  publicKey,
322
322
  getPrivateKey: () => privateKey,
323
- signSchnorr: (hash: Uint8Array) => new Uint8Array(64), // Schnorr signature
323
+ signSchnorr: (_hash: Uint8Array) => new Uint8Array(64), // Schnorr signature
324
324
  };
325
325
 
326
326
  expect(keyPair.signSchnorr).toBeDefined();
@@ -1092,7 +1092,7 @@ describe('Batch Signing Scenarios', () => {
1092
1092
  ];
1093
1093
 
1094
1094
  expect(tasks.length).toBe(1);
1095
- expect(tasks[0].inputIndex).toBe(0);
1095
+ expect(tasks[0]!.inputIndex).toBe(0);
1096
1096
  });
1097
1097
 
1098
1098
  it('should handle multi-input ECDSA signing', () => {