@btc-vision/bitcoin 6.3.6 → 6.4.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 (71) hide show
  1. package/.mocharc.json +13 -0
  2. package/browser/address.d.ts +1 -1
  3. package/browser/index.js +1 -1
  4. package/browser/index.js.LICENSE.txt +3 -3
  5. package/browser/networks.d.ts +1 -0
  6. package/build/address.d.ts +1 -1
  7. package/build/address.js +12 -5
  8. package/build/block.js +2 -2
  9. package/build/bufferutils.js +5 -5
  10. package/build/networks.d.ts +1 -0
  11. package/build/networks.js +11 -0
  12. package/build/psbt/psbtutils.js +2 -2
  13. package/build/psbt.js +3 -7
  14. package/package.json +26 -26
  15. package/src/address.ts +20 -6
  16. package/src/block.ts +233 -233
  17. package/src/bufferutils.ts +188 -180
  18. package/src/index.ts +86 -86
  19. package/src/networks.ts +12 -0
  20. package/src/psbt/bip371.ts +441 -441
  21. package/src/psbt/psbtutils.ts +4 -3
  22. package/src/psbt.ts +2187 -2187
  23. package/test/address.spec.ts +155 -177
  24. package/test/bitcoin.core.spec.ts +212 -234
  25. package/test/block.spec.ts +171 -194
  26. package/test/bufferutils.spec.ts +450 -513
  27. package/test/crypto.spec.ts +49 -55
  28. package/test/fixtures/address.json +3 -3
  29. package/test/integration/addresses.spec.ts +142 -154
  30. package/test/integration/bip32.spec.ts +130 -151
  31. package/test/integration/blocks.spec.ts +28 -28
  32. package/test/integration/cltv.spec.ts +241 -283
  33. package/test/integration/csv.spec.ts +452 -527
  34. package/test/integration/payments.spec.ts +110 -135
  35. package/test/integration/taproot.spec.ts +663 -707
  36. package/test/integration/transactions.spec.ts +668 -769
  37. package/test/payments.spec.ts +114 -125
  38. package/test/payments.utils.ts +165 -208
  39. package/test/psbt.spec.ts +1285 -1414
  40. package/test/script.spec.ts +186 -210
  41. package/test/script_number.spec.ts +26 -29
  42. package/test/script_signature.spec.ts +66 -66
  43. package/test/transaction.spec.ts +337 -387
  44. package/test/ts-node-register.js +7 -5
  45. package/test/tsconfig.json +4 -1
  46. package/test/types.spec.ts +53 -58
  47. package/.nyc_output/6368a5b2-daa5-4821-8ed0-b742d6fc7eab.json +0 -1
  48. package/.nyc_output/processinfo/6368a5b2-daa5-4821-8ed0-b742d6fc7eab.json +0 -1
  49. package/.nyc_output/processinfo/index.json +0 -1
  50. package/test/address.spec.js +0 -124
  51. package/test/bitcoin.core.spec.js +0 -170
  52. package/test/block.spec.js +0 -141
  53. package/test/bufferutils.spec.js +0 -427
  54. package/test/crypto.spec.js +0 -41
  55. package/test/integration/_regtest.js +0 -7
  56. package/test/integration/addresses.spec.js +0 -116
  57. package/test/integration/bip32.spec.js +0 -85
  58. package/test/integration/blocks.spec.js +0 -26
  59. package/test/integration/cltv.spec.js +0 -199
  60. package/test/integration/csv.spec.js +0 -362
  61. package/test/integration/payments.spec.js +0 -98
  62. package/test/integration/taproot.spec.js +0 -532
  63. package/test/integration/transactions.spec.js +0 -561
  64. package/test/payments.spec.js +0 -97
  65. package/test/payments.utils.js +0 -190
  66. package/test/psbt.spec.js +0 -1044
  67. package/test/script.spec.js +0 -151
  68. package/test/script_number.spec.js +0 -24
  69. package/test/script_signature.spec.js +0 -52
  70. package/test/transaction.spec.js +0 -269
  71. package/test/types.spec.js +0 -46
@@ -1,5 +1,7 @@
1
- // This file is required to run mocha tests on the TS files directly
2
-
3
- require('ts-node').register({
4
- project: 'test/tsconfig.json',
5
- });
1
+ // This file is required to run mocha tests on the TS files directly
2
+
3
+ import { register } from 'ts-node';
4
+
5
+ register({
6
+ project: 'test/tsconfig.json',
7
+ });
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ESNext",
4
- "module": "commonjs",
4
+ "module": "esnext",
5
+ "moduleResolution": "nodenext",
5
6
  "outDir": "../",
6
7
  "declaration": false,
