@multiplechain/bitcoin 0.4.4 → 0.4.5

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.umd.js CHANGED
@@ -129,5 +129,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
129
129
  Use Chrome, Firefox or Internet Explorer 11`)}var OK=Sa.Buffer,Qd=lt.crypto||lt.msCrypto;Qd&&Qd.getRandomValues?yg.exports=PK:yg.exports=TK;function PK(t,e){if(t>BK)throw new RangeError("requested too many random bytes");var r=OK.allocUnsafe(t);if(t>0)if(t>wg)for(var n=0;n<t;n+=wg)Qd.getRandomValues(r.slice(n,n+wg));else Qd.getRandomValues(r);return typeof e=="function"?pt.nextTick(function(){e(null,r)}):r}var kK=yg.exports;const _g=uo,NK=Sa.Buffer,V9=Rh.getCurveByName("secp256k1"),W9=_g.ONE,$9=V9.n,CK=V9.p;function ys(t,e,r,n){const s=n!==void 0?"["+n+"]":"";if(!NK.isBuffer(e))throw new Error(t+s+" must be a Buffer");if(e.length!==r)throw new Error(t+s+" must be "+r+" bytes long")}function Bh(t,e){if(!e||!e.length)throw new Error(t+" must be an array with one or more elements")}function G9(t){Bh("pubKeys",t);for(let e=0;e<t.length;e++)ys("pubKey",t[e],32,e)}function LK(t){Bh("messages",t);for(let e=0;e<t.length;e++)ys("message",t[e],32,e)}function DK(t){Bh("signatures",t);for(let e=0;e<t.length;e++)ys("signature",t[e],64,e)}function FK(t){Bh("nonces",t);for(let e=0;e<t.length;e++)ys("nonce",t[e],32,e)}function UK(t,e){const r=e!==void 0?"["+e+"]":"";if(!_g.isBigInteger(t)&&typeof t!="string")throw new Error("privateKey"+r+" must be a BigInteger or valid hex string");if(typeof t=="string"){if(t.match(/[^a-f^A-F^0-9]+/))throw new Error("privateKey must be a BigInteger or valid hex string");xg("privateKey",_g.fromHex(t));return}xg("privateKey",t)}function Z9(t,e){UK(t),ys("message",e,32)}function HK(t,e,r){ys("pubKey",t,32),ys("message",e,32),ys("signature",r,64)}function qK(t,e,r){if(G9(t),LK(e),DK(r),t.length!==e.length||e.length!==r.length)throw new Error("all parameters must be an array with the same length")}function zK(t,e,r,n,s){Z9(e,r),ys("sessionId",t,32),ys("pubKeyCombined",n,32),ys("ell",s,32)}function xg(t,e){if(e.compareTo(W9)<0||e.compareTo($9.subtract(W9))>0)throw new Error(t+" must be an integer in the range 1..n-1")}function jK(t,e){if(t.compareTo(CK)>=0)throw new Error("r is larger than or equal to field size");if(e.compareTo($9)>=0)throw new Error("s is larger than or equal to curve order")}function KK(t,e){if(e.curve.isInfinity(e))throw new Error("point is at infinity");const r=e.affineY.isEven();if(t!==r)throw new Error("point does not exist")}function VK(t){if(t.length!==32)throw new Error("aux must be 32 bytes")}var ep={checkSessionParams:zK,checkSignParams:Z9,checkVerifyParams:HK,checkBatchVerifyParams:qK,checkRange:xg,checkSignatureInput:jK,checkPointExists:KK,checkPubKeyArr:G9,checkArray:Bh,checkNonceArr:FK,checkAux:VK},X9={exports:{}};(function(t){(function(){var e="input is invalid type",r=typeof window=="object",n=r?window:{};n.JS_SHA256_NO_WINDOW&&(r=!1);var s=!r&&typeof self=="object",i=!n.JS_SHA256_NO_NODE_JS&&typeof pt=="object"&&pt.versions&&pt.versions.node;i?n=lt:s&&(n=self);var f=!n.JS_SHA256_NO_COMMON_JS&&!0&&t.exports,c=!n.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",b="0123456789abcdef".split(""),w=[-2147483648,8388608,32768,128],y=[24,16,8,0],_=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],B=["hex","array","digest","arrayBuffer"],M=[];(n.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(j){return Object.prototype.toString.call(j)==="[object Array]"}),c&&(n.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(j){return typeof j=="object"&&j.buffer&&j.buffer.constructor===ArrayBuffer});var E=function(j,re){return function(T){return new D(re,!0).update(T)[j]()}},O=function(j){var re=E("hex",j);i&&(re=k(re,j)),re.create=function(){return new D(j)},re.update=function(F){return re.create().update(F)};for(var T=0;T<B.length;++T){var q=B[T];re[q]=E(q,j)}return re},k=function(j,re){var T=void 0,q=void 0,F=re?"sha224":"sha256",m=function(a){if(typeof a=="string")return T.createHash(F).update(a,"utf8").digest("hex");if(a==null)throw new Error(e);return a.constructor===ArrayBuffer&&(a=new Uint8Array(a)),Array.isArray(a)||ArrayBuffer.isView(a)||a.constructor===q?T.createHash(F).update(new q(a)).digest("hex"):j(a)};return m},P=function(j,re){return function(T,q){return new z(T,re,!0).update(q)[j]()}},C=function(j){var re=P("hex",j);re.create=function(F){return new z(F,j)},re.update=function(F,m){return re.create(F).update(m)};for(var T=0;T<B.length;++T){var q=B[T];re[q]=P(q,j)}return re};function D(j,re){re?(M[0]=M[16]=M[1]=M[2]=M[3]=M[4]=M[5]=M[6]=M[7]=M[8]=M[9]=M[10]=M[11]=M[12]=M[13]=M[14]=M[15]=0,this.blocks=M):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],j?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=j}D.prototype.update=function(j){if(!this.finalized){var re,T=typeof j;if(T!=="string"){if(T==="object"){if(j===null)throw new Error(e);if(c&&j.constructor===ArrayBuffer)j=new Uint8Array(j);else if(!Array.isArray(j)&&(!c||!ArrayBuffer.isView(j)))throw new Error(e)}else throw new Error(e);re=!0}for(var q,F=0,m,a=j.length,h=this.blocks;F<a;){if(this.hashed&&(this.hashed=!1,h[0]=this.block,h[16]=h[1]=h[2]=h[3]=h[4]=h[5]=h[6]=h[7]=h[8]=h[9]=h[10]=h[11]=h[12]=h[13]=h[14]=h[15]=0),re)for(m=this.start;F<a&&m<64;++F)h[m>>2]|=j[F]<<y[m++&3];else for(m=this.start;F<a&&m<64;++F)q=j.charCodeAt(F),q<128?h[m>>2]|=q<<y[m++&3]:q<2048?(h[m>>2]|=(192|q>>6)<<y[m++&3],h[m>>2]|=(128|q&63)<<y[m++&3]):q<55296||q>=57344?(h[m>>2]|=(224|q>>12)<<y[m++&3],h[m>>2]|=(128|q>>6&63)<<y[m++&3],h[m>>2]|=(128|q&63)<<y[m++&3]):(q=65536+((q&1023)<<10|j.charCodeAt(++F)&1023),h[m>>2]|=(240|q>>18)<<y[m++&3],h[m>>2]|=(128|q>>12&63)<<y[m++&3],h[m>>2]|=(128|q>>6&63)<<y[m++&3],h[m>>2]|=(128|q&63)<<y[m++&3]);this.lastByteIndex=m,this.bytes+=m-this.start,m>=64?(this.block=h[16],this.start=m-64,this.hash(),this.hashed=!0):this.start=m}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},D.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var j=this.blocks,re=this.lastByteIndex;j[16]=this.block,j[re>>2]|=w[re&3],this.block=j[16],re>=56&&(this.hashed||this.hash(),j[0]=this.block,j[16]=j[1]=j[2]=j[3]=j[4]=j[5]=j[6]=j[7]=j[8]=j[9]=j[10]=j[11]=j[12]=j[13]=j[14]=j[15]=0),j[14]=this.hBytes<<3|this.bytes>>>29,j[15]=this.bytes<<3,this.hash()}},D.prototype.hash=function(){var j=this.h0,re=this.h1,T=this.h2,q=this.h3,F=this.h4,m=this.h5,a=this.h6,h=this.h7,u=this.blocks,l,g,A,x,p,d,S,I,N,G,ie;for(l=16;l<64;++l)p=u[l-15],g=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,p=u[l-2],A=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,u[l]=u[l-16]+g+u[l-7]+A<<0;for(ie=re&T,l=0;l<64;l+=4)this.first?(this.is224?(I=300032,p=u[0]-1413257819,h=p-150054599<<0,q=p+24177077<<0):(I=704751109,p=u[0]-210244248,h=p-1521486534<<0,q=p+143694565<<0),this.first=!1):(g=(j>>>2|j<<30)^(j>>>13|j<<19)^(j>>>22|j<<10),A=(F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7),I=j&re,x=I^j&T^ie,S=F&m^~F&a,p=h+A+S+_[l]+u[l],d=g+x,h=q+p<<0,q=p+d<<0),g=(q>>>2|q<<30)^(q>>>13|q<<19)^(q>>>22|q<<10),A=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),N=q&j,x=N^q&re^I,S=h&F^~h&m,p=a+A+S+_[l+1]+u[l+1],d=g+x,a=T+p<<0,T=p+d<<0,g=(T>>>2|T<<30)^(T>>>13|T<<19)^(T>>>22|T<<10),A=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),G=T&q,x=G^T&j^N,S=a&h^~a&F,p=m+A+S+_[l+2]+u[l+2],d=g+x,m=re+p<<0,re=p+d<<0,g=(re>>>2|re<<30)^(re>>>13|re<<19)^(re>>>22|re<<10),A=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),ie=re&T,x=ie^re&q^G,S=m&a^~m&h,p=F+A+S+_[l+3]+u[l+3],d=g+x,F=j+p<<0,j=p+d<<0;this.h0=this.h0+j<<0,this.h1=this.h1+re<<0,this.h2=this.h2+T<<0,this.h3=this.h3+q<<0,this.h4=this.h4+F<<0,this.h5=this.h5+m<<0,this.h6=this.h6+a<<0,this.h7=this.h7+h<<0},D.prototype.hex=function(){this.finalize();var j=this.h0,re=this.h1,T=this.h2,q=this.h3,F=this.h4,m=this.h5,a=this.h6,h=this.h7,u=b[j>>28&15]+b[j>>24&15]+b[j>>20&15]+b[j>>16&15]+b[j>>12&15]+b[j>>8&15]+b[j>>4&15]+b[j&15]+b[re>>28&15]+b[re>>24&15]+b[re>>20&15]+b[re>>16&15]+b[re>>12&15]+b[re>>8&15]+b[re>>4&15]+b[re&15]+b[T>>28&15]+b[T>>24&15]+b[T>>20&15]+b[T>>16&15]+b[T>>12&15]+b[T>>8&15]+b[T>>4&15]+b[T&15]+b[q>>28&15]+b[q>>24&15]+b[q>>20&15]+b[q>>16&15]+b[q>>12&15]+b[q>>8&15]+b[q>>4&15]+b[q&15]+b[F>>28&15]+b[F>>24&15]+b[F>>20&15]+b[F>>16&15]+b[F>>12&15]+b[F>>8&15]+b[F>>4&15]+b[F&15]+b[m>>28&15]+b[m>>24&15]+b[m>>20&15]+b[m>>16&15]+b[m>>12&15]+b[m>>8&15]+b[m>>4&15]+b[m&15]+b[a>>28&15]+b[a>>24&15]+b[a>>20&15]+b[a>>16&15]+b[a>>12&15]+b[a>>8&15]+b[a>>4&15]+b[a&15];return this.is224||(u+=b[h>>28&15]+b[h>>24&15]+b[h>>20&15]+b[h>>16&15]+b[h>>12&15]+b[h>>8&15]+b[h>>4&15]+b[h&15]),u},D.prototype.toString=D.prototype.hex,D.prototype.digest=function(){this.finalize();var j=this.h0,re=this.h1,T=this.h2,q=this.h3,F=this.h4,m=this.h5,a=this.h6,h=this.h7,u=[j>>24&255,j>>16&255,j>>8&255,j&255,re>>24&255,re>>16&255,re>>8&255,re&255,T>>24&255,T>>16&255,T>>8&255,T&255,q>>24&255,q>>16&255,q>>8&255,q&255,F>>24&255,F>>16&255,F>>8&255,F&255,m>>24&255,m>>16&255,m>>8&255,m&255,a>>24&255,a>>16&255,a>>8&255,a&255];return this.is224||u.push(h>>24&255,h>>16&255,h>>8&255,h&255),u},D.prototype.array=D.prototype.digest,D.prototype.arrayBuffer=function(){this.finalize();var j=new ArrayBuffer(this.is224?28:32),re=new DataView(j);return re.setUint32(0,this.h0),re.setUint32(4,this.h1),re.setUint32(8,this.h2),re.setUint32(12,this.h3),re.setUint32(16,this.h4),re.setUint32(20,this.h5),re.setUint32(24,this.h6),this.is224||re.setUint32(28,this.h7),j};function z(j,re,T){var q,F=typeof j;if(F==="string"){var m=[],a=j.length,h=0,u;for(q=0;q<a;++q)u=j.charCodeAt(q),u<128?m[h++]=u:u<2048?(m[h++]=192|u>>6,m[h++]=128|u&63):u<55296||u>=57344?(m[h++]=224|u>>12,m[h++]=128|u>>6&63,m[h++]=128|u&63):(u=65536+((u&1023)<<10|j.charCodeAt(++q)&1023),m[h++]=240|u>>18,m[h++]=128|u>>12&63,m[h++]=128|u>>6&63,m[h++]=128|u&63);j=m}else if(F==="object"){if(j===null)throw new Error(e);if(c&&j.constructor===ArrayBuffer)j=new Uint8Array(j);else if(!Array.isArray(j)&&(!c||!ArrayBuffer.isView(j)))throw new Error(e)}else throw new Error(e);j.length>64&&(j=new D(re,!0).update(j).array());var l=[],g=[];for(q=0;q<64;++q){var A=j[q]||0;l[q]=92^A,g[q]=54^A}D.call(this,re,T),this.update(g),this.oKeyPad=l,this.inner=!0,this.sharedMemory=T}z.prototype=new D,z.prototype.finalize=function(){if(D.prototype.finalize.call(this),this.inner){this.inner=!1;var j=this.array();D.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(j),D.prototype.finalize.call(this)}};var J=O();J.sha256=J,J.sha224=O(!0),J.sha256.hmac=C(),J.sha224.hmac=C(!0),f?t.exports=J:(n.sha256=J.sha256,n.sha224=J.sha224)})()})(X9);var WK=X9.exports;const $K=uo,GK=Sa.Buffer,ZK=WK;function XK(t){return $K.fromBuffer(t)}function JK(t){return t.toBuffer(32)}function YK(t){return GK.from(ZK.create().update(t).array())}var Th={bufferToInt:XK,intToBuffer:JK,hash:YK};const Vu=uo,Ag=Sa.Buffer,Sg=Rh,QK=kK,Oh=Sg.getCurveByName("secp256k1"),Eg=ep,ho=Th,Ig=Ag.concat,eV=Oh.G,Ph=Oh.p,Mg=Oh.n,tV=Vu.ZERO,rV=Vu.ONE,J9=Vu.valueOf(2),nV=Vu.valueOf(3),iV=Vu.valueOf(4),sV=Vu.valueOf(7);function aV(t,e,r){Eg.checkSignParams(t,r);const n=Bg("BIP0340/nonce",Ig([ho.intToBuffer(t),e,r]));return ho.bufferToInt(n).mod(Mg)}function Rg(t){return t.affineY.mod(J9).equals(tV)}function fV(t,e){return Rg(t)?e.clone():Mg.subtract(e)}function oV(t,e,r){const n=Bg("BIP0340/challenge",Ig([t,e,r]));return ho.bufferToInt(n).mod(Mg)}function uV(t,e,r){const n=eV.multiply(t),s=r.multiply(e);return n.add(s.negate())}function Bg(t,e){const r=ho.hash(t);return ho.hash(Ig([r,r,Ag.from(e)]))}function cV(t){const e=ho.bufferToInt(t),r=e.pow(nV).add(sV).mod(Ph),n=r.modPow(Ph.add(rV).divide(iV),Ph);if(r.compareTo(n.modPow(J9,Ph))!==0)throw new Error("c is not equal to y^2");let s=Sg.Point.fromAffine(Oh,e,n);return Rg(s)||(s=Sg.Point.fromAffine(Oh,e,Ph.subtract(n))),Eg.checkPointExists(!0,s),s}function hV(){let t=null;for(;;){t=ho.bufferToInt(Ag.from(QK(32)));try{return Eg.checkRange("a",t),t}catch{}}}var tp={deterministicGetK0:aV,isEven:Rg,getEvenKey:fV,getE:oV,getR:uV,taggedHash:Bg,liftX:cV,randomA:hV};const Y9=uo,lV=Sa.Buffer,Tg=Rh.getCurveByName("secp256k1"),Jn=tp,Wu=ep,Yn=Th,Q9=lV.concat,Og=Tg.G;Tg.p;const e_=Tg.n,dV=Y9.ZERO;function pV(t,e,r){Wu.checkSignParams(t,e),t=typeof t=="string"?Y9.fromHex(t):t;const n=Og.multiply(t),s=Yn.intToBuffer(n.affineX),i=Jn.getEvenKey(n,t);let f;if(r){Wu.checkAux(r);const _=Yn.intToBuffer(i.xor(Yn.bufferToInt(Jn.taggedHash("BIP0340/aux",r)))),B=Jn.taggedHash("BIP0340/nonce",Q9([_,s,e]));f=Yn.bufferToInt(B).mod(e_)}else f=Jn.deterministicGetK0(i,s,e);if(f.signum()===0)throw new Error("kPrime is zero");const c=Og.multiply(f),b=Jn.getEvenKey(c,f),w=Yn.intToBuffer(c.affineX),y=Jn.getE(w,s,e);return Q9([w,Yn.intToBuffer(b.add(y.multiply(i)).mod(e_))])}function vV(t,e,r){Wu.checkVerifyParams(t,e,r);const n=Jn.liftX(t),s=Yn.intToBuffer(n.affineX),i=Yn.bufferToInt(r.slice(0,32)),f=Yn.bufferToInt(r.slice(32,64));Wu.checkSignatureInput(i,f);const c=Jn.getE(Yn.intToBuffer(i),s,e),b=Jn.getR(f,c,n);if(b.curve.isInfinity(b)||!Jn.isEven(b)||!b.affineX.equals(i))throw new Error("signature verification failed")}function bV(t,e,r){Wu.checkBatchVerifyParams(t,e,r);let n=dV,s=null;for(let i=0;i<t.length;i++){const f=Jn.liftX(t[i]),c=Yn.intToBuffer(f.affineX),b=Yn.bufferToInt(r[i].slice(0,32)),w=Yn.bufferToInt(r[i].slice(32,64));Wu.checkSignatureInput(b,w);const y=Jn.getE(Yn.intToBuffer(b),c,e[i]),_=Jn.liftX(r[i].slice(0,32));if(i===0)n=n.add(w),s=_,s=s.add(f.multiply(y));else{const B=Jn.randomA();n=n.add(B.multiply(w)),s=s.add(_.multiply(B)),s=s.add(f.multiply(B.multiply(y)))}}if(!Og.multiply(n).equals(s))throw new Error("signature verification failed")}var mV={sign:pV,verify:vV,batchVerify:bV};const Pg=Sa.Buffer,t_=Rh.getCurveByName("secp256k1"),Vi=tp,kh=ep,Wi=Th,rp=Pg.concat,r_=t_.G,uf=t_.n,n_=Wi.hash(Pg.from("MuSig coefficient"));function i_(t){return kh.checkPubKeyArr(t),Wi.hash(rp(t))}function np(t,e){const r=Pg.alloc(4);r.writeUInt32LE(e);const n=rp([n_,n_,t,r]);return Wi.bufferToInt(Wi.hash(n)).mod(uf)}function gV(t,e){const r=e||i_(t);let n=null;for(let s=0;s<t.length;s++){const i=Vi.liftX(t[s]),f=np(r,s),c=i.multiply(f);n===null?n=c:n=n.add(c)}return n}function yV(t,e,r,n,s,i,f){kh.checkSessionParams(t,e,r,n,i);const c={sessionId:t,message:r,pubKeyCombined:n,pkParity:s,ell:i,idx:f},b=np(i,f);c.secretKey=e.multiply(b).mod(uf),c.ownKeyParity=Vi.isEven(r_.multiply(e)),c.pkParity!==c.ownKeyParity&&(c.secretKey=uf.subtract(c.secretKey));const w=rp([t,r,c.pubKeyCombined,Wi.intToBuffer(e)]);c.secretNonce=Wi.bufferToInt(Wi.hash(w)),kh.checkRange("secretNonce",c.secretNonce);const y=r_.multiply(c.secretNonce);return c.nonce=Wi.intToBuffer(y.affineX),c.nonceParity=Vi.isEven(y),c.commitment=Wi.hash(c.nonce),c}function wV(t,e){kh.checkNonceArr(e);let r=Vi.liftX(e[0]);for(let n=1;n<e.length;n++)r=r.add(Vi.liftX(e[n]));return t.combinedNonceParity=Vi.isEven(r),Wi.intToBuffer(r.affineX)}function _V(t,e,r,n){const s=Vi.getE(r,n,e),i=t.secretKey;let f=t.secretNonce;return t.nonceParity!==t.combinedNonceParity&&(f=uf.subtract(f)),i.multiply(s).add(f).mod(uf)}function xV(t,e,r,n,s,i){let f=Vi.getE(r,t.pubKeyCombined,t.message);const c=np(t.ell,n),b=Vi.liftX(s),w=Vi.liftX(i);t.pkParity||(f=uf.subtract(f));let y=Vi.getR(e,f.multiply(c).mod(uf),b);t.combinedNonceParity&&(y=y.negate());const _=y.add(w);if(!_.curve.isInfinity(_))throw new Error("partial signature verification failed")}function AV(t,e){const r=Vi.liftX(t);kh.checkArray("partialSigs",e);const n=Wi.intToBuffer(r.affineX);let s=e[0];for(let i=1;i<e.length;i++)s=s.add(e[i]).mod(uf);return rp([n,Wi.intToBuffer(s)])}var SV={computeEll:i_,computeCoefficient:np,pubKeyCombine:gV,sessionInitialize:yV,sessionNonceCombine:wV,partialSign:_V,partialSigVerify:xV,partialSigCombine:AV};const kg=Sa.Buffer,EV=Rh.getCurveByName("secp256k1"),s_=tp,Ng=Th,IV=kg.concat,MV=EV.G;function RV(t,e){e||(e=[]);const r=BV(e),n=Ng.intToBuffer(t.affineX),s=s_.liftX(n),i=Ng.bufferToInt(s_.taggedHash("TapTweak",IV([n,r]))),f=s.add(MV.multiply(i));return Ng.intToBuffer(f.affineX)}function BV(t){let e=kg.alloc(32,0);return!t||t.length===0?new kg(0):e}var TV={taprootConstruct:RV};const $u=mV;$u.check=ep,$u.convert=Th,$u.math=tp,$u.muSig=SV,$u.taproot=TV;var OV=$u,lo={exports:{}},Cg,a_;function Nh(){if(a_)return Cg;a_=1;var t=Gt,e=Yt;const r=Ui;var n=Xn,s=pr,i=En,f=ui(),c=cf(),b=Ma(),w=4294967295,y=w,_=w-1,B=w-2;const M=Math.pow(2,31),E=Math.pow(2,22),O=65535,k=512,P=Math.pow(2,16)-1;function C(D){if(!(this instanceof C))return new C(D);if(D)return this._fromObject(D)}return C.MAXINT=w,C.DEFAULT_SEQNUMBER=y,C.DEFAULT_LOCKTIME_SEQNUMBER=_,C.DEFAULT_RBF_SEQNUMBER=B,C.SEQUENCE_LOCKTIME_TYPE_FLAG=E,Object.defineProperty(C.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new f(this._scriptBuffer),this._script._isInput=!0),this._script)}}),C.fromObject=function(D){e.checkArgument(t.isObject(D));var z=new C;return z._fromObject(D)},C.prototype._fromObject=function(D){var z;if(typeof D.prevTxId=="string"&&i.isHexa(D.prevTxId)?z=ge.from(D.prevTxId,"hex"):z=D.prevTxId,this.witnesses=[],this.output=D.output?D.output instanceof b?D.output:new b(D.output):void 0,this.prevTxId=z||D.txidbuf,this.outputIndex=D.outputIndex==null?D.txoutnum:D.outputIndex,this.sequenceNumber=D.sequenceNumber==null?D.seqnum==null?y:D.seqnum:D.sequenceNumber,D.script===void 0&&D.scriptBuffer===void 0)throw new r.Transaction.Input.MissingScript;return this.setScript(D.scriptBuffer||D.script),this},C.prototype.toObject=C.prototype.toJSON=function(){var z={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(z.scriptString=this.script.toString()),this.output&&(z.output=this.output.toObject()),z},C.fromBufferReader=function(D){var z=new C;return z.prevTxId=D.readReverse(32),z.outputIndex=D.readUInt32LE(),z._scriptBuffer=D.readVarLengthBuffer(),z.sequenceNumber=D.readUInt32LE(),z},C.prototype.toBufferWriter=function(D){D||(D=new n),D.writeReverse(this.prevTxId),D.writeUInt32LE(this.outputIndex);var z=this._scriptBuffer;return D.writeVarintNum(z.length),D.write(z),D.writeUInt32LE(this.sequenceNumber),D},C.prototype.setScript=function(D){if(this._script=null,D instanceof f)this._script=D,this._script._isInput=!0,this._scriptBuffer=D.toBuffer();else if(i.isHexa(D))this._scriptBuffer=ge.from(D,"hex");else if(t.isString(D))this._script=new f(D),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(s.isBuffer(D))this._scriptBuffer=ge.from(D);else throw new TypeError("Invalid argument type: script");return this},C.prototype.getSignatures=function(){throw new r.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))},C.prototype.getSatoshisBuffer=function(){return e.checkState(this.output instanceof b),e.checkState(this.output._satoshisBN),new n().writeUInt64LEBN(this.output._satoshisBN).toBuffer()},C.prototype.isFullySigned=function(){throw new r.AbstractMethodInvoked("Input#isFullySigned")},C.prototype.isFinal=function(){return this.sequenceNumber!==C.MAXINT},C.prototype.addSignature=function(){throw new r.AbstractMethodInvoked("Input#addSignature")},C.prototype.clearSignatures=function(){throw new r.AbstractMethodInvoked("Input#clearSignatures")},C.prototype.hasWitnesses=function(){return!!(this.witnesses&&this.witnesses.length>0)},C.prototype.getWitnesses=function(){return this.witnesses},C.prototype.setWitnesses=function(D){this.witnesses=D},C.prototype.isValidSignature=function(D,z,J){return J=J||"ecdsa",z.signature.nhashtype=z.sigtype,c.verify(D,z.signature,z.publicKey,z.inputIndex,this.output.script,J)},C.prototype.isNull=function(){return this.prevTxId.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.outputIndex===4294967295},C.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length},C.prototype._getBaseSize=function(){return 40},C.prototype.lockForSeconds=function(D){if(e.checkArgument(t.isNumber(D)),D<0||D>=k*O)throw new r.Transaction.Input.LockTimeRange;return D=parseInt(Math.floor(D/k)),this.sequenceNumber=D|E,this},C.prototype.lockUntilBlockHeight=function(D){if(e.checkArgument(t.isNumber(D)),D<0||D>=P)throw new r.Transaction.Input.BlockHeightOutOfRange;return this.sequenceNumber=D,this},C.prototype.getLockTime=function(){if(this.sequenceNumber&M)return null;if(this.sequenceNumber&E){var D=k*(this.sequenceNumber&O);return D}else{var z=this.sequenceNumber&O;return z}},Cg=C,Cg}var Lg={exports:{}};typeof Object.create=="function"?Lg.exports=function(e,r){e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:Lg.exports=function(e,r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e};var Ch=Lg.exports,Dg,f_;function Lh(){if(f_)return Dg;f_=1;var t=Gt,e=Yt,r=Ch,n=pr,s=En,i=Ys(),f=Ui,c=oi;function b(w){if(!(this instanceof b))return new b(w);if(w instanceof b)return w;if(t.isObject(w))return this._fromObject(w);throw new f.InvalidArgument("TransactionSignatures must be instantiated from an object")}return r(b,c),b.prototype._fromObject=function(w){return this._checkObjectArgs(w),this.publicKey=new i(w.publicKey),this.prevTxId=n.isBuffer(w.prevTxId)?w.prevTxId:ge.from(w.prevTxId,"hex"),this.outputIndex=w.outputIndex,this.inputIndex=w.inputIndex,this.signature=w.signature instanceof c?w.signature:n.isBuffer(w.signature)?c.fromBuffer(w.signature):c.fromString(w.signature),this.sigtype=w.sigtype,this},b.prototype._checkObjectArgs=function(w){e.checkArgument(i(w.publicKey),"publicKey"),e.checkArgument(!t.isUndefined(w.inputIndex),"inputIndex"),e.checkArgument(!t.isUndefined(w.outputIndex),"outputIndex"),e.checkState(t.isNumber(w.inputIndex),"inputIndex must be a number"),e.checkState(t.isNumber(w.outputIndex),"outputIndex must be a number"),e.checkArgument(w.signature,"signature"),e.checkArgument(w.prevTxId,"prevTxId"),e.checkState(w.signature instanceof c||n.isBuffer(w.signature)||s.isHexa(w.signature),"signature must be a buffer or hexa value"),e.checkState(n.isBuffer(w.prevTxId)||s.isHexa(w.prevTxId),"prevTxId must be a buffer or hexa value"),e.checkArgument(w.sigtype,"sigtype"),e.checkState(t.isNumber(w.sigtype),"sigtype must be a number")},b.prototype.toObject=b.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}},b.fromObject=function(w){return e.checkArgument(w),new b(w)},Dg=b,Dg}var Fg,o_;function PV(){if(o_)return Fg;o_=1;var t=Ch,e=Yt,r=Nh(),n=Ma(),s=cf(),i=ui(),f=oi,c=Lh();function b(){r.apply(this,arguments)}return t(b,r),b.prototype.getSignatures=function(w,y,_,B,M,E){e.checkState(this.output instanceof n),B=B||f.SIGHASH_ALL;var O=y.toPublicKey();return O.toString()===this.output.script.getPublicKey().toString("hex")?[new c({publicKey:O,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:_,signature:s.sign(w,y,B,_,this.output.script,E),sigtype:B})]:[]},b.prototype.addSignature=function(w,y,_){return e.checkState(this.isValidSignature(w,y,_),"Signature is invalid"),this.setScript(i.buildPublicKeyIn(y.signature.toDER(),y.sigtype)),this},b.prototype.clearSignatures=function(){return this.setScript(i.empty()),this},b.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},b.SCRIPT_MAX_SIZE=73,b.prototype._estimateSize=function(){return this._getBaseSize()+b.SCRIPT_MAX_SIZE},Fg=b,Fg}var Ug,u_;function ip(){if(u_)return Ug;u_=1;var t=oi;ui(),Ma();var e=Ea,r=Xn,n=an,s=op(),i=Yt,f=Gt,c=function(_,B,M,E,O){var k,P,C;if(!(B&t.SIGHASH_ANYONECANPAY)){for(var D=[],z=0;z<_.inputs.length;z++){var J=_.inputs[z],j=new e(J.prevTxId).readReverse();D.push(j);var re=ge.alloc(4);re.writeUInt32LE(J.outputIndex,0),D.push(re)}k=n.sha256sha256(ge.concat(D))}if(!(B&t.SIGHASH_ANYONECANPAY)&&(B&31)!==t.SIGHASH_SINGLE&&(B&31)!==t.SIGHASH_NONE){for(var T=[],q=0;q<_.inputs.length;q++){var F=ge.alloc(4);F.writeUInt32LE(_.inputs[q].sequenceNumber,0),T.push(F)}P=n.sha256sha256(ge.concat(T))}var m=new r;if((B&31)!==t.SIGHASH_SINGLE&&(B&31)!==t.SIGHASH_NONE){for(var a=0;a<_.outputs.length;a++)_.outputs[a].toBufferWriter(m);C=n.sha256sha256(m.toBuffer())}else(B&31)===t.SIGHASH_SINGLE&&M<_.outputs.length&&(_.outputs[M].toBufferWriter(m),C=n.sha256sha256(m.toBuffer()));var h=new r;h.writeUInt32LE(_.version),h.write(k),h.write(P);var u=new e(_.inputs[M].prevTxId).readReverse();return h.write(u),h.writeUInt32LE(_.inputs[M].outputIndex),h.write(E),h.write(O),h.writeUInt32LE(_.inputs[M].sequenceNumber),h.write(C),h.writeUInt32LE(_.nLockTime),h.writeInt32LE(B),n.sha256sha256(h.toBuffer())};function b(y,_,B,M,E,O,k){k=k||"ecdsa";var P;if(k==="ecdsa"){let C=c(y,B,M,E,O);return P=s.sign(C,_).set({nhashtype:B}),P}throw new Error("signingMethod not supported ",k)}function w(y,_,B,M,E,O,k){if(i.checkArgument(!f.isUndefined(y)),i.checkArgument(!f.isUndefined(_)&&!f.isUndefined(_.nhashtype)),k=k||"ecdsa",k==="ecdsa"){let P=c(y,_.nhashtype,M,E,O);return s.verify(P,_,B)}throw new Error("signingMethod not supported ",k)}return Ug={sighash:c,sign:b,verify:w},Ug}var Hg,c_;function kV(){if(c_)return Hg;c_=1;var t=Ch,e=Yt,b=pr;Js();var r=an,n=Nh(),s=Ma(),i=cf(),f=ip(),c=Xn,b=pr,w=ui(),y=oi,_=Lh();function B(){n.apply(this,arguments)}return t(B,n),B.prototype.getRedeemScript=function(M){if(!this.redeemScript){var E=w.buildWitnessV0Out(M);if(w.buildScriptHashOut(E).equals(this.output.script)){var O=new w;O.add(E.toBuffer()),this.setScript(O),this.redeemScript=E}}return this.redeemScript},B.prototype.getScriptCode=function(M){var E=new c,O;this.output.script.isScriptHashOut()?O=this.getRedeemScript(M):O=this.output.script;var k=w.buildPublicKeyHashOut(O.toAddress()).toBuffer();return E.writeVarintNum(k.length),E.write(k),E.toBuffer()},B.prototype.getSighash=function(M,E,O,k){var P=this.getScriptCode(E),C=this.getSatoshisBuffer();return f.sighash(M,k,O,P,C)},B.prototype.getSignatures=function(M,E,O,k,P,C){e.checkState(this.output instanceof s),P=P||r.sha256ripemd160(E.publicKey.toBuffer()),k=k||y.SIGHASH_ALL,C=C||"ecdsa";var D;if(this.output.script.isScriptHashOut()?D=this.getRedeemScript(E.publicKey):D=this.output.script,D&&b.equals(P,D.getPublicKeyHash())){var z;if(D.isWitnessPublicKeyHashOut()){var J=this.getSatoshisBuffer(),j=this.getScriptCode(E.publicKey);z=f.sign(M,E,k,O,j,J,C)}else z=i.sign(M,E,k,O,this.output.script,C);return[new _({publicKey:E.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:O,signature:z,sigtype:k})]}return[]},B.prototype.addSignature=function(M,E,O){return e.checkState(this.isValidSignature(M,E,O),"Signature is invalid"),this.output.script.isWitnessPublicKeyHashOut()||this.output.script.isScriptHashOut()?this.setWitnesses([b.concat([E.signature.toDER(),b.integerAsSingleByteBuffer(E.sigtype)]),E.publicKey.toBuffer()]):this.setScript(w.buildPublicKeyHashIn(E.publicKey,E.signature.toDER(),E.sigtype)),this},B.prototype.clearSignatures=function(){return this.setScript(w.empty()),this.setWitnesses([]),this},B.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()||this.hasWitnesses()},B.prototype.isValidSignature=function(M,E,O){if(E.signature.nhashtype=E.sigtype,this.output.script.isWitnessPublicKeyHashOut()||this.output.script.isScriptHashOut()){var k=this.getScriptCode(),P=this.getSatoshisBuffer();return f.verify(M,E.signature,E.publicKey,E.inputIndex,k,P,O)}else return i.verify(M,E.signature,E.publicKey,E.inputIndex,this.output.script,O)},B.SCRIPT_MAX_SIZE=107,B.REDEEM_SCRIPT_SIZE=23,B.prototype._estimateSize=function(){let M=this._getBaseSize();M+=1;const O=B.SCRIPT_MAX_SIZE/4;return this.output.script.isWitnessPublicKeyHashOut()?M+=O:this.output.script.isScriptHashOut()?M+=O+B.REDEEM_SCRIPT_SIZE:M+=B.SCRIPT_MAX_SIZE,M},Hg=B,Hg}var qg,h_;function NV(){if(h_)return qg;h_=1;var t=Gt,e=Ch;Zg();var r=Nh(),n=Ma(),s=Yt,i=ui(),f=oi,c=cf();Ys();var b=pr,w=Lh();function y(_,B,M,E,O){O=O||{},r.apply(this,arguments);var k=this;B=B||_.publicKeys,M=M||_.threshold,E=E||_.signatures,O.noSorting?this.publicKeys=B:this.publicKeys=t.sortBy(B,function(P){return P.toString("hex")}),s.checkState(i.buildMultisigOut(this.publicKeys,M).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},t.each(this.publicKeys,function(P,C){k.publicKeyIndex[P.toString()]=C}),this.threshold=M,this.signatures=E?this._deserializeSignatures(E):new Array(this.publicKeys.length)}return e(y,r),y.prototype.toObject=function(){var _=r.prototype.toObject.apply(this,arguments);return _.threshold=this.threshold,_.publicKeys=t.map(this.publicKeys,function(B){return B.toString()}),_.signatures=this._serializeSignatures(),_},y.prototype._deserializeSignatures=function(_){return t.map(_,function(B){if(B)return new w(B)})},y.prototype._serializeSignatures=function(){return t.map(this.signatures,function(_){if(_)return _.toObject()})},y.prototype.getSignatures=function(_,B,M,E,O,k){s.checkState(this.output instanceof n),E=E||f.SIGHASH_ALL,k=k||"ecdsa";var P=this,C=[];return t.each(this.publicKeys,function(D){D.toString()===B.publicKey.toString()&&C.push(new w({publicKey:B.publicKey,prevTxId:P.prevTxId,outputIndex:P.outputIndex,inputIndex:M,signature:c.sign(_,B,E,M,P.output.script,k),sigtype:E}))}),C},y.prototype.addSignature=function(_,B,M){return s.checkState(!this.isFullySigned(),"All needed signatures have already been added"),s.checkArgument(!t.isUndefined(this.publicKeyIndex[B.publicKey.toString()],"Signature Undefined"),"Signature has no matching public key"),s.checkState(this.isValidSignature(_,B,M),"Invalid Signature"),this.signatures[this.publicKeyIndex[B.publicKey.toString()]]=B,this._updateScript(),this},y.prototype._updateScript=function(){return this.setScript(i.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},y.prototype._createSignatures=function(){return t.map(t.filter(this.signatures,function(_){return!t.isUndefined(_)}),function(_){return b.concat([_.signature.toDER(),b.integerAsSingleByteBuffer(_.sigtype)])})},y.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},y.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},y.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},y.prototype.countSignatures=function(){return t.reduce(this.signatures,function(_,B){return _+!!B},0)},y.prototype.publicKeysWithoutSignature=function(){var _=this;return t.filter(this.publicKeys,function(B){return!_.signatures[_.publicKeyIndex[B.toString()]]})},y.prototype.isValidSignature=function(_,B,M){return B.signature.nhashtype=B.sigtype,c.verify(_,B.signature,B.publicKey,B.inputIndex,this.output.script,M)},y.normalizeSignatures=function(_,B,M,E,O,k){return O.map(function(P){var C=null;return E=E.filter(function(D){if(C)return!0;var z=new w({signature:f.fromTxFormat(D),publicKey:P,prevTxId:B.prevTxId,outputIndex:B.outputIndex,inputIndex:M,sigtype:f.SIGHASH_ALL});z.signature.nhashtype=z.sigtype;var J=c.verify(_,z.signature,z.publicKey,z.inputIndex,B.output.script,k);return J?(C=z,!1):!0}),C||null})},y.OPCODES_SIZE=1,y.SIGNATURE_SIZE=73,y.prototype._estimateSize=function(){return this._getBaseSize()+y.OPCODES_SIZE+this.threshold*y.SIGNATURE_SIZE},qg=y,qg}var zg,l_;function CV(){if(l_)return zg;l_=1;var t=Gt,e=Ch,r=Nh(),n=Ma(),s=Yt,i=Js(),f=ui(),c=oi,b=cf(),w=ip(),y=Xn,_=pr,B=Lh();function M(E,O,k,P,C){C=C||{},r.apply(this,arguments),O=O||E.publicKeys,k=k||E.threshold,P=P||E.signatures,C.noSorting?this.publicKeys=O:this.publicKeys=t.sortBy(O,function(J){return J.toString("hex")}),this.redeemScript=f.buildMultisigOut(this.publicKeys,k,C);var D=f.buildWitnessMultisigOutFromScript(this.redeemScript);if(D.equals(this.output.script))this.nestedWitness=!1,this.type=i.PayToWitnessScriptHash;else if(f.buildScriptHashOut(D).equals(this.output.script))this.nestedWitness=!0,this.type=i.PayToScriptHash;else if(f.buildScriptHashOut(this.redeemScript).equals(this.output.script))this.nestedWitness=!1,this.type=i.PayToScriptHash;else throw new Error("Provided public keys don't hash to the provided output");if(this.nestedWitness){var z=new f;z.add(D.toBuffer()),this.setScript(z)}this.publicKeyIndex={};for(let J=0;J<this.publicKeys.length;J++){const j=this.publicKeys[J];this.publicKeyIndex[j.toString()]=J}this.threshold=k,this.signatures=P?this._deserializeSignatures(P):new Array(this.publicKeys.length)}return e(M,r),M.prototype.toObject=function(){var E=r.prototype.toObject.apply(this,arguments);return E.threshold=this.threshold,E.publicKeys=this.publicKeys.map(function(O){return O.toString()}),E.signatures=this._serializeSignatures(),E},M.prototype._deserializeSignatures=function(E){return E.map(function(O){if(O)return new B(O)})},M.prototype._serializeSignatures=function(){return this.signatures.map(function(E){if(E)return E.toObject()})},M.prototype.getScriptCode=function(){var E=new y;if(this.redeemScript.hasCodeseparators())throw new Error("@TODO");var O=this.redeemScript.toBuffer();return E.writeVarintNum(O.length),E.write(O),E.toBuffer()},M.prototype.getSighash=function(E,O,k,P){var C;if(this.nestedWitness||this.type===i.PayToWitnessScriptHash){var D=this.getScriptCode(),z=this.getSatoshisBuffer();C=w.sighash(E,P,k,D,z)}else C=b.sighash(E,P,k,this.redeemScript);return C},M.prototype.getSignatures=function(E,O,k,P,C,D){s.checkState(this.output instanceof n),P=P||c.SIGHASH_ALL,D=D||"ecdsa";const z=[];for(const T of this.publicKeys)if(T.toString()===O.publicKey.toString()){var J;if(this.nestedWitness||this.type===i.PayToWitnessScriptHash){var j=this.getScriptCode(),re=this.getSatoshisBuffer();J=w.sign(E,O,P,k,j,re,D)}else J=b.sign(E,O,P,k,this.redeemScript,D);z.push(new B({publicKey:O.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:k,signature:J,sigtype:P}))}return z},M.prototype.addSignature=function(E,O,k){return s.checkState(!this.isFullySigned(),"All needed signatures have already been added"),s.checkArgument(this.publicKeyIndex[O.publicKey.toString()]!=null,"Signature has no matching public key"),s.checkState(this.isValidSignature(E,O,k),"Invalid Signature!"),this.signatures[this.publicKeyIndex[O.publicKey.toString()]]=O,this._updateScript(),this},M.prototype._updateScript=function(){if(this.nestedWitness||this.type===i.PayToWitnessScriptHash){for(var E=[ge.alloc(0)],O=this._createSignatures(),k=0;k<O.length;k++)E.push(O[k]);E.push(this.redeemScript.toBuffer()),this.setWitnesses(E)}else{var P=f.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript});this.setScript(P)}return this},M.prototype._createSignatures=function(){return this.signatures.filter(function(E){return E!=null}).map(function(E){return _.concat([E.signature.toDER(),_.integerAsSingleByteBuffer(E.sigtype)])})},M.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},M.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},M.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},M.prototype.countSignatures=function(){return this.signatures.reduce(function(E,O){return E+!!O},0)},M.prototype.publicKeysWithoutSignature=function(){return this.publicKeys.filter(E=>!this.signatures[this.publicKeyIndex[E.toString()]])},M.prototype.isValidSignature=function(E,O,k){if(k=k||"ecdsa",this.nestedWitness||this.type===i.PayToWitnessScriptHash){O.signature.nhashtype=O.sigtype;var P=this.getScriptCode(),C=this.getSatoshisBuffer();return w.verify(E,O.signature,O.publicKey,O.inputIndex,P,C,k)}else return O.signature.nhashtype=O.sigtype,b.verify(E,O.signature,O.publicKey,O.inputIndex,this.redeemScript,k)},M.MAX_OPCODES_SIZE=8,M.MAX_SIGNATURE_SIZE=74,M.MAX_PUBKEY_SIZE=34,M.REDEEM_SCRIPT_SIZE=34,M.prototype._estimateSize=function(){let E=this._getBaseSize();const O=4,k=M.MAX_OPCODES_SIZE+this.threshold*M.MAX_SIGNATURE_SIZE+this.publicKeys.length*M.MAX_PUBKEY_SIZE;return this.type===i.PayToWitnessScriptHash?E+=k/O:this.nestedWitness?E+=k/O+M.REDEEM_SCRIPT_SIZE:E+=k,E},zg=M,zg}var d_;function jg(){return d_||(d_=1,lo.exports=Nh(),lo.exports.PublicKey=PV(),lo.exports.PublicKeyHash=kV(),lo.exports.MultiSig=NV(),lo.exports.MultiSigScriptHash=CV()),lo.exports}var Kg,p_;function cf(){if(p_)return Kg;p_=1;var t=oi,e=ui(),r=Ma(),n=Ea,s=Xn,i=Sn,f=an,c=op(),b=Yt,w=Gt;const y=OV;var _="0000000000000000000000000000000000000000000000000000000000000001",B="ffffffffffffffff",M=function(P,C,D,z){var J=Zg(),j=jg(),re,T=J.shallowCopy(P);for(z=new e(z),z.removeCodeseparators(),re=0;re<T.inputs.length;re++)T.inputs[re]=new j(T.inputs[re]).setScript(e.empty());if(T.inputs[D]=new j(T.inputs[D]).setScript(z),(C&31)===t.SIGHASH_NONE||(C&31)===t.SIGHASH_SINGLE)for(re=0;re<T.inputs.length;re++)re!==D&&(T.inputs[re].sequenceNumber=0);if((C&31)===t.SIGHASH_NONE)T.outputs=[];else if((C&31)===t.SIGHASH_SINGLE){if(D>=T.outputs.length)return ge.from(_,"hex");for(T.outputs.length=D+1,re=0;re<D;re++)T.outputs[re]=new r({satoshis:i.fromBuffer(ge.from(B,"hex")),script:e.empty()})}C&t.SIGHASH_ANYONECANPAY&&(T.inputs=[T.inputs[D]]);var q=new s().write(T.toBuffer()).writeInt32LE(C).toBuffer(),F=f.sha256sha256(q);return F=new n(F).readReverse(),F};function E(k,P,C,D,z,J){J=J||"ecdsa";let j=M(k,C,D,z),re;switch(J){case"ecdsa":re=c.sign(j,P,"little").set({nhashtype:C});break;case"schnorr":re=y.sign(P.toString(),j);break;default:throw new Error("signingMethod not supported ",J)}return re}function O(k,P,C,D,z,J){b.checkArgument(!w.isUndefined(k),"Transaction Undefined"),b.checkArgument(!w.isUndefined(P)&&!w.isUndefined(P.nhashtype),"Signature Undefined"),J=J||"ecdsa";let j=M(k,P.nhashtype,D,z),re=!1;switch(J){case"ecdsa":re=c.verify(j,P,C,"little");break;case"schnorr":re=y.verify(C,j,P);break;default:throw new Error("signingMethod not supported ",J)}return re}return Kg={sighash:M,sign:E,verify:O},Kg}var Vg=Gt,sp=Ui,LV=Yt,po={BTC:[1e8,8],mBTC:[1e5,5],uBTC:[100,2],bits:[100,2],satoshis:[1,0]};function Ot(t,e){if(!(this instanceof Ot))return new Ot(t,e);if(Vg.isNumber(e)){if(e<=0)throw new sp.Unit.InvalidRate(e);t=t/e,e=Ot.BTC}this._value=this._from(t,e);var r=this,n=function(s){Object.defineProperty(r,s,{get:function(){return r.to(s)},enumerable:!0})};Object.keys(po).forEach(n)}Object.keys(po).forEach(function(t){Ot[t]=t}),Ot.fromObject=function(e){return LV.checkArgument(Vg.isObject(e),"Argument is expected to be an object"),new Ot(e.amount,e.code)},Ot.fromBTC=function(t){return new Ot(t,Ot.BTC)},Ot.fromMillis=Ot.fromMilis=function(t){return new Ot(t,Ot.mBTC)},Ot.fromMicros=Ot.fromBits=function(t){return new Ot(t,Ot.bits)},Ot.fromSatoshis=function(t){return new Ot(t,Ot.satoshis)},Ot.fromFiat=function(t,e){return new Ot(t,e)},Ot.prototype._from=function(t,e){if(!po[e])throw new sp.Unit.UnknownCode(e);return parseInt((t*po[e][0]).toFixed())},Ot.prototype.to=function(t){if(Vg.isNumber(t)){if(t<=0)throw new sp.Unit.InvalidRate(t);return parseFloat((this.BTC*t).toFixed(2))}if(!po[t])throw new sp.Unit.UnknownCode(t);var e=this._value/po[t][0];return parseFloat(e.toFixed(po[t][1]))},Ot.prototype.toBTC=function(){return this.to(Ot.BTC)},Ot.prototype.toMillis=Ot.prototype.toMilis=function(){return this.to(Ot.mBTC)},Ot.prototype.toMicros=Ot.prototype.toBits=function(){return this.to(Ot.bits)},Ot.prototype.toSatoshis=function(){return this.to(Ot.satoshis)},Ot.prototype.atRate=function(t){return this.to(t)},Ot.prototype.toString=function(){return this.satoshis+" satoshis"},Ot.prototype.toObject=Ot.prototype.toJSON=function(){return{amount:this.BTC,code:Ot.BTC}},Ot.prototype.inspect=function(){return"<Unit: "+this.toString()+">"};var Wg=Ot,$g,v_;function b_(){if(v_)return $g;v_=1;var t=Gt,e=Yt,r=En,n=ui(),s=Js(),i=Wg;function f(c){if(!(this instanceof f))return new f(c);e.checkArgument(t.isObject(c),"Must provide an object from where to extract data");var b=c.address?new s(c.address):void 0,w=c.txid?c.txid:c.txId;if(!w||!r.isHexaString(w)||w.length>64)throw new Error("Invalid TXID in object",c);var y=t.isUndefined(c.vout)?c.outputIndex:c.vout;if(!t.isNumber(y))throw new Error("Invalid outputIndex, received "+y);e.checkArgument(!t.isUndefined(c.scriptPubKey)||!t.isUndefined(c.script),"Must provide the scriptPubKey for that output!");var _=new n(c.scriptPubKey||c.script);e.checkArgument(!t.isUndefined(c.amount)||!t.isUndefined(c.satoshis),"Must provide an amount for the output");var B=t.isUndefined(c.amount)?c.satoshis:new i.fromBTC(c.amount).toSatoshis();e.checkArgument(t.isNumber(B),"Amount must be a number"),r.defineImmutable(this,{address:b,txId:w,outputIndex:y,script:_,satoshis:B})}return f.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"},f.prototype.toString=function(){return this.txId+":"+this.outputIndex},f.fromObject=function(c){return new f(c)},f.prototype.toObject=f.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:i.fromSatoshis(this.satoshis).toBTC()}},$g=f,$g}var Gg,m_;function Zg(){if(m_)return Gg;m_=1;var t=Gt,e=Yt,r=gn,n=ge.compare||Pz(),s=Ui,i=pr,f=En,c=Ea,b=Xn,w=an,y=oi,_=cf(),B=ip(),M=Js(),E=b_(),O=jg(),k=O.PublicKeyHash,P=O.PublicKey,C=O.MultiSigScriptHash,D=O.MultiSig,z=Ma(),J=ui(),j=Dh(),re=Sn;function T(l,g){if(!(this instanceof T))return new T(l);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,l){if(l instanceof T)return T.shallowCopy(l);if(f.isHexa(l))this.fromString(l);else if(i.isBuffer(l))this.fromBuffer(l);else if(t.isObject(l))this.fromObject(l,g);else throw new s.InvalidArgument("Must provide an object or string to deserialize a transaction")}else this._newTransaction()}var q=2,F=0,m=1e6;T.DUST_AMOUNT=546,T.FEE_SECURITY_MARGIN=150,T.MAX_MONEY=21e6*1e8,T.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8,T.NLOCKTIME_MAX_VALUE=4294967295,T.FEE_PER_KB=1e5,T.CHANGE_OUTPUT_MAX_SIZE=62,T.MAXIMUM_EXTRA_SIZE=26,T.shallowCopy=function(l){var g=new T(l.toBuffer());return g};var a={configurable:!1,enumerable:!0,get:function(){return this._hash=new c(this._getHash()).readReverse().toString("hex"),this._hash}},h={configurable:!1,enumerable:!0,get:function(){return new c(this._getWitnessHash()).readReverse().toString("hex")}};Object.defineProperty(T.prototype,"witnessHash",h),Object.defineProperty(T.prototype,"hash",a),Object.defineProperty(T.prototype,"id",a);var u={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};return Object.defineProperty(T.prototype,"inputAmount",u),u.get=function(){return this._getOutputAmount()},Object.defineProperty(T.prototype,"outputAmount",u),Object.defineProperty(T.prototype,"size",{configurable:!1,enumerable:!1,get:function(){return this._calculateSize()}}),Object.defineProperty(T.prototype,"vsize",{configurable:!1,enumerable:!1,get:function(){return this._calculateVSize()}}),Object.defineProperty(T.prototype,"weight",{configurable:!1,enumerable:!1,get:function(){return this._calculateWeight()}}),T.prototype._getHash=function(){return w.sha256sha256(this.toBuffer(!0))},T.prototype._getWitnessHash=function(){return w.sha256sha256(this.toBuffer(!1))},T.prototype.serialize=function(l){return l===!0||l&&l.disableAll?this.uncheckedSerialize():this.checkedSerialize(l)},T.prototype.uncheckedSerialize=T.prototype.toString=function(){return this.toBuffer().toString("hex")},T.prototype.checkedSerialize=function(l){var g=this.getSerializationError(l);if(g)throw g.message+=" - For more information please see: https://github.com/bitpay/bitcore/blob/master/packages/bitcore-lib/docs/transaction.md#serialization-checks",g;return this.uncheckedSerialize()},T.prototype.invalidSatoshis=function(){for(var l=!1,g=0;g<this.outputs.length;g++)this.outputs[g].invalidSatoshis()&&(l=!0);return l},T.prototype.getSerializationError=function(l){if(l=l||{},this.invalidSatoshis())return new s.Transaction.InvalidSatoshis;var g=this._getUnspentValue(),A;return g<0?l.disableMoreOutputThanInput||(A=new s.Transaction.InvalidOutputAmountSum):A=this._hasFeeError(l,g),A||this._hasDustOutputs(l)||this._isMissingSignatures(l)},T.prototype._hasFeeError=function(l,g){if(this._fee!=null&&this._fee!==g)return new s.Transaction.FeeError.Different("Unspent value is "+g+" but specified fee is "+this._fee);if(!l.disableLargeFees){var A=Math.floor(T.FEE_SECURITY_MARGIN*this._estimateFee());if(g>A)return this._missingChange()?new s.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new s.Transaction.FeeError.TooLarge("expected less than "+A+" but got "+g)}if(!l.disableSmallFees){var x=Math.ceil(this._estimateFee()/T.FEE_SECURITY_MARGIN);if(g<x)return new s.Transaction.FeeError.TooSmall("expected more than "+x+" but got "+g)}},T.prototype._missingChange=function(){return!this._changeScript},T.prototype._hasDustOutputs=function(l){if(!l.disableDustOutputs){var g,A;for(g in this.outputs)if(A=this.outputs[g],A.satoshis<T.DUST_AMOUNT&&!A.script.isDataOut())return new s.Transaction.DustOutputs}},T.prototype._isMissingSignatures=function(l){if(!l.disableIsFullySigned&&!this.isFullySigned())return new s.Transaction.MissingSignatures},T.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"},T.prototype.toBuffer=function(l){var g=new b;return this.toBufferWriter(g,l).toBuffer()},T.prototype.hasWitnesses=function(){for(var l=0;l<this.inputs.length;l++)if(this.inputs[l].hasWitnesses())return!0;return!1},T.prototype.toBufferWriter=function(l,g){l.writeInt32LE(this.version);const A=this.hasWitnesses();A&&!g&&l.write(ge.from("0001","hex")),l.writeVarintNum(this.inputs?this.inputs.length:0);for(const x of this.inputs||[])x.toBufferWriter(l);l.writeVarintNum(this.outputs?this.outputs.length:0);for(const x of this.outputs||[])x.toBufferWriter(l);if(A&&!g)for(const x of this.inputs){const p=x.getWitnesses();l.writeVarintNum(p.length);for(let d=0;d<p.length;d++)l.writeVarintNum(p[d].length),l.write(p[d])}return l.writeUInt32LE(this.nLockTime),l},T.prototype.fromBuffer=function(l){var g=new c(l);return this.fromBufferReader(g)},T.prototype.fromBufferReader=function(l){e.checkArgument(!l.finished(),"No transaction data received"),this.version=l.readInt32LE();var g=l.readVarintNum(),A=!1;g===0&&l.buf[l.pos]!==0&&(l.pos+=1,A=!0,g=l.readVarintNum());for(var x=0;x<g;x++){var p=O.fromBufferReader(l);this.inputs.push(p)}for(var d=l.readVarintNum(),S=0;S<d;S++)this.outputs.push(z.fromBufferReader(l));if(A)for(var I=0;I<g;I++){for(var N=l.readVarintNum(),G=[],ie=0;ie<N;ie++){var Z=l.readVarintNum(),V=l.read(Z);G.push(V)}this.inputs[I].setWitnesses(G)}return this.nLockTime=l.readUInt32LE(),this},T.prototype.toObject=T.prototype.toJSON=function(){var g=[];this.inputs.forEach(function(p){g.push(p.toObject())});var A=[];this.outputs.forEach(function(p){A.push(p.toObject())});var x={hash:this.hash,version:this.version,inputs:g,outputs:A,nLockTime:this.nLockTime};return this._changeScript&&(x.changeScript=this._changeScript.toString()),this._changeIndex!=null&&(x.changeIndex=this._changeIndex),this._fee!=null&&(x.fee=this._fee),x},T.prototype.fromObject=function(g,A){e.checkArgument(t.isObject(g)||g instanceof T);var x;g instanceof T?x=g.toObject():x=g;for(const S of x.inputs||[]){if(!S.output||!S.output.script){this.uncheckedAddInput(new O(S));continue}var p=new J(S.output.script),d;if((p.isScriptHashOut()||p.isWitnessScriptHashOut())&&S.publicKeys&&S.threshold)d=new O.MultiSigScriptHash(S,S.publicKeys,S.threshold,S.signatures,A);else if(p.isPublicKeyHashOut()||p.isWitnessPublicKeyHashOut()||p.isScriptHashOut())d=new O.PublicKeyHash(S);else if(p.isPublicKeyOut())d=new O.PublicKey(S);else throw new s.Transaction.Input.UnsupportedScript(S.output.script);this.addInput(d)}for(const S of x.outputs||[])this.addOutput(new z(S));return x.changeIndex&&(this._changeIndex=x.changeIndex),x.changeScript&&(this._changeScript=new J(x.changeScript)),x.fee&&(this._fee=x.fee),this.nLockTime=x.nLockTime,this.version=x.version,this._checkConsistency(g),this},T.prototype._checkConsistency=function(l){this._changeIndex!=null&&(e.checkState(this._changeScript,"Change script is expected."),e.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),e.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),l&&l.hash&&e.checkState(l.hash===this.hash,"Hash in object does not match transaction hash.")},T.prototype.lockUntilDate=function(l){if(e.checkArgument(l),!isNaN(l)&&l<T.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.LockTimeTooEarly;t.isDate(l)&&(l=l.getTime()/1e3);for(var g=0;g<this.inputs.length;g++)this.inputs[g].sequenceNumber===O.DEFAULT_SEQNUMBER&&(this.inputs[g].sequenceNumber=O.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=l,this},T.prototype.lockUntilBlockHeight=function(l){if(e.checkArgument(!isNaN(l)),l>=T.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.BlockHeightTooHigh;if(l<0)throw new s.Transaction.NLockTimeOutOfRange;for(var g=0;g<this.inputs.length;g++)this.inputs[g].sequenceNumber===O.DEFAULT_SEQNUMBER&&(this.inputs[g].sequenceNumber=O.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=l,this},T.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<T.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null},T.prototype.fromString=function(l){this.fromBuffer(r.Buffer.from(l,"hex"))},T.prototype._newTransaction=function(){this.version=q,this.nLockTime=F},T.prototype.from=function(l,g,A,x){if(Array.isArray(l)){for(const d of l)this.from(d,g,A,x);return this}return this.inputs.some(function(d){return d.prevTxId.toString("hex")===l.txId&&d.outputIndex===l.outputIndex})?this:(g&&A?this._fromMultisigUtxo(l,g,A,x):this._fromNonP2SH(l),this)},T.prototype.associateInputs=function(l,g,A,x){let p=[];for(let d of l){const S=this.inputs.findIndex(I=>I.prevTxId.toString("hex")===d.txId&&I.outputIndex===d.outputIndex);if(p.push(S),S>=0){const I=this.inputs[S].sequenceNumber;this.inputs[S]=this._getInputFrom(d,g,A,x),this.inputs[S].sequenceNumber=I}}return p},T.prototype._selectInputType=function(l,g,A){var x;return l=new E(l),g&&A?l.script.isMultisigOut()?x=D:(l.script.isScriptHashOut()||l.script.isWitnessScriptHashOut())&&(x=C):l.script.isPublicKeyHashOut()||l.script.isWitnessPublicKeyHashOut()||l.script.isScriptHashOut()?x=k:l.script.isPublicKeyOut()?x=P:x=O,x},T.prototype._getInputFrom=function(l,g,A,x){l=new E(l);const p=this._selectInputType(l,g,A),d={output:new z({script:l.script,satoshis:l.satoshis}),prevTxId:l.txId,outputIndex:l.outputIndex,sequenceNumber:l.sequenceNumber,script:J.empty()};let S=g&&A?[g,A,!1,x]:[];return new p(d,...S)},T.prototype._fromNonP2SH=function(l){const g=this._getInputFrom(l);this.addInput(g)},T.prototype._fromMultisigUtxo=function(l,g,A,x){e.checkArgument(A<=g.length,"Number of required signatures must be greater than the number of public keys");const p=this._getInputFrom(l,g,A,x);this.addInput(p)},T.prototype.addInput=function(l,g,A){if(e.checkArgumentType(l,O,"input"),!l.output&&(g==null||A==null))throw new s.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return!l.output&&g&&A!=null&&(g=g instanceof J?g:new J(g),e.checkArgumentType(A,"number","satoshis"),l.output=new z({script:g,satoshis:A})),this.uncheckedAddInput(l)},T.prototype.uncheckedAddInput=function(l){return e.checkArgumentType(l,O,"input"),this.inputs.push(l),this._inputAmount=void 0,this._updateChangeOutput(),this},T.prototype.hasAllUtxoInfo=function(){return this.inputs.every(function(l){return!!l.output})},T.prototype.fee=function(l){return e.checkArgument(!isNaN(l),"amount must be a number"),this._fee=l,this._updateChangeOutput(),this},T.prototype.feePerKb=function(l){return e.checkArgument(!isNaN(l),"amount must be a number"),this._feePerKb=l,this._updateChangeOutput(),this},T.prototype.feePerByte=function(l){return e.checkArgument(!isNaN(l),"amount must be a number"),this._feePerByte=l,this._updateChangeOutput(),this},T.prototype.change=function(l){return e.checkArgument(l,"address is required"),this._changeScript=J.fromAddress(l),this._updateChangeOutput(),this},T.prototype.getChangeOutput=function(){return this._changeIndex!=null?this.outputs[this._changeIndex]:null},T.prototype.to=function(l,g){if(Array.isArray(l)){for(const A of l)this.to(A.address,A.satoshis);return this}return e.checkArgument(f.isNaturalNumber(g),"Amount is expected to be a positive integer"),this.addOutput(new z({script:J(new M(l)),satoshis:g})),this},T.prototype.addData=function(l){return this.addOutput(new z({script:J.buildDataOut(l),satoshis:0})),this},T.prototype.addOutput=function(l){return e.checkArgumentType(l,z,"output"),this._addOutput(l),this._updateChangeOutput(),this},T.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this},T.prototype._addOutput=function(l){this.outputs.push(l),this._outputAmount=void 0},T.prototype._getOutputAmount=function(){if(this._outputAmount==null){var l=this;this._outputAmount=0;for(const g of this.outputs||[])l._outputAmount+=g.satoshis}return this._outputAmount},T.prototype._getInputAmount=function(){return this._inputAmount==null&&(this._inputAmount=t.sumBy(this.inputs,function(l){if(l.output==null)throw new s.Transaction.Input.MissingPreviousOutput;return l.output.satoshis})),this._inputAmount},T.prototype._updateChangeOutput=function(l){if(this._changeScript){l||this._clearSignatures(),this._changeIndex!=null&&this._removeOutput(this._changeIndex);var g=this._getUnspentValue(),A=this.getFee(),x=g-A;x>T.DUST_AMOUNT?(this._changeIndex=this.outputs.length,this._addOutput(new z({script:this._changeScript,satoshis:x}))):this._changeIndex=void 0}},T.prototype.getFee=function(){return this.isCoinbase()?0:this._fee!=null?this._fee:this._changeScript?this._estimateFee():this._getUnspentValue()},T.prototype._estimateFee=function(){const l=this._estimateSize(),g=this._getUnspentValue(),A=this._feePerByte||(this._feePerKb||T.FEE_PER_KB)/1e3;function x(S){return S*A}const p=Math.ceil(x(l)),d=Math.ceil(x(l)+x(this._estimateSizeOfChangeOutput()));return!this._changeScript||g<=d?p:d},T.prototype._estimateSizeOfChangeOutput=function(){if(!this._changeScript)return 0;const l=this._changeScript.toBuffer().length;return 8+b.varintBufNum(l).length+l},T.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()},T.prototype._clearSignatures=function(){for(const l of this.inputs||[])l.clearSignatures()},T.prototype._estimateSize=function(){let l=4;this.hasWitnesses()&&(l+=.5),l+=b.varintBufNum(this.inputs.length).length;for(const g of this.inputs||[])l+=g._estimateSize();l+=b.varintBufNum(this.outputs.length).length;for(const g of this.outputs||[])l+=g.calculateSize();return l+=4,Math.ceil(l)},T.prototype._calculateSize=function(){return this.toBuffer().length},T.prototype._calculateVSize=function(l){const g=this._calculateWeight()/4;return l?g:Math.ceil(g)},T.prototype._calculateWeight=function(){return this.toBuffer(!0).length*3+this.toBuffer(!1).length},T.prototype._removeOutput=function(l){var g=this.outputs[l];this.outputs=t.without(this.outputs,g),this._outputAmount=void 0},T.prototype.removeOutput=function(l){this._removeOutput(l),this._updateChangeOutput()},T.prototype.sort=function(){return this.sortInputs(function(l){var g=Array.prototype.concat.apply([],l);let A=0;return g.forEach(x=>{x.i=A++}),g.sort(function(x,p){return n(x.prevTxId,p.prevTxId)||x.outputIndex-p.outputIndex||x.i-p.i}),g}),this.sortOutputs(function(l){var g=Array.prototype.concat.apply([],l);let A=0;return g.forEach(x=>{x.i=A++}),g.sort(function(x,p){return x.satoshis-p.satoshis||n(x.script.toBuffer(),p.script.toBuffer())||x.i-p.i}),g}),this},T.prototype.shuffleOutputs=function(){return this.sortOutputs(t.shuffle)},T.prototype.sortOutputs=function(l){var g=l(this.outputs);return this._newOutputOrder(g)},T.prototype.sortInputs=function(l){return this.inputs=l(this.inputs),this._clearSignatures(),this},T.prototype._newOutputOrder=function(l){var g=this.outputs.length!==l.length||t.difference(this.outputs,l).length!==0;if(g)throw new s.Transaction.InvalidSorting;if(this._changeIndex!=null){var A=this.outputs[this._changeIndex];this._changeIndex=l.indexOf(A)}return this.outputs=l,this},T.prototype.removeInput=function(l,g){var A;if(!g&&!isNaN(l)?A=l:A=this.inputs.findIndex(function(p){return p.prevTxId.toString("hex")===l&&p.outputIndex===g}),A<0||A>=this.inputs.length)throw new s.Transaction.InvalidIndex(A,this.inputs.length);var x=this.inputs[A];this.inputs=t.without(this.inputs,x),this._inputAmount=void 0,this._updateChangeOutput()},T.prototype.sign=function(l,g,A){if(e.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction."),Array.isArray(l)){for(const x of l)this.sign(x,g,A);return this}for(const x of this.getSignatures(l,g,A))this.applySignature(x,A);return this},T.prototype.getSignatures=function(l,g,A){l=new j(l),g=g||y.SIGHASH_ALL;var x=this,p=[],d=w.sha256ripemd160(l.publicKey.toBuffer());for(let S=0;S<this.inputs.length;S++){const I=this.inputs[S];for(const N of I.getSignatures(x,l,S,g,d,A))p.push(N)}return p},T.prototype.applySignature=function(l,g){return this.inputs[l.inputIndex].addSignature(this,l,g),this},T.prototype.isFullySigned=function(){for(const l of this.inputs||[])if(l.isFullySigned===O.prototype.isFullySigned)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs.every(function(l){return l.isFullySigned()})},T.prototype.isValidSignature=function(l,g){if(this.inputs[l.inputIndex].isValidSignature===O.prototype.isValidSignature)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[l.inputIndex].isValidSignature(this,l,g)},T.prototype.verifySignature=function(l,g,A,x,p,d,S){if(p==null&&(p=0),p===1){var I=x.toBuffer(),N=new b;N.writeVarintNum(I.length),N.write(I);var G;d?(e.checkState(f.isNaturalNumber(d)),G=new b().writeUInt64LEBN(new re(d)).toBuffer()):G=this.inputs[A].getSatoshisBuffer();var ie=B.verify(this,l,g,A,N.toBuffer(),G,S);return ie}return _.verify(this,l,g,A,x,S)},T.prototype.verify=function(){if(this.inputs.length===0)return"transaction txins empty";if(this.outputs.length===0)return"transaction txouts empty";for(var l=new re(0),g=0;g<this.outputs.length;g++){var A=this.outputs[g];if(A.invalidSatoshis())return"transaction txout "+g+" satoshis is invalid";if(A._satoshisBN.gt(new re(T.MAX_MONEY,10)))return"transaction txout "+g+" greater than MAX_MONEY";if(l=l.add(A._satoshisBN),l.gt(new re(T.MAX_MONEY)))return"transaction txout "+g+" total output greater than MAX_MONEY"}if(this.toBuffer().length>m)return"transaction over the maximum block size";var x={};for(g=0;g<this.inputs.length;g++){var p=this.inputs[g],d=p.prevTxId+":"+p.outputIndex;if(x[d]!=null)return"transaction input "+g+" duplicate input";x[d]=!0}var S=this.isCoinbase();if(S){var I=this.inputs[0]._scriptBuffer;if(I.length<2||I.length>100)return"coinbase transaction script size invalid"}else for(g=0;g<this.inputs.length;g++)if(this.inputs[g].isNull())return"transaction input "+g+" has null input";return!0},T.prototype.isCoinbase=function(){return this.inputs.length===1&&this.inputs[0].isNull()},T.prototype.isRBF=function(){for(var l=0;l<this.inputs.length;l++){var g=this.inputs[l];if(g.sequenceNumber<O.MAXINT-1)return!0}return!1},T.prototype.enableRBF=function(){for(var l=0;l<this.inputs.length;l++){var g=this.inputs[l];g.sequenceNumber>=O.MAXINT-1&&(g.sequenceNumber=O.DEFAULT_RBF_SEQNUMBER)}return this},T.prototype.setVersion=function(l){return e.checkArgument(f.isNaturalNumber(l)&&l<=q,"Wrong version number"),this.version=l,this},Gg=T,Gg}var g_;function ap(){return g_||(g_=1,Ia.exports=Zg(),Ia.exports.Input=jg(),Ia.exports.Output=Ma(),Ia.exports.UnspentOutput=b_(),Ia.exports.Signature=Lh(),Ia.exports.Sighash=cf(),Ia.exports.SighashWitness=ip()),Ia.exports}var Xg,y_;function DV(){if(y_)return Xg;y_=1;var t=Gt,e=P9(),r=cg,n=Sn,s=an,i=oi,f=Ys(),c=function b(w){if(!(this instanceof b))return new b(w);w?(this.initialize(),this.set(w)):this.initialize()};return c.SIGVERSION_BASE=0,c.SIGVERSION_WITNESS_V0=1,c.SIGVERSION_TAPROOT=2,c.SIGVERSION_TAPSCRIPT=3,c.prototype.verifyWitnessProgram=function(b,w,y,_,B){var M=new e,E=[];if(b===0)if(w.length===32){if(y.length===0)return this.errstr="SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY",!1;var O=y[y.length-1];M=new e(O);var k=s.sha256(O);if(k.toString("hex")!==w.toString("hex"))return this.errstr="SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH",!1;E=y.slice(0,-1)}else if(w.length===20){if(y.length!==2)return this.errstr="SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH",!1;M.add(r.OP_DUP),M.add(r.OP_HASH160),M.add(w),M.add(r.OP_EQUALVERIFY),M.add(r.OP_CHECKSIG),E=y}else return this.errstr="SCRIPT_ERR_WITNESS_PROGRAM_WRONG_LENGTH",!1;else return B&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM?(this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM",!1):!0;if(this.initialize(),this.set({script:M,stack:E,sigversion:c.SIGVERSION_WITNESS_V0,satoshis:_,flags:B}),!this.evaluate())return!1;if(this.stack.length!==1)return this.errstr="SCRIPT_ERR_EVAL_FALSE",!1;var P=this.stack[this.stack.length-1];return c.castToBool(P)?!0:(this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1)},c.prototype.verify=function(b,w,y,_,B,M,E){var O=ap();t.isUndefined(y)&&(y=new O),t.isUndefined(_)&&(_=0),t.isUndefined(B)&&(B=0),t.isUndefined(M)&&(M=null),t.isUndefined(E)&&(E=0),this.set({script:b,tx:y,nin:_,sigversion:c.SIGVERSION_BASE,satoshis:0,flags:B});var k;if(B&c.SCRIPT_VERIFY_SIGPUSHONLY&&!b.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;B&c.SCRIPT_VERIFY_P2SH&&(k=this.stack.slice());var P=this.stack;if(this.initialize(),this.set({script:w,stack:P,tx:y,nin:_,flags:B}),!this.evaluate())return!1;if(this.stack.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var C=this.stack[this.stack.length-1];if(!c.castToBool(C))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;var D=!1;if(B&c.SCRIPT_VERIFY_WITNESS){var z={};if(w.isWitnessProgram(z)&&(D=!0,b.toBuffer().length!==0||!this.verifyWitnessProgram(z.version,z.program,M,E,this.flags)))return!1}if(B&c.SCRIPT_VERIFY_P2SH&&w.isScriptHashOut()){if(!b.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(k.length===0)throw new Error("internal error - stack copy empty");var J=k[k.length-1],j=e.fromBuffer(J);if(k.pop(),this.initialize(),this.set({script:j,stack:k,tx:y,nin:_,flags:B}),!this.evaluate())return!1;if(k.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!c.castToBool(k[k.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1;if(B&c.SCRIPT_VERIFY_WITNESS){var re={};if(j.isWitnessProgram(re)){D=!0;var T=new e;if(T.add(j.toBuffer()),b.toHex()!==T.toHex())return this.errstr="SCRIPT_ERR_WITNESS_MALLEATED_P2SH",!1;if(!this.verifyWitnessProgram(re.version,re.program,M,E,this.flags))return!1;P=[P[0]]}}}if(this.flags&c.SCRIPT_VERIFY_CLEANSTACK){if(!(this.flags&c.SCRIPT_VERIFY_P2SH))throw"flags & SCRIPT_VERIFY_P2SH";if(k.length!=1)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return this.flags&c.SCRIPT_VERIFY_WITNESS&&!D&&M.length>0?(this.errstr="SCRIPT_ERR_WITNESS_UNEXPECTED",!1):!0},Xg=c,c.prototype.initialize=function(b){this.stack=[],this.altstack=[],this.pc=0,this.satoshis=0,this.sigversion=c.SIGVERSION_BASE,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},c.prototype.set=function(b){this.script=b.script||this.script,this.tx=b.tx||this.tx,this.nin=typeof b.nin<"u"?b.nin:this.nin,this.stack=b.stack||this.stack,this.altstack=b.altack||this.altstack,this.pc=typeof b.pc<"u"?b.pc:this.pc,this.pbegincodehash=typeof b.pbegincodehash<"u"?b.pbegincodehash:this.pbegincodehash,this.sigversion=typeof b.sigversion<"u"?b.sigversion:this.sigversion,this.satoshis=typeof b.satoshis<"u"?b.satoshis:this.satoshis,this.nOpCount=typeof b.nOpCount<"u"?b.nOpCount:this.nOpCount,this.vfExec=b.vfExec||this.vfExec,this.errstr=b.errstr||this.errstr,this.flags=typeof b.flags<"u"?b.flags:this.flags},c.true=ge.from([1]),c.false=ge.from([]),c.MAX_SCRIPT_ELEMENT_SIZE=520,c.LOCKTIME_THRESHOLD=5e8,c.LOCKTIME_THRESHOLD_BN=new n(c.LOCKTIME_THRESHOLD),c.SCRIPT_VERIFY_NONE=0,c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM=4096,c.SCRIPT_VERIFY_P2SH=1,c.SCRIPT_VERIFY_STRICTENC=2,c.SCRIPT_VERIFY_DERSIG=4,c.SCRIPT_VERIFY_LOW_S=8,c.SCRIPT_VERIFY_NULLDUMMY=16,c.SCRIPT_VERIFY_SIGPUSHONLY=32,c.SCRIPT_VERIFY_MINIMALDATA=64,c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,c.SCRIPT_VERIFY_CLEANSTACK=256,c.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,c.SCRIPT_VERIFY_WITNESS=1024,c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=2048,c.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024,c.SCRIPT_VERIFY_MINIMALIF=8192,c.SCRIPT_VERIFY_NULLFAIL=16384,c.SCRIPT_VERIFY_WITNESS_PUBKEYTYPE=32768,c.SCRIPT_ENABLE_SIGHASH_FORKID=65536,c.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17,c.SCRIPT_ENABLE_MONOLITH_OPCODES=1<<18,c.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31,c.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22,c.SEQUENCE_LOCKTIME_MASK=65535,c.castToBool=function(b){for(var w=0;w<b.length;w++)if(b[w]!==0)return!(w===b.length-1&&b[w]===128);return!1},c.prototype.checkSignatureEncoding=function(b){var w;if(b.length==0)return!0;if(this.flags&(c.SCRIPT_VERIFY_DERSIG|c.SCRIPT_VERIFY_LOW_S|c.SCRIPT_VERIFY_STRICTENC)&&!i.isTxDER(b))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if(this.flags&c.SCRIPT_VERIFY_LOW_S){if(w=i.fromTxFormat(b),!w.hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if(this.flags&c.SCRIPT_VERIFY_STRICTENC&&(w=i.fromTxFormat(b),!w.hasDefinedHashtype()))return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;return!0},c.prototype.checkPubkeyEncoding=function(b){return this.flags&c.SCRIPT_VERIFY_STRICTENC&&!f.isValid(b)?(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1):this.flags&c.SCRIPT_VERIFY_WITNESS_PUBKEYTYPE&&this.sigversion==c.SIGVERSION_WITNESS_V0&&!f.fromBuffer(b).compressed?(this.errstr="SCRIPT_ERR_WITNESS_PUBKEYTYPE",!1):!0},c.prototype.evaluate=function(){if(this.script.toBuffer().length>1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){var b=this.step();if(!b)return!1}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(w){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+w,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0},c.prototype.checkLockTime=function(b){return!(!(this.tx.nLockTime<c.LOCKTIME_THRESHOLD&&b.lt(c.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=c.LOCKTIME_THRESHOLD&&b.gte(c.LOCKTIME_THRESHOLD_BN))||b.gt(new n(this.tx.nLockTime))||!this.tx.inputs[this.nin].isFinal())},c.prototype.checkSequence=function(b){var w=this.tx.inputs[this.nin].sequenceNumber;if(this.tx.version<2||w&SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var y=c.SEQUENCE_LOCKTIME_TYPE_FLAG|c.SEQUENCE_LOCKTIME_MASK,_=new n(w&y),B=b.and(y),M=new n(c.SEQUENCE_LOCKTIME_TYPE_FLAG);return!(!(_.lt(M)&&B.lt(M)||_.gte(M)&&B.gte(M))||B.gt(_))},c.prototype.step=function(){var b=(this.flags&c.SCRIPT_VERIFY_MINIMALDATA)!==0,w=this.vfExec.indexOf(!1)===-1,y,_,B,M,E,O,k,P,C,D,z,J,j,re,T,q,F,m=this.script.chunks[this.pc];this.pc++;var a=m.opcodenum;if(t.isUndefined(a))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(m.buf&&m.buf.length>c.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(a>r.OP_16&&++this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(a===r.OP_CAT||a===r.OP_SUBSTR||a===r.OP_LEFT||a===r.OP_RIGHT||a===r.OP_INVERT||a===r.OP_AND||a===r.OP_OR||a===r.OP_XOR||a===r.OP_2MUL||a===r.OP_2DIV||a===r.OP_MUL||a===r.OP_DIV||a===r.OP_MOD||a===r.OP_LSHIFT||a===r.OP_RSHIFT)return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(w&&0<=a&&a<=r.OP_PUSHDATA4){if(b&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!m.buf)this.stack.push(c.false);else{if(m.len!==m.buf.length)throw new Error("Length of push value not equal to length of data");this.stack.push(m.buf)}}else if(w||r.OP_IF<=a&&a<=r.OP_ENDIF)switch(a){case r.OP_1NEGATE:case r.OP_1:case r.OP_2:case r.OP_3:case r.OP_4:case r.OP_5:case r.OP_6:case r.OP_7:case r.OP_8:case r.OP_9:case r.OP_10:case r.OP_11:case r.OP_12:case r.OP_13:case r.OP_14:case r.OP_15:case r.OP_16:E=a-(r.OP_1-1),y=new n(E).toScriptNumBuffer(),this.stack.push(y);break;case r.OP_NOP:break;case r.OP_NOP2:case r.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&c.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var h=n.fromScriptNumBuffer(this.stack[this.stack.length-1],b,5);if(h.lt(new n(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(h))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case r.OP_NOP3:case r.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&c.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)){if(this.flags&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var u=n.fromScriptNumBuffer(this.stack[this.stack.length-1],b,5);if(u.lt(new n(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(u&c.SEQUENCE_LOCKTIME_DISABLE_FLAG)break;if(!this.checkSequence(u))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case r.OP_NOP1:case r.OP_NOP4:case r.OP_NOP5:case r.OP_NOP6:case r.OP_NOP7:case r.OP_NOP8:case r.OP_NOP9:case r.OP_NOP10:if(this.flags&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case r.OP_IF:case r.OP_NOTIF:{if(q=!1,w){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(y=this.stack[this.stack.length-1],this.flags&c.SCRIPT_VERIFY_MINIMALIF){if(y=this.stack[this.stack.length-1],y.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(y.length==1&&y[0]!=1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1}q=c.castToBool(y),a===r.OP_NOTIF&&(q=!q),this.stack.pop()}this.vfExec.push(q)}break;case r.OP_ELSE:{if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1]}break;case r.OP_ENDIF:{if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop()}break;case r.OP_VERIFY:{if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(y=this.stack[this.stack.length-1],q=c.castToBool(y),q)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1}break;case r.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case r.OP_TOALTSTACK:{if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop())}break;case r.OP_FROMALTSTACK:{if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop())}break;case r.OP_2DROP:{if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop()}break;case r.OP_2DUP:{if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;_=this.stack[this.stack.length-2],B=this.stack[this.stack.length-1],this.stack.push(_),this.stack.push(B)}break;case r.OP_3DUP:{if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;_=this.stack[this.stack.length-3],B=this.stack[this.stack.length-2];var l=this.stack[this.stack.length-1];this.stack.push(_),this.stack.push(B),this.stack.push(l)}break;case r.OP_2OVER:{if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;_=this.stack[this.stack.length-4],B=this.stack[this.stack.length-3],this.stack.push(_),this.stack.push(B)}break;case r.OP_2ROT:{if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;M=this.stack.splice(this.stack.length-6,2),this.stack.push(M[0]),this.stack.push(M[1])}break;case r.OP_2SWAP:{if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;M=this.stack.splice(this.stack.length-4,2),this.stack.push(M[0]),this.stack.push(M[1])}break;case r.OP_IFDUP:{if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=this.stack[this.stack.length-1],q=c.castToBool(y),q&&this.stack.push(y)}break;case r.OP_DEPTH:y=new n(this.stack.length).toScriptNumBuffer(),this.stack.push(y);break;case r.OP_DROP:{if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop()}break;case r.OP_DUP:{if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-1])}break;case r.OP_NIP:{if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1)}break;case r.OP_OVER:{if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-2])}break;case r.OP_PICK:case r.OP_ROLL:{if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(y=this.stack[this.stack.length-1],P=n.fromScriptNumBuffer(y,b),E=P.toNumber(),this.stack.pop(),E<0||E>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=this.stack[this.stack.length-E-1],a===r.OP_ROLL&&this.stack.splice(this.stack.length-E-1,1),this.stack.push(y)}break;case r.OP_ROT:{if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;O=this.stack[this.stack.length-3],k=this.stack[this.stack.length-2];var g=this.stack[this.stack.length-1];this.stack[this.stack.length-3]=k,this.stack[this.stack.length-2]=g,this.stack[this.stack.length-1]=O}break;case r.OP_SWAP:{if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;O=this.stack[this.stack.length-2],k=this.stack[this.stack.length-1],this.stack[this.stack.length-2]=k,this.stack[this.stack.length-1]=O}break;case r.OP_TUCK:{if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,this.stack[this.stack.length-1])}break;case r.OP_SIZE:{if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;P=new n(this.stack[this.stack.length-1].length),this.stack.push(P.toScriptNumBuffer())}break;case r.OP_EQUAL:case r.OP_EQUALVERIFY:{if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;_=this.stack[this.stack.length-2],B=this.stack[this.stack.length-1];var A=_.toString("hex")===B.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(A?c.true:c.false),a===r.OP_EQUALVERIFY)if(A)this.stack.pop();else return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1}break;case r.OP_1ADD:case r.OP_1SUB:case r.OP_NEGATE:case r.OP_ABS:case r.OP_NOT:case r.OP_0NOTEQUAL:{if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(y=this.stack[this.stack.length-1],P=n.fromScriptNumBuffer(y,b),a){case r.OP_1ADD:P=P.add(n.One);break;case r.OP_1SUB:P=P.sub(n.One);break;case r.OP_NEGATE:P=P.neg();break;case r.OP_ABS:P.cmp(n.Zero)<0&&(P=P.neg());break;case r.OP_NOT:P=new n((P.cmp(n.Zero)===0)+0);break;case r.OP_0NOTEQUAL:P=new n((P.cmp(n.Zero)!==0)+0);break}this.stack.pop(),this.stack.push(P.toScriptNumBuffer())}break;case r.OP_ADD:case r.OP_SUB:case r.OP_BOOLAND:case r.OP_BOOLOR:case r.OP_NUMEQUAL:case r.OP_NUMEQUALVERIFY:case r.OP_NUMNOTEQUAL:case r.OP_LESSTHAN:case r.OP_GREATERTHAN:case r.OP_LESSTHANOREQUAL:case r.OP_GREATERTHANOREQUAL:case r.OP_MIN:case r.OP_MAX:{if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(C=n.fromScriptNumBuffer(this.stack[this.stack.length-2],b),D=n.fromScriptNumBuffer(this.stack[this.stack.length-1],b),P=new n(0),a){case r.OP_ADD:P=C.add(D);break;case r.OP_SUB:P=C.sub(D);break;case r.OP_BOOLAND:P=new n((C.cmp(n.Zero)!==0&&D.cmp(n.Zero)!==0)+0);break;case r.OP_BOOLOR:P=new n((C.cmp(n.Zero)!==0||D.cmp(n.Zero)!==0)+0);break;case r.OP_NUMEQUAL:P=new n((C.cmp(D)===0)+0);break;case r.OP_NUMEQUALVERIFY:P=new n((C.cmp(D)===0)+0);break;case r.OP_NUMNOTEQUAL:P=new n((C.cmp(D)!==0)+0);break;case r.OP_LESSTHAN:P=new n((C.cmp(D)<0)+0);break;case r.OP_GREATERTHAN:P=new n((C.cmp(D)>0)+0);break;case r.OP_LESSTHANOREQUAL:P=new n((C.cmp(D)<=0)+0);break;case r.OP_GREATERTHANOREQUAL:P=new n((C.cmp(D)>=0)+0);break;case r.OP_MIN:P=C.cmp(D)<0?C:D;break;case r.OP_MAX:P=C.cmp(D)>0?C:D;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(P.toScriptNumBuffer()),a===r.OP_NUMEQUALVERIFY)if(c.castToBool(this.stack[this.stack.length-1]))this.stack.pop();else return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1}break;case r.OP_WITHIN:{if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;C=n.fromScriptNumBuffer(this.stack[this.stack.length-3],b),D=n.fromScriptNumBuffer(this.stack[this.stack.length-2],b);var x=n.fromScriptNumBuffer(this.stack[this.stack.length-1],b);q=D.cmp(C)<=0&&C.cmp(x)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(q?c.true:c.false)}break;case r.OP_RIPEMD160:case r.OP_SHA1:case r.OP_SHA256:case r.OP_HASH160:case r.OP_HASH256:{if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=this.stack[this.stack.length-1];var p;a===r.OP_RIPEMD160?p=s.ripemd160(y):a===r.OP_SHA1?p=s.sha1(y):a===r.OP_SHA256?p=s.sha256(y):a===r.OP_HASH160?p=s.sha256ripemd160(y):a===r.OP_HASH256&&(p=s.sha256sha256(y)),this.stack.pop(),this.stack.push(p)}break;case r.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case r.OP_CHECKSIG:case r.OP_CHECKSIGVERIFY:{if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(z=this.stack[this.stack.length-2],J=this.stack[this.stack.length-1],!this.checkSignatureEncoding(z)||!this.checkPubkeyEncoding(J))return!1;j=new e().set({chunks:this.script.chunks.slice(this.pbegincodehash)});var d=new e().add(z);j.findAndDelete(d);try{re=i.fromTxFormat(z),T=f.fromBuffer(J,!1),F=this.tx.verifySignature(re,T,this.nin,j,this.sigversion,this.satoshis)}catch{F=!1}if(!F&&this.flags&c.SCRIPT_VERIFY_NULLFAIL&&z.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(F?c.true:c.false),a===r.OP_CHECKSIGVERIFY)if(F)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1}break;case r.OP_CHECKMULTISIG:case r.OP_CHECKMULTISIGVERIFY:{var S=1;if(this.stack.length<S)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var I=n.fromScriptNumBuffer(this.stack[this.stack.length-S],b).toNumber();if(I<0||I>20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=I,this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var N=++S;S+=I;var G=I+2;if(this.stack.length<S)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var ie=n.fromScriptNumBuffer(this.stack[this.stack.length-S],b).toNumber();if(ie<0||ie>I)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var Z=++S;if(S+=ie,this.stack.length<S)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;j=new e().set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var V=0;V<ie;V++)z=this.stack[this.stack.length-Z-V],j.findAndDelete(new e().add(z));for(F=!0;F&&ie>0;){if(z=this.stack[this.stack.length-Z],J=this.stack[this.stack.length-N],!this.checkSignatureEncoding(z)||!this.checkPubkeyEncoding(J))return!1;var Y;try{re=i.fromTxFormat(z),T=f.fromBuffer(J,!1),Y=this.tx.verifySignature(re,T,this.nin,j,this.sigversion,this.satoshis)}catch{Y=!1}Y&&(Z++,ie--),N++,I--,ie>I&&(F=!1)}for(;S-- >1;){if(!F&&this.flags&c.SCRIPT_VERIFY_NULLFAIL&&!G&&this.stack[this.stack.length-1].length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;G>0&&G--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&c.SCRIPT_VERIFY_NULLDUMMY&&this.stack[this.stack.length-1].length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(F?c.true:c.false),a===r.OP_CHECKMULTISIGVERIFY)if(F)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1}break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0},Xg}var w_;function ui(){return w_||(w_=1,$d.exports=P9(),$d.exports.Interpreter=DV()),$d.exports}var Jg,__;function Js(){if(__)return Jg;__=1;var t=Gt,e=Yt,r=Ui,n=Ah,s=Rz,i=ao,f=an,c=En,b=Ys();function w(_,B,M,E){if(!(this instanceof w))return new w(_,B,M);if(t.isArray(_)&&t.isNumber(B))return w.createMultisig(_,B,M,!1,E);if(_ instanceof w)return _;if(e.checkArgument(_,"First argument is required, please include address data.","guide/address.html"),B&&!i.get(B))throw new TypeError('Second argument must be "livenet" or "testnet".');if(M&&M!==w.PayToPublicKeyHash&&M!==w.PayToScriptHash&&M!==w.PayToWitnessPublicKeyHash&&M!==w.PayToWitnessScriptHash&&M!==w.PayToTaproot)throw new TypeError('Third argument must be "pubkeyhash", "scripthash", "witnesspubkeyhash", "witnessscripthash", or "taproot".');var O=this._classifyArguments(_,B,M);return O.network=O.network||i.get(B)||i.defaultNetwork,O.type=O.type||M||w.PayToPublicKeyHash,c.defineImmutable(this,{hashBuffer:O.hashBuffer,network:O.network,type:O.type}),this}w.prototype._classifyArguments=function(_,B,M){if((_ instanceof ge||_ instanceof Uint8Array)&&(_.length===20||_.length===32))return w._transformHash(_,B,M);if((_ instanceof ge||_ instanceof Uint8Array)&&_.length>=21)return w._transformBuffer(_,B,M);if(_ instanceof b)return w._transformPublicKey(_,B,M);if(_ instanceof y)return w._transformScript(_,B);if(typeof _=="string")return w._transformString(_,B,M);if(t.isObject(_))return w._transformObject(_);throw new TypeError("First argument is an unrecognized data format.")},w.PayToPublicKeyHash="pubkeyhash",w.PayToScriptHash="scripthash",w.PayToWitnessPublicKeyHash="witnesspubkeyhash",w.PayToWitnessScriptHash="witnessscripthash",w.PayToTaproot="taproot",w._transformHash=function(_,B,M){var E={};if(!(_ instanceof ge)&&!(_ instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(_.length!==20&&_.length!==32)throw new TypeError("Address hashbuffers must be either 20 or 32 bytes.");return E.hashBuffer=_,E.network=i.get(B)||i.defaultNetwork,E.type=M,E},w._transformObject=function(_){return e.checkArgument(_.hash||_.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),e.checkArgument(_.type,"Must provide a `type` property"),{hashBuffer:_.hash?ge.from(_.hash,"hex"):_.hashBuffer,network:i.get(_.network)||i.defaultNetwork,type:_.type}},w._classifyFromVersion=function(_){var B={};if(_.length>21){var M=s.decode(_.toString("utf8"));if(M.version!==0&&M.version!==1)throw new TypeError("Only witness v0 and v1 addresses are supported.");if(M.version===0)if(M.data.length===20)B.type=w.PayToWitnessPublicKeyHash;else if(M.data.length===32)B.type=w.PayToWitnessScriptHash;else throw new TypeError("Witness data must be either 20 or 32 bytes.");else if(M.version===1)if(M.data.length===32)B.type=w.PayToTaproot;else throw new TypeError("Witness data must be 32 bytes for v1");B.network=i.get(M.prefix,"bech32prefix")}else{var E=i.get(_[0],"pubkeyhash"),O=i.get(_[0],"scripthash");E?(B.network=E,B.type=w.PayToPublicKeyHash):O&&(B.network=O,B.type=w.PayToScriptHash)}return B},w._transformBuffer=function(_,B,M){var E={};if(!(_ instanceof ge)&&!(_ instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(_.length<21)throw new TypeError("Address buffer is incorrect length.");var O=i.get(B),k=w._classifyFromVersion(_);if(B&&!O)throw new TypeError("Unknown network");if(!k.network||O&&O.xpubkey!==k.network.xpubkey)throw new TypeError("Address has mismatched network type.");if(!k.type||M&&M!==k.type)throw new TypeError("Address has mismatched type.");return _.length>21?E.hashBuffer=s.decode(_.toString("utf8")).data:E.hashBuffer=_.slice(1),E.network=O||k.network,E.type=k.type,E},w._transformPublicKey=function(_,B,M){var E={};if(!(_ instanceof b))throw new TypeError("Address must be an instance of PublicKey.");if(M&&M!==w.PayToScriptHash&&M!==w.PayToWitnessPublicKeyHash&&M!==w.PayToPublicKeyHash&&M!==w.PayToTaproot)throw new TypeError("Type must be either pubkeyhash, witnesspubkeyhash, scripthash, or taproot to transform public key.");if(!_.compressed&&(M===w.PayToScriptHash||M===w.PayToWitnessPublicKeyHash))throw new TypeError("Witness addresses must use compressed public keys.");return M===w.PayToScriptHash?E.hashBuffer=f.sha256ripemd160(y.buildWitnessV0Out(_).toBuffer()):M===w.PayToTaproot?E.hashBuffer=f.sha256ripemd160(y.buildWitnessV1Out(_).toBuffer()):E.hashBuffer=f.sha256ripemd160(_.toBuffer()),E.type=M||w.PayToPublicKeyHash,E},w._transformScript=function(_,B){e.checkArgument(_ instanceof y,"script must be a Script instance");var M=_.getAddressInfo(B);if(!M)throw new r.Script.CantDeriveAddress(_);return M},w.createMultisig=function(_,B,M,E,O){if(M=M||_[0].network||i.defaultNetwork,O&&O!==w.PayToScriptHash&&O!==w.PayToWitnessScriptHash)throw new TypeError("Type must be either scripthash or witnessscripthash to create multisig.");if(E||O===w.PayToWitnessScriptHash){_=t.map(_,b);for(var k=0;k<_.length;k++)if(!_[k].compressed)throw new TypeError("Witness addresses must use compressed public keys.")}var P=y.buildMultisigOut(_,B);return E?w.payingTo(y.buildWitnessMultisigOutFromScript(P),M):w.payingTo(P,M,O)},w._transformString=function(_,B,M){if(typeof _!="string")throw new TypeError("data parameter supplied is not a string.");if(_.length>100)throw new TypeError("address string is too long");if(B&&!i.get(B))throw new TypeError("Unknown network");_=_.trim();try{var O=w._transformBuffer(ge.from(_,"utf8"),B,M);return O}catch(k){if(M===w.PayToWitnessPublicKeyHash||M===w.PayToWitnessScriptHash||M===w.PayToTaproot)throw k}var E=n.decode(_),O=w._transformBuffer(E,B,M);return O},w.fromPublicKey=function(_,B,M){var E=w._transformPublicKey(_,B,M);return B=B||i.defaultNetwork,new w(E.hashBuffer,B,E.type)},w.fromPublicKeyHash=function(_,B){var M=w._transformHash(_);return new w(M.hashBuffer,B,w.PayToPublicKeyHash)},w.fromScriptHash=function(_,B,O){e.checkArgument(_,"hash parameter is required");var E=w._transformHash(_);if(O===w.PayToWitnessScriptHash&&_.length!==32)throw new TypeError("Address hashbuffer must be exactly 32 bytes for v0 witness script hash.");var O=O||w.PayToScriptHash;return new w(E.hashBuffer,B,O)},w.payingTo=function(_,B,O){e.checkArgument(_,"script is required"),e.checkArgument(_ instanceof y,"script must be instance of Script");var E;O===w.PayToWitnessScriptHash?E=f.sha256(_.toBuffer()):E=f.sha256ripemd160(_.toBuffer());var O=O||w.PayToScriptHash;return w.fromScriptHash(E,B,O)},w.fromScript=function(_,B){e.checkArgument(_ instanceof y,"script must be a Script instance");var M=w._transformScript(_,B);return new w(M.hashBuffer,B,M.type)},w.fromBuffer=function(_,B,M){var E=w._transformBuffer(_,B,M);return new w(E.hashBuffer,E.network,E.type)},w.fromString=function(_,B,M){var E=w._transformString(_,B,M);return new w(E.hashBuffer,E.network,E.type)},w.fromObject=function(B){e.checkState(c.isHexa(B.hash),'Unexpected hash property, "'+B.hash+'", expected to be hex.');var M=ge.from(B.hash,"hex");return new w(M,B.network,B.type)},w.getValidationError=function(_,B,M){var E;try{new w(_,B,M)}catch(O){E=O}return E},w.isValid=function(_,B,M){return!w.getValidationError(_,B,M)},w.prototype.isPayToPublicKeyHash=function(){return this.type===w.PayToPublicKeyHash},w.prototype.isPayToScriptHash=function(){return this.type===w.PayToScriptHash},w.prototype.isPayToWitnessPublicKeyHash=function(){return this.type===w.PayToWitnessPublicKeyHash},w.prototype.isPayToWitnessScriptHash=function(){return this.type===w.PayToWitnessScriptHash},w.prototype.isPayToTaproot=function(){return this.type===w.PayToTaproot},w.prototype.toBuffer=function(){if(this.isPayToWitnessPublicKeyHash()||this.isPayToWitnessScriptHash())return ge.from(this.toString(),"utf8");var _=ge.from([this.network[this.type]]);return ge.concat([_,this.hashBuffer])},w.prototype.toObject=w.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}},w.prototype.toString=function(){if(this.isPayToWitnessPublicKeyHash()||this.isPayToWitnessScriptHash()||this.isPayToTaproot()){let _=this.network.bech32prefix,B=0,M=s.encodings.BECH32;return this.isPayToTaproot()&&(B=1,M=s.encodings.BECH32M),s.encode(_,B,this.hashBuffer,M)}return n.encode(this.toBuffer())},w.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"},Jg=w;var y=ui();return Jg}function vo(){}vo.getRandomBuffer=function(t){return pt.browser?vo.getRandomBufferBrowser(t):vo.getRandomBufferNode(t)},vo.getRandomBufferNode=function(t){var e=_u();return e.randomBytes(t)},vo.getRandomBufferBrowser=function(t){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");if(window.crypto&&window.crypto.getRandomValues)var e=window.crypto;else if(window.msCrypto&&window.msCrypto.getRandomValues)var e=window.msCrypto;else throw new Error("window.crypto.getRandomValues not available");var r=new Uint8Array(t);e.getRandomValues(r);var n=ge.from(r);return n},vo.getPseudoRandomBuffer=function(t){for(var e=4294967296,r=ge.alloc(t),n,s=0;s<=t;s++){var i=Math.floor(s/4),f=s-i*4;f===0?(n=Math.random()*e,r[s]=n&255):r[s]=(n=n>>>8)&255}return r};var fp=vo,Yg,x_;function Dh(){if(x_)return Yg;x_=1;var t=Gt,e=Js(),r=Ah,n=Sn,s=En,i=ao,f=Lu,c=Ys(),b=fp,w=Yt;function y(_,B){if(!(this instanceof y))return new y(_,B);if(_ instanceof y)return _;var M=this._classifyArguments(_,B);if(!M.bn||M.bn.cmp(new n(0))===0)throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!M.bn.lt(f.getN()))throw new TypeError("Number must be less than N");if(typeof M.network>"u")throw new TypeError('Must specify the network ("livenet" or "testnet")');return s.defineImmutable(this,{bn:M.bn,compressed:M.compressed,network:M.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}return y.prototype._classifyArguments=function(_,B){var M={compressed:!0,network:B?i.get(B):i.defaultNetwork};if(t.isUndefined(_)||t.isNull(_))M.bn=y._getRandomBN();else if(_ instanceof n)M.bn=_;else if(_ instanceof ge||_ instanceof Uint8Array)M=y._transformBuffer(_,B);else if(_.bn&&_.network)M=y._transformObject(_);else if(!B&&i.get(_))M.bn=y._getRandomBN(),M.network=i.get(_);else if(typeof _=="string")s.isHexa(_)?M.bn=new n(ge.from(_,"hex")):M=y._transformWIF(_,B);else throw new TypeError("First argument is an unrecognized data type.");return M},y._getRandomBN=function(){var _,B;do{var M=b.getRandomBuffer(32);B=n.fromBuffer(M),_=B.lt(f.getN())}while(!_);return B},y._transformBuffer=function(_,B){var M={};if(_.length===32)return y._transformBNBuffer(_,B);if(M.network=i.get(_[0],"privatekey"),!M.network)throw new Error("Invalid network");if(B&&M.network!==i.get(B))throw new TypeError("Private key network mismatch");if(_.length===34&&_[33]===1)M.compressed=!0;else if(_.length===33)M.compressed=!1;else throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");return M.bn=n.fromBuffer(_.slice(1,33)),M},y._transformBNBuffer=function(_,B){var M={};return M.network=i.get(B)||i.defaultNetwork,M.bn=n.fromBuffer(_),M.compressed=!1,M},y._transformWIF=function(_,B){return y._transformBuffer(r.decode(_),B)},y.fromBuffer=function(_,B){return new y(_,B)},y._transformObject=function(_){var B=new n(_.bn,"hex"),M=i.get(_.network);return{bn:B,network:M,compressed:_.compressed}},y.fromString=y.fromWIF=function(_){return w.checkArgument(t.isString(_),"First argument is expected to be a string."),new y(_)},y.fromObject=function(_){return w.checkArgument(t.isObject(_),"First argument is expected to be an object."),new y(_)},y.fromRandom=function(_){var B=y._getRandomBN();return new y(B,_)},y.getValidationError=function(_,B){var M;try{new y(_,B)}catch(E){M=E}return M},y.isValid=function(_,B){return _?!y.getValidationError(_,B):!1},y.prototype.toString=function(){return this.toBuffer().toString("hex")},y.prototype.toWIF=function(){var _=this.network,B=this.compressed,M;return B?M=ge.concat([ge.from([_.privatekey]),this.bn.toBuffer({size:32}),ge.from([1])]):M=ge.concat([ge.from([_.privatekey]),this.bn.toBuffer({size:32})]),r.encode(M)},y.prototype.toBigNumber=function(){return this.bn},y.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})},y.prototype.toBufferNoPadding=function(){return this.bn.toBuffer()},y.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=c.fromPrivateKey(this)),this._pubkey},y.prototype.toAddress=function(_,B){var M=this.toPublicKey();return e.fromPublicKey(M,_||this.network,B)},y.prototype.toObject=y.prototype.toJSON=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}},y.prototype.inspect=function(){var _=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toString()+", network: "+this.network+_+">"},Yg=y,Yg}var Qg,A_;function Ys(){if(A_)return Qg;A_=1;var t=Sn,e=Lu,r=an,n=En,s=ao,i=Gt,f=Yt;function c(b,w){if(!(this instanceof c))return new c(b,w);if(f.checkArgument(b,"First argument is required, please include public key data."),b instanceof c)return b;w=w||{};var y=this._classifyArgs(b,w);return y.point.validate(),n.defineImmutable(this,{point:y.point,compressed:y.compressed,network:y.network||s.defaultNetwork}),this}return c.prototype._classifyArgs=function(b,w){var y={compressed:i.isUndefined(w.compressed)||w.compressed};if(b instanceof e)y.point=b;else if(b.x&&b.y)y=c._transformObject(b);else if(typeof b=="string")y=c._transformDER(ge.from(b,"hex"));else if(c._isBuffer(b))y=c._transformDER(b);else if(c._isPrivateKey(b))y=c._transformPrivateKey(b);else throw new TypeError("First argument is an unrecognized data format.");return y.network||(y.network=i.isUndefined(w.network)?void 0:s.get(w.network)),y},c._isPrivateKey=function(b){var w=Dh();return b instanceof w},c._isBuffer=function(b){return b instanceof ge||b instanceof Uint8Array},c._transformPrivateKey=function(b){f.checkArgument(c._isPrivateKey(b),"Must be an instance of PrivateKey");var w={};return w.point=e.getG().mul(b.bn),w.compressed=b.compressed,w.network=b.network,w},c._transformDER=function(b,w){f.checkArgument(c._isBuffer(b),"Must be a hex buffer of DER encoded public key");var y={};w=i.isUndefined(w)?!0:w;var _,B,M,E;if(b[0]===4||!w&&(b[0]===6||b[0]===7)){if(M=b.slice(1,33),E=b.slice(33,65),M.length!==32||E.length!==32||b.length!==65)throw new TypeError("Length of x and y must be 32 bytes");_=new t(M),B=new t(E),y.point=new e(_,B),y.compressed=!1}else if(b[0]===3)M=b.slice(1),_=new t(M),y=c._transformX(!0,_),y.compressed=!0;else if(b[0]===2)M=b.slice(1),_=new t(M),y=c._transformX(!1,_),y.compressed=!0;else throw new TypeError("Invalid DER format public key");return y},c._transformX=function(b,w){f.checkArgument(typeof b=="boolean","Must specify whether y is odd or not (true or false)");var y={};return y.point=e.fromX(b,w),y},c._transformObject=function(b){var w=new t(b.x,"hex"),y=new t(b.y,"hex"),_=new e(w,y);return new c(_,{compressed:b.compressed})},c.fromPrivateKey=function(b){f.checkArgument(c._isPrivateKey(b),"Must be an instance of PrivateKey");var w=c._transformPrivateKey(b);return new c(w.point,{compressed:w.compressed,network:w.network})},c.fromDER=c.fromBuffer=function(b,w){f.checkArgument(c._isBuffer(b),"Must be a hex buffer of DER encoded public key");var y=c._transformDER(b,w);return new c(y.point,{compressed:y.compressed})},c.fromPoint=function(b,w){return f.checkArgument(b instanceof e,"First argument must be an instance of Point."),new c(b,{compressed:w})},c.fromString=function(b,w){var y=ge.from(b,w||"hex"),_=c._transformDER(y);return new c(_.point,{compressed:_.compressed})},c.fromX=function(b,w){var y=c._transformX(b,w);return new c(y.point,{compressed:y.compressed})},c.getValidationError=function(b){var w;try{new c(b)}catch(y){w=y}return w},c.isValid=function(b){return!c.getValidationError(b)},c.prototype.toObject=c.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},c.prototype.toBuffer=c.prototype.toDER=function(){var b=this.point.getX(),w=this.point.getY(),y=b.toBuffer({size:32}),_=w.toBuffer({size:32}),B;if(this.compressed){var M=_[_.length-1]%2;return M?B=ge.from([3]):B=ge.from([2]),ge.concat([B,y])}else return B=ge.from([4]),ge.concat([B,y,_])},c.prototype._getID=function(){return r.sha256ripemd160(this.toBuffer())},c.prototype.toAddress=function(b,w){var y=Js();return y.fromPublicKey(this,b||this.network,w)},c.prototype.toString=function(){return this.toDER().toString("hex")},c.prototype.inspect=function(){return"<PublicKey: "+this.toString()+(this.compressed?"":", uncompressed")+">"},Qg=c,Qg}var e2,S_;function op(){if(S_)return e2;S_=1;var t=Sn,e=Lu,r=oi,n=Ys(),s=fp,i=an,f=pr,c=Gt,b=Yt,w=function y(_){if(!(this instanceof y))return new y(_);_&&this.set(_)};return w.prototype.set=function(y){return this.hashbuf=y.hashbuf||this.hashbuf,this.endian=y.endian||this.endian,this.privkey=y.privkey||this.privkey,this.pubkey=y.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),this.sig=y.sig||this.sig,this.k=y.k||this.k,this.verified=y.verified||this.verified,this},w.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()},w.prototype.calci=function(){for(var y=0;y<4;y++){this.sig.i=y;var _;try{_=this.toPublicKey()}catch(B){console.error(B);continue}if(_.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")},w.fromString=function(y){var _=JSON.parse(y);return new w(_)},w.prototype.randomK=function(){var y=e.getN(),_;do _=t.fromBuffer(s.getRandomBuffer(32));while(!(_.lt(y)&&_.gt(t.Zero)));return this.k=_,this},w.prototype.deterministicK=function(y){c.isUndefined(y)&&(y=0);var _=ge.alloc(32);_.fill(1);var B=ge.alloc(32);B.fill(0);var M=this.privkey.bn.toBuffer({size:32}),E=this.endian==="little"?f.reverse(this.hashbuf):this.hashbuf;B=i.sha256hmac(ge.concat([_,ge.from([0]),M,E]),B),_=i.sha256hmac(_,B),B=i.sha256hmac(ge.concat([_,ge.from([1]),M,E]),B),_=i.sha256hmac(_,B),_=i.sha256hmac(_,B);for(var O=t.fromBuffer(_),k=e.getN(),P=0;P<y||!(O.lt(k)&&O.gt(t.Zero));P++)B=i.sha256hmac(ge.concat([_,ge.from([0])]),B),_=i.sha256hmac(_,B),_=i.sha256hmac(_,B),O=t.fromBuffer(_);return this.k=O,this},w.prototype.toPublicKey=function(){var y=this.sig.i;b.checkArgument(y===0||y===1||y===2||y===3,new Error("i must be equal to 0, 1, 2, or 3"));var _=t.fromBuffer(this.hashbuf),B=this.sig.r,M=this.sig.s,E=y&1,O=y>>1,k=e.getN(),P=e.getG(),C=O?B.add(k):B,D=e.fromX(E,C),z=D.mul(k);if(!z.isInfinity())throw new Error("nR is not a valid curve point");var J=_.neg().umod(k),j=B.invm(k),re=D.mul(M).add(P.mul(J)).mul(j),T=n.fromPoint(re,this.sig.compressed);return T},w.prototype.sigError=function(){if(!f.isBuffer(this.hashbuf)||this.hashbuf.length!==32)return"hashbuf must be a 32 byte buffer";var y=this.sig.r,_=this.sig.s;if(!(y.gt(t.Zero)&&y.lt(e.getN()))||!(_.gt(t.Zero)&&_.lt(e.getN())))return"r and s not in range";var B=t.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),M=e.getN(),E=_.invm(M),O=E.mul(B).umod(M),k=E.mul(y).umod(M),P=e.getG().mulAdd(O,this.pubkey.point,k);return P.isInfinity()?"p is infinity":P.getX().umod(M).cmp(y)!==0?"Invalid signature":!1},w.toLowS=function(y){return y.gt(t.fromBuffer(ge.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(y=e.getN().sub(y)),y},w.prototype._findSignature=function(y,_){var B=e.getN(),M=e.getG(),E=0,O,k,P,C;do(!this.k||E>0)&&this.deterministicK(E),E++,O=this.k,k=M.mul(O),P=k.x.umod(B),C=O.invm(B).mul(_.add(y.mul(P))).umod(B);while(P.cmp(t.Zero)<=0||C.cmp(t.Zero)<=0);return C=w.toLowS(C),{s:C,r:P}},w.prototype.sign=function(){var y=this.hashbuf,_=this.privkey,B=_.bn;b.checkState(y&&_&&B,new Error("invalid parameters")),b.checkState(f.isBuffer(y)&&y.length===32,new Error("hashbuf must be a 32 byte buffer"));var M=t.fromBuffer(y,this.endian?{endian:this.endian}:void 0),E=this._findSignature(B,M);return E.compressed=this.pubkey.compressed,this.sig=new r(E),this},w.prototype.signRandomK=function(){return this.randomK(),this.sign()},w.prototype.toString=function(){var y={};return this.hashbuf&&(y.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(y.privkey=this.privkey.toString()),this.pubkey&&(y.pubkey=this.pubkey.toString()),this.sig&&(y.sig=this.sig.toString()),this.k&&(y.k=this.k.toString()),JSON.stringify(y)},w.prototype.verify=function(){return this.sigError()?this.verified=!1:this.verified=!0,this},w.sign=function(y,_,B){return w().set({hashbuf:y,endian:B,privkey:_}).sign().sig},w.verify=function(y,_,B,M){return w().set({hashbuf:y,endian:M,sig:_,pubkey:B}).verify().verified},e2=w,e2}var E_=Xn,I_=Ea,FV=Sn,ws=function t(e){if(!(this instanceof t))return new t(e);if(ge.isBuffer(e))this.buf=e;else if(typeof e=="number"){var r=e;this.fromNumber(r)}else if(e instanceof FV){var n=e;this.fromBN(n)}else if(e){var s=e;this.set(s)}};ws.prototype.set=function(t){return this.buf=t.buf||this.buf,this},ws.prototype.fromString=function(t){return this.set({buf:ge.from(t,"hex")}),this},ws.prototype.toString=function(){return this.buf.toString("hex")},ws.prototype.fromBuffer=function(t){return this.buf=t,this},ws.prototype.fromBufferReader=function(t){return this.buf=t.readVarintBuf(),this},ws.prototype.fromBN=function(t){return this.buf=E_().writeVarintBN(t).concat(),this},ws.prototype.fromNumber=function(t){return this.buf=E_().writeVarintNum(t).concat(),this},ws.prototype.toBuffer=function(){return this.buf},ws.prototype.toBN=function(){return I_(this.buf).readVarintBN()},ws.prototype.toNumber=function(){return I_(this.buf).readVarintNum()};var UV=ws,up={exports:{}},cp=Gt,Fh=Sn,Gu=pr,hp=Ea,HV=Xn,qV=an,M_=Yt,zV=486604799,Kt=function t(e){if(!(this instanceof t))return new t(e);var r=t._from(e);return this.version=r.version,this.prevHash=r.prevHash,this.merkleRoot=r.merkleRoot,this.time=r.time,this.timestamp=r.time,this.bits=r.bits,this.nonce=r.nonce,r.hash&&M_.checkState(this.hash===r.hash,"Argument object hash property does not match block hash."),this};Kt._from=function(e){var r={};if(Gu.isBuffer(e))r=Kt._fromBufferReader(hp(e));else if(cp.isObject(e))r=Kt._fromObject(e);else throw new TypeError("Unrecognized argument for BlockHeader");return r},Kt._fromObject=function(e){M_.checkArgument(e,"data is required");var r=e.prevHash,n=e.merkleRoot;cp.isString(e.prevHash)&&(r=Gu.reverse(ge.from(e.prevHash,"hex"))),cp.isString(e.merkleRoot)&&(n=Gu.reverse(ge.from(e.merkleRoot,"hex")));var s={hash:e.hash,version:e.version,prevHash:r,merkleRoot:n,time:e.time,timestamp:e.time,bits:e.bits,nonce:e.nonce};return s},Kt.fromObject=function(e){var r=Kt._fromObject(e);return new Kt(r)},Kt.fromRawBlock=function(e){Gu.isBuffer(e)||(e=ge.from(e,"binary"));var r=hp(e);r.pos=Kt.Constants.START_OF_HEADER;var n=Kt._fromBufferReader(r);return new Kt(n)},Kt.fromBuffer=function(e){var r=Kt._fromBufferReader(hp(e));return new Kt(r)},Kt.fromString=function(e){var r=ge.from(e,"hex");return Kt.fromBuffer(r)},Kt._fromBufferReader=function(e){var r={};return r.version=e.readInt32LE(),r.prevHash=e.read(32),r.merkleRoot=e.read(32),r.time=e.readUInt32LE(),r.bits=e.readUInt32LE(),r.nonce=e.readUInt32LE(),r},Kt.fromBufferReader=function(e){var r=Kt._fromBufferReader(e);return new Kt(r)},Kt.prototype.toObject=Kt.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:Gu.reverse(this.prevHash).toString("hex"),merkleRoot:Gu.reverse(this.merkleRoot).toString("hex"),time:this.time,bits:this.bits,nonce:this.nonce}},Kt.prototype.toBuffer=function(){return this.toBufferWriter().concat()},Kt.prototype.toString=function(){return this.toBuffer().toString("hex")},Kt.prototype.toBufferWriter=function(e){return e||(e=new HV),e.writeInt32LE(this.version),e.write(this.prevHash),e.write(this.merkleRoot),e.writeUInt32LE(this.time),e.writeUInt32LE(this.bits),e.writeUInt32LE(this.nonce),e},Kt.prototype.getTargetDifficulty=function(e){e=e||this.bits;for(var r=new Fh(e&16777215),n=8*((e>>>24)-3);n-- >0;)r=r.mul(new Fh(2));return r},Kt.prototype.getDifficulty=function(){var e=this.getTargetDifficulty(zV).mul(new Fh(Math.pow(10,8))),r=this.getTargetDifficulty(),n=e.div(r).toString(10),s=n.length-8;return n=n.slice(0,s)+"."+n.slice(s),parseFloat(n)},Kt.prototype._getHash=function(){var e=this.toBuffer();return qV.sha256sha256(e)};var R_={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=hp(this._getHash()).readReverse().toString("hex")),this._id},set:cp.noop};Object.defineProperty(Kt.prototype,"id",R_),Object.defineProperty(Kt.prototype,"hash",R_),Kt.prototype.validTimestamp=function(){var e=Math.round(new Date().getTime()/1e3);return!(this.time>e+Kt.Constants.MAX_TIME_OFFSET)},Kt.prototype.validProofOfWork=function(){var e=new Fh(this.id,"hex"),r=this.getTargetDifficulty();return!(e.cmp(r)>0)},Kt.prototype.inspect=function(){return"<BlockHeader "+this.id+">"},Kt.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:2*60*60,LARGEST_HASH:new Fh("10000000000000000000000000000000000000000000000000000000000000000","hex")};var lp=Kt,t2=Gt,B_=lp,T_=Sn,O_=pr,r2=Ea,jV=Xn,KV=an,n2=ap(),P_=Yt;function Ft(t){return this instanceof Ft?(t2.extend(this,Ft._from(t)),this):new Ft(t)}Ft.MAX_BLOCK_SIZE=1e6,Ft._from=function(e){var r={};if(O_.isBuffer(e))r=Ft._fromBufferReader(r2(e));else if(t2.isObject(e))r=Ft._fromObject(e);else throw new TypeError("Unrecognized argument for Block");return r},Ft._fromObject=function(e){var r=[];e.transactions.forEach(function(s){s instanceof n2?r.push(s):r.push(n2().fromObject(s))});var n={header:B_.fromObject(e.header),transactions:r};return n},Ft.fromObject=function(e){var r=Ft._fromObject(e);return new Ft(r)},Ft._fromBufferReader=function(e){var r={};P_.checkState(!e.finished(),"No block data received"),r.header=B_.fromBufferReader(e);var n=e.readVarintNum();r.transactions=[];for(var s=0;s<n;s++)r.transactions.push(n2().fromBufferReader(e));return r},Ft.fromBufferReader=function(e){P_.checkArgument(e,"br is required");var r=Ft._fromBufferReader(e);return new Ft(r)},Ft.fromBuffer=function(e){return Ft.fromBufferReader(new r2(e))},Ft.fromString=function(e){var r=ge.from(e,"hex");return Ft.fromBuffer(r)},Ft.fromRawBlock=function(e){O_.isBuffer(e)||(e=ge.from(e,"binary"));var r=r2(e);r.pos=Ft.Values.START_OF_BLOCK;var n=Ft._fromBufferReader(r);return new Ft(n)},Ft.prototype.toObject=Ft.prototype.toJSON=function(){var e=[];return this.transactions.forEach(function(r){e.push(r.toObject())}),{header:this.header.toObject(),transactions:e}},Ft.prototype.toBuffer=function(){return this.toBufferWriter().concat()},Ft.prototype.toString=function(){return this.toBuffer().toString("hex")},Ft.prototype.toBufferWriter=function(e){e||(e=new jV),e.write(this.header.toBuffer()),e.writeVarintNum(this.transactions.length);for(var r=0;r<this.transactions.length;r++)this.transactions[r].toBufferWriter(e);return e},Ft.prototype.getTransactionHashes=function(){var e=[];if(this.transactions.length===0)return[Ft.Values.NULL_HASH];for(var r=0;r<this.transactions.length;r++)e.push(this.transactions[r]._getHash());return e},Ft.prototype.getMerkleTree=function(){for(var e=this.getTransactionHashes(),r=0,n=this.transactions.length;n>1;n=Math.floor((n+1)/2)){for(var s=0;s<n;s+=2){var i=Math.min(s+1,n-1),f=ge.concat([e[r+s],e[r+i]]);e.push(KV.sha256sha256(f))}r+=n}return e},Ft.prototype.getMerkleRoot=function(){var e=this.getMerkleTree();return e[e.length-1]},Ft.prototype.validMerkleRoot=function(){var e=new T_(this.header.merkleRoot.toString("hex"),"hex"),r=new T_(this.getMerkleRoot().toString("hex"),"hex");return e.cmp(r)===0},Ft.prototype._getHash=function(){return this.header._getHash()};var k_={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=this.header.id),this._id},set:t2.noop};Object.defineProperty(Ft.prototype,"id",k_),Object.defineProperty(Ft.prototype,"hash",k_),Ft.prototype.inspect=function(){return"<Block "+this.id+">"},Ft.Values={START_OF_BLOCK:8,NULL_HASH:ge.from("0000000000000000000000000000000000000000000000000000000000000000","hex")};var VV=Ft,bo=Gt,i2=lp,s2=pr,N_=Ea,WV=Xn,$V=an,C_=ap(),a2=Ui,mo=Yt;function yr(t){if(!(this instanceof yr))return new yr(t);var e={};if(s2.isBuffer(t))e=yr._fromBufferReader(N_(t));else if(bo.isObject(t)){var r;t.header instanceof i2?r=t.header:r=i2.fromObject(t.header),e={header:r,numTransactions:t.numTransactions,hashes:t.hashes,flags:t.flags}}else throw new TypeError("Unrecognized argument for MerkleBlock");return bo.extend(this,e),this._flagBitsUsed=0,this._hashesUsed=0,this}yr.fromBuffer=function(e){return yr.fromBufferReader(N_(e))},yr.fromBufferReader=function(e){return new yr(yr._fromBufferReader(e))},yr.prototype.toBuffer=function(){return this.toBufferWriter().concat()},yr.prototype.toBufferWriter=function(e){e||(e=new WV),e.write(this.header.toBuffer()),e.writeUInt32LE(this.numTransactions),e.writeVarintNum(this.hashes.length);for(var r=0;r<this.hashes.length;r++)e.write(ge.from(this.hashes[r],"hex"));for(e.writeVarintNum(this.flags.length),r=0;r<this.flags.length;r++)e.writeUInt8(this.flags[r]);return e},yr.prototype.toObject=yr.prototype.toJSON=function(){return{header:this.header.toObject(),numTransactions:this.numTransactions,hashes:this.hashes,flags:this.flags}},yr.prototype.validMerkleTree=function(){if(mo.checkState(bo.isArray(this.flags),"MerkleBlock flags is not an array"),mo.checkState(bo.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions||this.flags.length*8<this.hashes.length)return!1;var e=this._calcTreeHeight(),r={hashesUsed:0,flagBitsUsed:0},n=this._traverseMerkleTree(e,0,r);return r.hashesUsed!==this.hashes.length?!1:s2.equals(n,this.header.merkleRoot)},yr.prototype.filterdTxsHash=function(){if(mo.checkState(bo.isArray(this.flags),"MerkleBlock flags is not an array"),mo.checkState(bo.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)throw new a2.MerkleBlock.InvalidMerkleTree;if(this.flags.length*8<this.hashes.length)throw new a2.MerkleBlock.InvalidMerkleTree;if(this.hashes.length===1)return[];var e=this._calcTreeHeight(),r={hashesUsed:0,flagBitsUsed:0},n=this._traverseMerkleTree(e,0,r,!0);if(r.hashesUsed!==this.hashes.length)throw new a2.MerkleBlock.InvalidMerkleTree;return n},yr.prototype._traverseMerkleTree=function(e,r,n,i){n=n||{},n.txs=n.txs||[],n.flagBitsUsed=n.flagBitsUsed||0,n.hashesUsed=n.hashesUsed||0;var i=i||!1;if(n.flagBitsUsed>this.flags.length*8)return null;var f=this.flags[n.flagBitsUsed>>3]>>>(n.flagBitsUsed++&7)&1;if(e===0||!f){if(n.hashesUsed>=this.hashes.length)return null;var c=this.hashes[n.hashesUsed++];return e===0&&f&&n.txs.push(c),ge.from(c,"hex")}else{var b=this._traverseMerkleTree(e-1,r*2,n),w=b;return r*2+1<this._calcTreeWidth(e-1)&&(w=this._traverseMerkleTree(e-1,r*2+1,n)),i?n.txs:$V.sha256sha256(new ge.concat([b,w]))}},yr.prototype._calcTreeWidth=function(e){return this.numTransactions+(1<<e)-1>>e},yr.prototype._calcTreeHeight=function(){for(var e=0;this._calcTreeWidth(e)>1;)e++;return e},yr.prototype.hasTransaction=function(e){mo.checkArgument(!bo.isUndefined(e),"tx cannot be undefined"),mo.checkArgument(e instanceof C_||typeof e=="string",'Invalid tx given, tx must be a "string" or "Transaction"');var r=e;e instanceof C_&&(r=s2.reverse(ge.from(e.id,"hex")).toString("hex"));var n=[],s=this._calcTreeHeight();return this._traverseMerkleTree(s,0,{txs:n}),n.indexOf(r)!==-1},yr._fromBufferReader=function(e){mo.checkState(!e.finished(),"No merkleblock data received");var r={};r.header=i2.fromBufferReader(e),r.numTransactions=e.readUInt32LE();var n=e.readVarintNum();r.hashes=[];for(var s=0;s<n;s++)r.hashes.push(e.read(32).toString("hex"));var i=e.readVarintNum();for(r.flags=[],s=0;s<i;s++)r.flags.push(e.readUInt8());return r},yr.fromObject=function(e){return new yr(e)};var L_=yr;up.exports=VV,up.exports.BlockHeader=lp,up.exports.MerkleBlock=L_;var GV=up.exports,f2,D_;function F_(){if(D_)return f2;D_=1;var t=Gt,e=Yt,r=Sn,n=Kd,s=Ah,i=an,f=H_(),c=ao,b=Lu,w=Ys(),y=Ui,_=y,B=y.HDPublicKey,M=ya(),E=En,O=pr;function k(P){if(P instanceof k)return P;if(!(this instanceof k))return new k(P);if(P)if(t.isString(P)||O.isBuffer(P)){var C=k.getSerializedError(P);if(C){if(O.isBuffer(P)&&!k.getSerializedError(P.toString()))return this._buildFromSerialized(P.toString());if(C instanceof B.ArgumentIsPrivateExtended)return new f(P).hdPublicKey;throw C}else return this._buildFromSerialized(P)}else{if(t.isObject(P))return P instanceof f?this._buildFromPrivate(P):this._buildFromObject(P);throw new B.UnrecognizedArgument(P)}else throw new B.MustSupplyArgument}return k.isValidPath=function(P){if(t.isString(P)){var C=f._getDerivationIndexes(P);return C!==null&&t.every(C,k.isValidPath)}return t.isNumber(P)?P>=0&&P<k.Hardened:!1},k.prototype.derive=function(P,C){return this.deriveChild(P,C)},k.prototype.deriveChild=function(P,C){if(t.isNumber(P))return this._deriveWithNumber(P,C);if(t.isString(P))return this._deriveFromString(P);throw new B.InvalidDerivationArgument(P)},k.prototype._deriveWithNumber=function(P,C){if(P>=k.Hardened||C)throw new B.InvalidIndexCantDeriveHardened;if(P<0)throw new B.InvalidPath(P);var D=O.integerAsBuffer(P),z=O.concat([this.publicKey.toBuffer(),D]),J=i.sha512hmac(z,this._buffers.chainCode),j=r.fromBuffer(J.slice(0,32),{size:32}),re=J.slice(32,64),T;try{T=w.fromPoint(b.getG().mul(j).add(this.publicKey.point))}catch{return this._deriveWithNumber(P+1)}var q=new k({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:P,chainCode:re,publicKey:T});return q},k.prototype._deriveFromString=function(P){if(t.includes(P,"'"))throw new B.InvalidIndexCantDeriveHardened;if(!k.isValidPath(P))throw new B.InvalidPath(P);var C=f._getDerivationIndexes(P),D=C.reduce(function(z,J){return z._deriveWithNumber(J)},this);return D},k.isValidSerialized=function(P,C){return t.isNull(k.getSerializedError(P,C))},k.getSerializedError=function(P,C){if(!(t.isString(P)||O.isBuffer(P)))return new B.UnrecognizedArgument("expected buffer or string");if(!n.validCharacters(P))return new _.InvalidB58Char("(unknown)",P);try{P=s.decode(P)}catch{return new _.InvalidB58Checksum(P)}if(P.length!==k.DataSize)return new B.InvalidLength(P);if(!t.isUndefined(C)){var D=k._validateNetwork(P,C);if(D)return D}var z=O.integerFromBuffer(P.slice(0,4));return z===c.livenet.xprivkey||z===c.testnet.xprivkey?new B.ArgumentIsPrivateExtended:null},k._validateNetwork=function(P,C){var D=c.get(C);if(!D)return new _.InvalidNetworkArgument(C);var z=P.slice(k.VersionStart,k.VersionEnd);return O.integerFromBuffer(z)!==D.xpubkey?new _.InvalidNetwork(z):null},k.prototype._buildFromPrivate=function(P){var C=t.clone(P._buffers),D=b.getG().mul(r.fromBuffer(C.privateKey));return C.publicKey=b.pointToCompressed(D),C.version=O.integerAsBuffer(c.get(O.integerFromBuffer(C.version)).xpubkey),C.privateKey=void 0,C.checksum=void 0,C.xprivkey=void 0,this._buildFromBuffers(C)},k.prototype._buildFromObject=function(P){var C={version:P.network?O.integerAsBuffer(c.get(P.network).xpubkey):P.version,depth:t.isNumber(P.depth)?O.integerAsSingleByteBuffer(P.depth):P.depth,parentFingerPrint:t.isNumber(P.parentFingerPrint)?O.integerAsBuffer(P.parentFingerPrint):P.parentFingerPrint,childIndex:t.isNumber(P.childIndex)?O.integerAsBuffer(P.childIndex):P.childIndex,chainCode:t.isString(P.chainCode)?ge.from(P.chainCode,"hex"):P.chainCode,publicKey:t.isString(P.publicKey)?ge.from(P.publicKey,"hex"):O.isBuffer(P.publicKey)?P.publicKey:P.publicKey.toBuffer(),checksum:t.isNumber(P.checksum)?O.integerAsBuffer(P.checksum):P.checksum};return this._buildFromBuffers(C)},k.prototype._buildFromSerialized=function(P){var C=s.decode(P),D={version:C.slice(k.VersionStart,k.VersionEnd),depth:C.slice(k.DepthStart,k.DepthEnd),parentFingerPrint:C.slice(k.ParentFingerPrintStart,k.ParentFingerPrintEnd),childIndex:C.slice(k.ChildIndexStart,k.ChildIndexEnd),chainCode:C.slice(k.ChainCodeStart,k.ChainCodeEnd),publicKey:C.slice(k.PublicKeyStart,k.PublicKeyEnd),checksum:C.slice(k.ChecksumStart,k.ChecksumEnd),xpubkey:P};return this._buildFromBuffers(D)},k.prototype._buildFromBuffers=function(P){k._validateBufferArguments(P),E.defineImmutable(this,{_buffers:P});var C=[P.version,P.depth,P.parentFingerPrint,P.childIndex,P.chainCode,P.publicKey],D=O.concat(C),z=s.checksum(D);if(!P.checksum||!P.checksum.length)P.checksum=z;else if(P.checksum.toString("hex")!==z.toString("hex"))throw new _.InvalidB58Checksum(D,z);var J=c.get(O.integerFromBuffer(P.version)),j;j=s.encode(O.concat(C)),P.xpubkey=ge.from(j);var re=new w(P.publicKey,{network:J}),T=k.ParentFingerPrintSize,q=i.sha256ripemd160(re.toBuffer()).slice(0,T);return E.defineImmutable(this,{xpubkey:j,network:J,depth:O.integerFromSingleByteBuffer(P.depth),publicKey:re,fingerPrint:q}),this},k._validateBufferArguments=function(P){var C=function(D,z){var J=P[D];M(O.isBuffer(J),D+" argument is not a buffer, it's "+typeof J),M(J.length===z,D+" has not the expected size: found "+J.length+", expected "+z)};C("version",k.VersionSize),C("depth",k.DepthSize),C("parentFingerPrint",k.ParentFingerPrintSize),C("childIndex",k.ChildIndexSize),C("chainCode",k.ChainCodeSize),C("publicKey",k.PublicKeySize),P.checksum&&P.checksum.length&&C("checksum",k.CheckSumSize)},k.fromString=function(P){return e.checkArgument(t.isString(P),"No valid string was provided"),new k(P)},k.fromObject=function(P){return e.checkArgument(t.isObject(P),"No valid argument was provided"),new k(P)},k.prototype.toString=function(){return this.xpubkey},k.prototype.inspect=function(){return"<HDPublicKey: "+this.xpubkey+">"},k.prototype.toObject=k.prototype.toJSON=function(){return{network:c.get(O.integerFromBuffer(this._buffers.version)).name,depth:O.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:O.integerFromBuffer(this.fingerPrint),parentFingerPrint:O.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:O.integerFromBuffer(this._buffers.childIndex),chainCode:O.bufferToHex(this._buffers.chainCode),publicKey:this.publicKey.toString(),checksum:O.integerFromBuffer(this._buffers.checksum),xpubkey:this.xpubkey}},k.fromBuffer=function(P){return new k(P)},k.prototype.toBuffer=function(){return O.copy(this._buffers.xpubkey)},k.Hardened=2147483648,k.RootElementAlias=["m","M"],k.VersionSize=4,k.DepthSize=1,k.ParentFingerPrintSize=4,k.ChildIndexSize=4,k.ChainCodeSize=32,k.PublicKeySize=33,k.CheckSumSize=4,k.DataSize=78,k.SerializedByteSize=82,k.VersionStart=0,k.VersionEnd=k.VersionStart+k.VersionSize,k.DepthStart=k.VersionEnd,k.DepthEnd=k.DepthStart+k.DepthSize,k.ParentFingerPrintStart=k.DepthEnd,k.ParentFingerPrintEnd=k.ParentFingerPrintStart+k.ParentFingerPrintSize,k.ChildIndexStart=k.ParentFingerPrintEnd,k.ChildIndexEnd=k.ChildIndexStart+k.ChildIndexSize,k.ChainCodeStart=k.ChildIndexEnd,k.ChainCodeEnd=k.ChainCodeStart+k.ChainCodeSize,k.PublicKeyStart=k.ChainCodeEnd,k.PublicKeyEnd=k.PublicKeyStart+k.PublicKeySize,k.ChecksumStart=k.PublicKeyEnd,k.ChecksumEnd=k.ChecksumStart+k.CheckSumSize,M(k.PublicKeyEnd===k.DataSize),M(k.ChecksumEnd===k.SerializedByteSize),f2=k,f2}var o2,U_;function H_(){if(U_)return o2;U_=1;var t=ya(),e=gn,r=Gt,n=Yt,s=Sn,i=Kd,f=Ah,c=an,b=ao,w=Lu,y=Dh(),_=fp,B=Ui,M=B.HDPrivateKey,E=pr,O=En,k=128,P=1/8,C=512;function D(z){if(z instanceof D)return z;if(!(this instanceof D))return new D(z);if(!z)return this._generateRandomly();if(b.get(z))return this._generateRandomly(z);if(r.isString(z)||E.isBuffer(z))if(D.isValidSerialized(z))this._buildFromSerialized(z);else if(O.isValidJSON(z))this._buildFromJSON(z);else if(E.isBuffer(z)&&D.isValidSerialized(z.toString()))this._buildFromSerialized(z.toString());else throw D.getSerializedError(z);else if(r.isObject(z))this._buildFromObject(z);else throw new M.UnrecognizedArgument(z)}return D.isValidPath=function(z,J){if(r.isString(z)){var j=D._getDerivationIndexes(z);return j!==null&&r.every(j,D.isValidPath)}return r.isNumber(z)?(z<D.Hardened&&J===!0&&(z+=D.Hardened),z>=0&&z<D.MaxIndex):!1},D._getDerivationIndexes=function(z){var J=z.split("/");if(r.includes(D.RootElementAlias,z))return[];if(!r.includes(D.RootElementAlias,J[0]))return null;var j=J.slice(1).map(function(re){var T=re.slice(-1)==="'";if(T&&(re=re.slice(0,-1)),!re||re[0]==="-")return NaN;var q=+re;return T&&(q+=D.Hardened),q});return r.some(j,isNaN)?null:j},D.prototype.derive=function(z,J){return this.deriveNonCompliantChild(z,J)},D.prototype.deriveChild=function(z,J){if(r.isNumber(z))return this._deriveWithNumber(z,J);if(r.isString(z))return this._deriveFromString(z);throw new M.InvalidDerivationArgument(z)},D.prototype.deriveNonCompliantChild=function(z,J){if(r.isNumber(z))return this._deriveWithNumber(z,J,!0);if(r.isString(z))return this._deriveFromString(z,!0);throw new M.InvalidDerivationArgument(z)},D.prototype._deriveWithNumber=function(z,J,j){if(!D.isValidPath(z,J))throw new M.InvalidPath(z);J=z>=D.Hardened?!0:J,z<D.Hardened&&J===!0&&(z+=D.Hardened);var re=E.integerAsBuffer(z),T;if(J&&j){var q=this.privateKey.bn.toBuffer();T=E.concat([ge.from([0]),q,re])}else if(J){var F=this.privateKey.bn.toBuffer({size:32});t(F.length===32,"length of private key buffer is expected to be 32 bytes"),T=E.concat([ge.from([0]),F,re])}else T=E.concat([this.publicKey.toBuffer(),re]);var m=c.sha512hmac(T,this._buffers.chainCode),a=s.fromBuffer(m.slice(0,32),{size:32}),h=m.slice(32,64),u=a.add(this.privateKey.toBigNumber()).umod(w.getN()).toBuffer({size:32});if(!y.isValid(u))return this._deriveWithNumber(z+1,null,j);var l=new D({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:z,chainCode:h,privateKey:u});return l},D.prototype._deriveFromString=function(z,J){if(!D.isValidPath(z))throw new M.InvalidPath(z);var j=D._getDerivationIndexes(z),re=j.reduce(function(T,q){return T._deriveWithNumber(q,null,J)},this);return re},D.isValidSerialized=function(z,J){return!D.getSerializedError(z,J)},D.getSerializedError=function(z,J){if(!(r.isString(z)||E.isBuffer(z)))return new M.UnrecognizedArgument("Expected string or buffer");if(!i.validCharacters(z))return new B.InvalidB58Char("(unknown)",z);try{z=f.decode(z)}catch{return new B.InvalidB58Checksum(z)}if(z.length!==D.DataLength)return new M.InvalidLength(z);if(!r.isUndefined(J)){var j=D._validateNetwork(z,J);if(j)return j}return null},D._validateNetwork=function(z,J){var j=b.get(J);if(!j)return new B.InvalidNetworkArgument(J);var re=z.slice(0,4);return E.integerFromBuffer(re)!==j.xprivkey?new B.InvalidNetwork(re):null},D.fromString=function(z){return n.checkArgument(r.isString(z),"No valid string was provided"),new D(z)},D.fromObject=function(z){return n.checkArgument(r.isObject(z),"No valid argument was provided"),new D(z)},D.prototype._buildFromJSON=function(z){return this._buildFromObject(JSON.parse(z))},D.prototype._buildFromObject=function(z){var J={version:z.network?E.integerAsBuffer(b.get(z.network).xprivkey):z.version,depth:r.isNumber(z.depth)?E.integerAsSingleByteBuffer(z.depth):z.depth,parentFingerPrint:r.isNumber(z.parentFingerPrint)?E.integerAsBuffer(z.parentFingerPrint):z.parentFingerPrint,childIndex:r.isNumber(z.childIndex)?E.integerAsBuffer(z.childIndex):z.childIndex,chainCode:r.isString(z.chainCode)?ge.from(z.chainCode,"hex"):z.chainCode,privateKey:r.isString(z.privateKey)&&O.isHexa(z.privateKey)?ge.from(z.privateKey,"hex"):z.privateKey,checksum:z.checksum?z.checksum.length?z.checksum:E.integerAsBuffer(z.checksum):void 0};return this._buildFromBuffers(J)},D.prototype._buildFromSerialized=function(z){var J=f.decode(z),j={version:J.slice(D.VersionStart,D.VersionEnd),depth:J.slice(D.DepthStart,D.DepthEnd),parentFingerPrint:J.slice(D.ParentFingerPrintStart,D.ParentFingerPrintEnd),childIndex:J.slice(D.ChildIndexStart,D.ChildIndexEnd),chainCode:J.slice(D.ChainCodeStart,D.ChainCodeEnd),privateKey:J.slice(D.PrivateKeyStart,D.PrivateKeyEnd),checksum:J.slice(D.ChecksumStart,D.ChecksumEnd),xprivkey:z};return this._buildFromBuffers(j)},D.prototype._generateRandomly=function(z){return D.fromSeed(_.getRandomBuffer(64),z)},D.fromSeed=function(z,J){if(O.isHexaString(z)&&(z=ge.from(z,"hex")),!ge.isBuffer(z))throw new M.InvalidEntropyArgument(z);if(z.length<k*P)throw new M.InvalidEntropyArgument.NotEnoughEntropy(z);if(z.length>C*P)throw new M.InvalidEntropyArgument.TooMuchEntropy(z);var j=c.sha512hmac(z,ge.from("Bitcoin seed"));return new D({network:b.get(J)||b.defaultNetwork,depth:0,parentFingerPrint:0,childIndex:0,privateKey:j.slice(0,32),chainCode:j.slice(32,64)})},D.prototype._calcHDPublicKey=function(){if(!this._hdPublicKey){var z=F_();this._hdPublicKey=new z(this)}},D.prototype._buildFromBuffers=function(z){D._validateBufferArguments(z),O.defineImmutable(this,{_buffers:z});var J=[z.version,z.depth,z.parentFingerPrint,z.childIndex,z.chainCode,E.emptyBuffer(1),z.privateKey],j=e.Buffer.concat(J);if(!z.checksum||!z.checksum.length)z.checksum=f.checksum(j);else if(z.checksum.toString()!==f.checksum(j).toString())throw new B.InvalidB58Checksum(j);var re=b.get(E.integerFromBuffer(z.version)),T;T=f.encode(e.Buffer.concat(J)),z.xprivkey=ge.from(T);var q=new y(s.fromBuffer(z.privateKey),re),F=q.toPublicKey(),m=D.ParentFingerPrintSize,a=c.sha256ripemd160(F.toBuffer()).slice(0,m);return O.defineImmutable(this,{xprivkey:T,network:re,depth:E.integerFromSingleByteBuffer(z.depth),privateKey:q,publicKey:F,fingerPrint:a}),this._hdPublicKey=null,Object.defineProperty(this,"hdPublicKey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey}}),Object.defineProperty(this,"xpubkey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey.xpubkey}}),this},D._validateBufferArguments=function(z){var J=function(j,re){var T=z[j];t(E.isBuffer(T),j+" argument is not a buffer"),t(T.length===re,j+" has not the expected size: found "+T.length+", expected "+re)};J("version",D.VersionSize),J("depth",D.DepthSize),J("parentFingerPrint",D.ParentFingerPrintSize),J("childIndex",D.ChildIndexSize),J("chainCode",D.ChainCodeSize),J("privateKey",D.PrivateKeySize),z.checksum&&z.checksum.length&&J("checksum",D.CheckSumSize)},D.prototype.toString=function(){return this.xprivkey},D.prototype.inspect=function(){return"<HDPrivateKey: "+this.xprivkey+">"},D.prototype.toObject=D.prototype.toJSON=function(){return{network:b.get(E.integerFromBuffer(this._buffers.version),"xprivkey").name,depth:E.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:E.integerFromBuffer(this.fingerPrint),parentFingerPrint:E.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:E.integerFromBuffer(this._buffers.childIndex),chainCode:E.bufferToHex(this._buffers.chainCode),privateKey:this.privateKey.toBuffer().toString("hex"),checksum:E.integerFromBuffer(this._buffers.checksum),xprivkey:this.xprivkey}},D.fromBuffer=function(z){return new D(z.toString())},D.prototype.toBuffer=function(){return E.copy(this._buffers.xprivkey)},D.DefaultDepth=0,D.DefaultFingerprint=0,D.DefaultChildIndex=0,D.Hardened=2147483648,D.MaxIndex=2*D.Hardened,D.RootElementAlias=["m","M","m'","M'"],D.VersionSize=4,D.DepthSize=1,D.ParentFingerPrintSize=4,D.ChildIndexSize=4,D.ChainCodeSize=32,D.PrivateKeySize=32,D.CheckSumSize=4,D.DataLength=78,D.SerializedByteSize=82,D.VersionStart=0,D.VersionEnd=D.VersionStart+D.VersionSize,D.DepthStart=D.VersionEnd,D.DepthEnd=D.DepthStart+D.DepthSize,D.ParentFingerPrintStart=D.DepthEnd,D.ParentFingerPrintEnd=D.ParentFingerPrintStart+D.ParentFingerPrintSize,D.ChildIndexStart=D.ParentFingerPrintEnd,D.ChildIndexEnd=D.ChildIndexStart+D.ChildIndexSize,D.ChainCodeStart=D.ChildIndexEnd,D.ChainCodeEnd=D.ChainCodeStart+D.ChainCodeSize,D.PrivateKeyStart=D.ChainCodeEnd+1,D.PrivateKeyEnd=D.PrivateKeyStart+D.PrivateKeySize,D.ChecksumStart=D.PrivateKeyEnd,D.ChecksumEnd=D.ChecksumStart+D.CheckSumSize,t(D.ChecksumEnd===D.SerializedByteSize),o2=D,o2}var Uh=Gt,ZV=Dh(),XV=Ys(),dp=Js(),q_=Xn,pp=op(),u2=oi,JV=an.sha256sha256,YV=En,hf=Yt;function Or(t){return this instanceof Or?(hf.checkArgument(Uh.isString(t),"First argument should be a string"),this.message=t,this):new Or(t)}Or.MAGIC_BYTES=ge.from(`Bitcoin Signed Message:
