@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/module.mjs CHANGED
@@ -9677,26 +9677,28 @@ function encode_script_data(script) {
9677
9677
  }
9678
9678
 
9679
9679
  function is_return_script(script) {
9680
- return script.startsWith('6a');
9680
+ const bytes = Buff.bytes(script);
9681
+ return bytes.at(0) === 0x6a;
9681
9682
  }
9682
- function get_vout_info(txout) {
9683
+ function get_vout_script_info(script) {
9683
9684
  return {
9684
- type: get_vout_type(txout.script_pk),
9685
- version: get_vout_version(txout.script_pk)
9685
+ type: get_vout_script_type(script),
9686
+ version: get_vout_script_version(script)
9686
9687
  };
9687
9688
  }
9688
- function get_vout_type(script) {
9689
+ function get_vout_script_type(script) {
9690
+ const hex = Buff.bytes(script).hex;
9689
9691
  for (const [type, regex] of Object.entries(LOCK_SCRIPT_REGEX)) {
9690
- if (regex.test(script))
9692
+ if (regex.test(hex))
9691
9693
  return type;
9692
9694
  }
9693
- return 'unknown';
9695
+ return null;
9694
9696
  }
9695
- function get_vout_version(script) {
9696
- const wit_ver = script.slice(0, 4);
9697
- switch (wit_ver) {
9698
- case '0014': return 0;
9699
- case '5120': return 1;
9697
+ function get_vout_script_version(script) {
9698
+ const version = Buff.bytes(script);
9699
+ switch (version.at(0)) {
9700
+ case 0x00: return 0;
9701
+ case 0x51: return 1;
9700
9702
  default: return null;
9701
9703
  }
9702
9704
  }
@@ -10005,10 +10007,10 @@ var index$4 = /*#__PURE__*/Object.freeze({
10005
10007
  get_txout_size: get_txout_size,
10006
10008
  get_txsize: get_txsize,
10007
10009
  get_vin_size: get_vin_size,
10008
- get_vout_info: get_vout_info,
10010
+ get_vout_script_info: get_vout_script_info,
10011
+ get_vout_script_type: get_vout_script_type,
10012
+ get_vout_script_version: get_vout_script_version,
10009
10013
  get_vout_size: get_vout_size,
10010
- get_vout_type: get_vout_type,
10011
- get_vout_version: get_vout_version,
10012
10014
  get_vsize: get_vsize,
10013
10015
  is_return_script: is_return_script,
10014
10016
  normalize_prevout: normalize_prevout,