@vbyte/btc-dev 1.1.0 → 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/module.mjs CHANGED
@@ -8696,11 +8696,11 @@ var index$8 = /*#__PURE__*/Object.freeze({
8696
8696
  });
8697
8697
 
8698
8698
  const LOCKTIME_THRESHOLD = 500000000;
8699
- var LocktimeUtil;
8700
- (function (LocktimeUtil) {
8701
- LocktimeUtil.encode = encode_locktime;
8702
- LocktimeUtil.decode = decode_locktime;
8703
- })(LocktimeUtil || (LocktimeUtil = {}));
8699
+ var LocktimeField;
8700
+ (function (LocktimeField) {
8701
+ LocktimeField.encode = encode_locktime;
8702
+ LocktimeField.decode = decode_locktime;
8703
+ })(LocktimeField || (LocktimeField = {}));
8704
8704
  function encode_locktime(locktime) {
8705
8705
  switch (locktime.type) {
8706
8706
  case 'timelock':
@@ -8732,27 +8732,27 @@ function decode_locktime(locktime) {
8732
8732
  }
8733
8733
  }
8734
8734
 
8735
- var RefEncoder;
8736
- (function (RefEncoder) {
8737
- RefEncoder.outpoint = {
8735
+ var RefPointer;
8736
+ (function (RefPointer) {
8737
+ RefPointer.outpoint = {
8738
8738
  encode: encode_outpoint,
8739
8739
  decode: decode_outpoint,
8740
8740
  verify: verify_outpoint,
8741
8741
  assert: assert_outpoint,
8742
8742
  };
8743
- RefEncoder.record_id = {
8743
+ RefPointer.record_id = {
8744
8744
  encode: encode_inscription_id,
8745
8745
  decode: decode_inscription_id,
8746
8746
  verify: verify_inscription_id,
8747
8747
  assert: assert_inscription_id,
8748
8748
  };
8749
- RefEncoder.rune_id = {
8749
+ RefPointer.rune_id = {
8750
8750
  encode: encode_rune_id,
8751
8751
  decode: decode_rune_id,
8752
8752
  verify: verify_rune_id,
8753
8753
  assert: assert_rune_id,
8754
8754
  };
8755
- })(RefEncoder || (RefEncoder = {}));
8755
+ })(RefPointer || (RefPointer = {}));
8756
8756
  function encode_inscription_id(txid, order = 0) {
8757
8757
  return `${txid}i${order}`;
8758
8758
  }
@@ -8970,15 +8970,15 @@ function is_valid_op(word) {
8970
8970
  const MAX_WORD_SIZE = 520;
8971
8971
  function encode_script(words, varint = false) {
8972
8972
  if (words.length === 0)
8973
- return '00';
8973
+ return Buff.num(0, 1);
8974
8974
  const bytes = [];
8975
8975
  for (const word of words) {
8976
8976
  bytes.push(encode_script_word(word));
8977
8977
  }
8978
8978
  const buffer = Buff.join(bytes);
8979
8979
  return (varint)
8980
- ? buffer.prepend(Buff.varint(buffer.length, 'le')).hex
8981
- : buffer.hex;
8980
+ ? buffer.prepend(Buff.varint(buffer.length, 'le'))
8981
+ : buffer;
8982
8982
  }
8983
8983
  function encode_script_word(word) {
8984
8984
  let buff;
@@ -9103,17 +9103,17 @@ function is_valid_script(script) {
9103
9103
  const _0n = BigInt(0);
9104
9104
  const _1n = BigInt(1);
9105
9105
  const _26n = BigInt(26);
9106
- var ScribeEncoder;
9107
- (function (ScribeEncoder) {
9108
- ScribeEncoder.encode = encode_inscription;
9109
- ScribeEncoder.decode = decode_inscription;
9110
- })(ScribeEncoder || (ScribeEncoder = {}));
9106
+ var InscriptionUtil;
9107
+ (function (InscriptionUtil) {
9108
+ InscriptionUtil.encode = encode_inscription;
9109
+ InscriptionUtil.decode = decode_inscription;
9110
+ })(InscriptionUtil || (InscriptionUtil = {}));
9111
9111
  function decode_inscription(script) {
9112
9112
  const envelopes = parse_envelopes(script);
9113
9113
  return envelopes.map(parse_record);
9114
9114
  }
9115
9115
  function encode_inscription(data) {
9116
- return data.map(create_envelope).join('');
9116
+ return Buff.join(data.map(create_envelope));
9117
9117
  }
9118
9118
  function create_envelope(data) {
9119
9119
  let asm = ['OP_0', 'OP_IF', '6f7264'];
@@ -9192,7 +9192,7 @@ function parse_record(envelope) {
9192
9192
  i += 1;
9193
9193
  break;
9194
9194
  case 'OP_WITHIN':
9195
- record.ref = envelope[i + 1];
9195
+ record.ref = decode_bytes(envelope[i + 1]);
9196
9196
  i += 1;
9197
9197
  break;
9198
9198
  case 'OP_NOP':
@@ -9206,6 +9206,9 @@ function parse_record(envelope) {
9206
9206
  }
9207
9207
  return record;
9208
9208
  }
9209
+ function decode_bytes(bytes) {
9210
+ return Buff.bytes(bytes).hex;
9211
+ }
9209
9212
  function encode_id(identifier) {
9210
9213
  Assert.ok(identifier.includes('i'), 'identifier must include an index');
9211
9214
  const parts = identifier.split('i');
@@ -9214,8 +9217,8 @@ function encode_id(identifier) {
9214
9217
  const txid = bytes.reverse().hex;
9215
9218
  return (idx !== 0) ? txid + Buff.num(idx).hex : txid;
9216
9219
  }
9217
- function decode_id(hexstr) {
9218
- const bytes = Buff.hex(hexstr);
9220
+ function decode_id(identifier) {
9221
+ const bytes = Buff.bytes(identifier);
9219
9222
  const idx = bytes.at(-1) ?? 0;
9220
9223
  const txid = bytes.slice(0, -1).reverse().hex;
9221
9224
  return txid + 'i' + String(idx);
@@ -9223,14 +9226,14 @@ function decode_id(hexstr) {
9223
9226
  function encode_pointer(pointer) {
9224
9227
  return Buff.num(pointer).reverse().hex;
9225
9228
  }
9226
- function decode_pointer(hexstr) {
9227
- return Buff.hex(hexstr).reverse().num;
9229
+ function decode_pointer(bytes) {
9230
+ return Buff.bytes(bytes).reverse().num;
9228
9231
  }
9229
9232
  function encode_label(label) {
9230
9233
  return Buff.str(label).hex;
9231
9234
  }
9232
- function decode_label(hexstr) {
9233
- return Buff.hex(hexstr).str;
9235
+ function decode_label(label) {
9236
+ return Buff.bytes(label).str;
9234
9237
  }
9235
9238
  function encode_content(content) {
9236
9239
  const bytes = Buff.is_hex(content)
@@ -9250,9 +9253,9 @@ function encode_content(content) {
9250
9253
  }
9251
9254
  return chunks;
9252
9255
  }
9253
- function decode_content(hexstrs, type = 'hex') {
9254
- const data = Buff.join(hexstrs);
9255
- return (type === 'hex')
9256
+ function decode_content(chunks, format = 'hex') {
9257
+ const data = Buff.join(chunks);
9258
+ return (format === 'hex')
9256
9259
  ? data.hex
9257
9260
  : data.str;
9258
9261
  }
@@ -9270,8 +9273,8 @@ function encode_rune_label(label) {
9270
9273
  big = big - _1n;
9271
9274
  return Buff.big(big).reverse().hex;
9272
9275
  }
9273
- function decode_rune_label(hex) {
9274
- let big = Buff.hex(hex).reverse().big;
9276
+ function decode_rune_label(label) {
9277
+ let big = Buff.bytes(label).reverse().big;
9275
9278
  big = big + _1n;
9276
9279
  let result = '';
9277
9280
  while (big > _0n) {
@@ -9294,11 +9297,11 @@ const TIMELOCK_TYPE = 0x00400000;
9294
9297
  const TIMELOCK_VALUE_MASK = 0x0000FFFF;
9295
9298
  const TIMELOCK_VALUE_MAX = 0xFFFF;
9296
9299
  const TIMELOCK_GRANULARITY = 512;
9297
- var SequenceUtil;
9298
- (function (SequenceUtil) {
9299
- SequenceUtil.encode = encode_sequence;
9300
- SequenceUtil.decode = decode_sequence;
9301
- })(SequenceUtil || (SequenceUtil = {}));
9300
+ var SequenceField;
9301
+ (function (SequenceField) {
9302
+ SequenceField.encode = encode_sequence;
9303
+ SequenceField.decode = decode_sequence;
9304
+ })(SequenceField || (SequenceField = {}));
9302
9305
  function encode_sequence(data) {
9303
9306
  if (data.mode === 'height') {
9304
9307
  const height = parse_height(data.height);
@@ -9357,10 +9360,10 @@ function parse_height(height) {
9357
9360
 
9358
9361
  var index$7 = /*#__PURE__*/Object.freeze({
9359
9362
  __proto__: null,
9360
- get LocktimeUtil () { return LocktimeUtil; },
9361
- get RefEncoder () { return RefEncoder; },
9362
- get ScribeEncoder () { return ScribeEncoder; },
9363
- get SequenceUtil () { return SequenceUtil; },
9363
+ get InscriptionUtil () { return InscriptionUtil; },
9364
+ get LocktimeField () { return LocktimeField; },
9365
+ get RefPointer () { return RefPointer; },
9366
+ get SequenceField () { return SequenceField; },
9364
9367
  decode_inscription: decode_inscription,
9365
9368
  decode_locktime: decode_locktime,
9366
9369
  decode_sequence: decode_sequence,