130
130
  `),Or.prototype.magicHash=function(){var e=q_.varintBufNum(Or.MAGIC_BYTES.length),r=ge.from(this.message),n=q_.varintBufNum(r.length),s=ge.concat([e,Or.MAGIC_BYTES,n,r]),i=JV(s);return i},Or.prototype._sign=function(e){hf.checkArgument(e instanceof ZV,"First argument should be an instance of PrivateKey");var r=this.magicHash(),n=new pp;return n.hashbuf=r,n.privkey=e,n.pubkey=e.toPublicKey(),n.signRandomK(),n.calci(),n.sig},Or.prototype.sign=function(e){var r=this._sign(e);return r.toCompact().toString("base64")},Or.prototype._verify=function(e,r){hf.checkArgument(e instanceof XV,"First argument should be an instance of PublicKey"),hf.checkArgument(r instanceof u2,"Second argument should be an instance of Signature");var n=this.magicHash(),s=pp.verify(n,r,e);return s||(this.error="The signature was invalid"),s},Or.prototype.verify=function(e,r){hf.checkArgument(e),hf.checkArgument(r&&Uh.isString(r)),Uh.isString(e)&&(e=dp.fromString(e));var n=u2.fromCompact(ge.from(r,"base64")),s=new pp;s.hashbuf=this.magicHash(),s.sig=n;var i=s.toPublicKey(),f=dp.fromPublicKey(i,e.network);return e.toString()!==f.toString()?(this.error="The signature did not match the message digest",!1):this._verify(i,n)},Or.prototype.recoverPublicKey=function(e,r){hf.checkArgument(e),hf.checkArgument(r&&Uh.isString(r)),Uh.isString(e)&&(e=dp.fromString(e));var n=u2.fromCompact(ge.from(r,"base64")),s=new pp;s.hashbuf=this.magicHash(),s.sig=n;var i=s.toPublicKey(),f=dp.fromPublicKey(i,e.network);return e.toString()!==f.toString()&&(this.error="The signature did not match the message digest"),i.toString()},Or.fromString=function(t){return new Or(t)},Or.fromJSON=function(e){return YV.isValidJSON(e)&&(e=JSON.parse(e)),new Or(e.message)},Or.prototype.toObject=function(){return{message:this.message}},Or.prototype.toJSON=function(){return JSON.stringify(this.toObject())},Or.prototype.toString=function(){return this.message},Or.prototype.inspect=function(){return"<Message: "+this.toString()+">"};var QV=Or;ui();var vp={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */vp.exports,function(t,e){(function(r){var n=e&&!e.nodeType&&e,s=t&&!t.nodeType&&t,i=typeof lt=="object"&&lt;(i.global===i||i.window===i||i.self===i)&&(r=i);var f,c=2147483647,b=36,w=1,y=26,_=38,B=700,M=72,E=128,O="-",k=/^xn--/,P=/[^\x20-\x7E]/,C=/[\x2E\u3002\uFF0E\uFF61]/g,D={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},z=b-w,J=Math.floor,j=String.fromCharCode,re;function T(d){throw new RangeError(D[d])}function q(d,S){for(var I=d.length,N=[];I--;)N[I]=S(d[I]);return N}function F(d,S){var I=d.split("@"),N="";I.length>1&&(N=I[0]+"@",d=I[1]),d=d.replace(C,".");var G=d.split("."),ie=q(G,S).join(".");return N+ie}function m(d){for(var S=[],I=0,N=d.length,G,ie;I<N;)G=d.charCodeAt(I++),G>=55296&&G<=56319&&I<N?(ie=d.charCodeAt(I++),(ie&64512)==56320?S.push(((G&1023)<<10)+(ie&1023)+65536):(S.push(G),I--)):S.push(G);return S}function a(d){return q(d,function(S){var I="";return S>65535&&(S-=65536,I+=j(S>>>10&1023|55296),S=56320|S&1023),I+=j(S),I}).join("")}function h(d){return d-48<10?d-22:d-65<26?d-65:d-97<26?d-97:b}function u(d,S){return d+22+75*(d<26)-((S!=0)<<5)}function l(d,S,I){var N=0;for(d=I?J(d/B):d>>1,d+=J(d/S);d>z*y>>1;N+=b)d=J(d/z);return J(N+(z+1)*d/(d+_))}function g(d){var S=[],I=d.length,N,G=0,ie=E,Z=M,V,Y,ee,ce,W,$,de,ye,Ae;for(V=d.lastIndexOf(O),V<0&&(V=0),Y=0;Y<V;++Y)d.charCodeAt(Y)>=128&&T("not-basic"),S.push(d.charCodeAt(Y));for(ee=V>0?V+1:0;ee<I;){for(ce=G,W=1,$=b;ee>=I&&T("invalid-input"),de=h(d.charCodeAt(ee++)),(de>=b||de>J((c-G)/W))&&T("overflow"),G+=de*W,ye=$<=Z?w:$>=Z+y?y:$-Z,!(de<ye);$+=b)Ae=b-ye,W>J(c/Ae)&&T("overflow"),W*=Ae;N=S.length+1,Z=l(G-ce,N,ce==0),J(G/N)>c-ie&&T("overflow"),ie+=J(G/N),G%=N,S.splice(G++,0,ie)}return a(S)}function A(d){var S,I,N,G,ie,Z,V,Y,ee,ce,W,$=[],de,ye,Ae,Le;for(d=m(d),de=d.length,S=E,I=0,ie=M,Z=0;Z<de;++Z)W=d[Z],W<128&&$.push(j(W));for(N=G=$.length,G&&$.push(O);N<de;){for(V=c,Z=0;Z<de;++Z)W=d[Z],W>=S&&W<V&&(V=W);for(ye=N+1,V-S>J((c-I)/ye)&&T("overflow"),I+=(V-S)*ye,S=V,Z=0;Z<de;++Z)if(W=d[Z],W<S&&++I>c&&T("overflow"),W==S){for(Y=I,ee=b;ce=ee<=ie?w:ee>=ie+y?y:ee-ie,!(Y<ce);ee+=b)Le=Y-ce,Ae=b-ce,$.push(j(u(ce+Le%Ae,0))),Y=J(Le/Ae);$.push(j(u(Y,0))),ie=l(I,ye,N==G),I=0,++N}++I,++S}return $.join("")}function x(d){return F(d,function(S){return k.test(S)?g(S.slice(4).toLowerCase()):S})}function p(d){return F(d,function(S){return P.test(S)?"xn--"+A(S):S})}if(f={version:"1.4.1",ucs2:{decode:m,encode:a},decode:g,encode:A,toASCII:p,toUnicode:x},n&&s)if(t.exports==n)s.exports=f;else for(re in f)f.hasOwnProperty(re)&&(n[re]=f[re]);else r.punycode=f})(lt)}(vp,vp.exports);var eW=vp.exports;const tW=D3(eW);function rW(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var nW=function(t,e,r,n){e=e||"&",r=r||"=";var s={};if(typeof t!="string"||t.length===0)return s;var i=/\+/g;t=t.split(e);var f=1e3;n&&typeof n.maxKeys=="number"&&(f=n.maxKeys);var c=t.length;f>0&&c>f&&(c=f);for(var b=0;b<c;++b){var w=t[b].replace(i,"%20"),y=w.indexOf(r),_,B,M,E;y>=0?(_=w.substr(0,y),B=w.substr(y+1)):(_=w,B=""),M=decodeURIComponent(_),E=decodeURIComponent(B),rW(s,M)?iW(s[M])?s[M].push(E):s[M]=[s[M],E]:s[M]=E}return s},iW=Array.isArray||function(t){return Object.prototype.toString.call(t)==="[object Array]"},Hh=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}},sW=function(t,e,r,n){return e=e||"&",r=r||"=",t===null&&(t=void 0),typeof t=="object"?z_(fW(t),function(s){var i=encodeURIComponent(Hh(s))+r;return aW(t[s])?z_(t[s],function(f){return i+encodeURIComponent(Hh(f))}).join(e):i+encodeURIComponent(Hh(t[s]))}).join(e):n?encodeURIComponent(Hh(n))+r+encodeURIComponent(Hh(t)):""},aW=Array.isArray||function(t){return Object.prototype.toString.call(t)==="[object Array]"};function z_(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n<t.length;n++)r.push(e(t[n],n));return r}var fW=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e},j_,K_,oW=K_=nW,uW=j_=sW;function cW(t){return encodeURIComponent(t)}function hW(t){return decodeURIComponent(t)}var lW={decode:oW,encode:uW,parse:K_,stringify:j_,escape:cW,unescape:hW},dW={isString:function(t){return typeof t=="string"},isObject:function(t){return typeof t=="object"&&t!==null},isNull:function(t){return t===null},isNullOrUndefined:function(t){return t==null}},pW=tW,Qs=dW,vW=qh,bW=RW,V_=BW,mW=MW,gW=$i;function $i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var yW=/^([a-z0-9.+-]+:)/i,wW=/:[0-9]*$/,_W=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,xW=["<",">",'"',"`"," ","\r",`
