@smartledger/bsv 7.9.0 → 7.10.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/CHANGELOG.md +103 -0
- package/README.md +38 -38
- package/bsv-covenant.min.js +1 -1
- package/bsv-ecies.min.js +1 -1
- package/bsv-gdaf.min.js +54 -54
- package/bsv-ltp.min.js +58 -85
- package/bsv-message.min.js +2 -2
- package/bsv-mnemonic.min.js +12 -14
- package/bsv-script-helper.min.js +1 -1
- package/bsv-shamir.min.js +14 -16
- package/bsv-smartcontract.min.js +23 -25
- package/bsv.bundle.js +54 -54
- package/bsv.min.js +54 -54
- package/build/esbuild.js +86 -5
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/index.js +9 -1
- package/lib/covenant/helpers.js +146 -0
- package/lib/covenant/index.js +21 -0
- package/lib/covenant/pushtx.js +243 -0
- package/lib/covenant-interface.js +418 -397
- package/lib/custom-script-helper.js +44 -38
- package/lib/ecies/bitcore-ecies.js +3 -4
- package/lib/ecies/electrum-ecies.js +4 -6
- package/lib/ecies/errors.js +1 -1
- package/lib/gdaf/attestation-signer.js +7 -7
- package/lib/gdaf/attestation-verifier.js +5 -6
- package/lib/gdaf/did-resolver.js +10 -9
- package/lib/gdaf/smartledger-anchor.js +13 -12
- package/lib/gdaf/zk-prover.js +8 -8
- package/lib/ltp/anchor.js +2 -3
- package/lib/ltp/claim.js +2 -3
- package/lib/ltp/index.js +2 -3
- package/lib/ltp/obligation.js +9 -9
- package/lib/ltp/proof.js +7 -7
- package/lib/ltp/registry.js +4 -5
- package/lib/ltp/right.js +11 -11
- package/lib/message/index.js +5 -4
- package/lib/message/message.js +11 -11
- package/lib/mnemonic/errors.js +1 -1
- package/lib/mnemonic/index.js +5 -4
- package/lib/mnemonic/mnemonic.js +22 -10
- package/lib/ordinals/bsv20.js +4 -4
- package/lib/ordinals/inscription.js +8 -12
- package/lib/ordinals/ordlock.js +26 -21
- package/lib/smart_contract/authorizers.js +8 -6
- package/lib/smart_contract/builder.js +32 -26
- package/lib/smart_contract/covenant.js +32 -25
- package/lib/smart_contract/covenant_helpers.js +8 -139
- package/lib/smart_contract/debugger.js +9 -6
- package/lib/smart_contract/dsl.js +5 -6
- package/lib/smart_contract/index.js +11 -8
- package/lib/smart_contract/locks.js +3 -4
- package/lib/smart_contract/opcode_list.js +2 -3
- package/lib/smart_contract/pels.js +4 -5
- package/lib/smart_contract/preimage.js +11 -7
- package/lib/smart_contract/pushtx.js +8 -263
- package/lib/smart_contract/script_interpreter.js +112 -105
- package/lib/smart_contract/script_tester.js +24 -18
- package/lib/smart_contract/script_utils.js +15 -14
- package/lib/smart_contract/sighash.js +23 -15
- package/lib/smart_contract/stack_examiner.js +70 -63
- package/lib/smart_contract/token.js +6 -6
- package/lib/smart_contract/utxo_generator.js +21 -15
- package/lib/smartutxo.js +27 -21
- package/lib/spv/headerchain.js +3 -3
- package/lib/spv/merkleproof.js +3 -3
- package/package.json +4 -2
- package/test/build/bundle_externals.js +116 -0
- package/version.js +1 -1
package/bsv-script-helper.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var bsvScriptHelper=(()=>{var kr=Object.create;var or=Object.defineProperty;var $r=Object.getOwnPropertyDescriptor;var Gr=Object.getOwnPropertyNames;var Kr=Object.getPrototypeOf,Yr=Object.prototype.hasOwnProperty;var qr=(e,r,t)=>()=>{if(t)throw t[0];try{return e&&(r=e(e=0)),r}catch(i){throw t=[i],i}};var R=(e,r)=>()=>{try{return r||e((r={exports:{}}).exports,r),r.exports}catch(t){throw r=0,t}};var Vr=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of Gr(r))!Yr.call(e,n)&&n!==t&&or(e,n,{get:()=>r[n],enumerable:!(i=$r(r,n))||i.enumerable});return e};var ur=(e,r,t)=>(t=e!=null?kr(Kr(e)):{},Vr(r||!e||!e.__esModule?or(t,"default",{value:e,enumerable:!0}):t,e));var sr=R((_t,pr)=>{d();var y=pr.exports={},I,m;function j(){throw new Error("setTimeout has not been defined")}function X(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?I=setTimeout:I=j}catch{I=j}try{typeof clearTimeout=="function"?m=clearTimeout:m=X}catch{m=X}})();function cr(e){if(I===setTimeout)return setTimeout(e,0);if((I===j||!I)&&setTimeout)return I=setTimeout,setTimeout(e,0);try{return I(e,0)}catch{try{return I.call(null,e,0)}catch{return I.call(this,e,0)}}}function Wr(e){if(m===clearTimeout)return clearTimeout(e);if((m===X||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(e);try{return m(e)}catch{try{return m.call(null,e)}catch{return m.call(this,e)}}}var S=[],D=!1,C,K=-1;function jr(){!D||!C||(D=!1,C.length?S=C.concat(S):K=-1,S.length&&fr())}function fr(){if(!D){var e=cr(jr);D=!0;for(var r=S.length;r;){for(C=S,S=[];++K<r;)C&&C[K].run();K=-1,r=S.length}C=null,D=!1,Wr(e)}}y.nextTick=function(e){var r=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)r[t-1]=arguments[t];S.push(new hr(e,r)),S.length===1&&!D&&cr(fr)};function hr(e,r){this.fun=e,this.array=r}hr.prototype.run=function(){this.fun.apply(null,this.array)};y.title="browser";y.browser=!0;y.env={};y.argv=[];y.version="";y.versions={};function U(){}y.on=U;y.addListener=U;y.once=U;y.off=U;y.removeListener=U;y.removeAllListeners=U;y.emit=U;y.prependListener=U;y.prependOnceListener=U;y.listeners=function(e){return[]};y.binding=function(e){throw new Error("process.binding is not supported")};y.cwd=function(){return"/"};y.chdir=function(e){throw new Error("process.chdir is not supported")};y.umask=function(){return 0}});var yr=R(Y=>{"use strict";d();Y.byteLength=Qr;Y.toByteArray=Jr;Y.fromByteArray=rt;var F=[],B=[],Xr=typeof Uint8Array<"u"?Uint8Array:Array,Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(O=0,ar=Q.length;O<ar;++O)F[O]=Q[O],B[Q.charCodeAt(O)]=O;var O,ar;B[45]=62;B[95]=63;function lr(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var i=t===r?0:4-t%4;return[t,i]}function Qr(e){var r=lr(e),t=r[0],i=r[1];return(t+i)*3/4-i}function zr(e,r,t){return(r+t)*3/4-t}function Jr(e){var r,t=lr(e),i=t[0],n=t[1],o=new Xr(zr(e,i,n)),u=0,f=n>0?i-4:i,h;for(h=0;h<f;h+=4)r=B[e.charCodeAt(h)]<<18|B[e.charCodeAt(h+1)]<<12|B[e.charCodeAt(h+2)]<<6|B[e.charCodeAt(h+3)],o[u++]=r>>16&255,o[u++]=r>>8&255,o[u++]=r&255;return n===2&&(r=B[e.charCodeAt(h)]<<2|B[e.charCodeAt(h+1)]>>4,o[u++]=r&255),n===1&&(r=B[e.charCodeAt(h)]<<10|B[e.charCodeAt(h+1)]<<4|B[e.charCodeAt(h+2)]>>2,o[u++]=r>>8&255,o[u++]=r&255),o}function Zr(e){return F[e>>18&63]+F[e>>12&63]+F[e>>6&63]+F[e&63]}function vr(e,r,t){for(var i,n=[],o=r;o<t;o+=3)i=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),n.push(Zr(i));return n.join("")}function rt(e){for(var r,t=e.length,i=t%3,n=[],o=16383,u=0,f=t-i;u<f;u+=o)n.push(vr(e,u,u+o>f?f:u+o));return i===1?(r=e[t-1],n.push(F[r>>2]+F[r<<4&63]+"==")):i===2&&(r=(e[t-2]<<8)+e[t-1],n.push(F[r>>10]+F[r>>4&63]+F[r<<2&63]+"=")),n.join("")}});var wr=R(z=>{d();z.read=function(e,r,t,i,n){var o,u,f=n*8-i-1,h=(1<<f)-1,l=h>>1,a=-7,s=t?n-1:0,N=t?-1:1,g=e[r+s];for(s+=N,o=g&(1<<-a)-1,g>>=-a,a+=f;a>0;o=o*256+e[r+s],s+=N,a-=8);for(u=o&(1<<-a)-1,o>>=-a,a+=i;a>0;u=u*256+e[r+s],s+=N,a-=8);if(o===0)o=1-l;else{if(o===h)return u?NaN:(g?-1:1)*(1/0);u=u+Math.pow(2,i),o=o-l}return(g?-1:1)*u*Math.pow(2,o-i)};z.write=function(e,r,t,i,n,o){var u,f,h,l=o*8-n-1,a=(1<<l)-1,s=a>>1,N=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=i?0:o-1,W=i?1:-1,Hr=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(f=isNaN(r)?1:0,u=a):(u=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-u))<1&&(u--,h*=2),u+s>=1?r+=N/h:r+=N*Math.pow(2,1-s),r*h>=2&&(u++,h/=2),u+s>=a?(f=0,u=a):u+s>=1?(f=(r*h-1)*Math.pow(2,n),u=u+s):(f=r*Math.pow(2,s-1)*Math.pow(2,n),u=0));n>=8;e[t+g]=f&255,g+=W,f/=256,n-=8);for(u=u<<n|f,l+=n;l>0;e[t+g]=u&255,g+=W,u/=256,l-=8);e[t+g-W]|=Hr*128}});var Lr=R(k=>{"use strict";d();var J=yr(),b=wr(),dr=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;k.Buffer=c;k.SlowBuffer=ut;k.INSPECT_MAX_BYTES=50;var q=2147483647;k.kMaxLength=q;c.TYPED_ARRAY_SUPPORT=tt();!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function tt(){try{let e=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(e,r),e.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}});Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function T(e){if(e>q)throw new RangeError('The value "'+e+'" is invalid for option "size"');let r=new Uint8Array(e);return Object.setPrototypeOf(r,c.prototype),r}function c(e,r,t){if(typeof e=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return tr(e)}return gr(e,r,t)}c.poolSize=8192;function gr(e,r,t){if(typeof e=="string")return it(e,r);if(ArrayBuffer.isView(e))return nt(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(A(e,ArrayBuffer)||e&&A(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(A(e,SharedArrayBuffer)||e&&A(e.buffer,SharedArrayBuffer)))return v(e,r,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=e.valueOf&&e.valueOf();if(i!=null&&i!==e)return c.from(i,r,t);let n=ot(e);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return c.from(e[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}c.from=function(e,r,t){return gr(e,r,t)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function Ir(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function et(e,r,t){return Ir(e),e<=0?T(e):r!==void 0?typeof t=="string"?T(e).fill(r,t):T(e).fill(r):T(e)}c.alloc=function(e,r,t){return et(e,r,t)};function tr(e){return Ir(e),T(e<0?0:er(e)|0)}c.allocUnsafe=function(e){return tr(e)};c.allocUnsafeSlow=function(e){return tr(e)};function it(e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=mr(e,r)|0,i=T(t),n=i.write(e,r);return n!==t&&(i=i.slice(0,n)),i}function Z(e){let r=e.length<0?0:er(e.length)|0,t=T(r);for(let i=0;i<r;i+=1)t[i]=e[i]&255;return t}function nt(e){if(A(e,Uint8Array)){let r=new Uint8Array(e);return v(r.buffer,r.byteOffset,r.byteLength)}return Z(e)}function v(e,r,t){if(r<0||e.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return r===void 0&&t===void 0?i=new Uint8Array(e):t===void 0?i=new Uint8Array(e,r):i=new Uint8Array(e,r,t),Object.setPrototypeOf(i,c.prototype),i}function ot(e){if(c.isBuffer(e)){let r=er(e.length)|0,t=T(r);return t.length===0||e.copy(t,0,0,r),t}if(e.length!==void 0)return typeof e.length!="number"||nr(e.length)?T(0):Z(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Z(e.data)}function er(e){if(e>=q)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q.toString(16)+" bytes");return e|0}function ut(e){return+e!=e&&(e=0),c.alloc(+e)}c.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==c.prototype};c.compare=function(r,t){if(A(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),A(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(r)||!c.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let i=r.length,n=t.length;for(let o=0,u=Math.min(i,n);o<u;++o)if(r[o]!==t[o]){i=r[o],n=t[o];break}return i<n?-1:n<i?1:0};c.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};c.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return c.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<r.length;++i)t+=r[i].length;let n=c.allocUnsafe(t),o=0;for(i=0;i<r.length;++i){let u=r[i];if(A(u,Uint8Array))o+u.length>n.length?(c.isBuffer(u)||(u=c.from(u)),u.copy(n,o)):Uint8Array.prototype.set.call(n,u,o);else if(c.isBuffer(u))u.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=u.length}return n};function mr(e,r){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||A(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let t=e.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let n=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return rr(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Or(e).length;default:if(n)return i?-1:rr(e).length;r=(""+r).toLowerCase(),n=!0}}c.byteLength=mr;function ct(e,r,t){let i=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(e||(e="utf8");;)switch(e){case"hex":return xt(this,r,t);case"utf8":case"utf-8":return Ar(this,r,t);case"ascii":return wt(this,r,t);case"latin1":case"binary":return dt(this,r,t);case"base64":return lt(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,r,t);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}c.prototype._isBuffer=!0;function P(e,r,t){let i=e[r];e[r]=e[t],e[t]=i}c.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)P(this,t,t+1);return this};c.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)P(this,t,t+3),P(this,t+1,t+2);return this};c.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)P(this,t,t+7),P(this,t+1,t+6),P(this,t+2,t+5),P(this,t+3,t+4);return this};c.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?Ar(this,0,r):ct.apply(this,arguments)};c.prototype.toLocaleString=c.prototype.toString;c.prototype.equals=function(r){if(!c.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:c.compare(this,r)===0};c.prototype.inspect=function(){let r="",t=k.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"};dr&&(c.prototype[dr]=c.prototype.inspect);c.prototype.compare=function(r,t,i,n,o){if(A(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),i===void 0&&(i=r?r.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),t<0||i>r.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=i)return 0;if(n>=o)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,o>>>=0,this===r)return 0;let u=o-n,f=i-t,h=Math.min(u,f),l=this.slice(n,o),a=r.slice(t,i);for(let s=0;s<h;++s)if(l[s]!==a[s]){u=l[s],f=a[s];break}return u<f?-1:f<u?1:0};function Fr(e,r,t,i,n){if(e.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,nr(t)&&(t=n?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(n)return-1;t=e.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof r=="string"&&(r=c.from(r,i)),c.isBuffer(r))return r.length===0?-1:xr(e,r,t,i,n);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):xr(e,[r],t,i,n);throw new TypeError("val must be string, number or Buffer")}function xr(e,r,t,i,n){let o=1,u=e.length,f=r.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(e.length<2||r.length<2)return-1;o=2,u/=2,f/=2,t/=2}function h(a,s){return o===1?a[s]:a.readUInt16BE(s*o)}let l;if(n){let a=-1;for(l=t;l<u;l++)if(h(e,l)===h(r,a===-1?0:l-a)){if(a===-1&&(a=l),l-a+1===f)return a*o}else a!==-1&&(l-=l-a),a=-1}else for(t+f>u&&(t=u-f),l=t;l>=0;l--){let a=!0;for(let s=0;s<f;s++)if(h(e,l+s)!==h(r,s)){a=!1;break}if(a)return l}return-1}c.prototype.includes=function(r,t,i){return this.indexOf(r,t,i)!==-1};c.prototype.indexOf=function(r,t,i){return Fr(this,r,t,i,!0)};c.prototype.lastIndexOf=function(r,t,i){return Fr(this,r,t,i,!1)};function ft(e,r,t,i){t=Number(t)||0;let n=e.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;let o=r.length;i>o/2&&(i=o/2);let u;for(u=0;u<i;++u){let f=parseInt(r.substr(u*2,2),16);if(nr(f))return u;e[t+u]=f}return u}function ht(e,r,t,i){return V(rr(r,e.length-t),e,t,i)}function pt(e,r,t,i){return V(mt(r),e,t,i)}function st(e,r,t,i){return V(Or(r),e,t,i)}function at(e,r,t,i){return V(Ft(r,e.length-t),e,t,i)}c.prototype.write=function(r,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((i===void 0||i>o)&&(i=o),r.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let u=!1;for(;;)switch(n){case"hex":return ft(this,r,t,i);case"utf8":case"utf-8":return ht(this,r,t,i);case"ascii":case"latin1":case"binary":return pt(this,r,t,i);case"base64":return st(this,r,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return at(this,r,t,i);default:if(u)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),u=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function lt(e,r,t){return r===0&&t===e.length?J.fromByteArray(e):J.fromByteArray(e.slice(r,t))}function Ar(e,r,t){t=Math.min(e.length,t);let i=[],n=r;for(;n<t;){let o=e[n],u=null,f=o>239?4:o>223?3:o>191?2:1;if(n+f<=t){let h,l,a,s;switch(f){case 1:o<128&&(u=o);break;case 2:h=e[n+1],(h&192)===128&&(s=(o&31)<<6|h&63,s>127&&(u=s));break;case 3:h=e[n+1],l=e[n+2],(h&192)===128&&(l&192)===128&&(s=(o&15)<<12|(h&63)<<6|l&63,s>2047&&(s<55296||s>57343)&&(u=s));break;case 4:h=e[n+1],l=e[n+2],a=e[n+3],(h&192)===128&&(l&192)===128&&(a&192)===128&&(s=(o&15)<<18|(h&63)<<12|(l&63)<<6|a&63,s>65535&&s<1114112&&(u=s))}}u===null?(u=65533,f=1):u>65535&&(u-=65536,i.push(u>>>10&1023|55296),u=56320|u&1023),i.push(u),n+=f}return yt(i)}var Er=4096;function yt(e){let r=e.length;if(r<=Er)return String.fromCharCode.apply(String,e);let t="",i=0;for(;i<r;)t+=String.fromCharCode.apply(String,e.slice(i,i+=Er));return t}function wt(e,r,t){let i="";t=Math.min(e.length,t);for(let n=r;n<t;++n)i+=String.fromCharCode(e[n]&127);return i}function dt(e,r,t){let i="";t=Math.min(e.length,t);for(let n=r;n<t;++n)i+=String.fromCharCode(e[n]);return i}function xt(e,r,t){let i=e.length;(!r||r<0)&&(r=0),(!t||t<0||t>i)&&(t=i);let n="";for(let o=r;o<t;++o)n+=At[e[o]];return n}function Et(e,r,t){let i=e.slice(r,t),n="";for(let o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}c.prototype.slice=function(r,t){let i=this.length;r=~~r,t=t===void 0?i:~~t,r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<r&&(t=r);let n=this.subarray(r,t);return Object.setPrototypeOf(n,c.prototype),n};function w(e,r,t){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+r>t)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r],o=1,u=0;for(;++u<t&&(o*=256);)n+=this[r+u]*o;return n};c.prototype.readUintBE=c.prototype.readUIntBE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r+--t],o=1;for(;t>0&&(o*=256);)n+=this[r+--t]*o;return n};c.prototype.readUint8=c.prototype.readUInt8=function(r,t){return r=r>>>0,t||w(r,1,this.length),this[r]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||w(r,2,this.length),this[r]|this[r+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||w(r,2,this.length),this[r]<<8|this[r+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||w(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};c.prototype.readUint32BE=c.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};c.prototype.readBigUInt64LE=_(function(r){r=r>>>0,H(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&G(r,this.length-8);let n=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,o=this[++r]+this[++r]*2**8+this[++r]*2**16+i*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))});c.prototype.readBigUInt64BE=_(function(r){r=r>>>0,H(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&G(r,this.length-8);let n=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],o=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+i;return(BigInt(n)<<BigInt(32))+BigInt(o)});c.prototype.readIntLE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r],o=1,u=0;for(;++u<t&&(o*=256);)n+=this[r+u]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*t)),n};c.prototype.readIntBE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=t,o=1,u=this[r+--n];for(;n>0&&(o*=256);)u+=this[r+--n]*o;return o*=128,u>=o&&(u-=Math.pow(2,8*t)),u};c.prototype.readInt8=function(r,t){return r=r>>>0,t||w(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};c.prototype.readInt16LE=function(r,t){r=r>>>0,t||w(r,2,this.length);let i=this[r]|this[r+1]<<8;return i&32768?i|4294901760:i};c.prototype.readInt16BE=function(r,t){r=r>>>0,t||w(r,2,this.length);let i=this[r+1]|this[r]<<8;return i&32768?i|4294901760:i};c.prototype.readInt32LE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};c.prototype.readInt32BE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};c.prototype.readBigInt64LE=_(function(r){r=r>>>0,H(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&G(r,this.length-8);let n=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)});c.prototype.readBigInt64BE=_(function(r){r=r>>>0,H(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&G(r,this.length-8);let n=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(n)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+i)});c.prototype.readFloatLE=function(r,t){return r=r>>>0,t||w(r,4,this.length),b.read(this,r,!0,23,4)};c.prototype.readFloatBE=function(r,t){return r=r>>>0,t||w(r,4,this.length),b.read(this,r,!1,23,4)};c.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||w(r,8,this.length),b.read(this,r,!0,52,8)};c.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||w(r,8,this.length),b.read(this,r,!1,52,8)};function x(e,r,t,i,n,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>n||r<o)throw new RangeError('"value" argument is out of bounds');if(t+i>e.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(r,t,i,n){if(r=+r,t=t>>>0,i=i>>>0,!n){let f=Math.pow(2,8*i)-1;x(this,r,t,i,f,0)}let o=1,u=0;for(this[t]=r&255;++u<i&&(o*=256);)this[t+u]=r/o&255;return t+i};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(r,t,i,n){if(r=+r,t=t>>>0,i=i>>>0,!n){let f=Math.pow(2,8*i)-1;x(this,r,t,i,f,0)}let o=i-1,u=1;for(this[t+o]=r&255;--o>=0&&(u*=256);)this[t+o]=r/u&255;return t+i};c.prototype.writeUint8=c.prototype.writeUInt8=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,1,255,0),this[t]=r&255,t+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2};c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2};c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4};c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function Sr(e,r,t,i,n){Cr(r,i,n,e,t,7);let o=Number(r&BigInt(4294967295));e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,t}function Ur(e,r,t,i,n){Cr(r,i,n,e,t,7);let o=Number(r&BigInt(4294967295));e[t+7]=o,o=o>>8,e[t+6]=o,o=o>>8,e[t+5]=o,o=o>>8,e[t+4]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t+3]=u,u=u>>8,e[t+2]=u,u=u>>8,e[t+1]=u,u=u>>8,e[t]=u,t+8}c.prototype.writeBigUInt64LE=_(function(r,t=0){return Sr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=_(function(r,t=0){return Ur(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(r,t,i,n){if(r=+r,t=t>>>0,!n){let h=Math.pow(2,8*i-1);x(this,r,t,i,h-1,-h)}let o=0,u=1,f=0;for(this[t]=r&255;++o<i&&(u*=256);)r<0&&f===0&&this[t+o-1]!==0&&(f=1),this[t+o]=(r/u>>0)-f&255;return t+i};c.prototype.writeIntBE=function(r,t,i,n){if(r=+r,t=t>>>0,!n){let h=Math.pow(2,8*i-1);x(this,r,t,i,h-1,-h)}let o=i-1,u=1,f=0;for(this[t+o]=r&255;--o>=0&&(u*=256);)r<0&&f===0&&this[t+o+1]!==0&&(f=1),this[t+o]=(r/u>>0)-f&255;return t+i};c.prototype.writeInt8=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1};c.prototype.writeInt16LE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};c.prototype.writeInt16BE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};c.prototype.writeInt32LE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4};c.prototype.writeInt32BE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};c.prototype.writeBigInt64LE=_(function(r,t=0){return Sr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=_(function(r,t=0){return Ur(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Tr(e,r,t,i,n,o){if(t+i>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function _r(e,r,t,i,n){return r=+r,t=t>>>0,n||Tr(e,r,t,4,34028234663852886e22,-34028234663852886e22),b.write(e,r,t,i,23,4),t+4}c.prototype.writeFloatLE=function(r,t,i){return _r(this,r,t,!0,i)};c.prototype.writeFloatBE=function(r,t,i){return _r(this,r,t,!1,i)};function Rr(e,r,t,i,n){return r=+r,t=t>>>0,n||Tr(e,r,t,8,17976931348623157e292,-17976931348623157e292),b.write(e,r,t,i,52,8),t+8}c.prototype.writeDoubleLE=function(r,t,i){return Rr(this,r,t,!0,i)};c.prototype.writeDoubleBE=function(r,t,i){return Rr(this,r,t,!1,i)};c.prototype.copy=function(r,t,i,n){if(!c.isBuffer(r))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),t>=r.length&&(t=r.length),t||(t=0),n>0&&n<i&&(n=i),n===i||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),r.length-t<n-i&&(n=r.length-t+i);let o=n-i;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,n):Uint8Array.prototype.set.call(r,this.subarray(i,n),t),o};c.prototype.fill=function(r,t,i,n){if(typeof r=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(r.length===1){let u=r.charCodeAt(0);(n==="utf8"&&u<128||n==="latin1")&&(r=u)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,r||(r=0);let o;if(typeof r=="number")for(o=t;o<i;++o)this[o]=r;else{let u=c.isBuffer(r)?r:c.from(r,n),f=u.length;if(f===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(o=0;o<i-t;++o)this[o+t]=u[o%f]}return this};var M={};function ir(e,r,t){M[e]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}ir("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ir("ERR_INVALID_ARG_TYPE",function(e,r){return`The "${e}" argument must be of type number. Received type ${typeof r}`},TypeError);ir("ERR_OUT_OF_RANGE",function(e,r,t){let i=`The value of "${e}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>2**32?n=Br(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=Br(n)),n+="n"),i+=` It must be ${r}. Received ${n}`,i},RangeError);function Br(e){let r="",t=e.length,i=e[0]==="-"?1:0;for(;t>=i+4;t-=3)r=`_${e.slice(t-3,t)}${r}`;return`${e.slice(0,t)}${r}`}function Bt(e,r,t){H(r,"offset"),(e[r]===void 0||e[r+t]===void 0)&&G(r,e.length-(t+1))}function Cr(e,r,t,i,n,o){if(e>t||e<r){let u=typeof r=="bigint"?"n":"",f;throw o>3?r===0||r===BigInt(0)?f=`>= 0${u} and < 2${u} ** ${(o+1)*8}${u}`:f=`>= -(2${u} ** ${(o+1)*8-1}${u}) and < 2 ** ${(o+1)*8-1}${u}`:f=`>= ${r}${u} and <= ${t}${u}`,new M.ERR_OUT_OF_RANGE("value",f,e)}Bt(i,n,o)}function H(e,r){if(typeof e!="number")throw new M.ERR_INVALID_ARG_TYPE(r,"number",e)}function G(e,r,t){throw Math.floor(e)!==e?(H(e,t),new M.ERR_OUT_OF_RANGE(t||"offset","an integer",e)):r<0?new M.ERR_BUFFER_OUT_OF_BOUNDS:new M.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,e)}var gt=/[^+/0-9A-Za-z-_]/g;function It(e){if(e=e.split("=")[0],e=e.trim().replace(gt,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function rr(e,r){r=r||1/0;let t,i=e.length,n=null,o=[];for(let u=0;u<i;++u){if(t=e.charCodeAt(u),t>55295&&t<57344){if(!n){if(t>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(u+1===i){(r-=3)>-1&&o.push(239,191,189);continue}n=t;continue}if(t<56320){(r-=3)>-1&&o.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(r-=3)>-1&&o.push(239,191,189);if(n=null,t<128){if((r-=1)<0)break;o.push(t)}else if(t<2048){if((r-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function mt(e){let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t)&255);return r}function Ft(e,r){let t,i,n,o=[];for(let u=0;u<e.length&&!((r-=2)<0);++u)t=e.charCodeAt(u),i=t>>8,n=t%256,o.push(n),o.push(i);return o}function Or(e){return J.toByteArray(It(e))}function V(e,r,t,i){let n;for(n=0;n<i&&!(n+t>=r.length||n>=e.length);++n)r[n+t]=e[n];return n}function A(e,r){return e instanceof r||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===r.name}function nr(e){return e!==e}var At=(function(){let e="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let n=0;n<16;++n)r[i+n]=e[t]+e[n]}return r})();function _(e){return typeof BigInt>"u"?St:e}function St(){throw new Error("BigInt not supported")}});var L,E,d=qr(()=>{L=ur(sr()),E=ur(Lr())});var Nr=R((Ht,Pr)=>{d();Pr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv});var Mr=R(($t,Dr)=>{d();var p=Nr(),$=class{static createSignature(r,t,i,n,o,u=null){u=u||p.crypto.Signature.SIGHASH_ALL|p.crypto.Signature.SIGHASH_FORKID;let f=p.Transaction.sighash.sign(r,t,u,i,n,new p.crypto.BN(o));return E.Buffer.concat([f.toDER(),E.Buffer.from([u])])}static createMultisigScript(r,t){let i=new p.Script().add(p.Opcode[`OP_${r}`]);for(let n of t)i=i.add(n.toBuffer());return i.add(p.Opcode[`OP_${t.length}`]).add(p.Opcode.OP_CHECKMULTISIG)}static createMultisigUnlocking(r){let t=new p.Script().add(p.Opcode.OP_0);for(let i of r)t=t.add(i);return t}static createTimelockScript(r,t){let i=E.Buffer.from(r.toString(16).padStart(8,"0"),"hex").reverse();return new p.Script().add(i).add(p.Opcode.OP_CHECKLOCKTIMEVERIFY).add(p.Opcode.OP_DROP).add(t.toBuffer())}static createConditionalScript(r,t=null){let i=new p.Script().add(p.Opcode.OP_IF).add(r.toBuffer());return t&&(i=i.add(p.Opcode.OP_ELSE).add(t.toBuffer())),i.add(p.Opcode.OP_ENDIF)}static createP2PKHScript(r){return new p.Script().add(p.Opcode.OP_DUP).add(p.Opcode.OP_HASH160).add(r.toAddress().hashBuffer).add(p.Opcode.OP_EQUALVERIFY).add(p.Opcode.OP_CHECKSIG)}static createP2PKHUnlocking(r,t){return new p.Script().add(r).add(t.toBuffer())}static getPreimage(r,t,i,n,o=null){return o=o||p.crypto.Signature.SIGHASH_ALL|p.crypto.Signature.SIGHASH_FORKID,p.Transaction.sighash.sighash(r,o,t,i,new p.crypto.BN(n))}static createDataScript(r){return typeof r=="string"&&(r=E.Buffer.from(r,"utf8")),new p.Script().add(r)}static createOpReturnScript(r){return typeof r=="string"&&(r=E.Buffer.from(r,"utf8")),new p.Script().add(p.Opcode.OP_FALSE).add(p.Opcode.OP_RETURN).add(r)}static validateTransaction(r){try{return r.verify()}catch(t){return console.error("Transaction validation error:",t.message),!1}}static validateScript(r,t,i,n){try{return new p.Script.Interpreter().verify(r,t,i,n,p.Script.Interpreter.SCRIPT_VERIFY_P2SH|p.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|p.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID|p.Script.Interpreter.SCRIPT_ENABLE_MAGNETIC_OPCODES|p.Script.Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES)}catch(o){return console.error("Script validation error:",o.message),!1}}static createLowFeeTransaction(r,t,i=10){let n=new p.Transaction().feePerKb(i);for(let o of r)n=n.from(o);for(let o of t)n=n.to(o.address,o.satoshis);return n}};$.SIGHASH_ALL=p.crypto.Signature.SIGHASH_ALL|p.crypto.Signature.SIGHASH_FORKID;$.SIGHASH_NONE=p.crypto.Signature.SIGHASH_NONE|p.crypto.Signature.SIGHASH_FORKID;$.SIGHASH_SINGLE=p.crypto.Signature.SIGHASH_SINGLE|p.crypto.Signature.SIGHASH_FORKID;Dr.exports=$});var Ut=R((Kt,br)=>{d();br.exports=Mr()});return Ut();})();
|
|
1
|
+
var bsvScriptHelper=(()=>{var et=Object.create;var cr=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var ot=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var ft=(e,r,t)=>()=>{if(t)throw t[0];try{return e&&(r=e(e=0)),r}catch(i){throw t=[i],i}};var B=(e,r)=>()=>{try{return r||e((r={exports:{}}).exports,r),r.exports}catch(t){throw r=0,t}};var ct=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of nt(r))!ut.call(e,n)&&n!==t&&cr(e,n,{get:()=>r[n],enumerable:!(i=it(r,n))||i.enumerable});return e};var hr=(e,r,t)=>(t=e!=null?et(ot(e)):{},ct(r||!e||!e.__esModule?cr(t,"default",{value:e,enumerable:!0}):t,e));var yr=B((Wt,lr)=>{l();var y=lr.exports={},F,A;function z(){throw new Error("setTimeout has not been defined")}function J(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?F=setTimeout:F=z}catch{F=z}try{typeof clearTimeout=="function"?A=clearTimeout:A=J}catch{A=J}})();function sr(e){if(F===setTimeout)return setTimeout(e,0);if((F===z||!F)&&setTimeout)return F=setTimeout,setTimeout(e,0);try{return F(e,0)}catch{try{return F.call(null,e,0)}catch{return F.call(this,e,0)}}}function ht(e){if(A===clearTimeout)return clearTimeout(e);if((A===J||!A)&&clearTimeout)return A=clearTimeout,clearTimeout(e);try{return A(e)}catch{try{return A.call(null,e)}catch{return A.call(this,e)}}}var _=[],M=!1,b,V=-1;function st(){!M||!b||(M=!1,b.length?_=b.concat(_):V=-1,_.length&&ar())}function ar(){if(!M){var e=sr(st);M=!0;for(var r=_.length;r;){for(b=_,_=[];++V<r;)b&&b[V].run();V=-1,r=_.length}b=null,M=!1,ht(e)}}y.nextTick=function(e){var r=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)r[t-1]=arguments[t];_.push(new pr(e,r)),_.length===1&&!M&&sr(ar)};function pr(e,r){this.fun=e,this.array=r}pr.prototype.run=function(){this.fun.apply(null,this.array)};y.title="browser";y.browser=!0;y.env={};y.argv=[];y.version="";y.versions={};function R(){}y.on=R;y.addListener=R;y.once=R;y.off=R;y.removeListener=R;y.removeAllListeners=R;y.emit=R;y.prependListener=R;y.prependOnceListener=R;y.listeners=function(e){return[]};y.binding=function(e){throw new Error("process.binding is not supported")};y.cwd=function(){return"/"};y.chdir=function(e){throw new Error("process.chdir is not supported")};y.umask=function(){return 0}});var xr=B(W=>{"use strict";l();W.byteLength=pt;W.toByteArray=yt;W.fromByteArray=xt;var T=[],I=[],at=typeof Uint8Array<"u"?Uint8Array:Array,Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(N=0,dr=Z.length;N<dr;++N)T[N]=Z[N],I[Z.charCodeAt(N)]=N;var N,dr;I[45]=62;I[95]=63;function wr(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var i=t===r?0:4-t%4;return[t,i]}function pt(e){var r=wr(e),t=r[0],i=r[1];return(t+i)*3/4-i}function lt(e,r,t){return(r+t)*3/4-t}function yt(e){var r,t=wr(e),i=t[0],n=t[1],o=new at(lt(e,i,n)),u=0,c=n>0?i-4:i,h;for(h=0;h<c;h+=4)r=I[e.charCodeAt(h)]<<18|I[e.charCodeAt(h+1)]<<12|I[e.charCodeAt(h+2)]<<6|I[e.charCodeAt(h+3)],o[u++]=r>>16&255,o[u++]=r>>8&255,o[u++]=r&255;return n===2&&(r=I[e.charCodeAt(h)]<<2|I[e.charCodeAt(h+1)]>>4,o[u++]=r&255),n===1&&(r=I[e.charCodeAt(h)]<<10|I[e.charCodeAt(h+1)]<<4|I[e.charCodeAt(h+2)]>>2,o[u++]=r>>8&255,o[u++]=r&255),o}function dt(e){return T[e>>18&63]+T[e>>12&63]+T[e>>6&63]+T[e&63]}function wt(e,r,t){for(var i,n=[],o=r;o<t;o+=3)i=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),n.push(dt(i));return n.join("")}function xt(e){for(var r,t=e.length,i=t%3,n=[],o=16383,u=0,c=t-i;u<c;u+=o)n.push(wt(e,u,u+o>c?c:u+o));return i===1?(r=e[t-1],n.push(T[r>>2]+T[r<<4&63]+"==")):i===2&&(r=(e[t-2]<<8)+e[t-1],n.push(T[r>>10]+T[r>>4&63]+T[r<<2&63]+"=")),n.join("")}});var Er=B(v=>{l();v.read=function(e,r,t,i,n){var o,u,c=n*8-i-1,h=(1<<c)-1,p=h>>1,a=-7,s=t?n-1:0,D=t?-1:1,m=e[r+s];for(s+=D,o=m&(1<<-a)-1,m>>=-a,a+=c;a>0;o=o*256+e[r+s],s+=D,a-=8);for(u=o&(1<<-a)-1,o>>=-a,a+=i;a>0;u=u*256+e[r+s],s+=D,a-=8);if(o===0)o=1-p;else{if(o===h)return u?NaN:(m?-1:1)*(1/0);u=u+Math.pow(2,i),o=o-p}return(m?-1:1)*u*Math.pow(2,o-i)};v.write=function(e,r,t,i,n,o){var u,c,h,p=o*8-n-1,a=(1<<p)-1,s=a>>1,D=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=i?0:o-1,Q=i?1:-1,tt=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,u=a):(u=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-u))<1&&(u--,h*=2),u+s>=1?r+=D/h:r+=D*Math.pow(2,1-s),r*h>=2&&(u++,h/=2),u+s>=a?(c=0,u=a):u+s>=1?(c=(r*h-1)*Math.pow(2,n),u=u+s):(c=r*Math.pow(2,s-1)*Math.pow(2,n),u=0));n>=8;e[t+m]=c&255,m+=Q,c/=256,n-=8);for(u=u<<n|c,p+=n;p>0;e[t+m]=u&255,m+=Q,u/=256,p-=8);e[t+m-Q]|=tt*128}});var Or=B(G=>{"use strict";l();var rr=xr(),k=Er(),Br=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;G.Buffer=f;G.SlowBuffer=Ft;G.INSPECT_MAX_BYTES=50;var j=2147483647;G.kMaxLength=j;f.TYPED_ARRAY_SUPPORT=Et();!f.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Et(){try{let e=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(e,r),e.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}});Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function C(e){if(e>j)throw new RangeError('The value "'+e+'" is invalid for option "size"');let r=new Uint8Array(e);return Object.setPrototypeOf(r,f.prototype),r}function f(e,r,t){if(typeof e=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return nr(e)}return Fr(e,r,t)}f.poolSize=8192;function Fr(e,r,t){if(typeof e=="string")return gt(e,r);if(ArrayBuffer.isView(e))return It(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(U(e,ArrayBuffer)||e&&U(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(U(e,SharedArrayBuffer)||e&&U(e.buffer,SharedArrayBuffer)))return er(e,r,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=e.valueOf&&e.valueOf();if(i!=null&&i!==e)return f.from(i,r,t);let n=mt(e);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return f.from(e[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}f.from=function(e,r,t){return Fr(e,r,t)};Object.setPrototypeOf(f.prototype,Uint8Array.prototype);Object.setPrototypeOf(f,Uint8Array);function Ar(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function Bt(e,r,t){return Ar(e),e<=0?C(e):r!==void 0?typeof t=="string"?C(e).fill(r,t):C(e).fill(r):C(e)}f.alloc=function(e,r,t){return Bt(e,r,t)};function nr(e){return Ar(e),C(e<0?0:or(e)|0)}f.allocUnsafe=function(e){return nr(e)};f.allocUnsafeSlow=function(e){return nr(e)};function gt(e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!f.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=Tr(e,r)|0,i=C(t),n=i.write(e,r);return n!==t&&(i=i.slice(0,n)),i}function tr(e){let r=e.length<0?0:or(e.length)|0,t=C(r);for(let i=0;i<r;i+=1)t[i]=e[i]&255;return t}function It(e){if(U(e,Uint8Array)){let r=new Uint8Array(e);return er(r.buffer,r.byteOffset,r.byteLength)}return tr(e)}function er(e,r,t){if(r<0||e.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return r===void 0&&t===void 0?i=new Uint8Array(e):t===void 0?i=new Uint8Array(e,r):i=new Uint8Array(e,r,t),Object.setPrototypeOf(i,f.prototype),i}function mt(e){if(f.isBuffer(e)){let r=or(e.length)|0,t=C(r);return t.length===0||e.copy(t,0,0,r),t}if(e.length!==void 0)return typeof e.length!="number"||fr(e.length)?C(0):tr(e);if(e.type==="Buffer"&&Array.isArray(e.data))return tr(e.data)}function or(e){if(e>=j)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+j.toString(16)+" bytes");return e|0}function Ft(e){return+e!=e&&(e=0),f.alloc(+e)}f.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==f.prototype};f.compare=function(r,t){if(U(r,Uint8Array)&&(r=f.from(r,r.offset,r.byteLength)),U(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(r)||!f.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let i=r.length,n=t.length;for(let o=0,u=Math.min(i,n);o<u;++o)if(r[o]!==t[o]){i=r[o],n=t[o];break}return i<n?-1:n<i?1:0};f.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};f.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return f.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<r.length;++i)t+=r[i].length;let n=f.allocUnsafe(t),o=0;for(i=0;i<r.length;++i){let u=r[i];if(U(u,Uint8Array))o+u.length>n.length?(f.isBuffer(u)||(u=f.from(u)),u.copy(n,o)):Uint8Array.prototype.set.call(n,u,o);else if(f.isBuffer(u))u.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=u.length}return n};function Tr(e,r){if(f.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||U(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let t=e.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let n=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return ir(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Nr(e).length;default:if(n)return i?-1:ir(e).length;r=(""+r).toLowerCase(),n=!0}}f.byteLength=Tr;function At(e,r,t){let i=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(e||(e="utf8");;)switch(e){case"hex":return Nt(this,r,t);case"utf8":case"utf-8":return Sr(this,r,t);case"ascii":return Pt(this,r,t);case"latin1":case"binary":return bt(this,r,t);case"base64":return Ct(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ot(this,r,t);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}f.prototype._isBuffer=!0;function O(e,r,t){let i=e[r];e[r]=e[t],e[t]=i}f.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)O(this,t,t+1);return this};f.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)O(this,t,t+3),O(this,t+1,t+2);return this};f.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)O(this,t,t+7),O(this,t+1,t+6),O(this,t+2,t+5),O(this,t+3,t+4);return this};f.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?Sr(this,0,r):At.apply(this,arguments)};f.prototype.toLocaleString=f.prototype.toString;f.prototype.equals=function(r){if(!f.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:f.compare(this,r)===0};f.prototype.inspect=function(){let r="",t=G.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"};Br&&(f.prototype[Br]=f.prototype.inspect);f.prototype.compare=function(r,t,i,n,o){if(U(r,Uint8Array)&&(r=f.from(r,r.offset,r.byteLength)),!f.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),i===void 0&&(i=r?r.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),t<0||i>r.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=i)return 0;if(n>=o)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,o>>>=0,this===r)return 0;let u=o-n,c=i-t,h=Math.min(u,c),p=this.slice(n,o),a=r.slice(t,i);for(let s=0;s<h;++s)if(p[s]!==a[s]){u=p[s],c=a[s];break}return u<c?-1:c<u?1:0};function Ur(e,r,t,i,n){if(e.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,fr(t)&&(t=n?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(n)return-1;t=e.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof r=="string"&&(r=f.from(r,i)),f.isBuffer(r))return r.length===0?-1:gr(e,r,t,i,n);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):gr(e,[r],t,i,n);throw new TypeError("val must be string, number or Buffer")}function gr(e,r,t,i,n){let o=1,u=e.length,c=r.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(e.length<2||r.length<2)return-1;o=2,u/=2,c/=2,t/=2}function h(a,s){return o===1?a[s]:a.readUInt16BE(s*o)}let p;if(n){let a=-1;for(p=t;p<u;p++)if(h(e,p)===h(r,a===-1?0:p-a)){if(a===-1&&(a=p),p-a+1===c)return a*o}else a!==-1&&(p-=p-a),a=-1}else for(t+c>u&&(t=u-c),p=t;p>=0;p--){let a=!0;for(let s=0;s<c;s++)if(h(e,p+s)!==h(r,s)){a=!1;break}if(a)return p}return-1}f.prototype.includes=function(r,t,i){return this.indexOf(r,t,i)!==-1};f.prototype.indexOf=function(r,t,i){return Ur(this,r,t,i,!0)};f.prototype.lastIndexOf=function(r,t,i){return Ur(this,r,t,i,!1)};function Tt(e,r,t,i){t=Number(t)||0;let n=e.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;let o=r.length;i>o/2&&(i=o/2);let u;for(u=0;u<i;++u){let c=parseInt(r.substr(u*2,2),16);if(fr(c))return u;e[t+u]=c}return u}function Ut(e,r,t,i){return X(ir(r,e.length-t),e,t,i)}function St(e,r,t,i){return X(kt(r),e,t,i)}function _t(e,r,t,i){return X(Nr(r),e,t,i)}function Rt(e,r,t,i){return X($t(r,e.length-t),e,t,i)}f.prototype.write=function(r,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((i===void 0||i>o)&&(i=o),r.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let u=!1;for(;;)switch(n){case"hex":return Tt(this,r,t,i);case"utf8":case"utf-8":return Ut(this,r,t,i);case"ascii":case"latin1":case"binary":return St(this,r,t,i);case"base64":return _t(this,r,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,r,t,i);default:if(u)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),u=!0}};f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ct(e,r,t){return r===0&&t===e.length?rr.fromByteArray(e):rr.fromByteArray(e.slice(r,t))}function Sr(e,r,t){t=Math.min(e.length,t);let i=[],n=r;for(;n<t;){let o=e[n],u=null,c=o>239?4:o>223?3:o>191?2:1;if(n+c<=t){let h,p,a,s;switch(c){case 1:o<128&&(u=o);break;case 2:h=e[n+1],(h&192)===128&&(s=(o&31)<<6|h&63,s>127&&(u=s));break;case 3:h=e[n+1],p=e[n+2],(h&192)===128&&(p&192)===128&&(s=(o&15)<<12|(h&63)<<6|p&63,s>2047&&(s<55296||s>57343)&&(u=s));break;case 4:h=e[n+1],p=e[n+2],a=e[n+3],(h&192)===128&&(p&192)===128&&(a&192)===128&&(s=(o&15)<<18|(h&63)<<12|(p&63)<<6|a&63,s>65535&&s<1114112&&(u=s))}}u===null?(u=65533,c=1):u>65535&&(u-=65536,i.push(u>>>10&1023|55296),u=56320|u&1023),i.push(u),n+=c}return Lt(i)}var Ir=4096;function Lt(e){let r=e.length;if(r<=Ir)return String.fromCharCode.apply(String,e);let t="",i=0;for(;i<r;)t+=String.fromCharCode.apply(String,e.slice(i,i+=Ir));return t}function Pt(e,r,t){let i="";t=Math.min(e.length,t);for(let n=r;n<t;++n)i+=String.fromCharCode(e[n]&127);return i}function bt(e,r,t){let i="";t=Math.min(e.length,t);for(let n=r;n<t;++n)i+=String.fromCharCode(e[n]);return i}function Nt(e,r,t){let i=e.length;(!r||r<0)&&(r=0),(!t||t<0||t>i)&&(t=i);let n="";for(let o=r;o<t;++o)n+=Gt[e[o]];return n}function Ot(e,r,t){let i=e.slice(r,t),n="";for(let o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}f.prototype.slice=function(r,t){let i=this.length;r=~~r,t=t===void 0?i:~~t,r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<r&&(t=r);let n=this.subarray(r,t);return Object.setPrototypeOf(n,f.prototype),n};function w(e,r,t){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+r>t)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUintLE=f.prototype.readUIntLE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r],o=1,u=0;for(;++u<t&&(o*=256);)n+=this[r+u]*o;return n};f.prototype.readUintBE=f.prototype.readUIntBE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r+--t],o=1;for(;t>0&&(o*=256);)n+=this[r+--t]*o;return n};f.prototype.readUint8=f.prototype.readUInt8=function(r,t){return r=r>>>0,t||w(r,1,this.length),this[r]};f.prototype.readUint16LE=f.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||w(r,2,this.length),this[r]|this[r+1]<<8};f.prototype.readUint16BE=f.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||w(r,2,this.length),this[r]<<8|this[r+1]};f.prototype.readUint32LE=f.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||w(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};f.prototype.readUint32BE=f.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};f.prototype.readBigUInt64LE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,o=this[++r]+this[++r]*2**8+this[++r]*2**16+i*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))});f.prototype.readBigUInt64BE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],o=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+i;return(BigInt(n)<<BigInt(32))+BigInt(o)});f.prototype.readIntLE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r],o=1,u=0;for(;++u<t&&(o*=256);)n+=this[r+u]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*t)),n};f.prototype.readIntBE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=t,o=1,u=this[r+--n];for(;n>0&&(o*=256);)u+=this[r+--n]*o;return o*=128,u>=o&&(u-=Math.pow(2,8*t)),u};f.prototype.readInt8=function(r,t){return r=r>>>0,t||w(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};f.prototype.readInt16LE=function(r,t){r=r>>>0,t||w(r,2,this.length);let i=this[r]|this[r+1]<<8;return i&32768?i|4294901760:i};f.prototype.readInt16BE=function(r,t){r=r>>>0,t||w(r,2,this.length);let i=this[r+1]|this[r]<<8;return i&32768?i|4294901760:i};f.prototype.readInt32LE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};f.prototype.readInt32BE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};f.prototype.readBigInt64LE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)});f.prototype.readBigInt64BE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(n)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+i)});f.prototype.readFloatLE=function(r,t){return r=r>>>0,t||w(r,4,this.length),k.read(this,r,!0,23,4)};f.prototype.readFloatBE=function(r,t){return r=r>>>0,t||w(r,4,this.length),k.read(this,r,!1,23,4)};f.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||w(r,8,this.length),k.read(this,r,!0,52,8)};f.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||w(r,8,this.length),k.read(this,r,!1,52,8)};function E(e,r,t,i,n,o){if(!f.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>n||r<o)throw new RangeError('"value" argument is out of bounds');if(t+i>e.length)throw new RangeError("Index out of range")}f.prototype.writeUintLE=f.prototype.writeUIntLE=function(r,t,i,n){if(r=+r,t=t>>>0,i=i>>>0,!n){let c=Math.pow(2,8*i)-1;E(this,r,t,i,c,0)}let o=1,u=0;for(this[t]=r&255;++u<i&&(o*=256);)this[t+u]=r/o&255;return t+i};f.prototype.writeUintBE=f.prototype.writeUIntBE=function(r,t,i,n){if(r=+r,t=t>>>0,i=i>>>0,!n){let c=Math.pow(2,8*i)-1;E(this,r,t,i,c,0)}let o=i-1,u=1;for(this[t+o]=r&255;--o>=0&&(u*=256);)this[t+o]=r/u&255;return t+i};f.prototype.writeUint8=f.prototype.writeUInt8=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,1,255,0),this[t]=r&255,t+1};f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2};f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2};f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4};f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function _r(e,r,t,i,n){br(r,i,n,e,t,7);let o=Number(r&BigInt(4294967295));e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,t}function Rr(e,r,t,i,n){br(r,i,n,e,t,7);let o=Number(r&BigInt(4294967295));e[t+7]=o,o=o>>8,e[t+6]=o,o=o>>8,e[t+5]=o,o=o>>8,e[t+4]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t+3]=u,u=u>>8,e[t+2]=u,u=u>>8,e[t+1]=u,u=u>>8,e[t]=u,t+8}f.prototype.writeBigUInt64LE=L(function(r,t=0){return _r(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeBigUInt64BE=L(function(r,t=0){return Rr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeIntLE=function(r,t,i,n){if(r=+r,t=t>>>0,!n){let h=Math.pow(2,8*i-1);E(this,r,t,i,h-1,-h)}let o=0,u=1,c=0;for(this[t]=r&255;++o<i&&(u*=256);)r<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(r/u>>0)-c&255;return t+i};f.prototype.writeIntBE=function(r,t,i,n){if(r=+r,t=t>>>0,!n){let h=Math.pow(2,8*i-1);E(this,r,t,i,h-1,-h)}let o=i-1,u=1,c=0;for(this[t+o]=r&255;--o>=0&&(u*=256);)r<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(r/u>>0)-c&255;return t+i};f.prototype.writeInt8=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1};f.prototype.writeInt16LE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};f.prototype.writeInt16BE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};f.prototype.writeInt32LE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4};f.prototype.writeInt32BE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};f.prototype.writeBigInt64LE=L(function(r,t=0){return _r(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});f.prototype.writeBigInt64BE=L(function(r,t=0){return Rr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Cr(e,r,t,i,n,o){if(t+i>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Lr(e,r,t,i,n){return r=+r,t=t>>>0,n||Cr(e,r,t,4,34028234663852886e22,-34028234663852886e22),k.write(e,r,t,i,23,4),t+4}f.prototype.writeFloatLE=function(r,t,i){return Lr(this,r,t,!0,i)};f.prototype.writeFloatBE=function(r,t,i){return Lr(this,r,t,!1,i)};function Pr(e,r,t,i,n){return r=+r,t=t>>>0,n||Cr(e,r,t,8,17976931348623157e292,-17976931348623157e292),k.write(e,r,t,i,52,8),t+8}f.prototype.writeDoubleLE=function(r,t,i){return Pr(this,r,t,!0,i)};f.prototype.writeDoubleBE=function(r,t,i){return Pr(this,r,t,!1,i)};f.prototype.copy=function(r,t,i,n){if(!f.isBuffer(r))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),t>=r.length&&(t=r.length),t||(t=0),n>0&&n<i&&(n=i),n===i||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),r.length-t<n-i&&(n=r.length-t+i);let o=n-i;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,n):Uint8Array.prototype.set.call(r,this.subarray(i,n),t),o};f.prototype.fill=function(r,t,i,n){if(typeof r=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(r.length===1){let u=r.charCodeAt(0);(n==="utf8"&&u<128||n==="latin1")&&(r=u)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,r||(r=0);let o;if(typeof r=="number")for(o=t;o<i;++o)this[o]=r;else{let u=f.isBuffer(r)?r:f.from(r,n),c=u.length;if(c===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(o=0;o<i-t;++o)this[o+t]=u[o%c]}return this};var H={};function ur(e,r,t){H[e]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}ur("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ur("ERR_INVALID_ARG_TYPE",function(e,r){return`The "${e}" argument must be of type number. Received type ${typeof r}`},TypeError);ur("ERR_OUT_OF_RANGE",function(e,r,t){let i=`The value of "${e}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>2**32?n=mr(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=mr(n)),n+="n"),i+=` It must be ${r}. Received ${n}`,i},RangeError);function mr(e){let r="",t=e.length,i=e[0]==="-"?1:0;for(;t>=i+4;t-=3)r=`_${e.slice(t-3,t)}${r}`;return`${e.slice(0,t)}${r}`}function Dt(e,r,t){$(r,"offset"),(e[r]===void 0||e[r+t]===void 0)&&Y(r,e.length-(t+1))}function br(e,r,t,i,n,o){if(e>t||e<r){let u=typeof r=="bigint"?"n":"",c;throw o>3?r===0||r===BigInt(0)?c=`>= 0${u} and < 2${u} ** ${(o+1)*8}${u}`:c=`>= -(2${u} ** ${(o+1)*8-1}${u}) and < 2 ** ${(o+1)*8-1}${u}`:c=`>= ${r}${u} and <= ${t}${u}`,new H.ERR_OUT_OF_RANGE("value",c,e)}Dt(i,n,o)}function $(e,r){if(typeof e!="number")throw new H.ERR_INVALID_ARG_TYPE(r,"number",e)}function Y(e,r,t){throw Math.floor(e)!==e?($(e,t),new H.ERR_OUT_OF_RANGE(t||"offset","an integer",e)):r<0?new H.ERR_BUFFER_OUT_OF_BOUNDS:new H.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,e)}var Mt=/[^+/0-9A-Za-z-_]/g;function Ht(e){if(e=e.split("=")[0],e=e.trim().replace(Mt,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function ir(e,r){r=r||1/0;let t,i=e.length,n=null,o=[];for(let u=0;u<i;++u){if(t=e.charCodeAt(u),t>55295&&t<57344){if(!n){if(t>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(u+1===i){(r-=3)>-1&&o.push(239,191,189);continue}n=t;continue}if(t<56320){(r-=3)>-1&&o.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(r-=3)>-1&&o.push(239,191,189);if(n=null,t<128){if((r-=1)<0)break;o.push(t)}else if(t<2048){if((r-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function kt(e){let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t)&255);return r}function $t(e,r){let t,i,n,o=[];for(let u=0;u<e.length&&!((r-=2)<0);++u)t=e.charCodeAt(u),i=t>>8,n=t%256,o.push(n),o.push(i);return o}function Nr(e){return rr.toByteArray(Ht(e))}function X(e,r,t,i){let n;for(n=0;n<i&&!(n+t>=r.length||n>=e.length);++n)r[n+t]=e[n];return n}function U(e,r){return e instanceof r||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===r.name}function fr(e){return e!==e}var Gt=(function(){let e="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let n=0;n<16;++n)r[i+n]=e[t]+e[n]}return r})();function L(e){return typeof BigInt>"u"?qt:e}function qt(){throw new Error("BigInt not supported")}});var g,d,l=ft(()=>{g=hr(yr()),d=hr(Or())});var Mr=B((ee,Dr)=>{l();Dr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Transaction.sighash});var kr=B((ne,Hr)=>{l();Hr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Script.Interpreter});var Gr=B((ue,$r)=>{l();$r.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.crypto.Signature});var Kr=B((ce,qr)=>{l();qr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.crypto.BN});var Vr=B((se,Yr)=>{l();Yr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Transaction});var jr=B((pe,Wr)=>{l();Wr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Opcode});var Qr=B((ye,Xr)=>{l();Xr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Script});var vr=B((we,Zr)=>{l();var zr=Mr(),q=kr(),S=Gr(),Jr=Kr(),Kt=Vr(),x=jr(),P=Qr(),K=class{static createSignature(r,t,i,n,o,u=null){u=u||S.SIGHASH_ALL|S.SIGHASH_FORKID;let c=zr.sign(r,t,u,i,n,new Jr(o));return d.Buffer.concat([c.toDER(),d.Buffer.from([u])])}static createMultisigScript(r,t){let i=new P().add(x[`OP_${r}`]);for(let n of t)i=i.add(n.toBuffer());return i.add(x[`OP_${t.length}`]).add(x.OP_CHECKMULTISIG)}static createMultisigUnlocking(r){let t=new P().add(x.OP_0);for(let i of r)t=t.add(i);return t}static createTimelockScript(r,t){let i=d.Buffer.from(r.toString(16).padStart(8,"0"),"hex").reverse();return new P().add(i).add(x.OP_CHECKLOCKTIMEVERIFY).add(x.OP_DROP).add(t.toBuffer())}static createConditionalScript(r,t=null){let i=new P().add(x.OP_IF).add(r.toBuffer());return t&&(i=i.add(x.OP_ELSE).add(t.toBuffer())),i.add(x.OP_ENDIF)}static createP2PKHScript(r){return new P().add(x.OP_DUP).add(x.OP_HASH160).add(r.toAddress().hashBuffer).add(x.OP_EQUALVERIFY).add(x.OP_CHECKSIG)}static createP2PKHUnlocking(r,t){return new P().add(r).add(t.toBuffer())}static getPreimage(r,t,i,n,o=null){return o=o||S.SIGHASH_ALL|S.SIGHASH_FORKID,zr.sighash(r,o,t,i,new Jr(n))}static createDataScript(r){return typeof r=="string"&&(r=d.Buffer.from(r,"utf8")),new P().add(r)}static createOpReturnScript(r){return typeof r=="string"&&(r=d.Buffer.from(r,"utf8")),new P().add(x.OP_FALSE).add(x.OP_RETURN).add(r)}static validateTransaction(r){try{return r.verify()}catch(t){return console.error("Transaction validation error:",t.message),!1}}static validateScript(r,t,i,n){try{return new q().verify(r,t,i,n,q.SCRIPT_VERIFY_P2SH|q.SCRIPT_VERIFY_STRICTENC|q.SCRIPT_ENABLE_SIGHASH_FORKID|q.SCRIPT_ENABLE_MAGNETIC_OPCODES|q.SCRIPT_ENABLE_MONOLITH_OPCODES)}catch(o){return console.error("Script validation error:",o.message),!1}}static createLowFeeTransaction(r,t,i=10){let n=new Kt().feePerKb(i);for(let o of r)n=n.from(o);for(let o of t)n=n.to(o.address,o.satoshis);return n}};K.SIGHASH_ALL=S.SIGHASH_ALL|S.SIGHASH_FORKID;K.SIGHASH_NONE=S.SIGHASH_NONE|S.SIGHASH_FORKID;K.SIGHASH_SINGLE=S.SIGHASH_SINGLE|S.SIGHASH_FORKID;Zr.exports=K});var Yt=B((Ee,rt)=>{l();rt.exports=vr()});return Yt();})();
|
|
2
2
|
if(typeof module!=="undefined"&&module.exports){module.exports=bsvScriptHelper}else if(typeof define==="function"&&define.amd){define([],function(){return bsvScriptHelper})}
|