@vbyte/btc-dev 1.0.10 → 1.0.12
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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/lib/sighash/segwit.d.ts +4 -1
- package/dist/lib/sighash/segwit.js +6 -6
- package/dist/lib/sighash/taproot.d.ts +7 -6
- package/dist/lib/sighash/taproot.js +24 -53
- package/dist/lib/sighash/util.d.ts +4 -2
- package/dist/lib/sighash/util.js +16 -2
- package/dist/lib/signer/sign.js +8 -5
- package/dist/lib/signer/verify.d.ts +1 -2
- package/dist/lib/signer/verify.js +1 -5
- package/dist/lib/tx/create.d.ts +7 -6
- package/dist/lib/tx/create.js +25 -27
- package/dist/lib/tx/decode.d.ts +4 -9
- package/dist/lib/tx/decode.js +16 -28
- package/dist/lib/tx/encode.d.ts +1 -1
- package/dist/lib/tx/encode.js +6 -6
- package/dist/lib/tx/parse.d.ts +3 -2
- package/dist/lib/tx/parse.js +38 -5
- package/dist/lib/tx/util.d.ts +8 -4
- package/dist/lib/tx/util.js +39 -15
- package/dist/lib/tx/validate.d.ts +4 -2
- package/dist/lib/tx/validate.js +9 -2
- package/dist/main.cjs +4049 -4269
- package/dist/main.cjs.map +1 -1
- package/dist/module.mjs +4040 -4255
- package/dist/module.mjs.map +1 -1
- package/dist/package.json +2 -2
- package/dist/schema/taproot.d.ts +2 -2
- package/dist/schema/tx.d.ts +53 -40
- package/dist/schema/tx.js +9 -6
- package/dist/script.js +8 -8
- package/dist/script.js.map +1 -1
- package/dist/types/txdata.d.ts +28 -5
- package/package.json +2 -2
- package/src/index.ts +0 -2
- package/src/lib/sighash/segwit.ts +6 -6
- package/src/lib/sighash/taproot.ts +40 -70
- package/src/lib/sighash/util.ts +25 -3
- package/src/lib/signer/sign.ts +9 -5
- package/src/lib/signer/verify.ts +1 -18
- package/src/lib/tx/create.ts +44 -36
- package/src/lib/tx/decode.ts +23 -45
- package/src/lib/tx/encode.ts +10 -9
- package/src/lib/tx/parse.ts +61 -8
- package/src/lib/tx/util.ts +57 -20
- package/src/lib/tx/validate.ts +15 -2
- package/src/schema/tx.ts +10 -6
- package/src/types/txdata.ts +32 -5
- package/dist/class/index.d.ts +0 -5
- package/dist/class/index.js +0 -5
- package/dist/class/signer.d.ts +0 -18
- package/dist/class/signer.js +0 -34
- package/dist/class/tx.d.ts +0 -51
- package/dist/class/tx.js +0 -122
- package/dist/class/txin.d.ts +0 -27
- package/dist/class/txin.js +0 -59
- package/dist/class/txout.d.ts +0 -16
- package/dist/class/txout.js +0 -31
- package/dist/class/witness.d.ts +0 -23
- package/dist/class/witness.js +0 -68
- package/src/class/index.ts +0 -5
- package/src/class/signer.ts +0 -49
- package/src/class/tx.ts +0 -175
- package/src/class/txin.ts +0 -81
- package/src/class/txout.ts +0 -50
- package/src/class/witness.ts +0 -99
package/src/class/txout.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { decode_script } from '@/lib/script/index.js'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
assert_tx_output,
|
|
5
|
-
get_txout_size,
|
|
6
|
-
get_vout_type,
|
|
7
|
-
get_vout_version
|
|
8
|
-
} from '@/lib/tx/index.js'
|
|
9
|
-
|
|
10
|
-
import type { TxOutput } from '@/types/index.js'
|
|
11
|
-
|
|
12
|
-
export class TransactionOutput {
|
|
13
|
-
|
|
14
|
-
private readonly _txout : TxOutput
|
|
15
|
-
|
|
16
|
-
constructor (txout : TxOutput) {
|
|
17
|
-
assert_tx_output(txout)
|
|
18
|
-
this._txout = txout
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
get data () : TxOutput {
|
|
22
|
-
return this._txout
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get script_pk () {
|
|
26
|
-
return {
|
|
27
|
-
hex : this._txout.script_pk,
|
|
28
|
-
asm : decode_script(this._txout.script_pk)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
get size () {
|
|
33
|
-
return get_txout_size(this._txout)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get type () {
|
|
37
|
-
return get_vout_type(this._txout.script_pk)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get value () : bigint {
|
|
41
|
-
return this._txout.value
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get version () {
|
|
45
|
-
return get_vout_version(this._txout.script_pk)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
toJSON () { return this.data }
|
|
49
|
-
toString () { return JSON.stringify(this.data) }
|
|
50
|
-
}
|
package/src/class/witness.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Buff, Bytes } from '@vbyte/buff'
|
|
2
|
-
import { Assert } from '@vbyte/micro-lib'
|
|
3
|
-
import { decode_script } from '@/lib/script/index.js'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
parse_witness,
|
|
7
|
-
get_witness_size,
|
|
8
|
-
assert_witness,
|
|
9
|
-
} from '@/lib/witness/index.js'
|
|
10
|
-
|
|
11
|
-
import type {
|
|
12
|
-
ScriptField,
|
|
13
|
-
WitnessData,
|
|
14
|
-
WitnessSize,
|
|
15
|
-
WitnessType
|
|
16
|
-
} from '@/types/index.js'
|
|
17
|
-
|
|
18
|
-
export class TransactionWitness {
|
|
19
|
-
|
|
20
|
-
private readonly _elems : Buff[]
|
|
21
|
-
|
|
22
|
-
private _data : WitnessData
|
|
23
|
-
private _size : WitnessSize
|
|
24
|
-
|
|
25
|
-
constructor (witness : Bytes[]) {
|
|
26
|
-
assert_witness(witness)
|
|
27
|
-
this._elems = witness.map(e => Buff.bytes(e))
|
|
28
|
-
this._data = parse_witness(this._elems)
|
|
29
|
-
this._size = get_witness_size(this._elems)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
get annex () : string | null {
|
|
33
|
-
return this._data.annex
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get cblock () : string | null {
|
|
37
|
-
return this._data.cblock
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get data () : WitnessData {
|
|
41
|
-
return this._data
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get params () : string[] {
|
|
45
|
-
return this._data.params
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get script () : ScriptField | null {
|
|
49
|
-
if (this._data.script === null) return null
|
|
50
|
-
return {
|
|
51
|
-
hex : this._data.script,
|
|
52
|
-
asm : decode_script(this._data.script)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
get size () : WitnessSize {
|
|
57
|
-
return this._size
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
get stack () : string[] {
|
|
61
|
-
return this._elems.map(e => e.hex)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
get type () : WitnessType {
|
|
65
|
-
return this._data.type
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
get version () : number | null {
|
|
69
|
-
return this._data.version
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
_update () {
|
|
73
|
-
this._data = parse_witness(this._elems)
|
|
74
|
-
this._size = get_witness_size(this._elems)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
add (elem : Bytes) {
|
|
78
|
-
this._elems.push(Buff.bytes(elem))
|
|
79
|
-
this._update()
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
insert (index : number, elem : Bytes) {
|
|
83
|
-
Assert.ok(index >= 0 && index <= this._elems.length, 'index out of bounds')
|
|
84
|
-
if (index === this._elems.length) {
|
|
85
|
-
this._elems.push(Buff.bytes(elem))
|
|
86
|
-
} else {
|
|
87
|
-
this._elems.splice(index, 0, Buff.bytes(elem))
|
|
88
|
-
}
|
|
89
|
-
this._update()
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
remove (index : number) {
|
|
93
|
-
this._elems.splice(index, 1)
|
|
94
|
-
this._update()
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
toJSON () { return this.data }
|
|
98
|
-
toString () { return JSON.stringify(this.data) }
|
|
99
|
-
}
|