131
131
  `," "],AW=["{","}","|","\\","^","`"].concat(xW),c2=["'"].concat(AW),W_=["%","/","?",";","#"].concat(c2),$_=["/","?","#"],SW=255,G_=/^[+a-z0-9A-Z_-]{0,63}$/,EW=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,IW={javascript:!0,"javascript:":!0},h2={javascript:!0,"javascript:":!0},Zu={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},l2=lW;function qh(t,e,r){if(t&&Qs.isObject(t)&&t instanceof $i)return t;var n=new $i;return n.parse(t,e,r),n}$i.prototype.parse=function(t,e,r){if(!Qs.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t.indexOf("?"),s=n!==-1&&n<t.indexOf("#")?"?":"#",i=t.split(s),f=/\\/g;i[0]=i[0].replace(f,"/"),t=i.join(s);var c=t;if(c=c.trim(),!r&&t.split("#").length===1){var b=_W.exec(c);if(b)return this.path=c,this.href=c,this.pathname=b[1],b[2]?(this.search=b[2],e?this.query=l2.parse(this.search.substr(1)):this.query=this.search.substr(1)):e&&(this.search="",this.query={}),this}var w=yW.exec(c);if(w){w=w[0];var y=w.toLowerCase();this.protocol=y,c=c.substr(w.length)}if(r||w||c.match(/^\/\/[^@\/]+@[^@\/]+/)){var _=c.substr(0,2)==="//";_&&!(w&&h2[w])&&(c=c.substr(2),this.slashes=!0)}if(!h2[w]&&(_||w&&!Zu[w])){for(var B=-1,M=0;M<$_.length;M++){var E=c.indexOf($_[M]);E!==-1&&(B===-1||E<B)&&(B=E)}var O,k;B===-1?k=c.lastIndexOf("@"):k=c.lastIndexOf("@",B),k!==-1&&(O=c.slice(0,k),c=c.slice(k+1),this.auth=decodeURIComponent(O)),B=-1;for(var M=0;M<W_.length;M++){var E=c.indexOf(W_[M]);E!==-1&&(B===-1||E<B)&&(B=E)}B===-1&&(B=c.length),this.host=c.slice(0,B),c=c.slice(B),this.parseHost(),this.hostname=this.hostname||"";var P=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!P)for(var C=this.hostname.split(/\./),M=0,D=C.length;M<D;M++){var z=C[M];if(z&&!z.match(G_)){for(var J="",j=0,re=z.length;j<re;j++)z.charCodeAt(j)>127?J+="x":J+=z[j];if(!J.match(G_)){var T=C.slice(0,M),q=C.slice(M+1),F=z.match(EW);F&&(T.push(F[1]),q.unshift(F[2])),q.length&&(c="/"+q.join(".")+c),this.hostname=T.join(".");break}}}this.hostname.length>SW?this.hostname="":this.hostname=this.hostname.toLowerCase(),P||(this.hostname=pW.toASCII(this.hostname));var m=this.port?":"+this.port:"",a=this.hostname||"";this.host=a+m,this.href+=this.host,P&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),c[0]!=="/"&&(c="/"+c))}if(!IW[y])for(var M=0,D=c2.length;M<D;M++){var h=c2[M];if(c.indexOf(h)!==-1){var u=encodeURIComponent(h);u===h&&(u=escape(h)),c=c.split(h).join(u)}}var l=c.indexOf("#");l!==-1&&(this.hash=c.substr(l),c=c.slice(0,l));var g=c.indexOf("?");if(g!==-1?(this.search=c.substr(g),this.query=c.substr(g+1),e&&(this.query=l2.parse(this.query)),c=c.slice(0,g)):e&&(this.search="",this.query={}),c&&(this.pathname=c),Zu[y]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var m=this.pathname||"",A=this.search||"";this.path=m+A}return this.href=this.format(),this};function MW(t){return Qs.isString(t)&&(t=qh(t)),t instanceof $i?t.format():$i.prototype.format.call(t)}$i.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t),t=t.replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",s=!1,i="";this.host?s=t+this.host:this.hostname&&(s=t+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&Qs.isObject(this.query)&&Object.keys(this.query).length&&(i=l2.stringify(this.query));var f=this.search||i&&"?"+i||"";return e&&e.substr(-1)!==":"&&(e+=":"),this.slashes||(!e||Zu[e])&&s!==!1?(s="//"+(s||""),r&&r.charAt(0)!=="/"&&(r="/"+r)):s||(s=""),n&&n.charAt(0)!=="#"&&(n="#"+n),f&&f.charAt(0)!=="?"&&(f="?"+f),r=r.replace(/[?#]/g,function(c){return encodeURIComponent(c)}),f=f.replace("#","%23"),e+s+r+f+n};function RW(t,e){return qh(t,!1,!0).resolve(e)}$i.prototype.resolve=function(t){return this.resolveObject(qh(t,!1,!0)).format()};function BW(t,e){return t?qh(t,!1,!0).resolveObject(e):e}$i.prototype.resolveObject=function(t){if(Qs.isString(t)){var e=new $i;e.parse(t,!1,!0),t=e}for(var r=new $i,n=Object.keys(this),s=0;s<n.length;s++){var i=n[s];r[i]=this[i]}if(r.hash=t.hash,t.href==="")return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var f=Object.keys(t),c=0;c<f.length;c++){var b=f[c];b!=="protocol"&&(r[b]=t[b])}return Zu[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!Zu[t.protocol]){for(var w=Object.keys(t),y=0;y<w.length;y++){var _=w[y];r[_]=t[_]}return r.href=r.format(),r}if(r.protocol=t.protocol,!t.host&&!h2[t.protocol]){for(var D=(t.pathname||"").split("/");D.length&&!(t.host=D.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),D[0]!==""&&D.unshift(""),D.length<2&&D.unshift(""),r.pathname=D.join("/")}else r.pathname=t.pathname;if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var B=r.pathname||"",M=r.search||"";r.path=B+M}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var E=r.pathname&&r.pathname.charAt(0)==="/",O=t.host||t.pathname&&t.pathname.charAt(0)==="/",k=O||E||r.host&&t.pathname,P=k,C=r.pathname&&r.pathname.split("/")||[],D=t.pathname&&t.pathname.split("/")||[],z=r.protocol&&!Zu[r.protocol];if(z&&(r.hostname="",r.port=null,r.host&&(C[0]===""?C[0]=r.host:C.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(D[0]===""?D[0]=t.host:D.unshift(t.host)),t.host=null),k=k&&(D[0]===""||C[0]==="")),O)r.host=t.host||t.host===""?t.host:r.host,r.hostname=t.hostname||t.hostname===""?t.hostname:r.hostname,r.search=t.search,r.query=t.query,C=D;else if(D.length)C||(C=[]),C.pop(),C=C.concat(D),r.search=t.search,r.query=t.query;else if(!Qs.isNullOrUndefined(t.search)){if(z){r.hostname=r.host=C.shift();var J=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;J&&(r.auth=J.shift(),r.host=r.hostname=J.shift())}return r.search=t.search,r.query=t.query,(!Qs.isNull(r.pathname)||!Qs.isNull(r.search))&&(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!C.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var j=C.slice(-1)[0],re=(r.host||t.host||C.length>1)&&(j==="."||j==="..")||j==="",T=0,q=C.length;q>=0;q--)j=C[q],j==="."?C.splice(q,1):j===".."?(C.splice(q,1),T++):T&&(C.splice(q,1),T--);if(!k&&!P)for(;T--;T)C.unshift("..");k&&C[0]!==""&&(!C[0]||C[0].charAt(0)!=="/")&&C.unshift(""),re&&C.join("/").substr(-1)!=="/"&&C.push("");var F=C[0]===""||C[0]&&C[0].charAt(0)==="/";if(z){r.hostname=r.host=F?"":C.length?C.shift():"";var J=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;J&&(r.auth=J.shift(),r.host=r.hostname=J.shift())}return k=k||r.host&&C.length,k&&!F&&C.unshift(""),C.length?r.pathname=C.join("/"):(r.pathname=null,r.path=null),(!Qs.isNull(r.pathname)||!Qs.isNull(r.search))&&(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},$i.prototype.parseHost=function(){var t=this.host,e=wW.exec(t);e&&(e=e[0],e!==":"&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)};function TW(t,e){for(var r=0,n=t.length-1;n>=0;n--){var s=t[n];s==="."?t.splice(n,1):s===".."?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function OW(){for(var t="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var n=r>=0?arguments[r]:"/";if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)continue;t=n+"/"+t,e=n.charAt(0)==="/"}return t=TW(PW(t.split("/"),function(s){return!!s}),!e).join("/"),(e?"/":"")+t||"."}function PW(t,e){if(t.filter)return t.filter(e);for(var r=[],n=0;n<t.length;n++)e(t[n],n,t)&&r.push(t[n]);return r}var Z_=function(t){function e(){var n=this||self;return delete t.prototype.__magic__,n}if(typeof globalThis=="object")return globalThis;if(this)return e();t.defineProperty(t.prototype,"__magic__",{configurable:!0,get:e});var r=__magic__;return r}(Object),kW=mW,X_=vW,J_=bW,Y_=gW,lf=Z_.URL,Q_=Z_.URLSearchParams,NW=/%/g,CW=/\\/g,LW=/\n/g,DW=/\r/g,FW=/\t/g,UW=47;function HW(t){var e=t??null;return!!(e!==null&&(e!=null&&e.href)&&(e!=null&&e.origin))}function qW(t){if(t.hostname!=="")throw new TypeError('File URL host must be "localhost" or empty on browser');for(var e=t.pathname,r=0;r<e.length;r++)if(e[r]==="%"){var n=e.codePointAt(r+2)|32;if(e[r+1]==="2"&&n===102)throw new TypeError("File URL path must not include encoded / characters")}return decodeURIComponent(e)}function zW(t){return t.includes("%")&&(t=t.replace(NW,"%25")),t.includes("\\")&&(t=t.replace(CW,"%5C")),t.includes(`
