@vbyte/btc-dev 1.0.8 → 1.0.9

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.
@@ -1,5 +1,4 @@
1
1
  export * from './address.js';
2
- export * from './class.js';
3
2
  export * from './meta.js';
4
3
  export * from './psbt.js';
5
4
  export * from './sighash.js';
@@ -1,5 +1,4 @@
1
1
  export * from './address.js';
2
- export * from './class.js';
3
2
  export * from './meta.js';
4
3
  export * from './psbt.js';
5
4
  export * from './sighash.js';
@@ -1,6 +1,16 @@
1
+ import type { WitnessType, WitnessVersion } from './witness.js';
1
2
  export type LocktimeData = LocktimeStamp | LocktimeHeight;
2
3
  export type SequenceConfig = Partial<SequenceData>;
3
4
  export type SequenceData = SequenceHeightLock | SequenceStampLock;
5
+ export type TxOutputType = WitnessType | 'p2pkh' | 'p2sh' | 'opreturn';
6
+ export interface TxOutputInfo {
7
+ type: TxOutputType;
8
+ version: WitnessVersion;
9
+ }
10
+ export interface TxInputInfo {
11
+ type: WitnessType;
12
+ version: WitnessVersion;
13
+ }
4
14
  export interface LocktimeStamp {
5
15
  type: 'timelock';
6
16
  stamp: number;
@@ -17,6 +27,20 @@ export interface SequenceHeightLock {
17
27
  height: number;
18
28
  mode: 'height';
19
29
  }
30
+ export interface LocktimeField {
31
+ hex: string;
32
+ data: LocktimeData | null;
33
+ value: number;
34
+ }
35
+ export interface SequenceField {
36
+ hex: string;
37
+ data: SequenceData | null;
38
+ value: number;
39
+ }
40
+ export interface ScriptField {
41
+ asm: string[];
42
+ hex: string;
43
+ }
20
44
  export interface InscriptionData {
21
45
  content?: string;
22
46
  delegate?: string;
@@ -1,14 +1,4 @@
1
- import type { WitnessType, WitnessVersion } from './witness.js';
2
1
  export type TxInput = TxCoinbaseInput | TxSpendInput | TxVirtualInput;
3
- export type TxOutputType = WitnessType | 'p2pkh' | 'p2sh' | 'opreturn';
4
- export interface TxOutputInfo {
5
- type: TxOutputType;
6
- version: WitnessVersion;
7
- }
8
- export interface TxInputInfo {
9
- type: WitnessType;
10
- version: WitnessVersion;
11
- }
12
2
  export interface TxOutpoint {
13
3
  txid: string;
14
4
  vout: number;
@@ -56,8 +46,8 @@ export interface TxData {
56
46
  export interface TxSize {
57
47
  base: number;
58
48
  total: number;
59
- weight: number;
60
49
  vsize: number;
50
+ weight: number;
61
51
  }
62
52
  export interface TxValue {
63
53
  fees: bigint;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vbyte/btc-dev",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Batteries-included toolset for plebian bitcoin development",
5
5
  "type": "module",
6
6
  "keywords": [
package/src/class/tx.ts CHANGED
@@ -20,7 +20,6 @@ import {
20
20
  import type {
21
21
  TxData,
22
22
  TxTemplate,
23
- TransactionData,
24
23
  TxOutput,
25
24
  TxSize,
26
25
  TxValue,
@@ -50,19 +49,8 @@ export class Transaction {
50
49
  this._vout = this._tx.vout.map(txout => new TransactionOutput(txout))
51
50
  }
52
51
 
53
- get data () : TransactionData {
54
- return {
55
- hash : this.hash,
56
- locktime : this.locktime,
57
- return : this.return,
58
- size : this.size,
59
- spends : this.spends,
60
- txid : this.txid,
61
- value : this.value,
62
- version : this.version,
63
- vin : this.vin.map(txin => txin.data),
64
- vout : this.vout.map(txout => txout.data)
65
- }
52
+ get data () : TxData {
53
+ return this._tx
66
54
  }
67
55
 
68
56
  get hash () : string {
package/src/class/txin.ts CHANGED
@@ -8,10 +8,7 @@ import {
8
8
  get_txin_size,
9
9
  } from '@/lib/tx/index.js'
10
10
 
11
- import type {
12
- TxInput,
13
- TransactionInputData
14
- } from '@/types/index.js'
11
+ import type { TxInput } from '@/types/index.js'
15
12
 
16
13
  export class TransactionInput {
17
14
 
@@ -25,17 +22,8 @@ export class TransactionInput {
25
22
  return this._txin.coinbase
26
23
  }
27
24
 
28
- get data () : TransactionInputData {
29
- return {
30
- coinbase : this.coinbase,
31
- prevout : this.prevout?.data ?? null,
32
- script_sig : this.script_sig,
33
- sequence : this.sequence,
34
- size : this.size,
35
- txid : this.txid,
36
- vout : this.vout,
37
- witness : this.witness?.data ?? null
38
- }
25
+ get data () : TxInput {
26
+ return this._txin
39
27
  }
40
28
 
41
29
  get has_prevout () : boolean {
@@ -6,7 +6,7 @@ import {
6
6
  get_vout_version
7
7
  } from '@/lib/tx/index.js'
8
8
 
9
- import type { TxOutput, TransactionOutputData } from '@/types/index.js'
9
+ import type { TxOutput } from '@/types/index.js'
10
10
 
11
11
  export class TransactionOutput {
12
12
 
@@ -16,14 +16,8 @@ export class TransactionOutput {
16
16
  this._txout = txout
17
17
  }
18
18
 
19
- get data () : TransactionOutputData {
20
- return {
21
- script_pk : this.script_pk,
22
- size : this.size,
23
- type : this.type,
24
- value : this.value,
25
- version : this.version
26
- }
19
+ get data () : TxOutput {
20
+ return this._txout
27
21
  }
28
22
 
29
23
  get script_pk () {
@@ -1,5 +1,4 @@
1
1
  export * from './address.js'
2
- export * from './class.js'
3
2
  export * from './meta.js'
4
3
  export * from './psbt.js'
5
4
  export * from './sighash.js'
package/src/types/meta.ts CHANGED
@@ -1,6 +1,19 @@
1
+ import type{ WitnessType, WitnessVersion } from './witness.js'
2
+
1
3
  export type LocktimeData = LocktimeStamp | LocktimeHeight
2
4
  export type SequenceConfig = Partial<SequenceData>
3
5
  export type SequenceData = SequenceHeightLock | SequenceStampLock
6
+ export type TxOutputType = WitnessType | 'p2pkh' | 'p2sh' | 'opreturn'
7
+
8
+ export interface TxOutputInfo {
9
+ type : TxOutputType
10
+ version : WitnessVersion
11
+ }
12
+
13
+ export interface TxInputInfo {
14
+ type : WitnessType
15
+ version : WitnessVersion
16
+ }
4
17
 
5
18
  export interface LocktimeStamp {
6
19
  type : 'timelock' // Discriminator for timelock type
@@ -24,6 +37,23 @@ export interface SequenceHeightLock {
24
37
  mode : 'height' // Discriminator for heightlock mode.
25
38
  }
26
39
 
40
+ export interface LocktimeField {
41
+ hex : string
42
+ data : LocktimeData | null
43
+ value : number
44
+ }
45
+
46
+ export interface SequenceField {
47
+ hex : string
48
+ data : SequenceData | null
49
+ value : number
50
+ }
51
+
52
+ export interface ScriptField {
53
+ asm : string[]
54
+ hex : string
55
+ }
56
+
27
57
  export interface InscriptionData {
28
58
  content ?: string
29
59
  delegate ?: string
@@ -1,17 +1,4 @@
1
- import type { WitnessType, WitnessVersion } from './witness.js'
2
-
3
- export type TxInput = TxCoinbaseInput | TxSpendInput | TxVirtualInput
4
- export type TxOutputType = WitnessType | 'p2pkh' | 'p2sh' | 'opreturn'
5
-
6
- export interface TxOutputInfo {
7
- type : TxOutputType
8
- version : WitnessVersion
9
- }
10
-
11
- export interface TxInputInfo {
12
- type : WitnessType
13
- version : WitnessVersion
14
- }
1
+ export type TxInput = TxCoinbaseInput | TxSpendInput | TxVirtualInput
15
2
 
16
3
  export interface TxOutpoint {
17
4
  txid : string
@@ -68,8 +55,8 @@ export interface TxData {
68
55
  export interface TxSize {
69
56
  base : number
70
57
  total : number
71
- weight : number
72
58
  vsize : number
59
+ weight : number
73
60
  }
74
61
 
75
62
  export interface TxValue {
@@ -1,46 +0,0 @@
1
- import type { LocktimeData, SequenceData } from './meta.js';
2
- import type { TxOutput, TxOutputType, TxSize, TxValue } from './txdata.js';
3
- import type { WitnessData, WitnessVersion } from './witness.js';
4
- export interface LocktimeField {
5
- hex: string;
6
- data: LocktimeData | null;
7
- value: number;
8
- }
9
- export interface SequenceField {
10
- hex: string;
11
- data: SequenceData | null;
12
- value: number;
13
- }
14
- export interface ScriptField {
15
- asm: string[];
16
- hex: string;
17
- }
18
- export interface TransactionData {
19
- hash: string;
20
- locktime: LocktimeField;
21
- return: TxOutput | null;
22
- size: TxSize;
23
- spends: TransactionOutputData[];
24
- txid: string;
25
- value: TxValue;
26
- version: number;
27
- vin: TransactionInputData[];
28
- vout: TransactionOutputData[];
29
- }
30
- export interface TransactionInputData {
31
- coinbase?: string | null;
32
- prevout?: TransactionOutputData | null;
33
- script_sig?: ScriptField | null;
34
- sequence: SequenceField;
35
- size: number;
36
- txid: string;
37
- vout: number;
38
- witness?: WitnessData | null;
39
- }
40
- export interface TransactionOutputData {
41
- script_pk: ScriptField;
42
- size: number;
43
- type: TxOutputType;
44
- value: bigint;
45
- version: WitnessVersion | null;
46
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,52 +0,0 @@
1
- import type { LocktimeData, SequenceData } from './meta.js'
2
- import type { TxOutput, TxOutputType, TxSize, TxValue } from './txdata.js'
3
- import type { WitnessData, WitnessVersion } from './witness.js'
4
-
5
- export interface LocktimeField {
6
- hex : string
7
- data : LocktimeData | null
8
- value : number
9
- }
10
-
11
- export interface SequenceField {
12
- hex : string
13
- data : SequenceData | null
14
- value : number
15
- }
16
-
17
- export interface ScriptField {
18
- asm : string[]
19
- hex : string
20
- }
21
-
22
- export interface TransactionData {
23
- hash : string
24
- locktime : LocktimeField
25
- return : TxOutput | null
26
- size : TxSize
27
- spends : TransactionOutputData[]
28
- txid : string
29
- value : TxValue
30
- version : number
31
- vin : TransactionInputData[]
32
- vout : TransactionOutputData[]
33
- }
34
-
35
- export interface TransactionInputData {
36
- coinbase? : string | null
37
- prevout? : TransactionOutputData | null
38
- script_sig? : ScriptField | null
39
- sequence : SequenceField
40
- size : number
41
- txid : string
42
- vout : number
43
- witness? : WitnessData | null
44
- }
45
-
46
- export interface TransactionOutputData {
47
- script_pk : ScriptField
48
- size : number
49
- type : TxOutputType
50
- value : bigint
51
- version : WitnessVersion | null
52
- }