8
+ "allowSyntheticDefaultImports": true,
7
9
  "rootDir": "../",
8
10
  "rootDirs": [
9
11
  "../src",
@@ -16,6 +18,7 @@
16
18
  "lib": [
17
19
  "ES2021"
18
20
  ],
21
+ "resolvePackageJsonImports": true,
19
22
  "allowJs": false,
20
23
  "resolveJsonModule": true,
21
24
  "strict": true,
@@ -1,58 +1,53 @@
1
- import * as assert from 'assert';
2
- import { describe, it } from 'mocha';
3
- import * as types from '../src/types';
4
-
5
- const typeforce = require('typeforce');
6
-
7
- describe('types', () => {
8
- describe('Buffer Hash160/Hash256', () => {
9
- const buffer20byte = Buffer.alloc(20);
10
- const buffer32byte = Buffer.alloc(32);
11
-
12
- it('return true for valid size', () => {
13
- assert(types.Hash160bit(buffer20byte));
14
- assert(types.Hash256bit(buffer32byte));
15
- });
16
-
17
- it('return true for oneOf', () => {
18
- assert.doesNotThrow(() => {
19
- typeforce(
20
- types.oneOf(types.Hash160bit, types.Hash256bit),
21
- buffer32byte,
22
- );
23
- });
24
-
25
- assert.doesNotThrow(() => {
26
- typeforce(
27
- types.oneOf(types.Hash256bit, types.Hash160bit),
28
- buffer32byte,
29
- );
30
- });
31
- });
32
-
33
- it('throws for invalid size', () => {
34
- assert.throws(() => {
35
- types.Hash160bit(buffer32byte);
36
- }, /Expected Buffer\(Length: 20\), got Buffer\(Length: 32\)/);
37
-
38
- assert.throws(() => {
39
- types.Hash256bit(buffer20byte);
40
- }, /Expected Buffer\(Length: 32\), got Buffer\(Length: 20\)/);
41
- });
42
- });
43
-
44
- describe('Satoshi', () => {
45
- [
46
- { value: -1, result: false },
47
- { value: 0, result: true },
48
- { value: 1, result: true },
49
- { value: 20999999 * 1e8, result: true },
50
- { value: 21000000 * 1e8, result: true },
51
- { value: 21000001 * 1e8, result: false },
52
- ].forEach(f => {
53
- it('returns ' + f.result + ' for valid for ' + f.value, () => {
54
- assert.strictEqual(types.Satoshi(f.value), f.result);
55
- });
56
- });
57
- });
58
- });
1
+ import assert from 'assert';
2
+ import { describe, it } from 'mocha';
3
+ import * as types from '../src/types.js';
4
+
5
+ // @ts-ignore
6
+ import typeforce from 'typeforce';
7
+
8
+ describe('types', () => {
9
+ describe('Buffer Hash160/Hash256', () => {
10
+ const buffer20byte = Buffer.alloc(20);
11
+ const buffer32byte = Buffer.alloc(32);
12
+
13
+ it('return true for valid size', () => {
14
+ assert(types.Hash160bit(buffer20byte));
15
+ assert(types.Hash256bit(buffer32byte));
16
+ });
17
+
18
+ it('return true for oneOf', () => {
19
+ assert.doesNotThrow(() => {
20
+ typeforce(types.oneOf(types.Hash160bit, types.Hash256bit), buffer32byte);
21
+ });
22
+
23
+ assert.doesNotThrow(() => {
24
+ typeforce(types.oneOf(types.Hash256bit, types.Hash160bit), buffer32byte);
25
+ });
26
+ });
27
+
28
+ it('throws for invalid size', () => {
29
+ assert.throws(() => {
30
+ types.Hash160bit(buffer32byte);
31
+ }, /Expected Buffer\(Length: 20\), got Buffer\(Length: 32\)/);
32
+
33
+ assert.throws(() => {
34
+ types.Hash256bit(buffer20byte);
35
+ }, /Expected Buffer\(Length: 32\), got Buffer\(Length: 20\)/);
36
+ });
37
+ });
38
+
39
+ describe('Satoshi', () => {
40
+ [
41
+ { value: -1, result: false },
42
+ { value: 0, result: true },
43
+ { value: 1, result: true },
44
+ { value: 20999999 * 1e8, result: true },
45
+ { value: 21000000 * 1e8, result: true },
46
+ { value: 21000001 * 1e8, result: false },
47
+ ].forEach((f) => {
48
+ it('returns ' + f.result + ' for valid for ' + f.value, () => {
49
+ assert.strictEqual(types.Satoshi(f.value), f.result);
50
+ });
51
+ });
52
+ });
53
+ });