132
- `)&&(t=t.replace(LW,"%0A")),t.includes("\r")&&(t=t.replace(DW,"%0D")),t.includes(" ")&&(t=t.replace(FW,"%09")),t}var ex=function(e){if(typeof e>"u")throw new TypeError('The "domain" argument must be specified');return new lf("http://"+e).hostname},tx=function(e){if(typeof e>"u")throw new TypeError('The "domain" argument must be specified');return new lf("http://"+e).hostname},rx=function(e){var r=new lf("file://"),n=OW(e),s=e.charCodeAt(e.length-1);return s===UW&&n[n.length-1]!=="/"&&(n+="/"),r.pathname=zW(n),r},nx=function(e){if(!HW(e)&&typeof e!="string")throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type '+typeof e+" ("+e+")");var r=new lf(e);if(r.protocol!=="file:")throw new TypeError("The URL must be of scheme file");return qW(r)},ix=function(e,r){var n,s,i;if(r===void 0&&(r={}),!(e instanceof lf))return kW(e);if(typeof r!="object"||r===null)throw new TypeError('The "options" argument must be of type object.');var f=(n=r.auth)!=null?n:!0,c=(s=r.fragment)!=null?s:!0,b=(i=r.search)!=null?i:!0,w=new lf(e.toString());return f||(w.username="",w.password=""),c||(w.hash=""),b||(w.search=""),w.toString()},jW={format:ix,parse:X_,resolve:J_,resolveObject:V_,Url:Y_,URL:lf,URLSearchParams:Q_,domainToASCII:ex,domainToUnicode:tx,pathToFileURL:rx,fileURLToPath:nx};const KW=H1(Object.freeze(Object.defineProperty({__proto__:null,URL:lf,URLSearchParams:Q_,Url:Y_,default:jW,domainToASCII:ex,domainToUnicode:tx,fileURLToPath:nx,format:ix,parse:X_,pathToFileURL:rx,resolve:J_,resolveObject:V_},Symbol.toStringTag,{value:"Module"})));var sx=Gt,ax=KW,fx=Js(),ox=Wg,Er=function(t,e){if(!(this instanceof Er))return new Er(t,e);if(this.extras={},this.knownParams=e||[],this.address=this.network=this.amount=this.message=null,typeof t=="string"){var r=Er.parse(t);r.amount&&(r.amount=this._parseAmount(r.amount)),this._fromObject(r)}else if(typeof t=="object")this._fromObject(t);else throw new TypeError("Unrecognized data format.")};Er.fromString=function(e){if(typeof e!="string")throw new TypeError("Expected a string");return new Er(e)},Er.fromObject=function(e){return new Er(e)},Er.isValid=function(t,e){try{new Er(t,e)}catch{return!1}return!0},Er.parse=function(t){var e=ax.parse(t,!0);if(e.protocol!=="bitcoin:")throw new TypeError("Invalid bitcoin URI");var r=/[^:]*:\/?\/?([^?]*)/.exec(t);return e.query.address=r&&r[1]||void 0,e.query},Er.Members=["address","amount","message","label","r"],Er.prototype._fromObject=function(t){if(!fx.isValid(t.address))throw new TypeError("Invalid bitcoin address");this.address=new fx(t.address),this.network=this.address.network,this.amount=t.amount;for(var e in t)if(!(e==="address"||e==="amount")){if(/^req-/.exec(e)&&this.knownParams.indexOf(e)===-1)throw Error("Unknown required argument "+e);var r=Er.Members.indexOf(e)>-1?this:this.extras;r[e]=t[e]}},Er.prototype._parseAmount=function(t){if(t=Number(t),isNaN(t))throw new TypeError("Invalid amount");return ox.fromBTC(t).toSatoshis()},Er.prototype.toObject=Er.prototype.toJSON=function(){for(var e={},r=0;r<Er.Members.length;r++){var n=Er.Members[r];this.hasOwnProperty(n)&&typeof this[n]<"u"&&(e[n]=this[n].toString())}return sx.extend(e,this.extras),e},Er.prototype.toString=function(){var t={};return this.amount&&(t.amount=ox.fromSatoshis(this.amount).toBTC()),this.message&&(t.message=this.message),this.label&&(t.label=this.label),this.r&&(t.r=this.r),sx.extend(t,this.extras),ax.format({protocol:"bitcoin:",host:this.address,query:t})},Er.prototype.inspect=function(){return"<URI: "+this.toString()+">"};var VW=Er;(function(t){var e=t.exports;e.version="v"+LU.version,e.versionGuard=function(r){if(r!==void 0){var n="More than one instance of bitcore-lib found. Please make sure to require bitcore-lib and check that submodules do not also include their own bitcore-lib dependency.";throw new Error(n)}},e.versionGuard(lt._bitcore),lt._bitcore=e.version,e.crypto={},e.crypto.BN=Sn,e.crypto.ECDSA=op(),e.crypto.Hash=an,e.crypto.Random=fp,e.crypto.Point=Lu,e.crypto.Signature=oi,e.encoding={},e.encoding.Base58=Kd,e.encoding.Base58Check=Ah,e.encoding.BufferReader=Ea,e.encoding.BufferWriter=Xn,e.encoding.Varint=UV,e.util={},e.util.buffer=pr,e.util.js=En,e.util.preconditions=Yt,e.errors=Ui,e.Address=Js(),e.Block=GV,e.MerkleBlock=L_,e.BlockHeader=lp,e.HDPrivateKey=H_(),e.HDPublicKey=F_(),e.Message=QV,e.Networks=ao,e.Opcode=cg,e.PrivateKey=Dh(),e.PublicKey=Ys(),e.Script=ui(),e.Transaction=ap(),e.URI=VW,e.Unit=Wg,e.deps={},e.deps.bnjs=e7,e.deps.bs58=w9,e.deps.Buffer=ge,e.deps.elliptic=Dm,e.deps._=Gt,e.Transaction.sighash=cf()})(Q5);var bp=Q5.exports;class ux{constructor(e,r){At(this,"rawData");At(this,"signedData");At(this,"provider");this.rawData=e,this.provider=r??Va.instance}async sign(e){return this.rawData.bitcoreLib.sign(e),this.signedData=this.rawData.bitcoreLib.serialize(),this}async send(){var e;try{return(await sr({method:"POST",url:"https://blockstream.info/testnet/api/tx",data:this.signedData})).data}catch(r){throw new Error(JSON.stringify((e=r.response)==null?void 0:e.data))}}getRawData(){return this.rawData}getSignedData(){return this.signedData??""}}class WW{constructor(e){At(this,"provider");this.provider=e??Va.instance}getName(){return"Bitcoin"}getSymbol(){return"BTC"}getDecimals(){return 8}async getBalance(e){const r=this.provider.createEndpoint("address/"+e),n=await sr.get(r).then(i=>i.data),s=n.chain_stats.funded_txo_sum-n.chain_stats.spent_txo_sum;return Au(s)}async transfer(e,r,n){if(n<0)throw new Error(rn.INVALID_AMOUNT);if(n>await this.getBalance(e))throw new Error(rn.INSUFFICIENT_BALANCE);if(e===r)throw new Error(rn.INVALID_ADDRESS);const s=[],i=new bp.Transaction,f=new bp.Address(e),c=Y5(n),b=await sr.get(this.provider.createEndpoint("address/"+e+"/utxo")).then(w=>w.data);for(const w of b)s.push(new bp.Transaction.UnspentOutput({txId:w.txid,satoshis:w.value,address:f,outputIndex:w.vout,script:bp.Script.fromAddress(f)}));return i.from(s),i.change(e),i.to(r,c),new ux({sender:e,receiver:r,amount:c,bitcoreLib:i})}}const $W=Object.freeze(Object.defineProperty({__proto__:null,Coin:WW},Symbol.toStringTag,{value:"Module"}));let cx=0;class d2{constructor(e,r){At(this,"id");At(this,"provider");At(this,"data",null);this.id=e,this.provider=r??Va.instance}async getData(){var e;if(this.data!==null)return this.data;try{const r=(await sr.get(this.provider.createEndpoint("tx/"+this.id))).data;return(r==null?void 0:r.txid)!==this.id?this.data=null:this.data=r}catch(r){const n=r;if(String((e=n==null?void 0:n.response)==null?void 0:e.data).includes("Transaction not found")){if(cx>5)throw new Error(rn.TRANSACTION_NOT_FOUND);return cx++,await q3(2e3),await this.getData()}throw new Error(rn.RPC_REQUEST_ERROR)}}async wait(e=4e3){return await new Promise((r,n)=>{const s=async()=>{try{const i=await this.getStatus();if(i===tn.CONFIRMED){r(tn.CONFIRMED);return}else if(i===tn.FAILED){n(tn.FAILED);return}setTimeout(s,e)}catch{n(tn.FAILED)}};s()})}getId(){return this.id}async getType(){return Un.COIN}getUrl(){return this.provider.explorer+"tx/"+this.id}async getSigner(){const e=await this.getData();return(e==null?void 0:e.vin[0].prevout.scriptpubkey_address)??""}async getFee(){const e=await this.getData();return Au((e==null?void 0:e.fee)??0)}async getBlockNumber(){var r;const e=await this.getData();return((r=e==null?void 0:e.status)==null?void 0:r.block_height)??0}async getBlockTimestamp(){var r;const e=await this.getData();return((r=e==null?void 0:e.status)==null?void 0:r.block_time)??0}async getBlockConfirmationCount(){var n;const e=await this.getData();return e===null?0:(await sr.get(this.provider.createEndpoint("blocks/tip/height"))).data-((n=e==null?void 0:e.status)==null?void 0:n.block_height)}async getStatus(){var r;const e=await this.getData();return e===null?tn.PENDING:((r=e.status)==null?void 0:r.block_height)!==void 0?e.status.confirmed?tn.CONFIRMED:tn.FAILED:tn.PENDING}}class hx extends d2{async getReceiver(){const e=await this.getData();return(e==null?void 0:e.vout[0].scriptpubkey_address)??""}async getSender(){return await this.getSigner()}async getAmount(){const e=await this.getData();return Au((e==null?void 0:e.vout[0].value)??0)}async verifyTransfer(e,r,n){if(await this.getStatus()===tn.PENDING)return tn.PENDING;if(await this.getAmount()!==n)return tn.FAILED;if(e===Tn.INCOMING){if((await this.getReceiver()).toLowerCase()!==r.toLowerCase())return tn.FAILED}else if((await this.getSender()).toLowerCase()!==r.toLowerCase())return tn.FAILED;return tn.CONFIRMED}}const GW=Object.freeze(Object.defineProperty({__proto__:null,CoinTransaction:hx,Transaction:d2},Symbol.toStringTag,{value:"Module"}));class ZW{constructor(e,r,n){At(this,"type");At(this,"provider");At(this,"status",!1);At(this,"callbacks",[]);At(this,"triggeredTransactions",[]);At(this,"filter");At(this,"webSocket");At(this,"dynamicStop",()=>{});this.type=e,this.filter=r??{},this.provider=n??Va.instance}stop(){this.status&&(this.status=!1,this.dynamicStop())}start(){this.status||(this.status=!0,this[Ey[this.type]]())}getStatus(){return this.status}async on(e){if(this.webSocket===void 0)try{await V1(this.provider.wsUrl),this.webSocket=new ER(this.provider.wsUrl)}catch(r){throw new Error("WebSocket connection is not available"+(r instanceof Error?": "+r.message:""))}return this.start(),this.callbacks.push(e),!0}trigger(e){this.triggeredTransactions.includes(e.id)||(this.triggeredTransactions.push(e.id),this.callbacks.forEach(r=>{r(e)}))}isBlockCypherProcess(){return this.provider.isTestnet()||this.provider.blockCypherToken!==void 0}createMessage(e){let r;if(this.isBlockCypherProcess()){const n={event:"unconfirmed-tx",token:this.provider.blockCypherToken??this.provider.defaultBlockCypherToken};e!==void 0&&(n.address=e),r=JSON.stringify(n)}else r=JSON.stringify({op:"unconfirmed_sub"});return this.dynamicStop=()=>{this.isBlockCypherProcess()||this.webSocket.send(JSON.stringify({op:"unconfirmed_unsub"})),this.webSocket.close()},r}getValues(e){const r={txId:""};return this.isBlockCypherProcess()?(r.txId=e.hash,r.sender=e.inputs[0].addresses[0],r.receiver=e.outputs[0].addresses[0],r.amount=Au(e.outputs[0].value)):(r.txId=e.x.hash,r.receiver=e.x.out[0].addr,r.sender=e.x.inputs[0].prev_out.addr,r.amount=Au(e.x.out[0].value)),r}generalProcess(){const e=this.createMessage();this.webSocket.addEventListener("open",()=>{this.webSocket.send(e)}),this.webSocket.addEventListener("message",async r=>{var s;const n=this.getValues(JSON.parse(r.data));((s=this.filter)==null?void 0:s.signer)!==void 0&&n.sender!==this.filter.signer.toLowerCase()||this.trigger(new d2(n.txId))})}contractProcess(){throw new Error("This method is not implemented for Bitcoin.")}coinProcess(){const e=this.filter;if(e.signer!==void 0&&e.sender!==void 0&&e.signer!==e.sender)throw new Error("Sender and signer must be the same in coin transactions. Or only one of them can be defined.");const r=e.sender??e.signer,n=this.createMessage(e.receiver);this.webSocket.addEventListener("open",()=>{this.webSocket.send(n)}),this.webSocket.addEventListener("message",async s=>{var y,_;const i=JSON.parse(s.data),f={},c={};if(String(i.event).includes("events limit reached"))throw new Error("BlockCypher events limit reached.");const b=this.getValues(i);if(r!==void 0&&(f.sender=r.toLowerCase(),c.sender=(y=b.sender)==null?void 0:y.toLowerCase()),e.receiver!==void 0&&(f.receiver=e.receiver.toLowerCase(),c.receiver=(_=b.receiver)==null?void 0:_.toLowerCase()),!z3(f,c))return;const w=new hx(b.txId);e.amount!==void 0&&b.amount!==e.amount||this.trigger(w)})}tokenProcess(){throw new Error("This method is not implemented for Bitcoin.")}nftProcess(){throw new Error("This method is not implemented for Bitcoin.")}}const XW=Object.freeze(Object.defineProperty({__proto__:null,TransactionListener:ZW,TransactionSigner:ux},Symbol.toStringTag,{value:"Module"})),p2={},JW={Wallet:LR,registerAdapter:t=>{if(Object.values(p2).find(e=>e.id===t.id)!==void 0)throw new Error(`Adapter with id ${t.id} already exists`);p2[t.id]=t},adapters:Object.assign(p2,NU)};Br.Provider=Va,Br.assets=$W,Br.browser=JW,Br.models=GW,Br.services=XW,Br.types=kS,Br.utils=CU,Object.defineProperty(Br,Symbol.toStringTag,{value:"Module"})});
132
+ `)&&(t=t.replace(LW,"%0A")),t.includes("\r")&&(t=t.replace(DW,"%0D")),t.includes(" ")&&(t=t.replace(FW,"%09")),t}var ex=function(e){if(typeof e>"u")throw new TypeError('The "domain" argument must be specified');return new lf("http://"+e).hostname},tx=function(e){if(typeof e>"u")throw new TypeError('The "domain" argument must be specified');return new lf("http://"+e).hostname},rx=function(e){var r=new lf("file://"),n=OW(e),s=e.charCodeAt(e.length-1);return s===UW&&n[n.length-1]!=="/"&&(n+="/"),r.pathname=zW(n),r},nx=function(e){if(!HW(e)&&typeof e!="string")throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type '+typeof e+" ("+e+")");var r=new lf(e);if(r.protocol!=="file:")throw new TypeError("The URL must be of scheme file");return qW(r)},ix=function(e,r){var n,s,i;if(r===void 0&&(r={}),!(e instanceof lf))return kW(e);if(typeof r!="object"||r===null)throw new TypeError('The "options" argument must be of type object.');var f=(n=r.auth)!=null?n:!0,c=(s=r.fragment)!=null?s:!0,b=(i=r.search)!=null?i:!0,w=new lf(e.toString());return f||(w.username="",w.password=""),c||(w.hash=""),b||(w.search=""),w.toString()},jW={format:ix,parse:X_,resolve:J_,resolveObject:V_,Url:Y_,URL:lf,URLSearchParams:Q_,domainToASCII:ex,domainToUnicode:tx,pathToFileURL:rx,fileURLToPath:nx};const KW=H1(Object.freeze(Object.defineProperty({__proto__:null,URL:lf,URLSearchParams:Q_,Url:Y_,default:jW,domainToASCII:ex,domainToUnicode:tx,fileURLToPath:nx,format:ix,parse:X_,pathToFileURL:rx,resolve:J_,resolveObject:V_},Symbol.toStringTag,{value:"Module"})));var sx=Gt,ax=KW,fx=Js(),ox=Wg,Er=function(t,e){if(!(this instanceof Er))return new Er(t,e);if(this.extras={},this.knownParams=e||[],this.address=this.network=this.amount=this.message=null,typeof t=="string"){var r=Er.parse(t);r.amount&&(r.amount=this._parseAmount(r.amount)),this._fromObject(r)}else if(typeof t=="object")this._fromObject(t);else throw new TypeError("Unrecognized data format.")};Er.fromString=function(e){if(typeof e!="string")throw new TypeError("Expected a string");return new Er(e)},Er.fromObject=function(e){return new Er(e)},Er.isValid=function(t,e){try{new Er(t,e)}catch{return!1}return!0},Er.parse=function(t){var e=ax.parse(t,!0);if(e.protocol!=="bitcoin:")throw new TypeError("Invalid bitcoin URI");var r=/[^:]*:\/?\/?([^?]*)/.exec(t);return e.query.address=r&&r[1]||void 0,e.query},Er.Members=["address","amount","message","label","r"],Er.prototype._fromObject=function(t){if(!fx.isValid(t.address))throw new TypeError("Invalid bitcoin address");this.address=new fx(t.address),this.network=this.address.network,this.amount=t.amount;for(var e in t)if(!(e==="address"||e==="amount")){if(/^req-/.exec(e)&&this.knownParams.indexOf(e)===-1)throw Error("Unknown required argument "+e);var r=Er.Members.indexOf(e)>-1?this:this.extras;r[e]=t[e]}},Er.prototype._parseAmount=function(t){if(t=Number(t),isNaN(t))throw new TypeError("Invalid amount");return ox.fromBTC(t).toSatoshis()},Er.prototype.toObject=Er.prototype.toJSON=function(){for(var e={},r=0;r<Er.Members.length;r++){var n=Er.Members[r];this.hasOwnProperty(n)&&typeof this[n]<"u"&&(e[n]=this[n].toString())}return sx.extend(e,this.extras),e},Er.prototype.toString=function(){var t={};return this.amount&&(t.amount=ox.fromSatoshis(this.amount).toBTC()),this.message&&(t.message=this.message),this.label&&(t.label=this.label),this.r&&(t.r=this.r),sx.extend(t,this.extras),ax.format({protocol:"bitcoin:",host:this.address,query:t})},Er.prototype.inspect=function(){return"<URI: "+this.toString()+">"};var VW=Er;(function(t){var e=t.exports;e.version="v"+LU.version,e.versionGuard=function(r){if(r!==void 0){var n="More than one instance of bitcore-lib found. Please make sure to require bitcore-lib and check that submodules do not also include their own bitcore-lib dependency.";throw new Error(n)}},e.versionGuard(lt._bitcore),lt._bitcore=e.version,e.crypto={},e.crypto.BN=Sn,e.crypto.ECDSA=op(),e.crypto.Hash=an,e.crypto.Random=fp,e.crypto.Point=Lu,e.crypto.Signature=oi,e.encoding={},e.encoding.Base58=Kd,e.encoding.Base58Check=Ah,e.encoding.BufferReader=Ea,e.encoding.BufferWriter=Xn,e.encoding.Varint=UV,e.util={},e.util.buffer=pr,e.util.js=En,e.util.preconditions=Yt,e.errors=Ui,e.Address=Js(),e.Block=GV,e.MerkleBlock=L_,e.BlockHeader=lp,e.HDPrivateKey=H_(),e.HDPublicKey=F_(),e.Message=QV,e.Networks=ao,e.Opcode=cg,e.PrivateKey=Dh(),e.PublicKey=Ys(),e.Script=ui(),e.Transaction=ap(),e.URI=VW,e.Unit=Wg,e.deps={},e.deps.bnjs=e7,e.deps.bs58=w9,e.deps.Buffer=ge,e.deps.elliptic=Dm,e.deps._=Gt,e.Transaction.sighash=cf()})(Q5);var bp=Q5.exports;class ux{constructor(e,r){At(this,"rawData");At(this,"signedData");At(this,"provider");this.rawData=e,this.provider=r??Va.instance}async sign(e){return this.rawData.bitcoreLib.sign(e),this.signedData=this.rawData.bitcoreLib.serialize(),this}async send(){var e;try{return(await sr({method:"POST",url:this.provider.createEndpoint("tx"),data:this.signedData})).data}catch(r){throw new Error(JSON.stringify((e=r.response)==null?void 0:e.data))}}getRawData(){return this.rawData}getSignedData(){return this.signedData??""}}class WW{constructor(e){At(this,"provider");this.provider=e??Va.instance}getName(){return"Bitcoin"}getSymbol(){return"BTC"}getDecimals(){return 8}async getBalance(e){const r=this.provider.createEndpoint("address/"+e),n=await sr.get(r).then(i=>i.data),s=n.chain_stats.funded_txo_sum-n.chain_stats.spent_txo_sum;return Au(s)}async transfer(e,r,n){if(n<0)throw new Error(rn.INVALID_AMOUNT);if(n>await this.getBalance(e))throw new Error(rn.INSUFFICIENT_BALANCE);if(e===r)throw new Error(rn.INVALID_ADDRESS);const s=[],i=new bp.Transaction,f=new bp.Address(e),c=Y5(n),b=await sr.get(this.provider.createEndpoint("address/"+e+"/utxo")).then(w=>w.data);for(const w of b)s.push(new bp.Transaction.UnspentOutput({txId:w.txid,satoshis:w.value,address:f,outputIndex:w.vout,script:bp.Script.fromAddress(f)}));return i.from(s),i.change(e),i.to(r,c),new ux({sender:e,receiver:r,amount:c,bitcoreLib:i})}}const $W=Object.freeze(Object.defineProperty({__proto__:null,Coin:WW},Symbol.toStringTag,{value:"Module"}));let cx=0;class d2{constructor(e,r){At(this,"id");At(this,"provider");At(this,"data",null);this.id=e,this.provider=r??Va.instance}async getData(){var e;if(this.data!==null)return this.data;try{const r=(await sr.get(this.provider.createEndpoint("tx/"+this.id))).data;return(r==null?void 0:r.txid)!==this.id?this.data=null:this.data=r}catch(r){const n=r;if(String((e=n==null?void 0:n.response)==null?void 0:e.data).includes("Transaction not found")){if(cx>5)throw new Error(rn.TRANSACTION_NOT_FOUND);return cx++,await q3(2e3),await this.getData()}throw new Error(rn.RPC_REQUEST_ERROR)}}async wait(e=4e3){return await new Promise((r,n)=>{const s=async()=>{try{const i=await this.getStatus();if(i===tn.CONFIRMED){r(tn.CONFIRMED);return}else if(i===tn.FAILED){n(tn.FAILED);return}setTimeout(s,e)}catch{n(tn.FAILED)}};s()})}getId(){return this.id}async getType(){return Un.COIN}getUrl(){return this.provider.explorer+"tx/"+this.id}async getSigner(){const e=await this.getData();return(e==null?void 0:e.vin[0].prevout.scriptpubkey_address)??""}async getFee(){const e=await this.getData();return Au((e==null?void 0:e.fee)??0)}async getBlockNumber(){var r;const e=await this.getData();return((r=e==null?void 0:e.status)==null?void 0:r.block_height)??0}async getBlockTimestamp(){var r;const e=await this.getData();return((r=e==null?void 0:e.status)==null?void 0:r.block_time)??0}async getBlockConfirmationCount(){var n;const e=await this.getData();return e===null?0:(await sr.get(this.provider.createEndpoint("blocks/tip/height"))).data-((n=e==null?void 0:e.status)==null?void 0:n.block_height)}async getStatus(){var r;const e=await this.getData();return e===null?tn.PENDING:((r=e.status)==null?void 0:r.block_height)!==void 0?e.status.confirmed?tn.CONFIRMED:tn.FAILED:tn.PENDING}}class hx extends d2{async getReceiver(){const e=await this.getData();return(e==null?void 0:e.vout[0].scriptpubkey_address)??""}async getSender(){return await this.getSigner()}async getAmount(){const e=await this.getData();return Au((e==null?void 0:e.vout[0].value)??0)}async verifyTransfer(e,r,n){if(await this.getStatus()===tn.PENDING)return tn.PENDING;if(await this.getAmount()!==n)return tn.FAILED;if(e===Tn.INCOMING){if((await this.getReceiver()).toLowerCase()!==r.toLowerCase())return tn.FAILED}else if((await this.getSender()).toLowerCase()!==r.toLowerCase())return tn.FAILED;return tn.CONFIRMED}}const GW=Object.freeze(Object.defineProperty({__proto__:null,CoinTransaction:hx,Transaction:d2},Symbol.toStringTag,{value:"Module"}));class ZW{constructor(e,r,n){At(this,"type");At(this,"provider");At(this,"status",!1);At(this,"callbacks",[]);At(this,"triggeredTransactions",[]);At(this,"filter");At(this,"webSocket");At(this,"dynamicStop",()=>{});this.type=e,this.filter=r??{},this.provider=n??Va.instance}stop(){this.status&&(this.status=!1,this.dynamicStop())}start(){this.status||(this.status=!0,this[Ey[this.type]]())}getStatus(){return this.status}async on(e){if(this.webSocket===void 0)try{await V1(this.provider.wsUrl),this.webSocket=new ER(this.provider.wsUrl)}catch(r){throw new Error("WebSocket connection is not available"+(r instanceof Error?": "+r.message:""))}return this.start(),this.callbacks.push(e),!0}trigger(e){this.triggeredTransactions.includes(e.id)||(this.triggeredTransactions.push(e.id),this.callbacks.forEach(r=>{r(e)}))}isBlockCypherProcess(){return this.provider.isTestnet()||this.provider.blockCypherToken!==void 0}createMessage(e){let r;if(this.isBlockCypherProcess()){const n={event:"unconfirmed-tx",token:this.provider.blockCypherToken??this.provider.defaultBlockCypherToken};e!==void 0&&(n.address=e),r=JSON.stringify(n)}else r=JSON.stringify({op:"unconfirmed_sub"});return this.dynamicStop=()=>{this.isBlockCypherProcess()||this.webSocket.send(JSON.stringify({op:"unconfirmed_unsub"})),this.webSocket.close()},r}getValues(e){const r={txId:""};return this.isBlockCypherProcess()?(r.txId=e.hash,r.sender=e.inputs[0].addresses[0],r.receiver=e.outputs[0].addresses[0],r.amount=Au(e.outputs[0].value)):(r.txId=e.x.hash,r.receiver=e.x.out[0].addr,r.sender=e.x.inputs[0].prev_out.addr,r.amount=Au(e.x.out[0].value)),r}generalProcess(){const e=this.createMessage();this.webSocket.addEventListener("open",()=>{this.webSocket.send(e)}),this.webSocket.addEventListener("message",async r=>{var s;const n=this.getValues(JSON.parse(r.data));((s=this.filter)==null?void 0:s.signer)!==void 0&&n.sender!==this.filter.signer.toLowerCase()||this.trigger(new d2(n.txId))})}contractProcess(){throw new Error("This method is not implemented for Bitcoin.")}coinProcess(){const e=this.filter;if(e.signer!==void 0&&e.sender!==void 0&&e.signer!==e.sender)throw new Error("Sender and signer must be the same in coin transactions. Or only one of them can be defined.");const r=e.sender??e.signer,n=this.createMessage(e.receiver);this.webSocket.addEventListener("open",()=>{this.webSocket.send(n)}),this.webSocket.addEventListener("message",async s=>{var y,_;const i=JSON.parse(s.data),f={},c={};if(String(i.event).includes("events limit reached"))throw new Error("BlockCypher events limit reached.");const b=this.getValues(i);if(r!==void 0&&(f.sender=r.toLowerCase(),c.sender=(y=b.sender)==null?void 0:y.toLowerCase()),e.receiver!==void 0&&(f.receiver=e.receiver.toLowerCase(),c.receiver=(_=b.receiver)==null?void 0:_.toLowerCase()),!z3(f,c))return;const w=new hx(b.txId);e.amount!==void 0&&b.amount!==e.amount||this.trigger(w)})}tokenProcess(){throw new Error("This method is not implemented for Bitcoin.")}nftProcess(){throw new Error("This method is not implemented for Bitcoin.")}}const XW=Object.freeze(Object.defineProperty({__proto__:null,TransactionListener:ZW,TransactionSigner:ux},Symbol.toStringTag,{value:"Module"})),p2={},JW={Wallet:LR,registerAdapter:t=>{if(Object.values(p2).find(e=>e.id===t.id)!==void 0)throw new Error(`Adapter with id ${t.id} already exists`);p2[t.id]=t},adapters:Object.assign(p2,NU)};Br.Provider=Va,Br.assets=$W,Br.browser=JW,Br.models=GW,Br.services=XW,Br.types=kS,Br.utils=CU,Object.defineProperty(Br,Symbol.toStringTag,{value:"Module"})});
133
133
  //# sourceMappingURL=index.umd.js.map