@btc-vision/bitcoin 6.4.0 → 6.4.1
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/build/address.d.ts +1 -0
- package/build/address.js +56 -8
- package/build/networks.js +6 -6
- package/package.json +1 -1
- package/src/address.ts +71 -9
- package/src/block.ts +233 -233
- package/src/bufferutils.ts +188 -188
- package/src/networks.ts +6 -6
- package/src/psbt/psbtutils.ts +320 -320
- package/src/psbt.ts +2187 -2187
- package/test/address.spec.ts +155 -155
- package/test/bitcoin.core.spec.ts +212 -212
- package/test/block.spec.ts +171 -171
- package/test/bufferutils.spec.ts +450 -450
- package/test/crypto.spec.ts +49 -49
- package/test/integration/addresses.spec.ts +142 -142
- package/test/integration/bip32.spec.ts +130 -130
- package/test/integration/blocks.spec.ts +28 -28
- package/test/integration/cltv.spec.ts +241 -241
- package/test/integration/csv.spec.ts +452 -452
- package/test/integration/payments.spec.ts +110 -110
- package/test/integration/taproot.spec.ts +663 -663
- package/test/integration/transactions.spec.ts +668 -668
- package/test/payments.spec.ts +114 -114
- package/test/payments.utils.ts +165 -165
- package/test/psbt.spec.ts +1285 -1285
- package/test/script.spec.ts +186 -186
- package/test/script_number.spec.ts +26 -26
- package/test/script_signature.spec.ts +66 -66
- package/test/transaction.spec.ts +337 -337
- package/test/ts-node-register.js +7 -7
- package/test/types.spec.ts +53 -53
package/test/ts-node-register.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
+
// 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/types.spec.ts
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
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
|
-
});
|
|
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
|
+
});
|