@vbyte/btc-dev 1.0.13 → 1.0.15

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.
@@ -37,8 +37,8 @@ export interface TxOutput {
37
37
  }
38
38
  export interface TxTemplate {
39
39
  locktime?: number;
40
- vin?: TxInputTemplate[];
41
- vout?: TxOutputTemplate[];
40
+ vin: TxInputTemplate[];
41
+ vout: TxOutputTemplate[];
42
42
  version?: number;
43
43
  }
44
44
  export interface TxData {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vbyte/btc-dev",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Batteries-included toolset for plebian bitcoin development",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -78,7 +78,7 @@ export function create_tx_output (
78
78
  }
79
79
 
80
80
  export function create_tx (
81
- config? : TxTemplate
81
+ config? : Partial<TxTemplate>
82
82
  ) : TxData {
83
83
  assert_tx_template(config)
84
84
  const { vin = [], vout = [] } = config ?? { vin: [], vout: [] }
package/src/schema/tx.ts CHANGED
@@ -2,12 +2,14 @@ import { z } from 'zod'
2
2
 
3
3
  import { hex, hex32, uint } from '@vbyte/micro-lib/schema'
4
4
 
5
- const sats = z.bigint().positive().max(2_100_000_000_000_000n)
5
+ import type { TxOutput, TxOutputTemplate } from '@/types/index.js'
6
+
7
+ const sats = z.bigint().min(0n).max(2_100_000_000_000_000n)
6
8
 
7
9
  export const tx_output = z.object({
8
10
  value : sats,
9
11
  script_pk : hex,
10
- })
12
+ }) satisfies z.ZodType<TxOutput>
11
13
 
12
14
  export const tx_input = z.object({
13
15
  coinbase : hex.nullable(),
@@ -28,7 +30,7 @@ export const tx_data = z.object({
28
30
 
29
31
  export const vout_template = tx_output.extend({
30
32
  value : z.union([ uint, sats ])
31
- })
33
+ }) satisfies z.ZodType<TxOutputTemplate>
32
34
 
33
35
  export const vin_template = tx_input.extend({
34
36
  coinbase : hex.nullable().optional(),
@@ -39,8 +41,8 @@ export const vin_template = tx_input.extend({
39
41
  })
40
42
 
41
43
  export const tx_template = z.object({
42
- version : uint.default(1),
43
- vin : z.array(vin_template).default([]),
44
- vout : z.array(vout_template).default([]),
44
+ version : uint.optional(),
45
+ vin : z.array(vin_template),
46
+ vout : z.array(vout_template),
45
47
  locktime : uint.optional(),
46
48
  })
@@ -45,8 +45,8 @@ export interface TxOutput {
45
45
 
46
46
  export interface TxTemplate {
47
47
  locktime? : number
48
- vin? : TxInputTemplate[]
49
- vout? : TxOutputTemplate[]
48
+ vin : TxInputTemplate[]
49
+ vout : TxOutputTemplate[]
50
50
  version? : number
51
51
  }
52
52