@vbyte/btc-dev 1.0.4 → 1.0.6
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/dist/lib/witness/parse.d.ts +2 -2
- package/dist/main.cjs.map +1 -1
- package/dist/module.mjs.map +1 -1
- package/dist/package.json +3 -3
- package/dist/script.js.map +1 -1
- package/dist/types/witness.d.ts +6 -6
- package/package.json +3 -3
- package/src/class/witness.ts +2 -2
- package/src/lib/witness/parse.ts +2 -2
- package/src/types/witness.ts +6 -6
package/dist/types/witness.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export type WitnessContext =
|
|
1
|
+
export type WitnessContext = WitnessInfo | TaprootScript | SegwitScript | TaprootSpend | SegwitSpend;
|
|
2
2
|
export type WitnessVersion = number | null;
|
|
3
3
|
export type WitnessType = 'p2w-pkh' | 'p2w-sh' | 'p2tr-pk' | 'p2tr-ts' | 'unknown';
|
|
4
4
|
export interface WitnessSize {
|
|
5
5
|
size: number;
|
|
6
6
|
vsize: number;
|
|
7
7
|
}
|
|
8
|
-
export interface
|
|
8
|
+
export interface WitnessInfo {
|
|
9
9
|
annex: string | null;
|
|
10
10
|
cblock: string | null;
|
|
11
11
|
params: string[];
|
|
@@ -13,22 +13,22 @@ export interface WitnessData {
|
|
|
13
13
|
type: WitnessType;
|
|
14
14
|
version: WitnessVersion;
|
|
15
15
|
}
|
|
16
|
-
export interface TaprootScript extends
|
|
16
|
+
export interface TaprootScript extends WitnessInfo {
|
|
17
17
|
cblock: string;
|
|
18
18
|
script: string;
|
|
19
19
|
type: 'p2tr-ts';
|
|
20
20
|
version: 1;
|
|
21
21
|
}
|
|
22
|
-
export interface SegwitScript extends
|
|
22
|
+
export interface SegwitScript extends WitnessInfo {
|
|
23
23
|
script: string;
|
|
24
24
|
type: 'p2w-sh';
|
|
25
25
|
version: 0;
|
|
26
26
|
}
|
|
27
|
-
export interface TaprootSpend extends
|
|
27
|
+
export interface TaprootSpend extends WitnessInfo {
|
|
28
28
|
type: 'p2tr-pk';
|
|
29
29
|
version: 1;
|
|
30
30
|
}
|
|
31
|
-
export interface SegwitSpend extends
|
|
31
|
+
export interface SegwitSpend extends WitnessInfo {
|
|
32
32
|
type: 'p2w-pkh';
|
|
33
33
|
version: 0;
|
|
34
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vbyte/btc-dev",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Batteries-included toolset for plebian bitcoin development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"types": "./dist/types/index.d.ts",
|
|
34
34
|
"exports": {
|
|
35
35
|
".": {
|
|
36
|
-
"types": "./dist/types/index.d.ts",
|
|
37
36
|
"import": "./dist/index.js",
|
|
38
|
-
"default": "./dist/index.js"
|
|
37
|
+
"default": "./dist/index.js",
|
|
38
|
+
"types": "./dist/index.d.ts"
|
|
39
39
|
},
|
|
40
40
|
"./address": {
|
|
41
41
|
"types": "./dist/lib/address/index.d.ts",
|
package/src/class/witness.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import type {
|
|
10
10
|
ScriptField,
|
|
11
11
|
WitnessField,
|
|
12
|
-
|
|
12
|
+
WitnessInfo,
|
|
13
13
|
WitnessSize,
|
|
14
14
|
WitnessType
|
|
15
15
|
} from '@/types/index.js'
|
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
export class TransactionWitness {
|
|
18
18
|
|
|
19
19
|
private readonly _data : Buff[]
|
|
20
|
-
private readonly _meta :
|
|
20
|
+
private readonly _meta : WitnessInfo
|
|
21
21
|
private readonly _size : WitnessSize
|
|
22
22
|
|
|
23
23
|
constructor (witness : Bytes[]) {
|
package/src/lib/witness/parse.ts
CHANGED
|
@@ -3,13 +3,13 @@ import { is_valid_script } from '@/lib/script/decode.js'
|
|
|
3
3
|
import { TAPLEAF_VERSIONS } from '@/const.js'
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
|
-
|
|
6
|
+
WitnessInfo,
|
|
7
7
|
WitnessType
|
|
8
8
|
} from '@/types/index.js'
|
|
9
9
|
|
|
10
10
|
export function parse_witness_data (
|
|
11
11
|
witness : Bytes[]
|
|
12
|
-
) :
|
|
12
|
+
) : WitnessInfo {
|
|
13
13
|
// Parse the witness data.
|
|
14
14
|
const elems = witness.map(e => Buff.bytes(e))
|
|
15
15
|
const annex = parse_annex_data(elems)
|
package/src/types/witness.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type WitnessContext =
|
|
1
|
+
export type WitnessContext = WitnessInfo | TaprootScript | SegwitScript | TaprootSpend | SegwitSpend
|
|
2
2
|
export type WitnessVersion = number | null
|
|
3
3
|
export type WitnessType = 'p2w-pkh' | 'p2w-sh' | 'p2tr-pk' | 'p2tr-ts' | 'unknown'
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ export interface WitnessSize {
|
|
|
7
7
|
vsize : number
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export interface
|
|
10
|
+
export interface WitnessInfo {
|
|
11
11
|
annex : string | null
|
|
12
12
|
cblock : string | null
|
|
13
13
|
params : string[]
|
|
@@ -16,25 +16,25 @@ export interface WitnessData {
|
|
|
16
16
|
version : WitnessVersion
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export interface TaprootScript extends
|
|
19
|
+
export interface TaprootScript extends WitnessInfo {
|
|
20
20
|
cblock : string
|
|
21
21
|
script : string
|
|
22
22
|
type : 'p2tr-ts'
|
|
23
23
|
version : 1
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export interface SegwitScript extends
|
|
26
|
+
export interface SegwitScript extends WitnessInfo {
|
|
27
27
|
script : string
|
|
28
28
|
type : 'p2w-sh'
|
|
29
29
|
version : 0
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export interface TaprootSpend extends
|
|
32
|
+
export interface TaprootSpend extends WitnessInfo {
|
|
33
33
|
type : 'p2tr-pk'
|
|
34
34
|
version : 1
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export interface SegwitSpend extends
|
|
37
|
+
export interface SegwitSpend extends WitnessInfo {
|
|
38
38
|
type : 'p2w-pkh'
|
|
39
39
|
version : 0
|
|
40
40
|
}
|