@vbyte/btc-dev 1.0.12 → 1.0.14

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.
@@ -3,20 +3,13 @@ export interface TxOutpoint {
3
3
  txid: string;
4
4
  vout: number;
5
5
  }
6
- export interface TxInputConfig extends TxOutpoint {
6
+ export interface TxInputTemplate extends TxOutpoint {
7
7
  coinbase?: string | null;
8
8
  prevout?: TxOutput | null;
9
9
  script_sig?: string | null;
10
10
  sequence?: number;
11
11
  witness?: string[];
12
12
  }
13
- export interface TxInputTemplate extends TxOutpoint {
14
- coinbase: string | null;
15
- prevout: TxOutput | null;
16
- script_sig: string | null;
17
- sequence: number;
18
- witness: string[];
19
- }
20
13
  export interface TxCoinbaseInput extends TxOutpoint {
21
14
  coinbase: string;
22
15
  prevout: null;
@@ -43,10 +36,10 @@ export interface TxOutput {
43
36
  value: bigint;
44
37
  }
45
38
  export interface TxTemplate {
46
- locktime: number;
39
+ locktime?: number;
47
40
  vin: TxInputTemplate[];
48
41
  vout: TxOutputTemplate[];
49
- version: number;
42
+ version?: number;
50
43
  }
51
44
  export interface TxData {
52
45
  locktime: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vbyte/btc-dev",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Batteries-included toolset for plebian bitcoin development",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -22,24 +22,24 @@ import type {
22
22
  TxCoinbaseInput,
23
23
  TxOutputTemplate,
24
24
  TxVirtualInput,
25
- TxInputConfig
25
+ TxInputTemplate
26
26
  } from '@/types/index.js'
27
27
 
28
28
  export function create_coinbase_input (
29
- config : TxInputConfig
29
+ config : TxInputTemplate
30
30
  ) : TxCoinbaseInput {
31
31
  assert_vin_template(config)
32
32
  Assert.exists(config.coinbase, 'coinbase is required')
33
33
  const txid = COINBASE.TXID
34
34
  const vout = COINBASE.VOUT
35
35
  const coinbase = config.coinbase
36
- const witness = config.witness ?? []
36
+ const witness = config.witness ?? []
37
37
  const sequence = normalize_sequence(config.sequence)
38
38
  return { coinbase, prevout: null, script_sig: null, sequence, witness, txid, vout }
39
39
  }
40
40
 
41
41
  export function create_virtual_input (
42
- config : TxInputConfig
42
+ config : TxInputTemplate
43
43
  ) : TxVirtualInput {
44
44
  assert_vin_template(config)
45
45
  Assert.is_empty(config.coinbase, 'coinbase is not allowed')
@@ -50,7 +50,7 @@ export function create_virtual_input (
50
50
  }
51
51
 
52
52
  export function create_spend_input (
53
- config : TxInputConfig
53
+ config : TxInputTemplate
54
54
  ) : TxSpendInput {
55
55
  assert_vin_template(config)
56
56
  Assert.exists(config.prevout, 'prevout is required')
@@ -61,7 +61,7 @@ export function create_spend_input (
61
61
  }
62
62
 
63
63
  export function create_tx_input (
64
- config : TxInputConfig
64
+ config : TxInputTemplate
65
65
  ) : TxInput {
66
66
  if (config.coinbase) return create_coinbase_input(config)
67
67
  if (config.prevout) return create_spend_input(config)
@@ -78,10 +78,10 @@ export function create_tx_output (
78
78
  }
79
79
 
80
80
  export function create_tx (
81
- config: Partial<TxTemplate> = {}
81
+ config? : Partial<TxTemplate>
82
82
  ) : TxData {
83
83
  assert_tx_template(config)
84
- const { vin = [], vout = [] } = config
84
+ const { vin = [], vout = [] } = config ?? { vin: [], vout: [] }
85
85
  const locktime = config.locktime ?? DEFAULT.LOCKTIME
86
86
  const version = config.version ?? DEFAULT.VERSION
87
87
  const inputs = vin.map(txin => create_tx_input(txin))
@@ -5,7 +5,7 @@ export interface TxOutpoint {
5
5
  vout : number
6
6
  }
7
7
 
8
- export interface TxInputConfig extends TxOutpoint {
8
+ export interface TxInputTemplate extends TxOutpoint {
9
9
  coinbase? : string | null
10
10
  prevout? : TxOutput | null
11
11
  script_sig? : string | null
@@ -13,14 +13,6 @@ export interface TxInputConfig extends TxOutpoint {
13
13
  witness? : string[]
14
14
  }
15
15
 
16
- export interface TxInputTemplate extends TxOutpoint {
17
- coinbase : string | null
18
- prevout : TxOutput | null
19
- script_sig : string | null
20
- sequence : number
21
- witness : string[]
22
- }
23
-
24
16
  export interface TxCoinbaseInput extends TxOutpoint {
25
17
  coinbase : string
26
18
  prevout : null
@@ -52,10 +44,10 @@ export interface TxOutput {
52
44
  }
53
45
 
54
46
  export interface TxTemplate {
55
- locktime : number
56
- vin : TxInputTemplate[]
57
- vout : TxOutputTemplate[]
58
- version : number
47
+ locktime? : number
48
+ vin : TxInputTemplate[]
49
+ vout : TxOutputTemplate[]
50
+ version? : number
59
51
  }
60
52
 
61
53
  export interface TxData {