@vbyte/btc-dev 1.1.0 → 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/meta/locktime.d.ts +1 -1
- package/dist/lib/meta/locktime.js +5 -5
- package/dist/lib/meta/ref.d.ts +1 -1
- package/dist/lib/meta/ref.js +6 -6
- package/dist/lib/meta/scribe.d.ts +5 -3
- package/dist/lib/meta/scribe.js +21 -18
- package/dist/lib/meta/sequence.d.ts +1 -1
- package/dist/lib/meta/sequence.js +5 -5
- package/dist/lib/script/decode.d.ts +2 -1
- package/dist/lib/script/encode.d.ts +1 -1
- package/dist/lib/script/encode.js +3 -3
- package/dist/lib/tx/util.d.ts +5 -4
- package/dist/lib/tx/util.js +14 -12
- package/dist/main.cjs +61 -56
- package/dist/main.cjs.map +1 -1
- package/dist/module.mjs +61 -56
- package/dist/module.mjs.map +1 -1
- package/dist/package.json +1 -1
- package/dist/script.js +6 -6
- package/dist/script.js.map +1 -1
- package/dist/types/meta.d.ts +3 -3
- package/package.json +1 -1
- package/src/lib/meta/locktime.ts +1 -1
- package/src/lib/meta/ref.ts +1 -1
- package/src/lib/meta/scribe.ts +29 -24
- package/src/lib/meta/sequence.ts +1 -1
- package/src/lib/script/decode.ts +2 -2
- package/src/lib/script/encode.ts +4 -5
- package/src/lib/tx/util.ts +21 -19
- package/src/types/meta.ts +3 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Assert } from '@vbyte/micro-lib';
|
|
2
2
|
const LOCKTIME_THRESHOLD = 500000000;
|
|
3
|
-
export var
|
|
4
|
-
(function (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})(
|
|
3
|
+
export var LocktimeField;
|
|
4
|
+
(function (LocktimeField) {
|
|
5
|
+
LocktimeField.encode = encode_locktime;
|
|
6
|
+
LocktimeField.decode = decode_locktime;
|
|
7
|
+
})(LocktimeField || (LocktimeField = {}));
|
|
8
8
|
export function encode_locktime(locktime) {
|
|
9
9
|
switch (locktime.type) {
|
|
10
10
|
case 'timelock':
|
package/dist/lib/meta/ref.d.ts
CHANGED
package/dist/lib/meta/ref.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export var
|
|
2
|
-
(function (
|
|
3
|
-
|
|
1
|
+
export var RefPointer;
|
|
2
|
+
(function (RefPointer) {
|
|
3
|
+
RefPointer.outpoint = {
|
|
4
4
|
encode: encode_outpoint,
|
|
5
5
|
decode: decode_outpoint,
|
|
6
6
|
verify: verify_outpoint,
|
|
7
7
|
assert: assert_outpoint,
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
RefPointer.record_id = {
|
|
10
10
|
encode: encode_inscription_id,
|
|
11
11
|
decode: decode_inscription_id,
|
|
12
12
|
verify: verify_inscription_id,
|
|
13
13
|
assert: assert_inscription_id,
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
RefPointer.rune_id = {
|
|
16
16
|
encode: encode_rune_id,
|
|
17
17
|
decode: decode_rune_id,
|
|
18
18
|
verify: verify_rune_id,
|
|
19
19
|
assert: assert_rune_id,
|
|
20
20
|
};
|
|
21
|
-
})(
|
|
21
|
+
})(RefPointer || (RefPointer = {}));
|
|
22
22
|
function encode_inscription_id(txid, order = 0) {
|
|
23
23
|
return `${txid}i${order}`;
|
|
24
24
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Buff, Bytes } from '@vbyte/buff';
|
|
1
2
|
import type { InscriptionData } from '../../types/index.js';
|
|
2
|
-
export declare namespace
|
|
3
|
+
export declare namespace InscriptionUtil {
|
|
4
|
+
type Type = InscriptionData;
|
|
3
5
|
const encode: typeof encode_inscription;
|
|
4
6
|
const decode: typeof decode_inscription;
|
|
5
7
|
}
|
|
6
|
-
export declare function decode_inscription(script:
|
|
7
|
-
export declare function encode_inscription(data: InscriptionData[]):
|
|
8
|
+
export declare function decode_inscription(script: Bytes): InscriptionData[];
|
|
9
|
+
export declare function encode_inscription(data: InscriptionData[]): Buff;
|
package/dist/lib/meta/scribe.js
CHANGED
|
@@ -5,17 +5,17 @@ import { decode_script } from '../../lib/script/decode.js';
|
|
|
5
5
|
const _0n = BigInt(0);
|
|
6
6
|
const _1n = BigInt(1);
|
|
7
7
|
const _26n = BigInt(26);
|
|
8
|
-
export var
|
|
9
|
-
(function (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})(
|
|
8
|
+
export var InscriptionUtil;
|
|
9
|
+
(function (InscriptionUtil) {
|
|
10
|
+
InscriptionUtil.encode = encode_inscription;
|
|
11
|
+
InscriptionUtil.decode = decode_inscription;
|
|
12
|
+
})(InscriptionUtil || (InscriptionUtil = {}));
|
|
13
13
|
export function decode_inscription(script) {
|
|
14
14
|
const envelopes = parse_envelopes(script);
|
|
15
15
|
return envelopes.map(parse_record);
|
|
16
16
|
}
|
|
17
17
|
export function encode_inscription(data) {
|
|
18
|
-
return data.map(create_envelope)
|
|
18
|
+
return Buff.join(data.map(create_envelope));
|
|
19
19
|
}
|
|
20
20
|
function create_envelope(data) {
|
|
21
21
|
let asm = ['OP_0', 'OP_IF', '6f7264'];
|
|
@@ -94,7 +94,7 @@ function parse_record(envelope) {
|
|
|
94
94
|
i += 1;
|
|
95
95
|
break;
|
|
96
96
|
case 'OP_WITHIN':
|
|
97
|
-
record.ref = envelope[i + 1];
|
|
97
|
+
record.ref = decode_bytes(envelope[i + 1]);
|
|
98
98
|
i += 1;
|
|
99
99
|
break;
|
|
100
100
|
case 'OP_NOP':
|
|
@@ -108,6 +108,9 @@ function parse_record(envelope) {
|
|
|
108
108
|
}
|
|
109
109
|
return record;
|
|
110
110
|
}
|
|
111
|
+
function decode_bytes(bytes) {
|
|
112
|
+
return Buff.bytes(bytes).hex;
|
|
113
|
+
}
|
|
111
114
|
function encode_id(identifier) {
|
|
112
115
|
Assert.ok(identifier.includes('i'), 'identifier must include an index');
|
|
113
116
|
const parts = identifier.split('i');
|
|
@@ -116,8 +119,8 @@ function encode_id(identifier) {
|
|
|
116
119
|
const txid = bytes.reverse().hex;
|
|
117
120
|
return (idx !== 0) ? txid + Buff.num(idx).hex : txid;
|
|
118
121
|
}
|
|
119
|
-
function decode_id(
|
|
120
|
-
const bytes = Buff.
|
|
122
|
+
function decode_id(identifier) {
|
|
123
|
+
const bytes = Buff.bytes(identifier);
|
|
121
124
|
const idx = bytes.at(-1) ?? 0;
|
|
122
125
|
const txid = bytes.slice(0, -1).reverse().hex;
|
|
123
126
|
return txid + 'i' + String(idx);
|
|
@@ -125,14 +128,14 @@ function decode_id(hexstr) {
|
|
|
125
128
|
function encode_pointer(pointer) {
|
|
126
129
|
return Buff.num(pointer).reverse().hex;
|
|
127
130
|
}
|
|
128
|
-
function decode_pointer(
|
|
129
|
-
return Buff.
|
|
131
|
+
function decode_pointer(bytes) {
|
|
132
|
+
return Buff.bytes(bytes).reverse().num;
|
|
130
133
|
}
|
|
131
134
|
function encode_label(label) {
|
|
132
135
|
return Buff.str(label).hex;
|
|
133
136
|
}
|
|
134
|
-
function decode_label(
|
|
135
|
-
return Buff.
|
|
137
|
+
function decode_label(label) {
|
|
138
|
+
return Buff.bytes(label).str;
|
|
136
139
|
}
|
|
137
140
|
function encode_content(content) {
|
|
138
141
|
const bytes = Buff.is_hex(content)
|
|
@@ -152,9 +155,9 @@ function encode_content(content) {
|
|
|
152
155
|
}
|
|
153
156
|
return chunks;
|
|
154
157
|
}
|
|
155
|
-
function decode_content(
|
|
156
|
-
const data = Buff.join(
|
|
157
|
-
return (
|
|
158
|
+
function decode_content(chunks, format = 'hex') {
|
|
159
|
+
const data = Buff.join(chunks);
|
|
160
|
+
return (format === 'hex')
|
|
158
161
|
? data.hex
|
|
159
162
|
: data.str;
|
|
160
163
|
}
|
|
@@ -172,8 +175,8 @@ function encode_rune_label(label) {
|
|
|
172
175
|
big = big - _1n;
|
|
173
176
|
return Buff.big(big).reverse().hex;
|
|
174
177
|
}
|
|
175
|
-
function decode_rune_label(
|
|
176
|
-
let big = Buff.
|
|
178
|
+
function decode_rune_label(label) {
|
|
179
|
+
let big = Buff.bytes(label).reverse().big;
|
|
177
180
|
big = big + _1n;
|
|
178
181
|
let result = '';
|
|
179
182
|
while (big > _0n) {
|
|
@@ -3,11 +3,11 @@ const TIMELOCK_TYPE = 0x00400000;
|
|
|
3
3
|
const TIMELOCK_VALUE_MASK = 0x0000FFFF;
|
|
4
4
|
const TIMELOCK_VALUE_MAX = 0xFFFF;
|
|
5
5
|
const TIMELOCK_GRANULARITY = 512;
|
|
6
|
-
export var
|
|
7
|
-
(function (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})(
|
|
6
|
+
export var SequenceField;
|
|
7
|
+
(function (SequenceField) {
|
|
8
|
+
SequenceField.encode = encode_sequence;
|
|
9
|
+
SequenceField.decode = decode_sequence;
|
|
10
|
+
})(SequenceField || (SequenceField = {}));
|
|
11
11
|
export function encode_sequence(data) {
|
|
12
12
|
if (data.mode === 'height') {
|
|
13
13
|
const height = parse_height(data.height);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Buff } from '@vbyte/buff';
|
|
2
|
-
export declare function encode_script(words: (string | number | Uint8Array)[], varint?: boolean):
|
|
2
|
+
export declare function encode_script(words: (string | number | Uint8Array)[], varint?: boolean): Buff;
|
|
3
3
|
export declare function encode_script_word(word: string | number | Uint8Array): Uint8Array;
|
|
4
4
|
export declare function split_script_word(word: Uint8Array): Buff[];
|
|
5
5
|
export declare function prefix_word_size(word: Uint8Array): Buff;
|
|
@@ -3,15 +3,15 @@ import { get_asm_code, } from './words.js';
|
|
|
3
3
|
const MAX_WORD_SIZE = 520;
|
|
4
4
|
export function encode_script(words, varint = false) {
|
|
5
5
|
if (words.length === 0)
|
|
6
|
-
return
|
|
6
|
+
return Buff.num(0, 1);
|
|
7
7
|
const bytes = [];
|
|
8
8
|
for (const word of words) {
|
|
9
9
|
bytes.push(encode_script_word(word));
|
|
10
10
|
}
|
|
11
11
|
const buffer = Buff.join(bytes);
|
|
12
12
|
return (varint)
|
|
13
|
-
? buffer.prepend(Buff.varint(buffer.length, 'le'))
|
|
14
|
-
: buffer
|
|
13
|
+
? buffer.prepend(Buff.varint(buffer.length, 'le'))
|
|
14
|
+
: buffer;
|
|
15
15
|
}
|
|
16
16
|
export function encode_script_word(word) {
|
|
17
17
|
let buff;
|
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
|
@@ -8698,11 +8698,11 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
8698
8698
|
});
|
|
8699
8699
|
|
|
8700
8700
|
const LOCKTIME_THRESHOLD = 500000000;
|
|
8701
|
-
var
|
|
8702
|
-
(function (
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
})(
|
|
8701
|
+
var LocktimeField;
|
|
8702
|
+
(function (LocktimeField) {
|
|
8703
|
+
LocktimeField.encode = encode_locktime;
|
|
8704
|
+
LocktimeField.decode = decode_locktime;
|
|
8705
|
+
})(LocktimeField || (LocktimeField = {}));
|
|
8706
8706
|
function encode_locktime(locktime) {
|
|
8707
8707
|
switch (locktime.type) {
|
|
8708
8708
|
case 'timelock':
|
|
@@ -8734,27 +8734,27 @@ function decode_locktime(locktime) {
|
|
|
8734
8734
|
}
|
|
8735
8735
|
}
|
|
8736
8736
|
|
|
8737
|
-
var
|
|
8738
|
-
(function (
|
|
8739
|
-
|
|
8737
|
+
var RefPointer;
|
|
8738
|
+
(function (RefPointer) {
|
|
8739
|
+
RefPointer.outpoint = {
|
|
8740
8740
|
encode: encode_outpoint,
|
|
8741
8741
|
decode: decode_outpoint,
|
|
8742
8742
|
verify: verify_outpoint,
|
|
8743
8743
|
assert: assert_outpoint,
|
|
8744
8744
|
};
|
|
8745
|
-
|
|
8745
|
+
RefPointer.record_id = {
|
|
8746
8746
|
encode: encode_inscription_id,
|
|
8747
8747
|
decode: decode_inscription_id,
|
|
8748
8748
|
verify: verify_inscription_id,
|
|
8749
8749
|
assert: assert_inscription_id,
|
|
8750
8750
|
};
|
|
8751
|
-
|
|
8751
|
+
RefPointer.rune_id = {
|
|
8752
8752
|
encode: encode_rune_id,
|
|
8753
8753
|
decode: decode_rune_id,
|
|
8754
8754
|
verify: verify_rune_id,
|
|
8755
8755
|
assert: assert_rune_id,
|
|
8756
8756
|
};
|
|
8757
|
-
})(
|
|
8757
|
+
})(RefPointer || (RefPointer = {}));
|
|
8758
8758
|
function encode_inscription_id(txid, order = 0) {
|
|
8759
8759
|
return `${txid}i${order}`;
|
|
8760
8760
|
}
|
|
@@ -8972,15 +8972,15 @@ function is_valid_op(word) {
|
|
|
8972
8972
|
const MAX_WORD_SIZE = 520;
|
|
8973
8973
|
function encode_script(words, varint = false) {
|
|
8974
8974
|
if (words.length === 0)
|
|
8975
|
-
return
|
|
8975
|
+
return Buff.num(0, 1);
|
|
8976
8976
|
const bytes = [];
|
|
8977
8977
|
for (const word of words) {
|
|
8978
8978
|
bytes.push(encode_script_word(word));
|
|
8979
8979
|
}
|
|
8980
8980
|
const buffer = Buff.join(bytes);
|
|
8981
8981
|
return (varint)
|
|
8982
|
-
? buffer.prepend(Buff.varint(buffer.length, 'le'))
|
|
8983
|
-
: buffer
|
|
8982
|
+
? buffer.prepend(Buff.varint(buffer.length, 'le'))
|
|
8983
|
+
: buffer;
|
|
8984
8984
|
}
|
|
8985
8985
|
function encode_script_word(word) {
|
|
8986
8986
|
let buff;
|
|
@@ -9105,17 +9105,17 @@ function is_valid_script(script) {
|
|
|
9105
9105
|
const _0n = BigInt(0);
|
|
9106
9106
|
const _1n = BigInt(1);
|
|
9107
9107
|
const _26n = BigInt(26);
|
|
9108
|
-
var
|
|
9109
|
-
(function (
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
})(
|
|
9108
|
+
var InscriptionUtil;
|
|
9109
|
+
(function (InscriptionUtil) {
|
|
9110
|
+
InscriptionUtil.encode = encode_inscription;
|
|
9111
|
+
InscriptionUtil.decode = decode_inscription;
|
|
9112
|
+
})(InscriptionUtil || (InscriptionUtil = {}));
|
|
9113
9113
|
function decode_inscription(script) {
|
|
9114
9114
|
const envelopes = parse_envelopes(script);
|
|
9115
9115
|
return envelopes.map(parse_record);
|
|
9116
9116
|
}
|
|
9117
9117
|
function encode_inscription(data) {
|
|
9118
|
-
return data.map(create_envelope)
|
|
9118
|
+
return Buff.join(data.map(create_envelope));
|
|
9119
9119
|
}
|
|
9120
9120
|
function create_envelope(data) {
|
|
9121
9121
|
let asm = ['OP_0', 'OP_IF', '6f7264'];
|
|
@@ -9194,7 +9194,7 @@ function parse_record(envelope) {
|
|
|
9194
9194
|
i += 1;
|
|
9195
9195
|
break;
|
|
9196
9196
|
case 'OP_WITHIN':
|
|
9197
|
-
record.ref = envelope[i + 1];
|
|
9197
|
+
record.ref = decode_bytes(envelope[i + 1]);
|
|
9198
9198
|
i += 1;
|
|
9199
9199
|
break;
|
|
9200
9200
|
case 'OP_NOP':
|
|
@@ -9208,6 +9208,9 @@ function parse_record(envelope) {
|
|
|
9208
9208
|
}
|
|
9209
9209
|
return record;
|
|
9210
9210
|
}
|
|
9211
|
+
function decode_bytes(bytes) {
|
|
9212
|
+
return Buff.bytes(bytes).hex;
|
|
9213
|
+
}
|
|
9211
9214
|
function encode_id(identifier) {
|
|
9212
9215
|
Assert.ok(identifier.includes('i'), 'identifier must include an index');
|
|
9213
9216
|
const parts = identifier.split('i');
|
|
@@ -9216,8 +9219,8 @@ function encode_id(identifier) {
|
|
|
9216
9219
|
const txid = bytes.reverse().hex;
|
|
9217
9220
|
return (idx !== 0) ? txid + Buff.num(idx).hex : txid;
|
|
9218
9221
|
}
|
|
9219
|
-
function decode_id(
|
|
9220
|
-
const bytes = Buff.
|
|
9222
|
+
function decode_id(identifier) {
|
|
9223
|
+
const bytes = Buff.bytes(identifier);
|
|
9221
9224
|
const idx = bytes.at(-1) ?? 0;
|
|
9222
9225
|
const txid = bytes.slice(0, -1).reverse().hex;
|
|
9223
9226
|
return txid + 'i' + String(idx);
|
|
@@ -9225,14 +9228,14 @@ function decode_id(hexstr) {
|
|
|
9225
9228
|
function encode_pointer(pointer) {
|
|
9226
9229
|
return Buff.num(pointer).reverse().hex;
|
|
9227
9230
|
}
|
|
9228
|
-
function decode_pointer(
|
|
9229
|
-
return Buff.
|
|
9231
|
+
function decode_pointer(bytes) {
|
|
9232
|
+
return Buff.bytes(bytes).reverse().num;
|
|
9230
9233
|
}
|
|
9231
9234
|
function encode_label(label) {
|
|
9232
9235
|
return Buff.str(label).hex;
|
|
9233
9236
|
}
|
|
9234
|
-
function decode_label(
|
|
9235
|
-
return Buff.
|
|
9237
|
+
function decode_label(label) {
|
|
9238
|
+
return Buff.bytes(label).str;
|
|
9236
9239
|
}
|
|
9237
9240
|
function encode_content(content) {
|
|
9238
9241
|
const bytes = Buff.is_hex(content)
|
|
@@ -9252,9 +9255,9 @@ function encode_content(content) {
|
|
|
9252
9255
|
}
|
|
9253
9256
|
return chunks;
|
|
9254
9257
|
}
|
|
9255
|
-
function decode_content(
|
|
9256
|
-
const data = Buff.join(
|
|
9257
|
-
return (
|
|
9258
|
+
function decode_content(chunks, format = 'hex') {
|
|
9259
|
+
const data = Buff.join(chunks);
|
|
9260
|
+
return (format === 'hex')
|
|
9258
9261
|
? data.hex
|
|
9259
9262
|
: data.str;
|
|
9260
9263
|
}
|
|
@@ -9272,8 +9275,8 @@ function encode_rune_label(label) {
|
|
|
9272
9275
|
big = big - _1n;
|
|
9273
9276
|
return Buff.big(big).reverse().hex;
|
|
9274
9277
|
}
|
|
9275
|
-
function decode_rune_label(
|
|
9276
|
-
let big = Buff.
|
|
9278
|
+
function decode_rune_label(label) {
|
|
9279
|
+
let big = Buff.bytes(label).reverse().big;
|
|
9277
9280
|
big = big + _1n;
|
|
9278
9281
|
let result = '';
|
|
9279
9282
|
while (big > _0n) {
|
|
@@ -9296,11 +9299,11 @@ const TIMELOCK_TYPE = 0x00400000;
|
|
|
9296
9299
|
const TIMELOCK_VALUE_MASK = 0x0000FFFF;
|
|
9297
9300
|
const TIMELOCK_VALUE_MAX = 0xFFFF;
|
|
9298
9301
|
const TIMELOCK_GRANULARITY = 512;
|
|
9299
|
-
var
|
|
9300
|
-
(function (
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
})(
|
|
9302
|
+
var SequenceField;
|
|
9303
|
+
(function (SequenceField) {
|
|
9304
|
+
SequenceField.encode = encode_sequence;
|
|
9305
|
+
SequenceField.decode = decode_sequence;
|
|
9306
|
+
})(SequenceField || (SequenceField = {}));
|
|
9304
9307
|
function encode_sequence(data) {
|
|
9305
9308
|
if (data.mode === 'height') {
|
|
9306
9309
|
const height = parse_height(data.height);
|
|
@@ -9359,10 +9362,10 @@ function parse_height(height) {
|
|
|
9359
9362
|
|
|
9360
9363
|
var index$7 = /*#__PURE__*/Object.freeze({
|
|
9361
9364
|
__proto__: null,
|
|
9362
|
-
get
|
|
9363
|
-
get
|
|
9364
|
-
get
|
|
9365
|
-
get
|
|
9365
|
+
get InscriptionUtil () { return InscriptionUtil; },
|
|
9366
|
+
get LocktimeField () { return LocktimeField; },
|
|
9367
|
+
get RefPointer () { return RefPointer; },
|
|
9368
|
+
get SequenceField () { return SequenceField; },
|
|
9366
9369
|
decode_inscription: decode_inscription,
|
|
9367
9370
|
decode_locktime: decode_locktime,
|
|
9368
9371
|
decode_sequence: decode_sequence,
|
|
@@ -9676,26 +9679,28 @@ function encode_script_data(script) {
|
|
|
9676
9679
|
}
|
|
9677
9680
|
|
|
9678
9681
|
function is_return_script(script) {
|
|
9679
|
-
|
|
9682
|
+
const bytes = Buff.bytes(script);
|
|
9683
|
+
return bytes.at(0) === 0x6a;
|
|
9680
9684
|
}
|
|
9681
|
-
function
|
|
9685
|
+
function get_vout_script_info(script) {
|
|
9682
9686
|
return {
|
|
9683
|
-
type:
|
|
9684
|
-
version:
|
|
9687
|
+
type: get_vout_script_type(script),
|
|
9688
|
+
version: get_vout_script_version(script)
|
|
9685
9689
|
};
|
|
9686
9690
|
}
|
|
9687
|
-
function
|
|
9691
|
+
function get_vout_script_type(script) {
|
|
9692
|
+
const hex = Buff.bytes(script).hex;
|
|
9688
9693
|
for (const [type, regex] of Object.entries(LOCK_SCRIPT_REGEX)) {
|
|
9689
|
-
if (regex.test(
|
|
9694
|
+
if (regex.test(hex))
|
|
9690
9695
|
return type;
|
|
9691
9696
|
}
|
|
9692
|
-
return
|
|
9697
|
+
return null;
|
|
9693
9698
|
}
|
|
9694
|
-
function
|
|
9695
|
-
const
|
|
9696
|
-
switch (
|
|
9697
|
-
case
|
|
9698
|
-
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;
|
|
9699
9704
|
default: return null;
|
|
9700
9705
|
}
|
|
9701
9706
|
}
|
|
@@ -10004,10 +10009,10 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
10004
10009
|
get_txout_size: get_txout_size,
|
|
10005
10010
|
get_txsize: get_txsize,
|
|
10006
10011
|
get_vin_size: get_vin_size,
|
|
10007
|
-
|
|
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,
|
|
10008
10015
|
get_vout_size: get_vout_size,
|
|
10009
|
-
get_vout_type: get_vout_type,
|
|
10010
|
-
get_vout_version: get_vout_version,
|
|
10011
10016
|
get_vsize: get_vsize,
|
|
10012
10017
|
is_return_script: is_return_script,
|
|
10013
10018
|
normalize_prevout: normalize_prevout,
|