@vbyte/btc-dev 1.1.1 → 1.1.2
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/tx/util.d.ts +5 -4
- package/dist/lib/tx/util.js +14 -12
- package/dist/main.cjs +17 -15
- package/dist/main.cjs.map +1 -1
- package/dist/module.mjs +17 -15
- package/dist/module.mjs.map +1 -1
- package/dist/package.json +1 -1
- package/dist/script.js +1 -1
- package/dist/script.js.map +1 -1
- package/dist/types/meta.d.ts +3 -3
- package/package.json +1 -1
- package/src/lib/tx/util.ts +21 -19
- package/src/types/meta.ts +3 -3
package/dist/lib/tx/util.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Bytes } from '@vbyte/buff';
|
|
1
2
|
import type { TxData, TxOutput, TxOutputInfo, TxOutputTemplate, TxOutputType, TxValue, WitnessVersion } from '../../types/index.js';
|
|
2
|
-
export declare function is_return_script(script:
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
3
|
+
export declare function is_return_script(script: Bytes): boolean;
|
|
4
|
+
export declare function get_vout_script_info(script: Bytes): TxOutputInfo;
|
|
5
|
+
export declare function get_vout_script_type(script: Bytes): TxOutputType | null;
|
|
6
|
+
export declare function get_vout_script_version(script: Bytes): WitnessVersion | null;
|
|
6
7
|
export declare function get_txid(txdata: TxData): string;
|
|
7
8
|
export declare function get_txhash(txdata: TxData): string;
|
|
8
9
|
export declare function get_tx_value(txdata: TxData): TxValue;
|
package/dist/lib/tx/util.js
CHANGED
|
@@ -6,26 +6,28 @@ import { encode_tx } from './encode.js';
|
|
|
6
6
|
import { assert_tx_template } from './validate.js';
|
|
7
7
|
import { DEFAULT, LOCK_SCRIPT_REGEX } from '../../const.js';
|
|
8
8
|
export function is_return_script(script) {
|
|
9
|
-
|
|
9
|
+
const bytes = Buff.bytes(script);
|
|
10
|
+
return bytes.at(0) === 0x6a;
|
|
10
11
|
}
|
|
11
|
-
export function
|
|
12
|
+
export function get_vout_script_info(script) {
|
|
12
13
|
return {
|
|
13
|
-
type:
|
|
14
|
-
version:
|
|
14
|
+
type: get_vout_script_type(script),
|
|
15
|
+
version: get_vout_script_version(script)
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
export function
|
|
18
|
+
export function get_vout_script_type(script) {
|
|
19
|
+
const hex = Buff.bytes(script).hex;
|
|
18
20
|
for (const [type, regex] of Object.entries(LOCK_SCRIPT_REGEX)) {
|
|
19
|
-
if (regex.test(
|
|
21
|
+
if (regex.test(hex))
|
|
20
22
|
return type;
|
|
21
23
|
}
|
|
22
|
-
return
|
|
24
|
+
return null;
|
|
23
25
|
}
|
|
24
|
-
export function
|
|
25
|
-
const
|
|
26
|
-
switch (
|
|
27
|
-
case
|
|
28
|
-
case
|
|
26
|
+
export function get_vout_script_version(script) {
|
|
27
|
+
const version = Buff.bytes(script);
|
|
28
|
+
switch (version.at(0)) {
|
|
29
|
+
case 0x00: return 0;
|
|
30
|
+
case 0x51: return 1;
|
|
29
31
|
default: return null;
|
|
30
32
|
}
|
|
31
33
|
}
|
package/dist/main.cjs
CHANGED
|
@@ -9679,26 +9679,28 @@ function encode_script_data(script) {
|
|
|
9679
9679
|
}
|
|
9680
9680
|
|
|
9681
9681
|
function is_return_script(script) {
|
|
9682
|
-
|
|
9682
|
+
const bytes = Buff.bytes(script);
|
|
9683
|
+
return bytes.at(0) === 0x6a;
|
|
9683
9684
|
}
|
|
9684
|
-
function
|
|
9685
|
+
function get_vout_script_info(script) {
|
|
9685
9686
|
return {
|
|
9686
|
-
type:
|
|
9687
|
-
version:
|
|
9687
|
+
type: get_vout_script_type(script),
|
|
9688
|
+
version: get_vout_script_version(script)
|
|
9688
9689
|
};
|
|
9689
9690
|
}
|
|
9690
|
-
function
|
|
9691
|
+
function get_vout_script_type(script) {
|
|
9692
|
+
const hex = Buff.bytes(script).hex;
|
|
9691
9693
|
for (const [type, regex] of Object.entries(LOCK_SCRIPT_REGEX)) {
|
|
9692
|
-
if (regex.test(
|
|
9694
|
+
if (regex.test(hex))
|
|
9693
9695
|
return type;
|
|
9694
9696
|
}
|
|
9695
|
-
return
|
|
9697
|
+
return null;
|
|
9696
9698
|
}
|
|
9697
|
-
function
|
|
9698
|
-
const
|
|
9699
|
-
switch (
|
|
9700
|
-
case
|
|
9701
|
-
case
|
|
9699
|
+
function get_vout_script_version(script) {
|
|
9700
|
+
const version = Buff.bytes(script);
|
|
9701
|
+
switch (version.at(0)) {
|
|
9702
|
+
case 0x00: return 0;
|
|
9703
|
+
case 0x51: return 1;
|
|
9702
9704
|
default: return null;
|
|
9703
9705
|
}
|
|
9704
9706
|
}
|
|
@@ -10007,10 +10009,10 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
10007
10009
|
get_txout_size: get_txout_size,
|
|
10008
10010
|
get_txsize: get_txsize,
|
|
10009
10011
|
get_vin_size: get_vin_size,
|
|
10010
|
-
|
|
10012
|
+
get_vout_script_info: get_vout_script_info,
|
|
10013
|
+
get_vout_script_type: get_vout_script_type,
|
|
10014
|
+
get_vout_script_version: get_vout_script_version,
|
|
10011
10015
|
get_vout_size: get_vout_size,
|
|
10012
|
-
get_vout_type: get_vout_type,
|
|
10013
|
-
get_vout_version: get_vout_version,
|
|
10014
10016
|
get_vsize: get_vsize,
|
|
10015
10017
|
is_return_script: is_return_script,
|
|
10016
10018
|
normalize_prevout: normalize_prevout,
|