@vbyte/btc-dev 1.0.15 → 1.1.1
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/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/taproot/cblock.js +1 -0
- package/dist/main.cjs +100 -4036
- package/dist/main.cjs.map +1 -1
- package/dist/module.mjs +99 -4034
- package/dist/module.mjs.map +1 -1
- package/dist/package.json +5 -9
- package/dist/schema/tx.d.ts +12 -12
- package/dist/script.js +8 -8
- package/dist/script.js.map +1 -1
- package/dist/types/taproot.d.ts +1 -0
- package/package.json +5 -9
- package/src/index.ts +0 -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/taproot/cblock.ts +1 -0
- package/src/types/taproot.ts +1 -0
- package/dist/lib/psbt/encoder.d.ts +0 -5
- package/dist/lib/psbt/encoder.js +0 -21
- package/dist/lib/psbt/index.d.ts +0 -4
- package/dist/lib/psbt/index.js +0 -4
- package/dist/lib/psbt/meta.d.ts +0 -3
- package/dist/lib/psbt/meta.js +0 -11
- package/dist/lib/psbt/util.d.ts +0 -5
- package/dist/lib/psbt/util.js +0 -44
- package/dist/lib/psbt/validate.d.ts +0 -2
- package/dist/lib/psbt/validate.js +0 -11
- package/src/lib/psbt/encoder.ts +0 -24
- package/src/lib/psbt/index.ts +0 -4
- package/src/lib/psbt/meta.ts +0 -15
- package/src/lib/psbt/util.ts +0 -62
- package/src/lib/psbt/validate.ts +0 -18
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * as ADDRESS from './lib/address/index.js';
|
|
2
2
|
export * as META from './lib/meta/index.js';
|
|
3
|
-
export * as PSBT from './lib/psbt/index.js';
|
|
4
3
|
export * as SCRIPT from './lib/script/index.js';
|
|
5
4
|
export * as SIGHASH from './lib/sighash/index.js';
|
|
6
5
|
export * as SIGNER from './lib/signer/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * as ADDRESS from './lib/address/index.js';
|
|
2
2
|
export * as META from './lib/meta/index.js';
|
|
3
|
-
export * as PSBT from './lib/psbt/index.js';
|
|
4
3
|
export * as SCRIPT from './lib/script/index.js';
|
|
5
4
|
export * as SIGHASH from './lib/sighash/index.js';
|
|
6
5
|
export * as SIGNER from './lib/signer/index.js';
|
|
@@ -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;
|