@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.
- package/.mocharc.json +13 -0
- package/browser/address.d.ts +1 -1
- package/browser/index.js +1 -1
- package/browser/index.js.LICENSE.txt +3 -3
- package/browser/networks.d.ts +1 -0
- package/build/address.d.ts +1 -1
- package/build/address.js +12 -5
- package/build/block.js +2 -2
- package/build/bufferutils.js +5 -5
- package/build/networks.d.ts +1 -0
- package/build/networks.js +11 -0
- package/build/psbt/psbtutils.js +2 -2
- package/build/psbt.js +3 -7
- package/package.json +26 -26
- package/src/address.ts +20 -6
- package/src/block.ts +233 -233
- package/src/bufferutils.ts +188 -180
- package/src/index.ts +86 -86
- package/src/networks.ts +12 -0
- package/src/psbt/bip371.ts +441 -441
- package/src/psbt/psbtutils.ts +4 -3
- package/src/psbt.ts +2187 -2187
- package/test/address.spec.ts +155 -177
- package/test/bitcoin.core.spec.ts +212 -234
- package/test/block.spec.ts +171 -194
- package/test/bufferutils.spec.ts +450 -513
- package/test/crypto.spec.ts +49 -55
- package/test/fixtures/address.json +3 -3
- package/test/integration/addresses.spec.ts +142 -154
- package/test/integration/bip32.spec.ts +130 -151
- package/test/integration/blocks.spec.ts +28 -28
- package/test/integration/cltv.spec.ts +241 -283
- package/test/integration/csv.spec.ts +452 -527
- package/test/integration/payments.spec.ts +110 -135
- package/test/integration/taproot.spec.ts +663 -707
- package/test/integration/transactions.spec.ts +668 -769
- package/test/payments.spec.ts +114 -125
- package/test/payments.utils.ts +165 -208
- package/test/psbt.spec.ts +1285 -1414
- package/test/script.spec.ts +186 -210
- package/test/script_number.spec.ts +26 -29
- package/test/script_signature.spec.ts +66 -66
- package/test/transaction.spec.ts +337 -387
- package/test/ts-node-register.js +7 -5
- package/test/tsconfig.json +4 -1
- package/test/types.spec.ts +53 -58
- package/.nyc_output/6368a5b2-daa5-4821-8ed0-b742d6fc7eab.json +0 -1
- package/.nyc_output/processinfo/6368a5b2-daa5-4821-8ed0-b742d6fc7eab.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/test/address.spec.js +0 -124
- package/test/bitcoin.core.spec.js +0 -170
- package/test/block.spec.js +0 -141
- package/test/bufferutils.spec.js +0 -427
- package/test/crypto.spec.js +0 -41
- package/test/integration/_regtest.js +0 -7
- package/test/integration/addresses.spec.js +0 -116
- package/test/integration/bip32.spec.js +0 -85
- package/test/integration/blocks.spec.js +0 -26
- package/test/integration/cltv.spec.js +0 -199
- package/test/integration/csv.spec.js +0 -362
- package/test/integration/payments.spec.js +0 -98
- package/test/integration/taproot.spec.js +0 -532
- package/test/integration/transactions.spec.js +0 -561
- package/test/payments.spec.js +0 -97
- package/test/payments.utils.js +0 -190
- package/test/psbt.spec.js +0 -1044
- package/test/script.spec.js +0 -151
- package/test/script_number.spec.js +0 -24
- package/test/script_signature.spec.js +0 -52
- package/test/transaction.spec.js +0 -269
- package/test/types.spec.js +0 -46
package/test/ts-node-register.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
// This file is required to run mocha tests on the TS files directly
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
});
|
package/test/tsconfig.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ESNext",
|
|
4
|
-
"module": "
|
|
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,
|
package/test/types.spec.ts
CHANGED
|
@@ -1,58 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { describe, it } from 'mocha';
|
|
3
|
-
import * as types from '../src/types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
assert(types.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{ value:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
+
});
|